void glade_gtk_file_filter_write_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlContext *context, GladeXmlNode *node) { GladeXmlNode *strings_node; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node); strings_node = glade_xml_node_new (context, GLADE_TAG_MIME_TYPES); glade_gtk_filter_write_strings (widget, context, strings_node, FILTER_MIME, "glade-mime-types"); if (!glade_xml_node_get_children (strings_node)) glade_xml_node_delete (strings_node); else glade_xml_node_append_child (node, strings_node); strings_node = glade_xml_node_new (context, GLADE_TAG_PATTERNS); glade_gtk_filter_write_strings (widget, context, strings_node, FILTER_PATTERN, "glade-patterns"); if (!glade_xml_node_get_children (strings_node)) glade_xml_node_delete (strings_node); else glade_xml_node_append_child (node, strings_node); }
void glade_gtk_button_read_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlNode * node) { GObject *object; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->read_widget (adaptor, widget, node); glade_gtk_button_update_stock (widget); /* Fold "font-name" property into the "font" propery */ object = glade_widget_get_object (widget); if (GTK_IS_FONT_BUTTON (object)) { gchar *font_prop_value = NULL; glade_widget_property_get (widget, "font-name", &font_prop_value); if (font_prop_value != NULL) { glade_widget_property_set (widget, "font", font_prop_value); glade_widget_property_set (widget, "font-name", NULL); } } }
void glade_gtk_widget_read_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlNode * node) { const gchar *tooltip_markup = NULL; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node); /* Read in accelerators */ glade_gtk_read_accels (widget, node, TRUE); /* Read in atk props */ glade_gtk_widget_read_atk_props (widget, node); /* Read in the style classes */ glade_gtk_widget_read_style_classes (widget, node); /* Resolve the virtual tooltip use markup property */ glade_widget_property_get (widget, "tooltip-markup", &tooltip_markup); if (tooltip_markup != NULL) glade_widget_property_set (widget, "glade-tooltip-markup", TRUE); }
void glade_gtk_combo_box_text_write_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlContext *context, GladeXmlNode *node) { GladeXmlNode *attrs_node; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_COMBO_BOX)->write_widget (adaptor, widget, context, node); attrs_node = glade_xml_node_new (context, GLADE_TAG_ITEMS); glade_gtk_combo_box_text_write_items (widget, context, attrs_node); if (!glade_xml_node_get_children (attrs_node)) glade_xml_node_delete (attrs_node); else glade_xml_node_append_child (node, attrs_node); }
void glade_gtk_size_group_read_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlNode * node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node); glade_gtk_size_group_read_widgets (widget, node); }
void glade_gtk_combo_box_text_read_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlNode *node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_COMBO_BOX)->read_widget (adaptor, widget, node); glade_gtk_combo_box_text_read_items (widget, node); }
void glade_gtk_file_filter_read_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlNode *node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node); glade_gtk_filter_read_strings (widget, node, FILTER_MIME, "glade-mime-types"); glade_gtk_filter_read_strings (widget, node, FILTER_PATTERN, "glade-patterns"); }
void glade_gtk_window_write_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlContext * context, GladeXmlNode * node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context, node); glade_gtk_window_write_accel_groups (widget, context, node); }
void glade_gtk_icon_factory_write_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlContext *context, GladeXmlNode *node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and write all the normal properties.. */ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node); glade_gtk_icon_factory_write_sources (widget, context, node); }
void glade_gtk_tool_button_read_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlNode * node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->read_widget (adaptor, widget, node); /* Run this after the load so that icon-widget is resolved. */ g_signal_connect (glade_widget_get_project (widget), "parse-finished", G_CALLBACK (glade_gtk_tool_button_parse_finished), widget); }
void glade_gtk_image_write_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlContext *context, GladeXmlNode *node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and write all the normal properties (including "use-stock")... */ GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context, node); glade_gtk_write_icon_size (widget, context, node, "icon-size"); }
void glade_gtk_read_accels (GladeWidget * widget, GladeXmlNode * node, gboolean require_signal) { GladeProperty *property; GladeXmlNode *prop; GladeAccelInfo *ainfo; GValue *value = NULL; GList *accels = NULL; for (prop = glade_xml_node_get_children (node); prop; prop = glade_xml_node_next (prop)) { if (!glade_xml_node_verify_silent (prop, GLADE_TAG_ACCEL)) continue; if ((ainfo = glade_accel_read (prop, require_signal)) != NULL) accels = g_list_prepend (accels, ainfo); } if (accels) { value = g_new0 (GValue, 1); g_value_init (value, GLADE_TYPE_ACCEL_GLIST); g_value_take_boxed (value, accels); property = glade_widget_get_property (widget, "accelerator"); glade_property_set_value (property, value); g_value_unset (value); g_free (value); } }
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_parse_atk_relation (GladeProperty * property, GladeXmlNode * node) { GladeXmlNode *prop; GladePropertyClass *pclass; gchar *type, *target, *id, *tmp; gchar *string = NULL; 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_RELATION)) continue; if (!(type = glade_xml_get_property_string_required (prop, GLADE_TAG_A11Y_TYPE, NULL))) continue; if (!(target = glade_xml_get_property_string_required (prop, GLADE_TAG_A11Y_TARGET, NULL))) { g_free (type); continue; } id = glade_util_read_prop_name (type); pclass = glade_property_get_class (property); if (!strcmp (id, glade_property_class_id (pclass))) { if (string == NULL) string = g_strdup (target); else { tmp = g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER, target); string = (g_free (string), tmp); } } g_free (id); g_free (type); g_free (target); } /* we must synchronize this directly after loading this project * (i.e. lookup the actual objects after they've been parsed and * are present). this is a feature of object and object list properties * that needs a better api. */ if (string) { g_object_set_data_full (G_OBJECT (property), "glade-loaded-object", /* 'string' here is already allocated on the heap */ string, g_free); } }
void glade_gtk_window_read_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlNode * node) { if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node); /* Sync the icon mode */ if (glade_widget_property_original_default (widget, "icon") == FALSE) glade_widget_property_set (widget, "glade-window-icon-name", FALSE); else glade_widget_property_set (widget, "glade-window-icon-name", TRUE); glade_gtk_window_read_accel_groups (widget, node); }
void glade_gtk_button_write_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlContext * context, GladeXmlNode * node) { GladeProperty *prop; gboolean use_stock; gchar *stock = NULL; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* Do not save GtkColorButton GtkFontButton and GtkScaleButton label property */ if (!(GTK_IS_COLOR_BUTTON (glade_widget_get_object (widget)) || GTK_IS_FONT_BUTTON (glade_widget_get_object (widget)) || GTK_IS_SCALE_BUTTON (glade_widget_get_object (widget)))) { /* Make a copy of the GladeProperty, * override its value and ensure non-translatable if use-stock is TRUE */ prop = glade_widget_get_property (widget, "label"); prop = glade_property_dup (prop, widget); glade_widget_property_get (widget, "use-stock", &use_stock); if (use_stock) { glade_widget_property_get (widget, "stock", &stock); glade_property_i18n_set_translatable (prop, FALSE); glade_property_set (prop, stock); } glade_property_write (prop, context, node); g_object_unref (G_OBJECT (prop)); } /* Write out other normal properties and any other class derived custom properties after ... */ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_widget (adaptor, widget, context, node); }
void glade_gtk_image_read_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlNode *node) { GladeProperty *property; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node); if (glade_widget_property_original_default (widget, "icon-name") == FALSE) { property = glade_widget_get_property (widget, "icon-name"); glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_ICON); } else if (glade_widget_property_original_default (widget, "resource") == FALSE) { property = glade_widget_get_property (widget, "resource"); glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_RESOURCE); } else if (glade_widget_property_original_default (widget, "pixbuf") == FALSE) { property = glade_widget_get_property (widget, "pixbuf"); glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_FILENAME); } else /* if (glade_widget_property_original_default (widget, "stock") == FALSE) */ { property = glade_widget_get_property (widget, "stock"); glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_STOCK); } glade_property_sync (property); }
void glade_gtk_widget_write_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlContext * context, GladeXmlNode * node) { GladeProperty *prop; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* Make sure use-action-appearance and related-action properties are * ordered in a sane way and are only saved if there is an action */ prop = glade_widget_get_property (widget, "use-action-appearance"); if (prop && glade_property_get_enabled (prop)) glade_property_write (prop, context, node); prop = glade_widget_get_property (widget, "related-action"); if (prop && glade_property_get_enabled (prop)) glade_property_write (prop, context, node); /* Finally chain up and read in all the normal properties.. */ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node); }
/** * glade_property_write: * @property: a #GladeProperty * @context: A #GladeXmlContext * @node: A #GladeXmlNode * * Write @property to @node */ void glade_property_write (GladeProperty * property, GladeXmlContext * context, GladeXmlNode * node) { GladeXmlNode *prop_node; gchar *name, *value; gboolean save_always; g_return_if_fail (GLADE_IS_PROPERTY (property)); g_return_if_fail (node != NULL); /* This code should work the same for <packing>, <widget> and <template> */ if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_PACKING) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* There can be a couple of reasons to forcefully save a property */ save_always = (glade_property_class_save_always (property->priv->klass) || property->priv->save_always); save_always = save_always || (glade_property_class_optional (property->priv->klass) && property->priv->enabled); /* Skip properties that are default by original pspec default * (excepting those that specified otherwise). */ if (!save_always && glade_property_original_default (property)) return; /* Escape our string and save with underscores */ name = g_strdup (glade_property_class_id (property->priv->klass)); glade_util_replace (name, '-', '_'); /* convert the value of this property to a string */ if (!(value = glade_widget_adaptor_string_from_value (glade_property_class_get_adaptor (property->priv->klass), property->priv->klass, property->priv->value))) /* make sure we keep the empty string, also... upcomming * funcs that may not like NULL. */ value = g_strdup (""); /* Now dump the node values... */ prop_node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY); glade_xml_node_append_child (node, prop_node); /* Name and value */ glade_xml_node_set_property_string (prop_node, GLADE_XML_TAG_NAME, name); glade_xml_set_content (prop_node, value); /* i18n stuff */ if (glade_property_class_translatable (property->priv->klass)) { if (property->priv->i18n_translatable) glade_xml_node_set_property_string (prop_node, GLADE_TAG_TRANSLATABLE, GLADE_XML_TAG_I18N_TRUE); if (property->priv->i18n_context) glade_xml_node_set_property_string (prop_node, GLADE_TAG_CONTEXT, property->priv->i18n_context); if (property->priv->i18n_comment) glade_xml_node_set_property_string (prop_node, GLADE_TAG_COMMENT, property->priv->i18n_comment); } g_free (name); g_free (value); }
void glade_gtk_entry_read_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlNode * node) { GladeProperty *property; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) return; /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node); if (!glade_widget_property_original_default (widget, "text")) { property = glade_widget_get_property (widget, "text"); glade_widget_property_set (widget, "use-entry-buffer", FALSE); glade_property_sync (property); } else { gint target_minor, target_major; glade_project_get_target_version (glade_widget_get_project (widget), "gtk+", &target_major, &target_minor); property = glade_widget_get_property (widget, "buffer"); /* Only default to the buffer setting if the project version supports it. */ if (GPC_VERSION_CHECK (glade_property_get_class (property), target_major, target_minor)) { glade_widget_property_set (widget, "use-entry-buffer", TRUE); glade_property_sync (property); } else glade_widget_property_set (widget, "use-entry-buffer", FALSE); } if (!glade_widget_property_original_default (widget, "primary-icon-name")) { property = glade_widget_get_property (widget, "primary-icon-name"); glade_widget_property_set (widget, "primary-icon-mode", GLADE_IMAGE_MODE_ICON); } else if (!glade_widget_property_original_default (widget, "primary-icon-pixbuf")) { property = glade_widget_get_property (widget, "primary-icon-pixbuf"); glade_widget_property_set (widget, "primary-icon-mode", GLADE_IMAGE_MODE_FILENAME); } else /* if (glade_widget_property_original_default (widget, "stock") == FALSE) */ { property = glade_widget_get_property (widget, "primary-icon-stock"); glade_widget_property_set (widget, "primary-icon-mode", GLADE_IMAGE_MODE_STOCK); } glade_property_sync (property); if (!glade_widget_property_original_default (widget, "secondary-icon-name")) { property = glade_widget_get_property (widget, "secondary-icon-name"); glade_widget_property_set (widget, "secondary-icon-mode", GLADE_IMAGE_MODE_ICON); } else if (!glade_widget_property_original_default (widget, "secondary-icon-pixbuf")) { property = glade_widget_get_property (widget, "secondary-icon-pixbuf"); glade_widget_property_set (widget, "secondary-icon-mode", GLADE_IMAGE_MODE_FILENAME); } else /* if (glade_widget_property_original_default (widget, "stock") == FALSE) */ { property = glade_widget_get_property (widget, "secondary-icon-stock"); glade_widget_property_set (widget, "secondary-icon-mode", GLADE_IMAGE_MODE_STOCK); } glade_property_sync (property); if (!glade_widget_property_original_default (widget, "primary-icon-tooltip-markup")) glade_widget_property_set (widget, "glade-primary-tooltip-markup", TRUE); if (!glade_widget_property_original_default (widget, "secondary-icon-tooltip-markup")) glade_widget_property_set (widget, "glade-secondary-tooltip-markup", TRUE); }
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); } }