[monkey-bubble: 296/753] Take a `const gchar *moniker'. (gnome_selector_client_construct):



commit 8080148290af25404202472500d403cf268185d2
Author: Martin Baulig <baulig suse de>
Date:   Sun May 20 14:23:42 2001 +0000

    Take a `const gchar *moniker'. (gnome_selector_client_construct):
    
    2001-05-20  Martin Baulig  <baulig suse de>
    
    	* gnome-selector-client.h
    	(gnome_selector_client_new): Take a `const gchar *moniker'.
    	(gnome_selector_client_construct): Likewise.
    	(gnome_selector_client_new_from_objref): New function.
    	(gnome_selector_client_construct_from_objref): Likewise.

 libgnomeui/ChangeLog                |    8 ++
 libgnomeui/gnome-component-widget.c |  122 ++++++++++++++++++++++++++++++++---
 libgnomeui/gnome-component-widget.h |   45 ++++++++-----
 libgnomeui/gnome-entry.c            |    4 +-
 libgnomeui/gnome-file-entry.c       |    2 +-
 5 files changed, 151 insertions(+), 30 deletions(-)
---
diff --git a/libgnomeui/ChangeLog b/libgnomeui/ChangeLog
index c0895e8..b496467 100644
--- a/libgnomeui/ChangeLog
+++ b/libgnomeui/ChangeLog
@@ -1,3 +1,11 @@
+2001-05-20  Martin Baulig  <baulig suse de>
+
+	* gnome-selector-client.h
+	(gnome_selector_client_new): Take a `const gchar *moniker'.
+	(gnome_selector_client_construct): Likewise.
+	(gnome_selector_client_new_from_objref): New function.
+	(gnome_selector_client_construct_from_objref): Likewise.
+
 2001-05-19  Martin Baulig  <baulig suse de>
 
 	* gnome-image-entry-component.[ch]: Moved to ../components.
diff --git a/libgnomeui/gnome-component-widget.c b/libgnomeui/gnome-component-widget.c
index bb8d3ac..49b9230 100644
--- a/libgnomeui/gnome-component-widget.c
+++ b/libgnomeui/gnome-component-widget.c
@@ -26,12 +26,16 @@
 
 #include <config.h>
 #include <libgnomeui/gnome-entry.h>
+#include <bonobo/bonobo-moniker-util.h>
 #include <bonobo/bonobo-exception.h>
 #include <bonobo/bonobo-async.h>
 
 struct _GnomeSelectorClientPrivate {
     GNOME_Selector selector;
     Bonobo_EventSource_ListenerId listener_id;
+    gboolean constructed;
+
+    BonoboPropertyBag *pbag;
 
     GNOME_Selector_ClientID client_id;
 
@@ -49,6 +53,10 @@ static BonoboWidgetClass *gnome_selector_client_parent_class;
 
 static GNOME_Selector_AsyncID last_async_id = 0;
 
+enum {
+    PROP_0
+};
+
 static void
 gnome_selector_client_finalize (GObject *object)
 {
@@ -61,6 +69,42 @@ gnome_selector_client_finalize (GObject *object)
 }
 
 static void
+gnome_selector_client_set_property (GObject *object, guint param_id,
+				    const GValue *value, GParamSpec *pspec)
+{
+    GnomeSelectorClient *client;
+
+    g_return_if_fail (object != NULL);
+    g_return_if_fail (GNOME_IS_SELECTOR_CLIENT (object));
+
+    client = GNOME_SELECTOR_CLIENT (object);
+
+    switch (param_id) {
+    default:
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+	break;
+    }
+}
+
+static void
+gnome_selector_client_get_property (GObject *object, guint param_id, GValue *value,
+				    GParamSpec *pspec)
+{
+    GnomeSelectorClient *client;
+
+    g_return_if_fail (object != NULL);
+    g_return_if_fail (GNOME_IS_SELECTOR_CLIENT (object));
+
+    client = GNOME_SELECTOR_CLIENT (client);
+
+    switch (param_id) {
+    default:
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+	break;
+    }
+}
+
+static void
 gnome_selector_client_class_init (GnomeSelectorClientClass *klass)
 {
     GObjectClass *object_class = (GObjectClass *) klass;
@@ -68,6 +112,9 @@ gnome_selector_client_class_init (GnomeSelectorClientClass *klass)
     gnome_selector_client_parent_class = g_type_class_peek_parent (klass);
 
     object_class->finalize = gnome_selector_client_finalize;
+
+    object_class->get_property = gnome_selector_client_get_property;
+    object_class->set_property = gnome_selector_client_set_property;
 }
 
 static void
@@ -100,32 +147,64 @@ gnome_selector_client_get_type (void)
 }
 
 GnomeSelectorClient *
