Custom widgets with GtkBuilder
- From: Braden McDaniel <braden endoframe com>
- To: gtk-list gnome org
- Subject: Custom widgets with GtkBuilder
- Date: Wed, 23 Jul 2008 00:45:16 -0400
I posted this query to gtk-app-devel a couple of days ago; but so far it
has no takers. Hopefully someone here will have some insight...
I'm migrating some code from libglade to GtkBuilder.
I have inherited GtkFileChooserDialog in order to perform some setup
when creating it (i.e., set title, set the default response, and add
some filters). With libglade, I was performing this logic in a _new
function; I delegated to the _new function in the callback supplied to
glade_register_widget.
When migrating to GtkBuilder, I didn't find an equivalent of
glade_register_widget. I concluded that GtkBuilder must simply use
g_object_new and decided that the most convenient way to do the
initialization I want to do would be to move it to the _init function.
That function now looks like this:
void
openvrml_player_file_chooser_dialog_init(
OpenvrmlPlayerFileChooserDialog * dialog)
{
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_default_response(GTK_DIALOG(dialog),
GTK_RESPONSE_ACCEPT);
GtkFileFilter * const world_filter = gtk_file_filter_new();
g_return_if_fail(world_filter);
scope_guard world_filter_guard = make_guard(g_object_unref,
world_filter);
boost::ignore_unused_variable_warning(world_filter_guard);
gtk_file_filter_set_name(world_filter, "VRML/X3D worlds");
gtk_file_filter_add_mime_type(world_filter, "x-world/x-vrml");
gtk_file_filter_add_mime_type(world_filter, "model/vrml");
gtk_file_filter_add_mime_type(world_filter, "model/x3d+vrml");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), world_filter);
world_filter_guard.dismiss();
GtkFileFilter * const all_filter = gtk_file_filter_new();
g_return_if_fail(all_filter);
scope_guard all_filter_guard = make_guard(g_object_unref, all_filter);
boost::ignore_unused_variable_warning(all_filter_guard);
gtk_file_filter_set_name(all_filter, "All files");
gtk_file_filter_add_pattern(all_filter, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), all_filter);
all_filter_guard.dismiss();
}
But since moving the code and having GtkBuilder create the widget, I'm
now getting these assertion failures:
(openvrml-player:25152): Gtk-CRITICAL **: gtk_file_chooser_add_filter: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed
(openvrml-player:25152): Gtk-CRITICAL **: gtk_file_chooser_add_filter: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed
I have a feeling that I've overlooked something and GtkBuilder isn't
creating the widget correctly; any ideas?
--
Braden McDaniel e-mail: <braden endoframe com>
<http://endoframe.com> Jabber: <braden jabber org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]