GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Sep 20, 2014 6:02 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Calling another program for opening a file.
PostPosted: Thu Apr 24, 2008 10:40 am 
Offline
Familiar Face

Joined: Fri Apr 04, 2008 9:59 am
Posts: 10
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 11:12 am 
Offline
GTK+ Guru

Joined: Tue Feb 05, 2008 8:39 am
Posts: 130
I do such things in this way:
Code:
g_spawn_command_line_async("xdg-open my_help.pdf", NULL); // my_help.pdf - your file


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 25, 2008 8:09 pm 
Offline
Familiar Face

Joined: Fri Apr 04, 2008 9:59 am
Posts: 10
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?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 26, 2008 4:48 am 
Offline
GTK+ Guru

Joined: Tue Feb 05, 2008 8:39 am
Posts: 130
My code snippet looks so:
Code:
#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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 26, 2008 8:50 pm 
Offline
Familiar Face

Joined: Fri Apr 04, 2008 9:59 am
Posts: 10
Thank you very much for your help.Now it works without any problem. :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group