LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 08-30-2004, 02:01 AM   #1
goelvish
LQ Newbie
 
Registered: Aug 2004
Posts: 8

Rep: Reputation: 0
Getting a widget GTK programming


Hi all ,
I am new to the world of GTK programming. After a lot of struggle I was able to configure it.
Now can some one tell me how can I get a widget from an application. Which are the methods that shall help me in getting a widget.

Thanx in advace
Vishal G.
 
Old 08-30-2004, 02:23 AM   #2
herrera
LQ Newbie
 
Registered: Jul 2004
Distribution: Fedora Core
Posts: 4

Rep: Reputation: 0
How do you want to "GET" a widget? I'm not sure I understand you, but if you're just begining with your programming, then I suggest you start off with Mono/Gtk#. Will be quite easier for you to learn.
http://www.go-mono.com/
 
Old 08-30-2004, 02:42 AM   #3
goelvish
LQ Newbie
 
Registered: Aug 2004
Posts: 8

Original Poster
Rep: Reputation: 0
I want to get the widget through C code. I have opened a gnome-calculator application and want to get a widget in this application.
Thanx.
 
Old 08-30-2004, 05:43 AM   #4
wizard7423
LQ Newbie
 
Registered: Jul 2004
Posts: 27

Rep: Reputation: 15
Hi,

if i well understand your question you want to get a generic GtkWidget.
There are a lot of different way to do this. All this way depends on the particular context (a main window, a menuitem, and so on...). But you can try in this way:
GtkWidget *generic_widget=lookup_widget(gtk_widget_get_toplevel(a_widget),"the_name_of_needed_widget);

with the lookup_widget function you looking for a fixed widget in a widget's tree whose root is the toplevel object in which "a_widget" is nested. Obviously the gtk_widget_get_toplevel function gets the toplevel widget.
So to "get" a widget you need two things: the name of the widget you are looking for, and another widget that is in the same window of the widget you want.
 
Old 08-30-2004, 06:04 AM   #5
goelvish
LQ Newbie
 
Registered: Aug 2004
Posts: 8

Original Poster
Rep: Reputation: 0
Hi,
This was really informative. But I am stuck as I dont know the widget name. I have an application like gnome-calculator. There are several buttons on this calculator application. I want to have an access to these button widget. How can I do this?
Thanx Vishal
 
Old 08-31-2004, 06:30 AM   #6
wizard7423
LQ Newbie
 
Registered: Jul 2004
Posts: 27

Rep: Reputation: 15
ok...even if i'm not an expert...but i think you should have a code like this (into a file called "application_directory/src/interface.c"):

void
on_connectMainButton_clicked (GtkButton *button,
gpointer user_data)
{
GtkWidget *obj=gtk_widget_get_toplevel(GTK_WIDGET(button));
GtkWidget *status=NULL;
guint cont_id, id;
GtkWidget *connecting;
static gchar *string="Connecting...";
connecting=create_Connecting();
gtk_widget_show(connecting);
status = lookup_widget(GTK_WIDGET(obj), "statusbar");
if(status==NULL)
{
perror("Status bar error");
gtk_exit(1);
}
}

void
on_disconnectMainButton_activate (GtkButton *button,
gpointer user_data)
{
static gchar *string = "i'm disconnecting from server...";
static gchar *title="Disconnecting";
gboolean g;
GtkWidget *connecting;
GtkWidget *cell_label;
connecting=create_Connecting();
gtk_window_set_title(GTK_WINDOW(connecting),title);
cell_label = lookup_widget(GTK_WIDGET(connecting), "label");
gtk_label_set_text(GTK_LABEL(cell_label), string);
gtk_widget_show(connecting);
}

....and so on. At this point you must know and recognize the button you need in some way....and then use it.
if tasks that this code is not similar yours probably your application was written directly with gtk instructions....in this case it's harder to discover the button code you need...
try with some tutorial on internet...but you need to learn a new language....it will be a bit long and difficult....
I hope to you it are of aid
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 GtkImage Widget Rajahuroman Programming 8 03-14-2006 07:56 PM
GTK widget appearance neiljmac Linux - Software 1 12-25-2004 07:43 AM
How to get Source code of Gtk File Selection Widget chaits Linux - General 0 04-14-2004 10:43 AM
Which GTK Widget to use? jpbarto Programming 0 11-20-2003 08:34 PM
what is a gtk-widget ? gladeiator Programming 3 10-30-2003 06:34 PM


All times are GMT -5. The time now is 10:00 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration