[Glade-users] callback -> gpointer user_data problem (perhaps Bug)
- From: lists brachttal net (Andreas Volz)
- Subject: [Glade-users] callback -> gpointer user_data problem (perhaps Bug)
- Date: Sun, 1 Aug 2004 12:22:56 +0200
Hi,
I created a GUI window in glade and created a toolbar for it. In the
window I added a GtkTreeView that I like to modify from the toolbar
(delete/add/...). So I created a button on the toolbar and connected a
signal "clicked" to the button. As object I gave the GtkTreeview object
(here: treeview_menu). As I understand the the callback could access now
treeview_menu with a cast of "gpointer user_data". But see what hapens:
my apps sourcecode:
void on_toolbutton_del_clicked (GtkToolButton *toolbutton,
gpointer user_data)
{
GtkWidget *treeview_menu;
treeview_menu = (GtkWidget*) user_data;
delete_table_row (treeview_menu);
}
This is printed if I click delete:
(e16menuedit2:23698): GLib-GObject-WARNING **: invalid cast from
`GtkToolButton' to `GtkTreeView'
(e16menuedit2:23698): Gtk-CRITICAL **: file gtktreeview.c: line 8693
(gtk_tree_view_get_model): assertion `GTK_IS_TREE_VIEW (tree_view)'
failed
(e16menuedit2:23698): GLib-GObject-WARNING **: invalid cast from
`GtkToolButton' to `GtkTreeView'
(e16menuedit2:23698): Gtk-CRITICAL **: file gtktreeview.c: line 8860
(gtk_tree_view_get_selection): assertion `GTK_IS_TREE_VIEW (tree_view)'
failed
(e16menuedit2:23698): Gtk-CRITICAL **: file gtktreeselection.c: line 362
(gtk_tree_selection_get_selected): assertion `GTK_IS_TREE_SELECTION
(selection)' failed
I use libglade to create the GUI, but looked into the created
interface.c to see what happens here:
This is how Glade connect the callback in interface.c:
g_signal_connect_swapped ((gpointer) toolbutton_del, "clicked",
G_CALLBACK (on_toolbutton_del_clicked),
GTK_OBJECT (treeview_menu));
But this doesn't work (at least with libglade) I didn't test the
interface.c source. If I connect the toolbutton myself in sourcecode it
looks like this:
GtkWidget *toolitem1;
toolitem1 = glade_xml_get_widget (main_xml, "toolbutton_del");
g_signal_connect (toolitem1, "clicked",
G_CALLBACK (on_toolbutton_del_clicked),
treeview_menu);
And this works! I'm not a really perfect gkt2 hacker and doesn't
understand all aspects of callback connecting. But why use Glade the
_swapped version to connect callbacks? And why doesn't this work? Same
problems with menubars (and probability other widgets) if I use
user_data to send objects to a widget.
I don't think it's a Glade or libglade bug, because other I think other
people had noticed this before. But where is my problem?
regards
Andreas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]