diff options
author | Tristan Van Berkom <tvb@src.gnome.org> | 2008-04-02 09:37:59 +0000 |
---|---|---|
committer | Tristan Van Berkom <tvb@src.gnome.org> | 2008-04-02 09:37:59 +0000 |
commit | f0e30042271f263b1867a232f0b0acfa42d696cc (patch) | |
tree | ed5ec41962b30c32ecc205c95e31fc71447abd6d | |
parent | c14b27004355a04b50f5f411d90b56882f870d1f (diff) | |
download | glade-f0e30042271f263b1867a232f0b0acfa42d696cc.tar.gz |
- Implemented atk relations
* gladeui/glade-widget-adaptor.c, gladeui/glade-signal.c:
Implemented loading of signals.
svn path=/branches/builder/; revision=1760
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | gladeui/glade-property-class.c | 97 | ||||
-rw-r--r-- | gladeui/glade-signal.c | 32 | ||||
-rw-r--r-- | gladeui/glade-signal.h | 3 | ||||
-rw-r--r-- | gladeui/glade-widget-adaptor.c | 23 | ||||
-rw-r--r-- | gladeui/glade-widget.c | 2 | ||||
-rw-r--r-- | gladeui/glade-xml-utils.h | 4 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk.c | 105 |
8 files changed, 142 insertions, 128 deletions
@@ -11,6 +11,10 @@ - Implemented loading of accelerators. - Implemented loading of atk properties (not relations or actions yet...) - Implemented loading of atk actions now... + - Implemented atk relations + + * gladeui/glade-widget-adaptor.c, gladeui/glade-signal.c: + Implemented loading of signals. 2008-04-01 Tristan Van Berkom <tvb@gnome.org> diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c index b8deba28..7a71a654 100644 --- a/gladeui/glade-property-class.c +++ b/gladeui/glade-property-class.c @@ -53,102 +53,6 @@ #define NUMERICAL_PAGE_INCREMENT 10 #define NUMERICAL_PAGE_SIZE 1 - -/* Hardcoded recognized atk actions - */ -typedef struct { - gchar *prop_name; - gchar *id; - gchar *name; - gchar *tooltip; -} GPCAtkPropertyTab; - -static const GPCAtkPropertyTab action_names_table[] = { - { "click", "atk-click", N_("Click"), - N_("Set the description of the Click atk action") }, - { "press", "atk-press", N_("Press"), - N_("Set the description of the Press atk action") }, - { "release", "atk-release", N_("Release"), - N_("Set the description of the Release atk action") }, - { "activate", "atk-activate", N_("Activate"), - N_("Set the description of the Activate atk action") } -}; - -static const GPCAtkPropertyTab relation_names_table[] = { - { "controlled-by", "atk-controlled-by", N_("Controlled By"), - N_("Indicates an object controlled by one or more target objects") }, - - { "controlled-for", "atk-controlled-for", N_("Controller For"), - N_("Indicates an object is a controller for one or more target objects") }, - - { "labelled-by", "atk-labelled-by", N_("Labelled By"), - N_("Indicates an object is labelled by one or more target objects") }, - - { "label-for", "atk-label-for", N_("Label For"), - N_("Indicates an object is a label for one or more target objects") }, - - { "member-of", "atk-member-of", N_("Member Of"), - N_("Indicates an object is a member of a group of one or more target objects") }, - - { "child-node-of", "atk-child-node-of", N_("Child Node Of"), - N_("Indicates an object is a cell in a treetable which is displayed " - "because a cell in the same column is expanded and identifies that cell") }, - - { "flows-to", "atk-flows-to", N_("Flows To"), - N_("Indicates that the object has content that flows logically to another " - "AtkObject in a sequential way (text-flow, for instance).") }, - - { "flows-from", "atk-flows-from", N_("Flows From"), - N_("Indicates that the object has content that flows logically from another " - "AtkObject in a sequential way, (for instance text-flow)") }, - - { "subwindow-of", "atk-subwindow-of", N_("Subwindow Of"), - N_("Indicates a subwindow attached to a component but otherwise has no " - "connection in the UI hierarchy to that component") }, - - { "embeds", "atk-embeds", N_("Embeds"), - N_("Indicates that the object visually embeds another object's content, " - "i.e. this object's content flows around another's content") }, - - { "embedded-by", "atk-embedded-by", N_("Embedded By"), - N_("Inverse of 'Embeds', indicates that this object's content " - "is visually embedded in another object") }, - - { "popup-for", "atk-popup-for", N_("Popup For"), - N_("Indicates that an object is a popup for another object") }, - - { "parent-window-of", "atk-parent-window-of", N_("Parent Window Of"), - N_("Indicates that an object is a parent window of another object") } -}; - - -/** - * glade_property_class_atk_realname: - * @atk_name: The id of the atk property - * - * Translates a GladePropertyClass->id to the name that should be - * saved into the glade file. - * - * Returns: a pointer to a constant string. - */ -G_CONST_RETURN gchar * -glade_property_class_atk_realname (const gchar *atk_name) -{ - gint i; - - g_return_val_if_fail (atk_name != NULL, NULL); - - for (i = 0; i < G_N_ELEMENTS (action_names_table); i++) - if (!strcmp (action_names_table[i].id, atk_name)) - return action_names_table[i].prop_name; - - for (i = 0; i < G_N_ELEMENTS (relation_names_table); i++) - if (!strcmp (relation_names_table[i].id, atk_name)) - return relation_names_table[i].prop_name; - - return atk_name; -} - /** * glade_property_class_new: * @handle: A generic pointer (i.e. a #GladeWidgetClass) @@ -1152,6 +1056,7 @@ glade_property_class_new_from_spec (gpointer handle, if (spec->flags & G_PARAM_CONSTRUCT_ONLY) property_class->construct_only = TRUE; + /* XXXX Is this still valid ??? NO !*/ if (g_type_is_a (spec->owner_type, ATK_TYPE_OBJECT)) { property_class->type = GPC_ATK_PROPERTY; diff --git a/gladeui/glade-signal.c b/gladeui/glade-signal.c index b111073e..87dc44c5 100644 --- a/gladeui/glade-signal.c +++ b/gladeui/glade-signal.c @@ -146,25 +146,37 @@ glade_signal_write (GladeSignalInfo *info, GladeSignal *signal, return TRUE; } +#endif // LOADING_WAS_IMPLEMENTED + /* * Returns a new GladeSignal with the attributes defined in node */ -GladeSignal *glade_signal_new_from_signal_info (GladeSignalInfo *info) +GladeSignal * +glade_signal_read (GladeXmlNode *node) { GladeSignal *signal; + gchar *name, *handler; - g_return_val_if_fail (info != NULL, NULL); + g_return_val_if_fail (glade_xml_node_verify_silent + (node, GLADE_XML_TAG_SIGNAL), NULL); - signal = g_new0 (GladeSignal, 1); - signal->name = g_strdup (info->name); - glade_util_replace (signal->name, '_', '-'); - signal->handler = g_strdup (info->handler); - signal->after = info->after; - signal->userdata = g_strdup (info->object); + if (!(name = + glade_xml_get_property_string_required (node, GLADE_XML_TAG_NAME, NULL))) + return NULL; + glade_util_replace (name, '_', '-'); - if (!signal->name) + if (!(handler = + glade_xml_get_property_string_required (node, GLADE_XML_TAG_HANDLER, NULL))) + { + g_free (name); return NULL; + } + + signal = g_new0 (GladeSignal, 1); + signal->name = name; + signal->handler = handler; + signal->after = glade_xml_get_property_boolean (node, GLADE_XML_TAG_AFTER, FALSE); + signal->userdata = glade_xml_get_property_string (node, GLADE_XML_TAG_OBJECT); return signal; } -#endif // LOADING_WAS_IMPLEMENTED diff --git a/gladeui/glade-signal.h b/gladeui/glade-signal.h index d99a17a5..f771aed6 100644 --- a/gladeui/glade-signal.h +++ b/gladeui/glade-signal.h @@ -34,6 +34,9 @@ void glade_signal_free (GladeSignal *signal); gboolean glade_signal_equal (GladeSignal *sig1, GladeSignal *sig2); +GladeSignal *glade_signal_read (GladeXmlNode *node); + + /* XXX gboolean glade_signal_write (GladeSignalInfo *info, GladeSignal *signal, */ /* GladeInterface *interface); */ diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c index c40532ba..58aa193b 100644 --- a/gladeui/glade-widget-adaptor.c +++ b/gladeui/glade-widget-adaptor.c @@ -760,16 +760,11 @@ glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeXmlNode *node) { + GladeXmlNode *sig_node; GList *props; - /* XXX Here were looking at a GladeWidget object built with native - * defaults - */ - - /* first all the properties */ - g_print ("reading widget '%s' of class '%s'\n", - widget->name, adaptor->name); + GladeSignal *signal; - /* Get the packing properties */ + /* Read in the properties */ for (props = widget->properties; props; props = props->next) { @@ -779,8 +774,18 @@ glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor *adaptor, widget->project, node, TRUE); } - /* then all the signals */ + /* Read in the signals */ + for (sig_node = glade_xml_node_get_children (node); + sig_node; sig_node = glade_xml_node_next (sig_node)) + { + if (!glade_xml_node_verify_silent (sig_node, GLADE_XML_TAG_SIGNAL)) + continue; + + if (!(signal = glade_signal_read (sig_node))) + continue; + glade_widget_add_signal_handler (widget, signal); + } } static GType diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c index adbcd88b..92db87d6 100644 --- a/gladeui/glade-widget.c +++ b/gladeui/glade-widget.c @@ -1918,7 +1918,7 @@ glade_widget_fill_from_widget_info (GladeWidgetInfo *info, } } - /* Signals */ + /* Signals XXX */ for (i = 0; i < info->n_signals; ++i) { GladeSignal *signal; diff --git a/gladeui/glade-xml-utils.h b/gladeui/glade-xml-utils.h index a79dde12..0b60317c 100644 --- a/gladeui/glade-xml-utils.h +++ b/gladeui/glade-xml-utils.h @@ -28,10 +28,10 @@ typedef struct _GladeXmlDoc GladeXmlDoc; #define GLADE_XML_TAG_ID "id" #define GLADE_XML_TAG_SIGNAL "signal" #define GLADE_XML_TAG_HANDLER "handler" +#define GLADE_XML_TAG_AFTER "after" +#define GLADE_XML_TAG_OBJECT "object" #define GLADE_XML_TAG_NAME "name" #define GLADE_XML_TAG_CHILD "child" -#define GLADE_XML_TAG_SIGNAL "signal" -#define GLADE_XML_TAG_AFTER "after" #define GLADE_XML_TAG_PACKING "packing" #define GLADE_XML_TAG_PLACEHOLDER "placeholder" #define GLADE_XML_TAG_INTERNAL_CHILD "internal-child" diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c index b057d8b4..c9353c1f 100644 --- a/plugins/gtk+/glade-gtk.c +++ b/plugins/gtk+/glade-gtk.c @@ -253,6 +253,28 @@ glade_gtk_stop_emission_POINTER (gpointer instance, gpointer dummy, gpointer dat #define GLADE_TAG_A11Y_PROPERTY "atkproperty" #define GLADE_TAG_A11Y_ACTION_NAME "action_name" /* We should make -/_ synonymous */ #define GLADE_TAG_A11Y_DESC "description" +#define GLADE_TAG_A11Y_RELATION "atkrelation" +#define GLADE_TAG_A11Y_TARGET "target" +#define GLADE_TAG_A11Y_TYPE "type" + +static const gchar *atk_relations_list[] = { + "controlled-by", + "controller-for", + "labelled-by", + "label-for", + "member-of", + "node-child-of", + "flows-to", + "flows-from", + "subwindow-of", + "embeds", + "embedded-by", + "popup-for", + "parent-window-of", + "described-by", + "description-for", + NULL +}; static GdkModifierType @@ -414,9 +436,6 @@ glade_gtk_parse_atk_props (GladeWidget *widget, if ((property = glade_widget_get_property (widget, id)) != NULL) { - - g_print ("Found property '%s'\n", id); - /* Complex statement just getting the value here... */ if ((!is_action && !(value = glade_xml_get_content (prop))) || @@ -429,10 +448,6 @@ glade_gtk_parse_atk_props (GladeWidget *widget, continue; } - - g_print ("got value '%s' for property '%s'\n", value, id); - - /* Set the parsed value on the property ... */ gvalue = glade_property_class_make_gvalue_from_string (property->klass, value, widget->project); @@ -464,10 +479,72 @@ glade_gtk_parse_atk_props (GladeWidget *widget, } static void +glade_gtk_parse_atk_relation (GladeProperty *property, + GladeXmlNode *node) +{ + GladeXmlNode *prop; + 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); + + if (!strcmp (id, property->klass->id)) + { + 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", + g_strdup (string), g_free); + } +} + +static void glade_gtk_widget_read_atk_props (GladeWidget *widget, GladeXmlNode *node) { - GladeXmlNode *atk_node; + GladeXmlNode *atk_node; + GladeProperty *property; + gint i; if ((atk_node = glade_xml_search_child (node, GLADE_TAG_A11Y_A11Y)) != NULL) @@ -476,9 +553,17 @@ glade_gtk_widget_read_atk_props (GladeWidget *widget, glade_gtk_parse_atk_props (widget, atk_node); /* Relations */ - + for (i = 0; atk_relations_list[i]; i++) + { + if ((property = + glade_widget_get_property (widget, + atk_relations_list[i]))) + glade_gtk_parse_atk_relation (property, atk_node); + else + g_warning ("Couldnt find atk relation %s", + atk_relations_list[i]); + } } - } void |