GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Oct 31, 2014 6:15 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Embed Another Program in a GTK Program
PostPosted: Thu Sep 20, 2012 7:44 pm 
Offline
Familiar Face

Joined: Sat Mar 03, 2012 2:45 am
Posts: 18
Hello Everyone,

I am trying to embed Nautilus and possibly the gnome-terminal into my GTK Application. I would like to add it to a section on a hbox? Any Ideas. I have goggled an i am not finding much on how to embed an external program into a GTK+ Applcation. I am using C on Ubuntu 12.04.

Thank You!


Top
 Profile  
 
 Post subject: Re: Embed Another Program in a GTK Program
PostPosted: Fri Sep 21, 2012 5:43 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
You don't mention which version of GTK your using but with Ubuntu 12.04, I'll assume it's gtk+3 because it's available from synaptic in that version of Ubuntu.

1) Don't use hbox, it been deprecated since gtk version 3.2
http://developer.gnome.org/gtk3/stable/GtkHBox.html#gtk-hbox-new

2) You can use gtk_box_new() with orientation set to GTK_ORIENTATION_HORIZONTAL. But even GtkBox is going away eventually so you should use GtkGrid instead.
(The manual only mentions this in the documentation for GtkVBox)
http://developer.gnome.org/gtk3/stable/GtkVBox.html#GtkVBox.description

3) You don't actually embed a terminal in a GtkWindow. Instead use a GtkTextView widget to simulate it. You launch a terminal as a background process and communicate with it using pipes and one of the g_spawn() functions.
http://www.gtkforums.com/viewtopic.php?t=3818
http://developer.gnome.org/glib/stable/glib-Spawning-Processes.html#g-spawn-command-line-sync

4) To keep it simple I would have a "SEND" button to transmit what you've typed in the GtkTextView to the terminal. That way you avoid writing keypress code to capture the "ENTER" key.

As far a Nautilus I'm not shure.


Top
 Profile  
 
 Post subject: Re: Embed Another Program in a GTK Program
PostPosted: Fri Sep 21, 2012 10:32 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

Directly embedding Nautilus is not possible, since this app doesn't have any widgets exposed to 3rd party app developers. As for terminal, there is a library called VTE, which is the main part of gnome-terminal and can be easily embedded in your app.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: Embed Another Program in a GTK Program
PostPosted: Sat Sep 22, 2012 4:01 am 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
I came across VTE in the past but had forgot all about it. Thanks Tadeboro.

http://developer.gnome.org/vte/


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group