-gnome_selector_client_construct (GnomeSelectorClient *client, GNOME_Selector corba_selector,
+gnome_selector_client_construct (GnomeSelectorClient *client, const gchar *moniker,
 				 Bonobo_UIContainer uic)
 {
-    Bonobo_Control corba_control;
-    Bonobo_EventSource event_source;
+    GNOME_SelectorFactory factory;
+    GNOME_Selector selector;
     CORBA_Environment ev;
 
     g_return_val_if_fail (client != NULL, NULL);
     g_return_val_if_fail (GNOME_IS_SELECTOR_CLIENT (client), NULL);
-    g_return_val_if_fail (corba_selector != CORBA_OBJECT_NIL, NULL);
+    g_return_val_if_fail (moniker != NULL, NULL);
+    g_return_val_if_fail (!client->_priv->constructed, NULL);
 
     CORBA_exception_init (&ev);
 
-    corba_control = GNOME_Selector_getControl (corba_selector, &ev);
-    if (BONOBO_EX (&ev) || (corba_control == CORBA_OBJECT_NIL)) {
+    client->_priv->pbag = bonobo_property_bag_new (NULL, NULL, client);
+    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;
     }
 
-    if (!bonobo_widget_construct_control_from_objref (BONOBO_WIDGET (client), corba_control, uic)) {
+    selector = GNOME_SelectorFactory_createSelector (factory, BONOBO_OBJREF (client->_priv->pbag), &ev);
+
+    if (BONOBO_EX (&ev) || (selector == NULL)) {
 	g_object_unref (G_OBJECT (client));
 	CORBA_exception_free (&ev);
 	return NULL;
     }
 
+    CORBA_exception_free (&ev);
+
+    return gnome_selector_client_construct_from_objref (client, selector, uic);
+}
+
+GnomeSelectorClient *
+gnome_selector_client_construct_from_objref (GnomeSelectorClient *client,
+					     GNOME_Selector corba_selector,
+					     Bonobo_UIContainer uic)
+{
+    Bonobo_Control corba_control;
+    Bonobo_EventSource event_source;
+    CORBA_Environment ev;
+
+    g_return_val_if_fail (client != NULL, NULL);
+    g_return_val_if_fail (GNOME_IS_SELECTOR_CLIENT (client), NULL);
+    g_return_val_if_fail (corba_selector != NULL, NULL);
+    g_return_val_if_fail (!client->_priv->constructed, NULL);
+
+    client->_priv->constructed = TRUE;
+
+    CORBA_exception_init (&ev);
+
+    client->_priv->pbag = bonobo_property_bag_new (NULL, NULL, client);
+    bonobo_property_bag_add_gtk_args (client->_priv->pbag, G_OBJECT (client));
+
     client->_priv->selector = bonobo_object_dup_ref (corba_selector, &ev);
     if (BONOBO_EX (&ev)) {
 	g_object_unref (G_OBJECT (client));
@@ -133,6 +212,19 @@ gnome_selector_client_construct (GnomeSelectorClient *client, GNOME_Selector cor
 	return NULL;
     }
 
+    corba_control = GNOME_Selector_getControl (client->_priv->selector, &ev);
+    if (BONOBO_EX (&ev) || (corba_control == CORBA_OBJECT_NIL)) {
+	g_object_unref (G_OBJECT (client));
+	CORBA_exception_free (&ev);
+	return NULL;
+    }
+
+    if (!bonobo_widget_construct_control_from_objref (BONOBO_WIDGET (client), corba_control, uic)) {
+	g_object_unref (G_OBJECT (client));
+	CORBA_exception_free (&ev);
+	return NULL;
+    }
+
     client->_priv->client_id = GNOME_Selector_getClientID (client->_priv->selector, &ev);
     if (BONOBO_EX (&ev)) {
 	g_object_unref (G_OBJECT (client));
@@ -163,7 +255,19 @@ gnome_selector_client_construct (GnomeSelectorClient *client, GNOME_Selector cor
 }
 
 GnomeSelectorClient *
-gnome_selector_client_new (GNOME_Selector corba_selector, Bonobo_UIContainer uic)
+gnome_selector_client_new (const gchar *moniker, Bonobo_UIContainer uic)
+{
+    GnomeSelectorClient *client;
+
+    g_return_val_if_fail (moniker != NULL, NULL);
+
+    client = g_object_new (gnome_selector_client_get_type (), NULL);
+
+    return gnome_selector_client_construct (client, moniker, uic);
+}
+
+GnomeSelectorClient *
+gnome_selector_client_new_from_objref (GNOME_Selector corba_selector, Bonobo_UIContainer uic)
 {
     GnomeSelectorClient *client;
 
@@ -171,7 +275,7 @@ gnome_selector_client_new (GNOME_Selector corba_selector, Bonobo_UIContainer uic
 
     client = g_object_new (gnome_selector_client_get_type (), NULL);
 
-    return gnome_selector_client_construct (client, corba_selector, uic);
+    return gnome_selector_client_construct_from_objref (client, corba_selector, uic);
 }
 
 gchar *
diff --git a/libgnomeui/gnome-component-widget.h b/libgnomeui/gnome-component-widget.h
index 6653d66..04f2f4a 100644
--- a/libgnomeui/gnome-component-widget.h
+++ b/libgnomeui/gnome-component-widget.h
@@ -74,43 +74,52 @@ struct _GnomeSelectorClientClass {
 };
 
 GtkType
-gnome_selector_client_get_type           (void) G_GNUC_CONST;
+gnome_selector_client_get_type              (void) G_GNUC_CONST;
 
 GnomeSelectorClient *
-gnome_selector_client_new                (GNOME_Selector       corba_selector,
-                                          Bonobo_UIContainer   uic);
+gnome_selector_client_new                   (const gchar         *moniker,
+                                             Bonobo_UIContainer   uic);
 
 GnomeSelectorClient *
-gnome_selector_client_construct          (GnomeSelectorClient *client,
-                                          GNOME_Selector       corba_selector,
-                                          Bonobo_UIContainer   uic);
+gnome_selector_client_new_from_objref       (GNOME_Selector       corba_selector,
+                                             Bonobo_UIContainer   uic);
+
+GnomeSelectorClient *
+gnome_selector_client_construct             (GnomeSelectorClient *client,
+                                             const gchar         *moniker,
+                                             Bonobo_UIContainer   uic);
+
+GnomeSelectorClient *
+gnome_selector_client_construct_from_objref (GnomeSelectorClient *client,
+                                             GNOME_Selector       corba_selector,
+                                             Bonobo_UIContainer   uic);
 
 /* Get/set the text in the entry widget. */
 gchar *
-gnome_selector_client_get_entry_text     (GnomeSelectorClient *client);
+gnome_selector_client_get_entry_text        (GnomeSelectorClient *client);
 
 void
-gnome_selector_client_set_entry_text     (GnomeSelectorClient *client,
-                                          const gchar         *text);
+gnome_selector_client_set_entry_text        (GnomeSelectorClient *client,
+                                             const gchar         *text);
 
 /* If the entry widget is derived from GtkEditable, then we can use this
  * function to send an "activate" signal to it. */
 void
-gnome_selector_client_activate_entry     (GnomeSelectorClient *client);
+gnome_selector_client_activate_entry        (GnomeSelectorClient *client);
 
 /* Get/set URI. */
 
 gchar *
-gnome_selector_client_get_uri            (GnomeSelectorClient *client);
+gnome_selector_client_get_uri               (GnomeSelectorClient *client);
 
 void
-gnome_selector_client_set_uri            (GnomeSelectorClient             *client,
-                                          GnomeSelectorClientAsyncHandle **handle_return,
-                                          const gchar                     *uri,
-                                          guint                            timeout_msec,
-                                          GnomeSelectorClientAsyncFunc     async_func,
-                                          gpointer                         user_data,
-					  GDestroyNotify                   destroy_fn);
+gnome_selector_client_set_uri               (GnomeSelectorClient             *client,
+                                             GnomeSelectorClientAsyncHandle **handle_return,
+                                             const gchar                     *uri,
+                                             guint                            timeout_msec,
+                                             GnomeSelectorClientAsyncFunc     async_func,
+                                             gpointer                         user_data,
+                                             GDestroyNotify                   destroy_fn);
 
 G_END_DECLS
 
diff --git a/libgnomeui/gnome-entry.c b/libgnomeui/gnome-entry.c
index 8795f0d..5a5f770 100644
--- a/libgnomeui/gnome-entry.c
+++ b/libgnomeui/gnome-entry.c
@@ -122,7 +122,7 @@ gnome_entry_construct (GnomeEntry         *gentry,
 	g_return_val_if_fail (GNOME_IS_ENTRY (gentry), NULL);
 	g_return_val_if_fail (corba_selector != CORBA_OBJECT_NIL, NULL);
 
-	return (GtkWidget *) gnome_selector_client_construct
+	return (GtkWidget *) gnome_selector_client_construct_from_objref
 		(GNOME_SELECTOR_CLIENT (gentry), corba_selector, uic);
 }
 
@@ -154,7 +154,7 @@ gnome_entry_new_full (GnomeSelector      *selector,
 
 	event_source = bonobo_event_source_new ();
 
-	gnome_selector_construct (selector, event_source);
+	gnome_selector_construct (selector, event_source, CORBA_OBJECT_NIL);
 
 	gnome_selector_bind_to_control (selector,
 					BONOBO_OBJECT (gentry->_priv->control));
diff --git a/libgnomeui/gnome-file-entry.c b/libgnomeui/gnome-file-entry.c
index 7df9564..9015745 100644
--- a/libgnomeui/gnome-file-entry.c
+++ b/libgnomeui/gnome-file-entry.c
@@ -106,7 +106,7 @@ gnome_file_entry_construct (GnomeFileEntry     *fentry,
     g_return_val_if_fail (GNOME_IS_FILE_ENTRY (fentry), NULL);
     g_return_val_if_fail (corba_selector != CORBA_OBJECT_NIL, NULL);
 
-    return (GtkWidget *) gnome_selector_client_construct
+    return (GtkWidget *) gnome_selector_client_construct_from_objref
 	(GNOME_SELECTOR_CLIENT (fentry), corba_selector, uic);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]