[Glade-users] Variables switched in the GtkDialog Response Callback
- From: diogofsr at gmail.com (Diogo Ramos)
- Subject: [Glade-users] Variables switched in the GtkDialog Response Callback
- Date: Sat, 2 Jun 2007 00:11:11 -0300
I was playing during some time with the gtkdialog response callback and I
had noticed some strange behaviors.
Them finale, I figured it out.
The protoptipe of the callback in the gtk manual is:
void user_function (GtkDialog *dialog,
gint arg1,
gpointer
user_data)
But, when I set glade to pass one widget from user_data, the protoptipe is
actually switched.
What I mean is that *dialog becomes user_data and user_data becomes *dialog.
So, if I want to use the widget which I passed thought the glade_xml, I use
*dialog, not user_data.
I made a little test file:
main.c
/*************************/
#include <gtk/gtk.h>
#include <stdlib.h>
#include <glade/glade.h>
void
resposta( GtkDialog *dialog, gint arg1, gpointer data )
{
switch( arg1 )
{
case GTK_RESPONSE_OK:
{
const gchar *str = NULL;
str = gtk_entry_get_text( GTK_ENTRY(dialog));
printf("Entry:%s\n", str );
break;
}
case GTK_RESPONSE_CANCEL:
{
gtk_main_quit();
}
}
}
int main( int argc, char *argv[] )
{
GladeXML *xmlTree;
GtkWidget *dialog1;
gtk_init(&argc, &argv);
xmlTree = glade_xml_new ("interface.glade", NULL, NULL);
dialog1 = glade_xml_get_widget(xmlTree, "dialog1");
glade_xml_signal_autoconnect(xmlTree);
g_object_unref( xmlTree );
gtk_widget_show(dialog1);
gtk_main();
return EXIT_SUCCESS;
}
/********************/
interface.glade
/********************/
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.0 on Fri Jun 1 22:29:58 2007 by didi at Cometa
-->
<glade-interface>
<widget class="GtkDialog" id="dialog1">
<property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<signal name="response" handler="resposta" object="entry1"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">button</property>
<property name="response_id">-5</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">button</property>
<property name="response_id">-6</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
/********************/
Is this behavior desired or is it a bug?
Seems to be a bug, but what I know? ;-)
--
Diogo F. S. Ramos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20070602/a286dd9a/attachment.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]