[monkey-bubble: 323/753] Create the property bag and use the factory.
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 323/753] Create the property bag and use the factory.
- Date: Wed, 14 Jul 2010 22:22:48 +0000 (UTC)
commit 95b0ebe2e6be904bb668cf308c368db55d522256
Author: Martin Baulig <baulig suse de>
Date: Wed May 23 21:36:54 2001 +0000
Create the property bag and use the factory.
2001-05-23 Martin Baulig <baulig suse de>
* gnome-selector-client.c (gnome_selector_client_construct): Create the
property bag and use the factory.
libgnomeui/ChangeLog | 5 +
libgnomeui/gnome-component-widget.c | 159 +++++++++++++++++++++--------------
2 files changed, 99 insertions(+), 65 deletions(-)
---
diff --git a/libgnomeui/ChangeLog b/libgnomeui/ChangeLog
index 3b10bca..24c67ba 100644
--- a/libgnomeui/ChangeLog
+++ b/libgnomeui/ChangeLog
@@ -1,3 +1,8 @@
+2001-05-23 Martin Baulig <baulig suse de>
+
+ * gnome-selector-client.c (gnome_selector_client_construct): Create the
+ property bag and use the factory.
+
2001-05-21 Martin Baulig <baulig suse de>
* gnome-selector-client.c (PROP_WANT_ENTRY_WIDGET, PROP_WANT_SELECTOR_WIDGET,
diff --git a/libgnomeui/gnome-component-widget.c b/libgnomeui/gnome-component-widget.c
index cae2b8d..304e22d 100644
--- a/libgnomeui/gnome-component-widget.c
+++ b/libgnomeui/gnome-component-widget.c
@@ -89,6 +89,62 @@ gnome_selector_client_finalize (GObject *object)
}
static void
+set_arg_tristate (BonoboArg *arg, GNOME_Tristate value, CORBA_Environment *ev)
+{
+ switch (value) {
+ case GNOME_TRISTATE_YES:
+ BONOBO_ARG_SET_BOOLEAN (arg, TRUE);
+ break;
+ case GNOME_TRISTATE_NO:
+ BONOBO_ARG_SET_BOOLEAN (arg, FALSE);
+ break;
+ default:
+ bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
+ break;
+ }
+}
+
+static void
+gnome_selector_client_pbag_get_property (BonoboPropertyBag *bag, BonoboArg *arg,
+ guint arg_id, CORBA_Environment *ev,
+ gpointer user_data)
+{
+ GnomeSelectorClient *client;
+
+ g_return_if_fail (user_data != NULL);
+ g_return_if_fail (GNOME_IS_SELECTOR_CLIENT (user_data));
+
+ client = GNOME_SELECTOR_CLIENT (user_data);
+
+ switch (arg_id) {
+ case PROP_WANT_ENTRY_WIDGET:
+ set_arg_tristate (arg, client->_priv->want_entry_widget, ev);
+ break;
+ case PROP_WANT_SELECTOR_WIDGET:
+ set_arg_tristate (arg, client->_priv->want_selector_widget, ev);
+ break;
+ case PROP_WANT_BROWSE_DIALOG:
+ set_arg_tristate (arg, client->_priv->want_browse_dialog, ev);
+ break;
+ case PROP_WANT_BROWSE_BUTTON:
+ set_arg_tristate (arg, client->_priv->want_browse_button, ev);
+ break;
+ case PROP_WANT_CLEAR_BUTTON:
+ set_arg_tristate (arg, client->_priv->want_clear_button, ev);
+ break;
+ case PROP_WANT_DEFAULT_BUTTON:
+ set_arg_tristate (arg, client->_priv->want_default_button, ev);
+ break;
+ case PROP_BROWSE_DIALOG_MONIKER:
+ BONOBO_ARG_SET_STRING (arg, client->_priv->browse_dialog_moniker);
+ break;
+ default:
+ g_warning (G_STRLOC ": unknown property id %d", arg_id);
+ break;
+ }
+}
+
+static void
gnome_selector_client_set_property (GObject *object, guint param_id,
const GValue *value, GParamSpec *pspec)
{
@@ -265,68 +321,13 @@ gnome_selector_client_get_type (void)
return type;
}
-static void
-add_tristate_arg (GnomeSelectorClient *client, GPtrArray *args, const gchar *prop_name)
-{
- GValue value = { 0, };
- GNOME_Tristate retval;
-
- g_value_init (&value, GNOME_TYPE_TRISTATE);
- g_object_get_property (G_OBJECT (client), prop_name, &value);
- retval = g_value_get_enum (&value);
- g_value_unset (&value);
-
- if (retval == GNOME_TRISTATE_NO)
- g_ptr_array_add (args, g_strdup_printf ("%s=0", prop_name));
- else if (retval == GNOME_TRISTATE_YES)
- g_ptr_array_add (args, g_strdup_printf ("%s=1", prop_name));
-}
-
-static gchar *
-create_moniker_string (GnomeSelectorClient *client, const gchar *moniker)
-{
- GPtrArray *args;
- gchar *args_string, *retval;
- CORBA_Environment ev;
- gchar *pbag_moniker;
-
- args = g_ptr_array_new ();
- add_tristate_arg (client, args, "want-entry-widget");
- add_tristate_arg (client, args, "want-selector-widget");
- add_tristate_arg (client, args, "want-browse-dialog");
- add_tristate_arg (client, args, "want-browse-button");
- add_tristate_arg (client, args, "want-clear-button");
- add_tristate_arg (client, args, "want-default-button");
-
- g_ptr_array_add (args, NULL);
- args_string = g_strjoinv (";", (gchar **) args->pdata);
- g_ptr_array_free (args, TRUE);
-
- CORBA_exception_init (&ev);
- pbag_moniker = CORBA_ORB_object_to_string (bonobo_orb (),
- BONOBO_OBJREF (client->_priv->pbag),
- &ev);
- CORBA_exception_free (&ev);
-
- if (!args_string || args_string[0] == '\0')
- retval = g_strdup_printf ("%s!property-bag=%s", moniker, pbag_moniker);
- else
- retval = g_strdup_printf ("%s!%s;property-bag=%s", moniker, args_string,
- pbag_moniker);
-
- CORBA_free (pbag_moniker);
- g_free (args_string);
-
- return retval;
-}
-
GnomeSelectorClient *
gnome_selector_client_construct (GnomeSelectorClient *client, const gchar *moniker,
Bonobo_UIContainer uic)
{
+ GNOME_SelectorFactory factory;
GNOME_Selector selector;
CORBA_Environment ev;
- gchar *new_moniker;
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (GNOME_IS_SELECTOR_CLIENT (client), NULL);
@@ -335,17 +336,45 @@ gnome_selector_client_construct (GnomeSelectorClient *client, const gchar *monik
CORBA_exception_init (&ev);
- client->_priv->pbag = bonobo_property_bag_new (NULL, NULL, NULL);
-
- if (G_OBJECT_TYPE (client) != GNOME_TYPE_SELECTOR_CLIENT)
- bonobo_property_bag_add_gtk_args (client->_priv->pbag, G_OBJECT (client));
-
- new_moniker = create_moniker_string (client, moniker);
+ g_message (G_STRLOC);
+
+ client->_priv->pbag = bonobo_property_bag_new (gnome_selector_client_pbag_get_property,
+ NULL, client);
+
+ bonobo_property_bag_add (client->_priv->pbag,
+ "browse-dialog-moniker", PROP_BROWSE_DIALOG_MONIKER,
+ BONOBO_ARG_STRING, NULL, NULL, BONOBO_PROPERTY_READABLE);
+ bonobo_property_bag_add (client->_priv->pbag,
+ "want-entry-widget", PROP_WANT_ENTRY_WIDGET,
+ BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE);
+ bonobo_property_bag_add (client->_priv->pbag,
+ "want-browse-dialog", PROP_WANT_BROWSE_DIALOG,
+ BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE);
+ bonobo_property_bag_add (client->_priv->pbag,
+ "want-selector-widget", PROP_WANT_SELECTOR_WIDGET,
+ BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE);
+ bonobo_property_bag_add (client->_priv->pbag,
+ "want-browse-button", PROP_WANT_BROWSE_BUTTON,
+ BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE);
+ bonobo_property_bag_add (client->_priv->pbag,
+ "want-default-button", PROP_WANT_DEFAULT_BUTTON,
+ BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE);
+ bonobo_property_bag_add (client->_priv->pbag,
+ "want-clear-button", PROP_WANT_CLEAR_BUTTON,
+ BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE);
+
+ bonobo_property_bag_add_gtk_args (client->_priv->pbag, G_OBJECT (client));
+
+ factory = bonobo_get_object (moniker, "GNOME/SelectorFactory", &ev);
+ if (BONOBO_EX (&ev) || (factory == CORBA_OBJECT_NIL)) {
+ g_object_unref (G_OBJECT (client));
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
- g_message (G_STRLOC " : `%s'", new_moniker);
+ selector = GNOME_SelectorFactory_createSelector (factory, BONOBO_OBJREF (client->_priv->pbag), &ev);
- selector = bonobo_get_object (new_moniker, "GNOME/Selector", &ev);
- if (BONOBO_EX (&ev) || (selector == CORBA_OBJECT_NIL)) {
+ if (BONOBO_EX (&ev) || (selector == NULL)) {
g_object_unref (G_OBJECT (client));
CORBA_exception_free (&ev);
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]