|
Home > Archive > Unix Programming > January 2004 > Are there any programmers here using Glade?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Are there any programmers here using Glade?
|
|
|
| I would like some good tutorials on basic stuff, like how to get the text
into a variable, for example, when a user puts text into a textbox, or how
to add items to a combobox, or how to use the main gnomewindow instead of
opening up a separate window each time.
Much appreciated!
-atv
| |
| Aaron Walker 2004-01-23, 5:01 pm |
| atv wrote:quote:
> I would like some good tutorials on basic stuff, like how to get the text
> into a variable, for example, when a user puts text into a textbox, or how
> to add items to a combobox, or how to use the main gnomewindow instead of
> opening up a separate window each time.
>
> Much appreciated!
> -atv
Check out the glade-users mailing list
http://glade.gnome.org/lists.html
There's a sleu of folks there to help you out.
Aaron
| |
| Aaron Walker 2004-01-23, 5:01 pm |
| atv wrote:quote:
> I would like some good tutorials on basic stuff, like how to get the text
> into a variable, for example, when a user puts text into a textbox, or how
> to add items to a combobox, or how to use the main gnomewindow instead of
> opening up a separate window each time.
>
> Much appreciated!
> -atv
Check out the glade-users mailing list
http://glade.gnome.org/lists.html
There's a sleu of folks there to help you out.
Aaron
| |
| Alexandre Jasmin 2004-01-23, 5:01 pm |
| Le Sun, 30 Nov 2003 23:04:55 +0100, atv a écrit_:
quote:
> I would like some good tutorials on basic stuff, like how to get the
> text into a variable, for example, when a user puts text into a textbox,
> or how to add items to a combobox, or how to use the main gnomewindow
> instead of opening up a separate window each time.
>
> Much appreciated!
> -atv
First off, you should know that comp.unix.programmer is not the best place
to discuss the Gtk+ toolkit (and its interface builder glade) because they
are an abstraction layer on top of the Unix low level system calls and
library calls. Gtk is also portable to non Unix systems and a very complex
topic in itself. While I can answer this question, I suggest that you take
a look at the gnome developer's site http://developer.gnome.org/ to see
what other resources are available.
It is important to note that you CAN'T program in glade. It's only an
interface builder, a tool that help you design a GUI.
One you have "drawn" your graphical interface, there are two ways to make
a program with glade. The first one is to have glade generate an
application skeleton for you. It will include all the code needed to
create your application GUI. You then modify it to create a working
program.
The second way is to use libglade. In that case glade will not generate
any code but you have to distribute the .glade file with your application.
The way it works is that you call glade_xml_new() in your program to have
the GUI constructed from the .glade file. This method is more cleaner in
my opinion.
So that is how you can make a simple application with a GtkEntry
and a GtkComboBox using glade and libglade.
First you build the gui in glade and save the .glade xml file. In this
case, glade_test.glade
------------------------------
glade_test.glade
------------------------------
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window">
<property name="visible">True</property>
<property name="title" translatable="yes">window</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<signal name="destroy" handler="on_window_destroy" last_modification_time="Mon, 01 Dec 2003 01:37:28 GMT"/>
<child>
<widget class="GtkVBox" id="vbox">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<property name="spacing">0</property>
<child>
<widget class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
<signal name="activate" handler="on_entry_activate" last_modification_time="Mon, 01 Dec 2003 01:17:59 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCombo" id="combo">
<property name="visible">True</property>
<property name="value_in_list">False</property>
<property name="allow_empty">True</property>
<property name="case_sensitive">False</property>
<property name="enable_arrow_keys">True</property>
<property name="enable_arrows_always">False</property>
<child internal-child="entry">
<widget class="GtkEntry" id="combo-entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
</child>
<child internal-child="list">
<widget class="GtkList" id="combo-list1">
<property name="visible">True</property>
<property name="selection_mode">GTK_SELECTION_BROWSE</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
------------------------------
Then you write a c program that will recreate the GUI using libglade...
------------------------------
glade_test.c
------------------------------
#include <gtk/gtk.h>
#include <glade/glade.h>
static GtkWidget *entry;
static GtkWidget *combo;
static GList *items = NULL;
void on_window_destroy(GtkWindow *window, gpointer user_data)
{
gtk_main_quit();
}
void on_entry_activate(GtkEntry *entry, gpointer user_data)
{
items = g_list_append(items, (char *)gtk_entry_get_text(GTK_ENTRY(entry)));
gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
}
int main (int argc, char **argv)
{
GladeXML *xml;
gtk_init(&argc, &argv);
glade_init();
xml = glade_xml_new("glade_test.glade", "window", NULL);
if (!xml) {
g_warning("problem while loading the .glade file");
return 1;
}
entry = glade_xml_get_widget(xml, "entry");
combo = glade_xml_get_widget(xml, "combo");
glade_xml_signal_autoconnect(xml);
gtk_main();
return 0;
}
------------------------------
glade_xml_new() loads the GtkWindow 'window' from the file
glade_test.glade then glade_xml_get_widget() is used to retrieve a pointer
the two relevant widgets.
glade_xml_signal_autoconnect() connect the two callback functions to the
related gtk signals. Note that those functions have to be specified in
the glade as well.
The code that may be the most important to you is in the
on_entry_activate() signal callback. It adds the text in entry to the list
of the combo box. I'll let you guess how it works. ;-)
| |
| Alexandre Jasmin 2004-01-23, 5:01 pm |
| Le Sun, 30 Nov 2003 23:04:55 +0100, atv a écrit_:
quote:
> I would like some good tutorials on basic stuff, like how to get the
> text into a variable, for example, when a user puts text into a textbox,
> or how to add items to a combobox, or how to use the main gnomewindow
> instead of opening up a separate window each time.
>
> Much appreciated!
> -atv
First off, you should know that comp.unix.programmer is not the best place
to discuss the Gtk+ toolkit (and its interface builder glade) because they
are an abstraction layer on top of the Unix low level system calls and
library calls. Gtk is also portable to non Unix systems and a very complex
topic in itself. While I can answer this question, I suggest that you take
a look at the gnome developer's site http://developer.gnome.org/ to see
what other resources are available.
It is important to note that you CAN'T program in glade. It's only an
interface builder, a tool that help you design a GUI.
One you have "drawn" your graphical interface, there are two ways to make
a program with glade. The first one is to have glade generate an
application skeleton for you. It will include all the code needed to
create your application GUI. You then modify it to create a working
program.
The second way is to use libglade. In that case glade will not generate
any code but you have to distribute the .glade file with your application.
The way it works is that you call glade_xml_new() in your program to have
the GUI constructed from the .glade file. This method is more cleaner in
my opinion.
So that is how you can make a simple application with a GtkEntry
and a GtkComboBox using glade and libglade.
First you build the gui in glade and save the .glade xml file. In this
case, glade_test.glade
------------------------------
glade_test.glade
------------------------------
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window">
<property name="visible">True</property>
<property name="title" translatable="yes">window</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<signal name="destroy" handler="on_window_destroy" last_modification_time="Mon, 01 Dec 2003 01:37:28 GMT"/>
<child>
<widget class="GtkVBox" id="vbox">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<property name="spacing">0</property>
<child>
<widget class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
<signal name="activate" handler="on_entry_activate" last_modification_time="Mon, 01 Dec 2003 01:17:59 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCombo" id="combo">
<property name="visible">True</property>
<property name="value_in_list">False</property>
<property name="allow_empty">True</property>
<property name="case_sensitive">False</property>
<property name="enable_arrow_keys">True</property>
<property name="enable_arrows_always">False</property>
<child internal-child="entry">
<widget class="GtkEntry" id="combo-entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
</child>
<child internal-child="list">
<widget class="GtkList" id="combo-list1">
<property name="visible">True</property>
<property name="selection_mode">GTK_SELECTION_BROWSE</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
------------------------------
Then you write a c program that will recreate the GUI using libglade...
------------------------------
glade_test.c
------------------------------
#include <gtk/gtk.h>
#include <glade/glade.h>
static GtkWidget *entry;
static GtkWidget *combo;
static GList *items = NULL;
void on_window_destroy(GtkWindow *window, gpointer user_data)
{
gtk_main_quit();
}
void on_entry_activate(GtkEntry *entry, gpointer user_data)
{
items = g_list_append(items, (char *)gtk_entry_get_text(GTK_ENTRY(entry)));
gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
}
int main (int argc, char **argv)
{
GladeXML *xml;
gtk_init(&argc, &argv);
glade_init();
xml = glade_xml_new("glade_test.glade", "window", NULL);
if (!xml) {
g_warning("problem while loading the .glade file");
return 1;
}
entry = glade_xml_get_widget(xml, "entry");
combo = glade_xml_get_widget(xml, "combo");
glade_xml_signal_autoconnect(xml);
gtk_main();
return 0;
}
------------------------------
glade_xml_new() loads the GtkWindow 'window' from the file
glade_test.glade then glade_xml_get_widget() is used to retrieve a pointer
the two relevant widgets.
glade_xml_signal_autoconnect() connect the two callback functions to the
related gtk signals. Note that those functions have to be specified in
the glade as well.
The code that may be the most important to you is in the
on_entry_activate() signal callback. It adds the text in entry to the list
of the combo box. I'll let you guess how it works. ;-)
| |
| Alexandre Jasmin 2004-01-23, 5:01 pm |
| > void on_entry_activate(GtkEntry *entry, gpointer user_data) {quote:
> items = g_list_append(items, (char
> *)gtk_entry_get_text(GTK_ENTRY(entry)));
> gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
> }
No!! It can't be!
There's a big mistake or mine here. ;-) should read..
items = g_list_append(items, g_strdup(gtk_entry_get_text(GTK_ENTRY(en
try))));
gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
you need to strdup or all the item in the list will point to the current
text in entry
| |
| Alexandre Jasmin 2004-01-23, 5:01 pm |
| > void on_entry_activate(GtkEntry *entry, gpointer user_data) {quote:
> items = g_list_append(items, (char
> *)gtk_entry_get_text(GTK_ENTRY(entry)));
> gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
> }
No!! It can't be!
There's a big mistake or mine here. ;-) should read..
items = g_list_append(items, g_strdup(gtk_entry_get_text(GTK_ENTRY(en
try))));
gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
you need to strdup or all the item in the list will point to the current
text in entry
| |
|
| Alexandre Jasmin wrote:
quote:
>
> No!! It can't be!
>
> There's a big mistake or mine here. ;-) should read..
>
> items = g_list_append(items,
> g_strdup(gtk_entry_get_text(GTK_ENTRY(en
try))));
> gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
>
> you need to strdup or all the item in the list will point to the current
> text in entry
Thank you so much! This is really helpful. Yes i think i will use libglade,
but i'm still a bit new to this glade stuff, so i'll design my gui first,
then use the glade file. The code glade builds is quite horrible.
Kind regards,
atv
| |
|
| Alexandre Jasmin wrote:
quote:
>
> No!! It can't be!
>
> There's a big mistake or mine here. ;-) should read..
>
> items = g_list_append(items,
> g_strdup(gtk_entry_get_text(GTK_ENTRY(en
try))));
> gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
>
> you need to strdup or all the item in the list will point to the current
> text in entry
Thank you so much! This is really helpful. Yes i think i will use libglade,
but i'm still a bit new to this glade stuff, so i'll design my gui first,
then use the glade file. The code glade builds is quite horrible.
Kind regards,
atv
| |
|
| Alexandre Jasmin wrote:
quote:
> Le Sun, 30 Nov 2003 23:04:55 +0100, atv a écrit_:
>
>
> First off, you should know that comp.unix.programmer is not the best place
> to discuss the Gtk+ toolkit (and its interface builder glade) because they
> are an abstraction layer on top of the Unix low level system calls and
> library calls. Gtk is also portable to non Unix systems and a very complex
> topic in itself. While I can answer this question, I suggest that you take
> a look at the gnome developer's site http://developer.gnome.org/ to see
> what other resources are available.
>
> It is important to note that you CAN'T program in glade. It's only an
> interface builder, a tool that help you design a GUI.
>
> One you have "drawn" your graphical interface, there are two ways to make
> a program with glade. The first one is to have glade generate an
> application skeleton for you. It will include all the code needed to
> create your application GUI. You then modify it to create a working
> program.
>
> The second way is to use libglade. In that case glade will not generate
> any code but you have to distribute the .glade file with your application.
> The way it works is that you call glade_xml_new() in your program to have
> the GUI constructed from the .glade file. This method is more cleaner in
> my opinion.
>
> So that is how you can make a simple application with a GtkEntry
> and a GtkComboBox using glade and libglade.
>
> First you build the gui in glade and save the .glade xml file. In this
> case, glade_test.glade
>
>
> ------------------------------
> glade_test.glade
> ------------------------------
> <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
>
> <glade-interface>
>
> <widget class="GtkWindow" id="window">
> <property name="visible">True</property>
> <property name="title" translatable="yes">window</property>
> <property name="type">GTK_WINDOW_TOPLEVEL</property>
> <property name="window_position">GTK_WIN_POS_NONE</property>
> <property name="modal">False</property>
> <property name="resizable">True</property>
> <property name="destroy_with_parent">False</property>
> <signal name="destroy" handler="on_window_destroy"
> last_modification_time="Mon, 01 Dec 2003 01:37:28 GMT"/>
>
> <child>
> <widget class="GtkVBox" id="vbox">
> <property name="visible">True</property>
> <property name="homogeneous">True</property>
> <property name="spacing">0</property>
>
> <child>
> <widget class="GtkEntry" id="entry">
> <property name="visible">True</property>
> <property name="can_focus">True</property>
> <property name="editable">True</property>
> <property name="visibility">True</property>
> <property name="max_length">0</property>
> <property name="text" translatable="yes"></property>
> <property name="has_frame">True</property>
> <property name="invisible_char" translatable="yes">*</property>
> <property name="activates_default">False</property>
> <signal name="activate" handler="on_entry_activate"
> last_modification_time="Mon, 01 Dec 2003 01:17:59 GMT"/>
> </widget>
> <packing>
> <property name="padding">0</property>
> <property name="expand">False</property>
> <property name="fill">False</property>
> </packing>
> </child>
>
> <child>
> <widget class="GtkCombo" id="combo">
> <property name="visible">True</property>
> <property name="value_in_list">False</property>
> <property name="allow_empty">True</property>
> <property name="case_sensitive">False</property>
> <property name="enable_arrow_keys">True</property>
> <property name="enable_arrows_always">False</property>
>
> <child internal-child="entry">
> <widget class="GtkEntry" id="combo-entry1">
> <property name="visible">True</property>
> <property name="can_focus">True</property>
> <property name="editable">True</property>
> <property name="visibility">True</property>
> <property name="max_length">0</property>
> <property name="text" translatable="yes"></property>
> <property name="has_frame">True</property>
> <property name="invisible_char"
> translatable="yes">*</property> <property
> name="activates_default">False</property>
> </widget>
> </child>
>
> <child internal-child="list">
> <widget class="GtkList" id="combo-list1">
> <property name="visible">True</property>
> <property
> name="selection_mode">GTK_SELECTION_BROWSE</property>
> </widget>
> </child>
> </widget>
> <packing>
> <property name="padding">0</property>
> <property name="expand">False</property>
> <property name="fill">False</property>
> </packing>
> </child>
> </widget>
> </child>
> </widget>
>
> </glade-interface>
> ------------------------------
>
> Then you write a c program that will recreate the GUI using libglade...
>
> ------------------------------
> glade_test.c
> ------------------------------
> #include <gtk/gtk.h>
> #include <glade/glade.h>
>
> static GtkWidget *entry;
> static GtkWidget *combo;
> static GList *items = NULL;
>
> void on_window_destroy(GtkWindow *window, gpointer user_data)
> {
> gtk_main_quit();
> }
>
> void on_entry_activate(GtkEntry *entry, gpointer user_data)
> {
> items = g_list_append(items, (char
> *)gtk_entry_get_text(GTK_ENTRY(entry)));
> gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
> }
>
> int main (int argc, char **argv)
> {
> GladeXML *xml;
>
> gtk_init(&argc, &argv);
> glade_init();
>
> xml = glade_xml_new("glade_test.glade", "window", NULL);
>
> if (!xml) {
> g_warning("problem while loading the .glade file");
> return 1;
> }
>
> entry = glade_xml_get_widget(xml, "entry");
> combo = glade_xml_get_widget(xml, "combo");
>
> glade_xml_signal_autoconnect(xml);
>
> gtk_main();
>
> return 0;
> }
> ------------------------------
>
> glade_xml_new() loads the GtkWindow 'window' from the file
> glade_test.glade then glade_xml_get_widget() is used to retrieve a pointer
> the two relevant widgets.
>
> glade_xml_signal_autoconnect() connect the two callback functions to the
> related gtk signals. Note that those functions have to be specified in
> the glade as well.
>
> The code that may be the most important to you is in the
> on_entry_activate() signal callback. It adds the text in entry to the list
> of the combo box. I'll let you guess how it works. ;-)
Argh. stupid question, but i can't seem to figure it out. How does one
compile this ? I do a gcc -Wall test.c -o test -llibglade
Do i need to specify gtk as a lib to ?
Suse9.0 put the header files in /opt/gnome/include for gtk,gdk and all the
other stuff.
Pls help
| |
|
| Alexandre Jasmin wrote:
quote:
> Le Sun, 30 Nov 2003 23:04:55 +0100, atv a écrit_:
>
>
> First off, you should know that comp.unix.programmer is not the best place
> to discuss the Gtk+ toolkit (and its interface builder glade) because they
> are an abstraction layer on top of the Unix low level system calls and
> library calls. Gtk is also portable to non Unix systems and a very complex
> topic in itself. While I can answer this question, I suggest that you take
> a look at the gnome developer's site http://developer.gnome.org/ to see
> what other resources are available.
>
> It is important to note that you CAN'T program in glade. It's only an
> interface builder, a tool that help you design a GUI.
>
> One you have "drawn" your graphical interface, there are two ways to make
> a program with glade. The first one is to have glade generate an
> application skeleton for you. It will include all the code needed to
> create your application GUI. You then modify it to create a working
> program.
>
> The second way is to use libglade. In that case glade will not generate
> any code but you have to distribute the .glade file with your application.
> The way it works is that you call glade_xml_new() in your program to have
> the GUI constructed from the .glade file. This method is more cleaner in
> my opinion.
>
> So that is how you can make a simple application with a GtkEntry
> and a GtkComboBox using glade and libglade.
>
> First you build the gui in glade and save the .glade xml file. In this
> case, glade_test.glade
>
>
> ------------------------------
> glade_test.glade
> ------------------------------
> <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
>
> <glade-interface>
>
> <widget class="GtkWindow" id="window">
> <property name="visible">True</property>
> <property name="title" translatable="yes">window</property>
> <property name="type">GTK_WINDOW_TOPLEVEL</property>
> <property name="window_position">GTK_WIN_POS_NONE</property>
> <property name="modal">False</property>
> <property name="resizable">True</property>
> <property name="destroy_with_parent">False</property>
> <signal name="destroy" handler="on_window_destroy"
> last_modification_time="Mon, 01 Dec 2003 01:37:28 GMT"/>
>
> <child>
> <widget class="GtkVBox" id="vbox">
> <property name="visible">True</property>
> <property name="homogeneous">True</property>
> <property name="spacing">0</property>
>
> <child>
> <widget class="GtkEntry" id="entry">
> <property name="visible">True</property>
> <property name="can_focus">True</property>
> <property name="editable">True</property>
> <property name="visibility">True</property>
> <property name="max_length">0</property>
> <property name="text" translatable="yes"></property>
> <property name="has_frame">True</property>
> <property name="invisible_char" translatable="yes">*</property>
> <property name="activates_default">False</property>
> <signal name="activate" handler="on_entry_activate"
> last_modification_time="Mon, 01 Dec 2003 01:17:59 GMT"/>
> </widget>
> <packing>
> <property name="padding">0</property>
> <property name="expand">False</property>
> <property name="fill">False</property>
> </packing>
> </child>
>
> <child>
> <widget class="GtkCombo" id="combo">
> <property name="visible">True</property>
> <property name="value_in_list">False</property>
> <property name="allow_empty">True</property>
> <property name="case_sensitive">False</property>
> <property name="enable_arrow_keys">True</property>
> <property name="enable_arrows_always">False</property>
>
> <child internal-child="entry">
> <widget class="GtkEntry" id="combo-entry1">
> <property name="visible">True</property>
> <property name="can_focus">True</property>
> <property name="editable">True</property>
> <property name="visibility">True</property>
> <property name="max_length">0</property>
> <property name="text" translatable="yes"></property>
> <property name="has_frame">True</property>
> <property name="invisible_char"
> translatable="yes">*</property> <property
> name="activates_default">False</property>
> </widget>
> </child>
>
> <child internal-child="list">
> <widget class="GtkList" id="combo-list1">
> <property name="visible">True</property>
> <property
> name="selection_mode">GTK_SELECTION_BROWSE</property>
> </widget>
> </child>
> </widget>
> <packing>
> <property name="padding">0</property>
> <property name="expand">False</property>
> <property name="fill">False</property>
> </packing>
> </child>
> </widget>
> </child>
> </widget>
>
> </glade-interface>
> ------------------------------
>
> Then you write a c program that will recreate the GUI using libglade...
>
> ------------------------------
> glade_test.c
> ------------------------------
> #include <gtk/gtk.h>
> #include <glade/glade.h>
>
> static GtkWidget *entry;
> static GtkWidget *combo;
> static GList *items = NULL;
>
> void on_window_destroy(GtkWindow *window, gpointer user_data)
> {
> gtk_main_quit();
> }
>
> void on_entry_activate(GtkEntry *entry, gpointer user_data)
> {
> items = g_list_append(items, (char
> *)gtk_entry_get_text(GTK_ENTRY(entry)));
> gtk_combo_set_popdown_strings(GTK_COMBO(
combo), items);
> }
>
> int main (int argc, char **argv)
> {
> GladeXML *xml;
>
> gtk_init(&argc, &argv);
> glade_init();
>
> xml = glade_xml_new("glade_test.glade", "window", NULL);
>
> if (!xml) {
> g_warning("problem while loading the .glade file");
> return 1;
> }
>
> entry = glade_xml_get_widget(xml, "entry");
> combo = glade_xml_get_widget(xml, "combo");
>
> glade_xml_signal_autoconnect(xml);
>
> gtk_main();
>
> return 0;
> }
> ------------------------------
>
> glade_xml_new() loads the GtkWindow 'window' from the file
> glade_test.glade then glade_xml_get_widget() is used to retrieve a pointer
> the two relevant widgets.
>
> glade_xml_signal_autoconnect() connect the two callback functions to the
> related gtk signals. Note that those functions have to be specified in
> the glade as well.
>
> The code that may be the most important to you is in the
> on_entry_activate() signal callback. It adds the text in entry to the list
> of the combo box. I'll let you guess how it works. ;-)
Argh. stupid question, but i can't seem to figure it out. How does one
compile this ? I do a gcc -Wall test.c -o test -llibglade
Do i need to specify gtk as a lib to ?
Suse9.0 put the header files in /opt/gnome/include for gtk,gdk and all the
other stuff.
Pls help
| |
|
| Alexandre Jasmin wrote:
Well i'm using pkg-config to compile this, but each time i use the program
i get:
test:21059): libglade-CRITICAL **: file glade-xml.c: line 1172
(glade_xml_build_interface): assertion `wid != NULL' failed
is this a bug in glade-xml.c ?
thanks
| |
|
| Alexandre Jasmin wrote:
Well i'm using pkg-config to compile this, but each time i use the program
i get:
test:21059): libglade-CRITICAL **: file glade-xml.c: line 1172
(glade_xml_build_interface): assertion `wid != NULL' failed
is this a bug in glade-xml.c ?
thanks
| |
| Alexandre Jasmin 2004-01-23, 5:01 pm |
| Le Mon, 01 Dec 2003 11:21:16 +0100, atv a écrit_:
quote:
> Alexandre Jasmin wrote:
>
> Well i'm using pkg-config to compile this, but each time i use the program
> i get:
>
> test:21059): libglade-CRITICAL **: file glade-xml.c: line 1172
> (glade_xml_build_interface): assertion `wid != NULL' failed
I'm not sure...
Try to compile it this way..
gcc -Wall -o glade_test `pkg-config --cflags libglade-2.0` \
`pkg-config --libs libglade-2.0` \
`pkg-config --cflags gtk+-2.0` \
`pkg-config --libs gtk+-2.0` glade_test.c
And make sure to copy the .glade file exactly as shown.
I also placed it on my web server.
http://r4p70r.net/glade_test.glade
| |
| Alexandre Jasmin 2004-01-23, 5:01 pm |
| Le Mon, 01 Dec 2003 11:21:16 +0100, atv a écrit_:
quote:
> Alexandre Jasmin wrote:
>
> Well i'm using pkg-config to compile this, but each time i use the program
> i get:
>
> test:21059): libglade-CRITICAL **: file glade-xml.c: line 1172
> (glade_xml_build_interface): assertion `wid != NULL' failed
I'm not sure...
Try to compile it this way..
gcc -Wall -o glade_test `pkg-config --cflags libglade-2.0` \
`pkg-config --libs libglade-2.0` \
`pkg-config --cflags gtk+-2.0` \
`pkg-config --libs gtk+-2.0` glade_test.c
And make sure to copy the .glade file exactly as shown.
I also placed it on my web server.
http://r4p70r.net/glade_test.glade
| |
| bad_knee 2004-01-23, 5:02 pm |
| > First off, you should know that comp.unix.programmer is not the best placequote:
> to discuss the Gtk+ toolkit (and its interface builder glade) because they
I think I'm going to barf. All that you wrote, and simply ignoring the
original post would have sufficed. Amazing.
| |
| bad_knee 2004-01-23, 5:02 pm |
| > First off, you should know that comp.unix.programmer is not the best placequote:
> to discuss the Gtk+ toolkit (and its interface builder glade) because they
I think I'm going to barf. All that you wrote, and simply ignoring the
original post would have sufficed. Amazing.
|
|
|
|
|