GladeAccelInfo * glade_accel_read (GladeXmlNode * node, gboolean require_signal) { GladeAccelInfo *ainfo; gchar *key, *modifiers, *signal; g_return_val_if_fail (node != NULL, NULL); if (!glade_xml_node_verify (node, GLADE_TAG_ACCEL)) return NULL; /* Get from xml... */ key = glade_xml_get_property_string_required (node, GLADE_TAG_ACCEL_KEY, NULL); if (require_signal) signal = glade_xml_get_property_string_required (node, GLADE_TAG_ACCEL_SIGNAL, NULL); else signal = glade_xml_get_property_string (node, GLADE_TAG_ACCEL_SIGNAL); modifiers = glade_xml_get_property_string (node, GLADE_TAG_ACCEL_MODIFIERS); /* translate to GladeAccelInfo... */ ainfo = g_new0 (GladeAccelInfo, 1); ainfo->key = gdk_keyval_from_name (key); ainfo->signal = signal; /* take string ownership... */ ainfo->modifiers = glade_gtk_parse_modifiers (modifiers); g_free (modifiers); return ainfo; }
/** * glade_property_read: * @property: a #GladeProperty or #NULL * @project: the #GladeProject * @node: the #GladeXmlNode to read, will either be a 'widget' * node or a 'child' node for packing properties. * * Read the value and any attributes for @property from @node, assumes * @property is being loaded for @project * * Note that object values will only be resolved after the project is * completely loaded */ void glade_property_read (GladeProperty * property, GladeProject * project, GladeXmlNode * prop) { GValue *gvalue = NULL; gchar /* *id, *name, */ * value; gint translatable = FALSE; gchar *comment = NULL, *context = NULL; g_return_if_fail (GLADE_IS_PROPERTY (property)); g_return_if_fail (GLADE_IS_PROJECT (project)); g_return_if_fail (prop != NULL); if (!glade_xml_node_verify (prop, GLADE_XML_TAG_PROPERTY)) return; if (!(value = glade_xml_get_content (prop))) return; /* If an optional property is specified in the * glade file, its enabled */ property->priv->enabled = TRUE; if (glade_property_class_is_object (property->priv->klass)) { /* we must synchronize this directly after loading this project * (i.e. lookup the actual objects after they've been parsed and * are present). */ g_object_set_data_full (G_OBJECT (property), "glade-loaded-object", g_strdup (value), g_free); } else { gvalue = glade_property_class_make_gvalue_from_string (property->priv->klass, value, project); GLADE_PROPERTY_GET_KLASS (property)->set_value (property, gvalue); g_value_unset (gvalue); g_free (gvalue); } translatable = glade_xml_get_property_boolean (prop, GLADE_TAG_TRANSLATABLE, FALSE); comment = glade_xml_get_property_string (prop, GLADE_TAG_COMMENT); context = glade_xml_get_property_string (prop, GLADE_TAG_CONTEXT); glade_property_i18n_set_translatable (property, translatable); glade_property_i18n_set_comment (property, comment); glade_property_i18n_set_context (property, context); g_free (comment); g_free (context); g_free (value); }
static void glade_gtk_widget_read_style_classes (GladeWidget * widget, GladeXmlNode * node) { GladeXmlNode *style_node; GladeXmlNode *class_node; GList *string_list = NULL; if ((style_node = glade_xml_search_child (node, GLADE_TAG_STYLE)) != NULL) { for (class_node = glade_xml_node_get_children (style_node); class_node; class_node = glade_xml_node_next (class_node)) { gchar *name; if (!glade_xml_node_verify (class_node, GLADE_TAG_CLASS)) continue; name = glade_xml_get_property_string (class_node, GLADE_TAG_NAME); string_list = glade_string_list_append (string_list, name, NULL, NULL, FALSE, NULL); g_free (name); } glade_widget_property_set (widget, "glade-style-classes", string_list); glade_string_list_free (string_list); } }
static void glade_gtk_parse_atk_props_gtkbuilder (GladeWidget * widget, GladeXmlNode * node) { GladeXmlNode *child, *object_node; gchar *internal; /* Search for internal "accessible" child and redirect parse from there */ for (child = glade_xml_node_get_children (node); child; child = glade_xml_node_next (child)) { if (glade_xml_node_verify_silent (child, GLADE_XML_TAG_CHILD)) { if ((internal = glade_xml_get_property_string (child, GLADE_XML_TAG_INTERNAL_CHILD))) { if (!strcmp (internal, GLADE_TAG_A11Y_INTERNAL_NAME) && (object_node = glade_xml_search_child_required (child, GLADE_XML_TAG_WIDGET))) glade_gtk_parse_atk_props (widget, object_node); g_free (internal); } } } }
static void glade_gtk_combo_box_text_read_items (GladeWidget *widget, GladeXmlNode *node) { GladeXmlNode *items_node; GladeXmlNode *item_node; GList *string_list = NULL; if ((items_node = glade_xml_search_child (node, GLADE_TAG_ITEMS)) != NULL) { for (item_node = glade_xml_node_get_children (items_node); item_node; item_node = glade_xml_node_next (item_node)) { gchar *str, *comment, *context; gchar *id; gboolean translatable; if (!glade_xml_node_verify (item_node, GLADE_TAG_ITEM)) continue; if ((str = glade_xml_get_content (item_node)) == NULL) continue; id = glade_xml_get_property_string (item_node, GLADE_TAG_ID); context = glade_xml_get_property_string (item_node, GLADE_TAG_CONTEXT); comment = glade_xml_get_property_string (item_node, GLADE_TAG_COMMENT); translatable = glade_xml_get_property_boolean (item_node, GLADE_TAG_TRANSLATABLE, FALSE); string_list = glade_string_list_append (string_list, str, comment, context, translatable, id); g_free (str); g_free (context); g_free (comment); g_free (id); } glade_widget_property_set (widget, "glade-items", string_list); glade_string_list_free (string_list); } }
static void glade_gtk_icon_factory_read_sources (GladeWidget *widget, GladeXmlNode *node) { GladeIconSources *sources; GtkIconSource *source; GladeXmlNode *sources_node, *source_node; GValue *value; GList *list; gchar *current_icon_name = NULL; GdkPixbuf *pixbuf; if ((sources_node = glade_xml_search_child (node, GLADE_TAG_SOURCES)) == NULL) return; sources = glade_icon_sources_new (); /* Here we expect all icon sets to remain together in the list. */ for (source_node = glade_xml_node_get_children (sources_node); source_node; source_node = glade_xml_node_next (source_node)) { gchar *icon_name; gchar *str; if (!glade_xml_node_verify (source_node, GLADE_TAG_SOURCE)) continue; if (!(icon_name = glade_xml_get_property_string_required (source_node, GLADE_TAG_STOCK_ID, NULL))) continue; if (! (str = glade_xml_get_property_string_required (source_node, GLADE_TAG_FILENAME, NULL))) { g_free (icon_name); continue; } if (!current_icon_name || strcmp (current_icon_name, icon_name) != 0) current_icon_name = (g_free (current_icon_name), g_strdup (icon_name)); G_GNUC_BEGIN_IGNORE_DEPRECATIONS source = gtk_icon_source_new (); G_GNUC_END_IGNORE_DEPRECATIONS /* Deal with the filename... */ value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, str, glade_widget_get_project (widget)); pixbuf = g_value_dup_object (value); g_value_unset (value); g_free (value); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_icon_source_set_pixbuf (source, pixbuf); G_GNUC_END_IGNORE_DEPRECATIONS g_object_unref (G_OBJECT (pixbuf)); g_free (str); /* Now the attributes... */ if ((str = glade_xml_get_property_string (source_node, GLADE_TAG_DIRECTION)) != NULL) { GtkTextDirection direction = glade_utils_enum_value_from_string (GTK_TYPE_TEXT_DIRECTION, str); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_icon_source_set_direction_wildcarded (source, FALSE); gtk_icon_source_set_direction (source, direction); G_GNUC_END_IGNORE_DEPRECATIONS g_free (str); } if ((str = glade_xml_get_property_string (source_node, GLADE_TAG_SIZE)) != NULL) { GtkIconSize size = glade_utils_enum_value_from_string (GTK_TYPE_ICON_SIZE, str); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_icon_source_set_size_wildcarded (source, FALSE); gtk_icon_source_set_size (source, size); G_GNUC_END_IGNORE_DEPRECATIONS g_free (str); } if ((str = glade_xml_get_property_string (source_node, GLADE_TAG_STATE)) != NULL) { GtkStateType state = glade_utils_enum_value_from_string (GTK_TYPE_STATE_TYPE, str); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_icon_source_set_state_wildcarded (source, FALSE); gtk_icon_source_set_state (source, state); G_GNUC_END_IGNORE_DEPRECATIONS g_free (str); } if ((list = g_hash_table_lookup (sources->sources, g_strdup (current_icon_name))) != NULL) { GList *new_list = g_list_append (list, source); /* Warning: if we use g_list_prepend() the returned pointer will be different * so we would have to replace the list pointer in the hash table. * But before doing that we have to steal the old list pointer otherwise * we would have to make a copy then add the new icon to finally replace the hash table * value. * Anyways if we choose to prepend we would have to reverse the list outside this loop * so its better to append. */ if (new_list != list) { /* current g_list_append() returns the same pointer so this is not needed */ g_hash_table_steal (sources->sources, current_icon_name); g_hash_table_insert (sources->sources, g_strdup (current_icon_name), new_list); } } else { list = g_list_append (NULL, source); g_hash_table_insert (sources->sources, g_strdup (current_icon_name), list); } } if (g_hash_table_size (sources->sources) > 0) glade_widget_property_set (widget, "sources", sources); glade_icon_sources_free (sources); }
static void glade_gtk_parse_atk_props (GladeWidget * widget, GladeXmlNode * node) { GladeXmlNode *prop; GladeProperty *property; GValue *gvalue; gchar *value, *name, *id, *comment; gint translatable; gboolean is_action; for (prop = glade_xml_node_get_children (node); prop; prop = glade_xml_node_next (prop)) { if (glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_PROPERTY)) is_action = FALSE; else if (glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_ACTION)) is_action = TRUE; else continue; if (!is_action && !(name = glade_xml_get_property_string_required (prop, GLADE_XML_TAG_NAME, NULL))) continue; else if (is_action && !(name = glade_xml_get_property_string_required (prop, GLADE_TAG_A11Y_ACTION_NAME, NULL))) continue; /* Make sure we are working with dashes and * not underscores ... */ id = glade_util_read_prop_name (name); g_free (name); /* We are namespacing the action properties internally * just incase they clash (all property names must be * unique...) */ if (is_action) { name = g_strdup_printf ("atk-%s", id); g_free (id); id = name; } if ((property = glade_widget_get_property (widget, id)) != NULL) { /* Complex statement just getting the value here... */ if ((!is_action && !(value = glade_xml_get_content (prop))) || (is_action && !(value = glade_xml_get_property_string_required (prop, GLADE_TAG_A11Y_DESC, NULL)))) { /* XXX should be a glade_xml_get_content_required()... */ g_free (id); continue; } /* Set the parsed value on the property ... */ gvalue = glade_property_class_make_gvalue_from_string (glade_property_get_class (property), value, glade_widget_get_project (widget)); glade_property_set_value (property, gvalue); g_value_unset (gvalue); g_free (gvalue); /* Deal with i18n... ... XXX Do i18n context !!! */ translatable = glade_xml_get_property_boolean (prop, GLADE_TAG_TRANSLATABLE, FALSE); comment = glade_xml_get_property_string (prop, GLADE_TAG_COMMENT); glade_property_i18n_set_translatable (property, translatable); glade_property_i18n_set_comment (property, comment); g_free (comment); g_free (value); } g_free (id); } }