get/set_prop patch
- From: Alex Larsson <alexl redhat com>
- To: Michael Meeks <michael ximian com>
- Cc: <gnome-components-list gnome org>
- Subject: get/set_prop patch
- Date: Tue, 26 Jun 2001 11:15:32 -0400 (EDT)
After some profiling of Nauilus and discussion with Michael i have come up
with a patch that basically removes Bonobu UI handler from the Nautilus
open new window profiles.
It is a bit hacky, but it is binary compatible. We should probably solve
this in another way in Bonobo 2.
This patch might also help evolution performance, and any app that does a
lot of bonobo_ui_component_set_prop.
/ Alex
Index: bonobo/bonobo-ui-component.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-component.c,v
retrieving revision 1.44
diff -u -p -r1.44 bonobo-ui-component.c
--- bonobo/bonobo-ui-component.c 2001/05/24 08:40:07 1.44
+++ bonobo/bonobo-ui-component.c 2001/06/26 15:04:35
@@ -1112,6 +1112,7 @@ impl_set_prop (BonoboUIComponent *compo
const char *value,
CORBA_Environment *opt_ev)
{
+#ifdef OLD_SLOW_SET_PROP
BonoboUINode *node;
char *parent_path;
Bonobo_UIContainer container;
@@ -1139,6 +1140,25 @@ impl_set_prop (BonoboUIComponent *compo
bonobo_ui_node_free (node);
bonobo_object_unref (BONOBO_OBJECT (component));
+#else
+ char *full_path;
+
+ g_return_if_fail (BONOBO_IS_UI_COMPONENT (component));
+
+ full_path = g_malloc (strlen (path) + 1 + strlen (prop) + 1);
+ strcpy (full_path, path);
+ strcat (full_path, "#");
+ strcat (full_path, prop);
+
+ bonobo_object_ref (BONOBO_OBJECT (component));
+
+ bonobo_ui_component_set (
+ component, full_path, value, opt_ev);
+
+ g_free (full_path);
+
+ bonobo_object_unref (BONOBO_OBJECT (component));
+#endif
}
/**
@@ -1186,6 +1206,7 @@ impl_get_prop (BonoboUIComponent *compon
const char *prop,
CORBA_Environment *opt_ev)
{
+#ifdef OLD_SLOW_GET_PROP
BonoboUINode *node;
xmlChar *ans;
gchar *ret;
@@ -1207,6 +1228,34 @@ impl_get_prop (BonoboUIComponent *compon
bonobo_ui_node_free (node);
return ret;
+#else
+ char *full_path;
+ xmlChar *ans;
+ gchar *ret;
+
+ g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (component), NULL);
+
+ full_path = g_malloc (strlen (path) + 1 + strlen (prop) + 1);
+ strcpy (full_path, path);
+ strcat (full_path, "#");
+ strcat (full_path, prop);
+
+ bonobo_object_ref (BONOBO_OBJECT (component));
+
+ ans = bonobo_ui_component_get (component, full_path, FALSE, opt_ev);
+
+ if (ans) {
+ ret = g_strdup (ans);
+ bonobo_ui_node_free_string (ans);
+ } else
+ ret = NULL;
+
+ g_free (full_path);
+
+ bonobo_object_unref (BONOBO_OBJECT (component));
+
+ return ret;
+#endif
}
/**
Index: bonobo/bonobo-ui-container.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-container.c,v
retrieving revision 1.22
diff -u -p -r1.22 bonobo-ui-container.c
--- bonobo/bonobo-ui-container.c 2001/05/08 01:10:16 1.22
+++ bonobo/bonobo-ui-container.c 2001/06/26 15:04:35
@@ -79,20 +79,37 @@ impl_Bonobo_UIContainer_setNode (Portabl
BonoboUIEngine *engine = get_engine (servant);
BonoboUIError err;
BonoboUINode *node;
+ const CORBA_char *property;
/* fprintf (stderr, "Merging :\n%s\n", xml);*/
if (!xml)
err = BONOBO_UI_ERROR_BAD_PARAM;
else {
- node = bonobo_ui_node_from_string (xml);
+ if ((property = strrchr (path, '/')) &&
+ (property = strrchr (property, '#'))) {
+ char *real_path;
+ real_path = g_strdup (path);
+ real_path [property-path] = 0;
+ property = property + 1; /* Skip the '#' */
+
+ err = bonobo_ui_engine_xml_set_prop (engine,
+ real_path,
+ property,
+ xml,
+ component_name);
+ g_free (real_path);
+ } else {
+ node = bonobo_ui_node_from_string (xml);
- if (!node)
- err = BONOBO_UI_ERROR_INVALID_XML;
- else
- err = bonobo_ui_engine_xml_merge_tree (
- engine, path, node, component_name);
+ if (!node)
+ err = BONOBO_UI_ERROR_INVALID_XML;
+ else
+ err = bonobo_ui_engine_xml_merge_tree (
+ engine, path, node, component_name);
+ }
}
+
if (err) {
if (err == BONOBO_UI_ERROR_INVALID_PATH)
@@ -114,12 +131,24 @@ impl_Bonobo_UIContainer_getNode (Portabl
{
BonoboUIEngine *engine = get_engine (servant);
CORBA_char *xml;
-
- xml = bonobo_ui_engine_xml_get (engine, path, nodeOnly);
- if (!xml) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_UIContainer_InvalidPath, NULL);
- return NULL;
+ const CORBA_char *property;
+
+ if ((property = strrchr (path, '/')) &&
+ (property = strrchr (property, '#'))) {
+ char *real_path;
+ real_path = g_strdup (path);
+ real_path [property-path] = 0;
+ property = property + 1; /* Skip the '#' */
+
+ xml = bonobo_ui_engine_xml_get_prop (engine, real_path, property);
+ g_free (real_path);
+ } else {
+ xml = bonobo_ui_engine_xml_get (engine, path, nodeOnly);
+ if (!xml) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_Bonobo_UIContainer_InvalidPath, NULL);
+ return NULL;
+ }
}
return xml;
Index: bonobo/bonobo-ui-engine.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-engine.c,v
retrieving revision 1.16
diff -u -p -r1.16 bonobo-ui-engine.c
--- bonobo/bonobo-ui-engine.c 2001/05/24 08:49:06 1.16
+++ bonobo/bonobo-ui-engine.c 2001/06/26 15:04:35
@@ -989,6 +989,41 @@ state_update_now (BonoboUIEngine *engine
}
/**
+ * bonobo_ui_engine_xml_get_prop:
+ * @engine: the engine
+ * @path: the path into the tree
+ * @prop: The property
+ *
+ * This function fetches the property @prop at node
+ * at @path in the internal structure.
+ *
+ * Return value: the XML string - use bonobo_ui_node_free_string to free
+ **/
+CORBA_char *
+bonobo_ui_engine_xml_get_prop (BonoboUIEngine *engine,
+ const char *path,
+ const char *prop)
+{
+ char *str;
+ BonoboUINode *node;
+ CORBA_char *ret;
+
+ g_return_val_if_fail (BONOBO_IS_UI_ENGINE (engine), NULL);
+
+ node = bonobo_ui_xml_get_path (engine->priv->tree, path);
+ if (!node)
+ return NULL;
+ else {
+ str = bonobo_ui_node_get_attr (node, prop);
+ if (!str)
+ return NULL;
+ ret = CORBA_string_dup (str);
+ bonobo_ui_node_free_string (str);
+ return ret;
+ }
+}
+
+/**
* bonobo_ui_engine_xml_get:
* @engine: the engine
* @path: the path into the tree
@@ -1144,6 +1179,44 @@ bonobo_ui_engine_object_get (BonoboUIEng
if (info->object != CORBA_OBJECT_NIL)
*object = bonobo_object_dup_ref (info->object, ev);
+ return BONOBO_UI_ERROR_OK;
+}
+
+/**
+ * bonobo_ui_engine_xml_set_prop:
+ * @engine: the engine
+ * @path: the path into the tree
+ * @property: The property to set
+ * @value: The new value of the property
+ * @component: the component ID associated with the nodes.
+ *
+ * This function sets the property of a node in the internal tree
+ * representation at @path in @engine.
+ *
+ * Return value: flag on error
+ **/
+BonoboUIError
+bonobo_ui_engine_xml_set_prop (BonoboUIEngine *engine,
+ const char *path,
+ const char *property,
+ const char *value,
+ const char *component)
+{
+ BonoboUINode *node;
+
+ g_return_val_if_fail (BONOBO_IS_UI_ENGINE (engine),
+ BONOBO_UI_ERROR_BAD_PARAM);
+
+ node = bonobo_ui_engine_get_path (engine, path);
+
+ if (!node)
+ return BONOBO_UI_ERROR_INVALID_PATH;
+
+ bonobo_ui_node_set_attr (node, property, value);
+ bonobo_ui_xml_set_dirty (engine->priv->tree, node);
+
+ bonobo_ui_engine_update (engine);
+
return BONOBO_UI_ERROR_OK;
}
Index: bonobo/bonobo-ui-engine.h
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-engine.h,v
retrieving revision 1.5
diff -u -p -r1.5 bonobo-ui-engine.h
--- bonobo/bonobo-ui-engine.h 2001/01/09 20:47:59 1.5
+++ bonobo/bonobo-ui-engine.h 2001/06/26 15:04:35
@@ -160,8 +160,16 @@ Bonobo_Unknown bonobo_ui_engine_get_comp
CORBA_char *bonobo_ui_engine_xml_get (BonoboUIEngine *engine,
const char *path,
gboolean node_only);
+CORBA_char * bonobo_ui_engine_xml_get_prop (BonoboUIEngine *engine,
+ const char *path,
+ const char *property);
gboolean bonobo_ui_engine_xml_node_exists (BonoboUIEngine *engine,
const char *path);
+BonoboUIError bonobo_ui_engine_xml_set_prop (BonoboUIEngine *engine,
+ const char *path,
+ const char *property,
+ const char *value,
+ const char *component);
BonoboUIError bonobo_ui_engine_xml_merge_tree (BonoboUIEngine *engine,
const char *path,
BonoboUINode *tree,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]