GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling another program for opening a file.

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
Redlion
Familiar Face


Joined: 04 Apr 2008
Posts: 8

PostPosted: Thu Apr 24, 2008 10:40 am    Post subject: Calling another program for opening a file. Reply with quote

Hello everyone!
I need some help about this main problem;well I created one PDF document which is going to be the help of my application.Now I want to "link" this help to the program itself.In other terms, I want that the application calls the pdf reader to open the pdf file when the user click on the menu help button.
I wanted to know how do I do that.Thanks for your attention and answers.
Back to top
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 44

PostPosted: Thu Apr 24, 2008 11:12 am    Post subject: Reply with quote

I do such things in this way:
Code: (C)
1
g_spawn_command_line_async("xdg-open my_help.pdf", NULL); // my_help.pdf - your file
Back to top
Redlion
Familiar Face


Joined: 04 Apr 2008
Posts: 8

PostPosted: Fri Apr 25, 2008 8:09 pm    Post subject: Reply with quote

Thanks.But when I try it my program crash.I'm on windows.I have of course made some search about. But I'm a bit lost.Especially with the function "g_spawn_async ()".Could you help me again? or at least give me an example of code?
Back to top
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 44

PostPosted: Sat Apr 26, 2008 4:48 am    Post subject: Reply with quote

My code snippet looks so:
Code: (C)
1
2
3
4
5
6
#if defined WIN32
  ShellExecute(NULL, NULL, "my_file.pdf", NULL, NULL, SW_NORMAL);
#else
 
g_spawn_command_line_async("xdg-open my_file.pdf", NULL);
#endif
Unfortunally there is no common way for Linux and Windows. This code snippet works in my program on Linux and on Windows any way.
Back to top
Redlion
Familiar Face


Joined: 04 Apr 2008
Posts: 8

PostPosted: Sat Apr 26, 2008 8:50 pm    Post subject: Reply with quote

Thank you very much for your help.Now it works without any problem. :D
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP