LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-20-2012, 08:45 PM   #1
VarwigSoftware
LQ Newbie
 
Registered: Sep 2012
Posts: 2

Rep: Reputation: Disabled
Embed Another Program in a GTK Program


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.

Is there a way to use X Window in a GTK App? or a GTK Widget that shows other programs?

Thank You!
 
Old 09-20-2012, 11:41 PM   #2
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 291

Rep: Reputation: Disabled
if you want to embed a Vterminal in your GTK application you need to install libvte and all its variants. The VTE widget is for GTK2.x only. Look here for the documentation -> http://developer.gnome.org/vte/unsta...eTerminal.html


A basic example of embedding the vte
Code:
#include <gtk/gtk.h>
#include <vte/vte.h>

static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
gtk_main_quit();
return FALSE;
}

// To compile append gcc file.c -o output `pkg-config --cflags --libs gtk+-2.0 vte`
int main(int argc, char *argv[]) {

gtk_init(&argc, &argv);
GtkWidget *window;
GtkWidget *table;
GtkWidget *swindow;
GtkWidget *vte;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_widget_show(window);

table = gtk_table_new(10, 10, TRUE);
gtk_container_add(GTK_CONTAINER(window), table);
gtk_widget_show(table);

vte = vte_terminal_new();
gtk_widget_show(vte);

swindow = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(swindow), vte);
gtk_table_attach_defaults(GTK_TABLE(table), swindow, 0, 10, 0, 10);
gtk_widget_show(swindow);

g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(delete_event), NULL);

gtk_main();
return 0;
}

Last edited by amboxer21; 09-21-2012 at 01:56 AM.
 
Old 09-21-2012, 01:57 AM   #3
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 291

Rep: Reputation: Disabled
As for nautilus -> http://developer.gnome.org/libnautil...-provider.html

EDIT: if your going to embed anything don't use boxes to pack. Pack using tables.

Last edited by amboxer21; 09-21-2012 at 02:25 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gtk Plug, Socket, embed one program into another. arkashkin Programming 0 03-26-2010 07:27 AM
Embed linux, yum upgrade and program in a CD. shihao Linux - Software 8 01-27-2010 12:16 AM
about gtk+ program ganguly Linux - General 1 05-11-2005 07:29 AM
Gtk-Warning but program still works... I close konsole, program closes Laptop2250 Linux - Software 2 11-14-2003 11:18 PM
gtk program souvik Programming 1 06-08-2001 04:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration