static void gb_slider_add_child (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *type) { GbSliderPosition position = GB_SLIDER_NONE; g_assert (GTK_IS_BUILDABLE (buildable)); g_assert (GTK_IS_BUILDER (builder)); g_assert (G_IS_OBJECT (child)); if (!GTK_IS_WIDGET (child)) { g_warning ("Child \"%s\" must be of type GtkWidget.", g_type_name (G_OBJECT_TYPE (child))); return; } if (ide_str_equal0 (type, "bottom")) position = GB_SLIDER_BOTTOM; else if (ide_str_equal0 (type, "top")) position = GB_SLIDER_TOP; else if (ide_str_equal0 (type, "left")) position = GB_SLIDER_LEFT; else if (ide_str_equal0 (type, "right")) position = GB_SLIDER_RIGHT; gtk_container_add_with_properties (GTK_CONTAINER (buildable), GTK_WIDGET (child), "position", position, NULL); }
static gboolean gb_shortcuts_dialog_custom_tag_start (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *tagname, GMarkupParser *parser, gpointer *data) { g_assert (GTK_IS_BUILDABLE (buildable)); g_assert (GTK_IS_BUILDER (builder)); g_assert (tagname != NULL); g_assert (parser != NULL); g_assert (data != NULL); if (g_strcmp0 (tagname, "views") == 0) { ViewsParserData *parser_data; parser_data = g_slice_new0 (ViewsParserData); parser_data->self = g_object_ref (buildable); parser_data->builder = g_object_ref (builder); parser_data->stack = g_queue_new (); parser_data->column_image_size_groups = g_queue_new (); parser_data->column_desc_size_groups = g_queue_new (); *parser = ViewsParser; *data = parser_data; return TRUE; } return FALSE; }
/** * gtk_buildable_parser_finished: * @buildable: a #GtkBuildable * @builder: a #GtkBuilder * * Called when the builder finishes the parsing of a * <link linkend="BUILDER-UI">GtkBuilder UI definition</link>. * Note that this will be called once for each time * gtk_builder_add_from_file() or gtk_builder_add_from_string() * is called on a builder. * * Since: 2.12 **/ void gtk_buildable_parser_finished (GtkBuildable *buildable, GtkBuilder *builder) { GtkBuildableIface *iface; g_return_if_fail (GTK_IS_BUILDABLE (buildable)); g_return_if_fail (GTK_IS_BUILDER (builder)); iface = GTK_BUILDABLE_GET_IFACE (buildable); if (iface->parser_finished) (* iface->parser_finished) (buildable, builder); }
/** * gtk_buildable_get_name: * @buildable: a #GtkBuildable * * Gets the name of the @buildable object. * * #GtkBuilder sets the name based on the the * <link linkend="BUILDER-UI">GtkBuilder UI definition</link> * used to construct the @buildable. * * Returns: the name set with gtk_buildable_set_name() * * Since: 2.12 **/ const gchar * gtk_buildable_get_name (GtkBuildable *buildable) { GtkBuildableIface *iface; g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), NULL); iface = GTK_BUILDABLE_GET_IFACE (buildable); if (iface->get_name) return (* iface->get_name) (buildable); else return (const gchar*)g_object_get_data (G_OBJECT (buildable), "gtk-builder-name"); }
/** * gtk_buildable_custom_finished: * @buildable: a #GtkBuildable * @builder: a #GtkBuilder * @child: (allow-none): child object or %NULL for non-child tags * @tagname: the name of the tag * @data: user data created in custom_tag_start * * This is similar to gtk_buildable_parser_finished() but is * called once for each custom tag handled by the @buildable. * * Since: 2.12 **/ void gtk_buildable_custom_finished (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *tagname, gpointer data) { GtkBuildableIface *iface; g_return_if_fail (GTK_IS_BUILDABLE (buildable)); g_return_if_fail (GTK_IS_BUILDER (builder)); iface = GTK_BUILDABLE_GET_IFACE (buildable); if (iface->custom_finished) (* iface->custom_finished) (buildable, builder, child, tagname, data); }
/** * gtk_buildable_construct_child: * @buildable: A #GtkBuildable * @builder: #GtkBuilder used to construct this object * @name: name of child to construct * * Constructs a child of @buildable with the name @name. * * #GtkBuilder calls this function if a "constructor" has been * specified in the UI definition. * * Returns: (transfer full): the constructed child * * Since: 2.12 **/ GObject * gtk_buildable_construct_child (GtkBuildable *buildable, GtkBuilder *builder, const gchar *name) { GtkBuildableIface *iface; g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), NULL); g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL); g_return_val_if_fail (name != NULL, NULL); iface = GTK_BUILDABLE_GET_IFACE (buildable); g_return_val_if_fail (iface->construct_child != NULL, NULL); return (* iface->construct_child) (buildable, builder, name); }
/** * gtk_buildable_add_child: * @buildable: a #GtkBuildable * @builder: a #GtkBuilder * @child: child to add * @type: (allow-none): kind of child or %NULL * * Adds a child to @buildable. @type is an optional string * describing how the child should be added. * * Since: 2.12 **/ void gtk_buildable_add_child (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *type) { GtkBuildableIface *iface; g_return_if_fail (GTK_IS_BUILDABLE (buildable)); g_return_if_fail (GTK_IS_BUILDER (builder)); iface = GTK_BUILDABLE_GET_IFACE (buildable); g_return_if_fail (iface->add_child != NULL); (* iface->add_child) (buildable, builder, child, type); }
/** * gtk_buildable_get_internal_child: * @buildable: a #GtkBuildable * @builder: a #GtkBuilder * @childname: name of child * * Get the internal child called @childname of the @buildable object. * * Returns: (transfer none): the internal child of the buildable object * * Since: 2.12 **/ GObject * gtk_buildable_get_internal_child (GtkBuildable *buildable, GtkBuilder *builder, const gchar *childname) { GtkBuildableIface *iface; g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), NULL); g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL); g_return_val_if_fail (childname != NULL, NULL); iface = GTK_BUILDABLE_GET_IFACE (buildable); if (!iface->get_internal_child) return NULL; return (* iface->get_internal_child) (buildable, builder, childname); }
static const gchar * get_name (gpointer obj) { GtkWidget *widget; if (obj == NULL) return "(nil)"; else if (GTK_IS_WIDGET (obj)) widget = GTK_WIDGET (obj); else if (GTK_IS_ACCESSIBLE (obj)) widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); else return "OOPS"; if (GTK_IS_BUILDABLE (widget)) return gtk_buildable_get_name (GTK_BUILDABLE (widget)); else return G_OBJECT_TYPE_NAME (widget); }
/** * gtk_buildable_set_name: * @buildable: a #GtkBuildable * @name: name to set * * Sets the name of the @buildable object. * * Since: 2.12 **/ void gtk_buildable_set_name (GtkBuildable *buildable, const gchar *name) { GtkBuildableIface *iface; g_return_if_fail (GTK_IS_BUILDABLE (buildable)); g_return_if_fail (name != NULL); iface = GTK_BUILDABLE_GET_IFACE (buildable); if (iface->set_name) (* iface->set_name) (buildable, name); else g_object_set_data_full (G_OBJECT (buildable), "gtk-builder-name", g_strdup (name), g_free); }
/** * gtk_buildable_set_buildable_property: * @buildable: a #GtkBuildable * @builder: a #GtkBuilder * @name: name of property * @value: value of property * * Sets the property name @name to @value on the @buildable object. * * Since: 2.12 **/ void gtk_buildable_set_buildable_property (GtkBuildable *buildable, GtkBuilder *builder, const gchar *name, const GValue *value) { GtkBuildableIface *iface; g_return_if_fail (GTK_IS_BUILDABLE (buildable)); g_return_if_fail (GTK_IS_BUILDER (builder)); g_return_if_fail (name != NULL); g_return_if_fail (value != NULL); iface = GTK_BUILDABLE_GET_IFACE (buildable); if (iface->set_buildable_property) (* iface->set_buildable_property) (buildable, builder, name, value); else g_object_set_property (G_OBJECT (buildable), name, value); }
/** * gtk_buildable_custom_tag_start: * @buildable: a #GtkBuildable * @builder: a #GtkBuilder used to construct this object * @child: (allow-none): child object or %NULL for non-child tags * @tagname: name of tag * @parser: (out): a #GMarkupParser structure to fill in * @data: (out): return location for user data that will be passed in * to parser functions * * This is called for each unknown element under <child>. * * Returns: %TRUE if a object has a custom implementation, %FALSE * if it doesn't. * * Since: 2.12 **/ gboolean gtk_buildable_custom_tag_start (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *tagname, GMarkupParser *parser, gpointer *data) { GtkBuildableIface *iface; g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), FALSE); g_return_val_if_fail (GTK_IS_BUILDER (builder), FALSE); g_return_val_if_fail (tagname != NULL, FALSE); iface = GTK_BUILDABLE_GET_IFACE (buildable); g_return_val_if_fail (iface->custom_tag_start != NULL, FALSE); return (* iface->custom_tag_start) (buildable, builder, child, tagname, parser, data); }
static GObject * egg_search_bar_get_internal_child (GtkBuildable *buildable, GtkBuilder *builder, const gchar *childname) { EggSearchBar *self = (EggSearchBar *)buildable; EggSearchBarPrivate *priv = egg_search_bar_get_instance_private (self); g_assert (GTK_IS_BUILDABLE (buildable)); g_assert (EGG_IS_SEARCH_BAR (self)); g_assert (GTK_IS_BUILDER (builder)); g_assert (childname != NULL); if (g_strcmp0 (childname, "entry") == 0) return G_OBJECT (priv->entry); else if (g_strcmp0 (childname, "revealer") == 0) return G_OBJECT (priv->revealer); return NULL; }
static void end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { ParserData *data = (ParserData*)user_data; GTK_NOTE (BUILDER, g_message ("</%s>", element_name)); if (data->subparser && data->subparser->start) { subparser_end (context, element_name, data, error); return; } if (strcmp (element_name, "requires") == 0) { RequiresInfo *req_info = state_pop_info (data, RequiresInfo); /* TODO: Allow third party widget developers to check thier * required versions, possibly throw a signal allowing them * to check thier library versions here. */ if (!strcmp (req_info->library, "gtk+")) { if (!GTK_CHECK_VERSION (req_info->major, req_info->minor, 0)) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_VERSION_MISMATCH, "Required %s version %d.%d, current version is %d.%d", req_info->library, req_info->major, req_info->minor, GTK_MAJOR_VERSION, GTK_MINOR_VERSION); _gtk_builder_prefix_error (data->builder, context, error); } } free_requires_info (req_info, NULL); } else if (strcmp (element_name, "interface") == 0) { } else if (data->requested_objects && !data->inside_requested_object) { /* If outside a requested object, simply ignore this tag */ } else if (strcmp (element_name, "menu") == 0) { _gtk_builder_menu_end (data); } else if (strcmp (element_name, "object") == 0 || strcmp (element_name, "template") == 0) { ObjectInfo *object_info = state_pop_info (data, ObjectInfo); ChildInfo* child_info = state_peek_info (data, ChildInfo); if (data->requested_objects && data->inside_requested_object && (data->cur_object_level == data->requested_object_level)) { GTK_NOTE (BUILDER, g_message ("requested object end found at level %d", data->requested_object_level)); data->inside_requested_object = FALSE; } --data->cur_object_level; g_assert (data->cur_object_level >= 0); object_info->object = builder_construct (data, object_info, error); if (!object_info->object) { free_object_info (object_info); return; } if (child_info) child_info->object = object_info->object; if (GTK_IS_BUILDABLE (object_info->object) && GTK_BUILDABLE_GET_IFACE (object_info->object)->parser_finished) data->finalizers = g_slist_prepend (data->finalizers, object_info->object); _gtk_builder_add_signals (data->builder, object_info->signals); free_object_info (object_info); } else if (strcmp (element_name, "property") == 0) { PropertyInfo *prop_info = state_pop_info (data, PropertyInfo); CommonInfo *info = state_peek_info (data, CommonInfo); g_assert (info != NULL); /* Normal properties */ if (strcmp (info->tag.name, "object") == 0 || strcmp (info->tag.name, "template") == 0) { ObjectInfo *object_info = (ObjectInfo*)info; if (prop_info->translatable && prop_info->text->len) { const gchar *translated; translated = _gtk_builder_parser_translate (data->domain, prop_info->context, prop_info->text->str); g_string_assign (prop_info->text, translated); } object_info->properties = g_slist_prepend (object_info->properties, prop_info); } else g_assert_not_reached (); } else if (strcmp (element_name, "child") == 0) { ChildInfo *child_info = state_pop_info (data, ChildInfo); _gtk_builder_add (data->builder, child_info); free_child_info (child_info); } else if (strcmp (element_name, "signal") == 0) { SignalInfo *signal_info = state_pop_info (data, SignalInfo); ObjectInfo *object_info = (ObjectInfo*)state_peek_info (data, CommonInfo); g_assert (object_info != NULL); signal_info->object_name = g_strdup (object_info->id); object_info->signals = g_slist_prepend (object_info->signals, signal_info); } else if (strcmp (element_name, "placeholder") == 0) { } else { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_UNHANDLED_TAG, "Unhandled tag: <%s>", element_name); _gtk_builder_prefix_error (data->builder, context, error); } }