[monkey-bubble: 329/753] New function. (gnome_selector_client_add_uri): New function.



commit 50134265fe00a83e509d6476f08c3b192bdd0d36
Author: Martin Baulig <baulig suse de>
Date:   Fri May 25 17:18:00 2001 +0000

    New function. (gnome_selector_client_add_uri): New function.
    
    2001-05-25  Martin Baulig  <baulig suse de>
    
    	* gnome-selector-client.c
    	(gnome_selector_client_set_uri): New function.
    	(gnome_selector_client_add_uri): New function.

 libgnomeui/ChangeLog                |    6 ++
 libgnomeui/gnome-component-widget.c |  156 +++++++++++++++++-----------------
 libgnomeui/gnome-component-widget.h |   65 +++++++--------
 3 files changed, 116 insertions(+), 111 deletions(-)
---
diff --git a/libgnomeui/ChangeLog b/libgnomeui/ChangeLog
index 24c67ba..1f9ee1a 100644
--- a/libgnomeui/ChangeLog
+++ b/libgnomeui/ChangeLog
@@ -1,3 +1,9 @@
+2001-05-25  Martin Baulig  <baulig suse de>
+
+	* gnome-selector-client.c
+	(gnome_selector_client_set_uri): New function.
+	(gnome_selector_client_add_uri): New function.
+
 2001-05-23  Martin Baulig  <baulig suse de>
 
 	* gnome-selector-client.c (gnome_selector_client_construct): Create the
diff --git a/libgnomeui/gnome-component-widget.c b/libgnomeui/gnome-component-widget.c
index 304e22d..07e33a2 100644
--- a/libgnomeui/gnome-component-widget.c
+++ b/libgnomeui/gnome-component-widget.c
@@ -34,6 +34,7 @@
 struct _GnomeSelectorClientPrivate {
     GNOME_Selector selector;
     Bonobo_EventSource_ListenerId listener_id;
+    GnomeAsyncContext *async_ctx;
 
     gchar *browse_dialog_moniker;
 
@@ -62,7 +63,7 @@ gnome_selector_client_event_cb (BonoboListener    *listener,
 
 static BonoboWidgetClass *gnome_selector_client_parent_class;
 
-static GNOME_Selector_AsyncID last_async_id = 0;
+static GNOME_Selector_AsyncID last_async_id G_GNUC_UNUSED = 0;
 
 enum {
     PROP_0,
@@ -403,6 +404,8 @@ gnome_selector_client_construct_from_objref (GnomeSelectorClient *client,
 
     CORBA_exception_init (&ev);
 
+    client->_priv->async_ctx = gnome_async_context_new ();
+
     client->_priv->selector = bonobo_object_dup_ref (corba_selector, &ev);
     if (BONOBO_EX (&ev)) {
 	g_object_unref (G_OBJECT (client));
@@ -476,6 +479,25 @@ gnome_selector_client_new_from_objref (GNOME_Selector corba_selector, Bonobo_UIC
     return gnome_selector_client_construct_from_objref (client, corba_selector, uic);
 }
 
+static GNOME_Selector_AsyncData *
+gnome_selector_client_create_async_data (GnomeSelectorClient *client, const gchar *uri,
+					 GnomeAsyncHandle *async_handle)
+{
+    GNOME_Selector_AsyncData *async_data;
+
+    g_return_val_if_fail (client != NULL, NULL);
+    g_return_val_if_fail (GNOME_IS_SELECTOR_CLIENT (client), NULL);
+
+    async_data = GNOME_Selector_AsyncData__alloc ();
+    async_data->client_id = client->_priv->client_id;
+    async_data->async_id = ++last_async_id;
+    async_data->user_data._type = TC_null;
+
+    g_hash_table_insert (client->_priv->async_ops, GINT_TO_POINTER (async_data->async_id), async_handle);
+
+    return async_data;
+}
+
 gchar *
 gnome_selector_client_get_entry_text (GnomeSelectorClient *client)
 {
@@ -525,68 +547,13 @@ gnome_selector_client_activate_entry (GnomeSelectorClient *client)
     CORBA_exception_free (&ev);
 }
 
-struct _GnomeSelectorClientAsyncHandle {
-    GNOME_Selector_AsyncContext  *async_ctx;
-    GnomeSelectorClient          *client;
-    guint                         timeout_msec;
-    GnomeSelectorClientAsyncFunc  async_func;
-    gpointer                      user_data;
-    GDestroyNotify                destroy_fn;
-};
-
-static GnomeSelectorClientAsyncHandle *
-_gnome_selector_client_async_handle_get (GnomeSelectorClient *client,
-					 GnomeSelectorClientAsyncFunc async_func,
-					 gpointer user_data, GDestroyNotify destroy_fn)
-{
-    GnomeSelectorClientAsyncHandle *async_handle;
-
-    g_return_val_if_fail (client != NULL, NULL);
-    g_return_val_if_fail (GNOME_IS_SELECTOR_CLIENT (client), NULL);
-
-    async_handle = g_new0 (GnomeSelectorClientAsyncHandle, 1);
-    async_handle->client = client;
-    async_handle->async_func = async_func;
-    async_handle->user_data = user_data;
-    async_handle->destroy_fn = destroy_fn;
-
-    async_handle->async_ctx = GNOME_Selector_AsyncContext__alloc ();
-    async_handle->async_ctx->client_id = client->_priv->client_id;
-    async_handle->async_ctx->async_id = ++last_async_id;
-    async_handle->async_ctx->user_data._type = TC_null;
-
-    g_object_ref (G_OBJECT (async_handle->client));
-
-    g_hash_table_insert (client->_priv->async_ops, GINT_TO_POINTER (last_async_id), async_handle);
-
-    return async_handle;
-}
-
-static void
-_gnome_selector_client_async_handle_free (GnomeSelectorClientAsyncHandle *async_handle)
-{
-    g_return_if_fail (async_handle != NULL);
-    g_return_if_fail (async_handle->client != NULL);
-    g_return_if_fail (GNOME_IS_SELECTOR_CLIENT (async_handle->client));
-
-    g_hash_table_remove (async_handle->client->_priv->async_ops,
-			 GINT_TO_POINTER (async_handle->async_ctx->async_id));
-
-    if (async_handle->destroy_fn)
-	async_handle->destroy_fn (async_handle->user_data);
-
-    g_object_unref (G_OBJECT (async_handle->client));
-    CORBA_free (async_handle->async_ctx);
-    g_free (async_handle);
-}
-
 static void
 gnome_selector_client_event_cb (BonoboListener *listener, char *event_name, 
 				CORBA_any *any, CORBA_Environment *ev, gpointer user_data)
 {
     GnomeSelectorClient *client;
     GNOME_Selector_AsyncReply *async_reply;
-    GnomeSelectorClientAsyncHandle *async_handle;
+    GnomeAsyncHandle *async_handle;
 
     g_return_if_fail (user_data != NULL);
     g_return_if_fail (GNOME_IS_SELECTOR_CLIENT (user_data));
@@ -598,25 +565,20 @@ gnome_selector_client_event_cb (BonoboListener *listener, char *event_name,
     async_reply = any->_value;
 
     /* Is the event for us ? */
-    if (async_reply->ctx.client_id != client->_priv->client_id)
+    if (async_reply->async_data.client_id != client->_priv->client_id)
 	return;
 
     async_handle = g_hash_table_lookup (client->_priv->async_ops,
-					GINT_TO_POINTER (async_reply->ctx.async_id));
+					GINT_TO_POINTER (async_reply->async_data.async_id));
 
     g_message (G_STRLOC ": %p - `%s' - (%d,%d) - `%s' - %d - %p", client, event_name,
-	       async_reply->ctx.client_id, async_reply->ctx.async_id, async_reply->uri,
-	       async_reply->success, async_handle);
+	       async_reply->async_data.client_id, async_reply->async_data.async_id,
+	       async_reply->uri, async_reply->success, async_handle);
 
     if (!async_handle)
 	return;
 
-    if (async_handle->async_func)
-	async_handle->async_func (client, async_handle, async_reply->type,
-				  async_reply->uri, async_reply->error, async_reply->success,
-				  async_handle->user_data);
-
-    _gnome_selector_client_async_handle_free (async_handle);
+    gnome_async_handle_completed (async_handle, async_reply->success);
 }
 
 gchar *
@@ -638,25 +600,63 @@ gnome_selector_client_get_uri (GnomeSelectorClient *client)
 }
 
 void
-gnome_selector_client_set_uri (GnomeSelectorClient             *client,
-			       GnomeSelectorClientAsyncHandle **async_handle_return,
-                               const gchar                     *uri,
-                               guint                            timeout_msec,
-                               GnomeSelectorClientAsyncFunc     async_func,
-			       gpointer                         user_data,
-			       GDestroyNotify                   destroy_fn)
+gnome_selector_client_set_uri (GnomeSelectorClient  *client,
+			       GnomeAsyncHandle    **async_handle_return,
+                               const gchar          *uri,
+                               guint                 timeout_msec,
+                               GnomeAsyncFunc        async_func,
+			       gpointer              user_data)
+{
+    CORBA_Environment ev;
+    GnomeAsyncHandle *async_handle;
+    GNOME_Selector_AsyncData *async_data;
+
+    g_return_if_fail (client != NULL);
+    g_return_if_fail (GNOME_IS_SELECTOR_CLIENT (client));
+
+    async_handle = gnome_async_context_get (client->_priv->async_ctx, GNOME_ASYNC_TYPE_SET_URI, 
+					    async_func, G_OBJECT (client), uri, user_data,
+					    NULL);
+    if (async_handle_return) {
+	*async_handle_return = async_handle;
+	gnome_async_handle_ref (async_handle);
+    }
+
+    async_data = gnome_selector_client_create_async_data (client, uri, async_handle);
+
+    CORBA_exception_init (&ev);
+    GNOME_Selector_setURI (client->_priv->selector, uri, async_data, &ev);
+    CORBA_exception_free (&ev);
+}
+
+void
+gnome_selector_client_add_uri (GnomeSelectorClient  *client,
+			       GnomeAsyncHandle    **async_handle_return,
+                               const gchar          *uri,
+			       glong                 position,
+			       guint                 list_id,
+                               guint                 timeout_msec,
+                               GnomeAsyncFunc        async_func,
+			       gpointer              user_data)
 {
     CORBA_Environment ev;
-    GnomeSelectorClientAsyncHandle *async_handle;
+    GnomeAsyncHandle *async_handle;
+    GNOME_Selector_AsyncData *async_data;
 
     g_return_if_fail (client != NULL);
     g_return_if_fail (GNOME_IS_SELECTOR_CLIENT (client));
 
-    async_handle = _gnome_selector_client_async_handle_get (client, async_func, user_data, destroy_fn);
-    if (async_handle_return)
+    async_handle = gnome_async_context_get (client->_priv->async_ctx, GNOME_ASYNC_TYPE_ADD_URI, 
+					    async_func, G_OBJECT (client), uri, user_data,
+					    NULL);
+    if (async_handle_return) {
 	*async_handle_return = async_handle;
+	gnome_async_handle_ref (async_handle);
+    }
+
+    async_data = gnome_selector_client_create_async_data (client, uri, async_handle);
 
     CORBA_exception_init (&ev);
-    GNOME_Selector_setURI (client->_priv->selector, uri, async_handle->async_ctx, &ev);
+    GNOME_Selector_addURI (client->_priv->selector, uri, position, list_id, async_data, &ev);
     CORBA_exception_free (&ev);
 }
diff --git a/libgnomeui/gnome-component-widget.h b/libgnomeui/gnome-component-widget.h
index 04f2f4a..4509e58 100644
--- a/libgnomeui/gnome-component-widget.h
+++ b/libgnomeui/gnome-component-widget.h
@@ -34,6 +34,7 @@
 
 
 #include <bonobo/bonobo-widget.h>
+#include <libgnome/gnome-async-context.h>
 #include <libgnome/Gnome.h>
 
 
@@ -51,17 +52,6 @@ typedef struct _GnomeSelectorClient             GnomeSelectorClient;
 typedef struct _GnomeSelectorClientPrivate      GnomeSelectorClientPrivate;
 typedef struct _GnomeSelectorClientClass        GnomeSelectorClientClass;
 
-typedef struct _GnomeSelectorClientAsyncHandle  GnomeSelectorClientAsyncHandle;
-
-typedef void (*GnomeSelectorClientAsyncFunc)   (GnomeSelectorClient            *client,
-                                                GnomeSelectorClientAsyncHandle *async_handle,
-                                                GNOME_Selector_AsyncType        async_type,
-                                                const gchar                    *uri,
-                                                const gchar                    *error,
-                                                gboolean                        success,
-                                                gpointer                        user_data);
-
-
 struct _GnomeSelectorClient {
     BonoboWidget widget;
         
@@ -77,49 +67,58 @@ GtkType
 gnome_selector_client_get_type              (void) G_GNUC_CONST;
 
 GnomeSelectorClient *
-gnome_selector_client_new                   (const gchar         *moniker,
-                                             Bonobo_UIContainer   uic);
+gnome_selector_client_new                   (const gchar           *moniker,
+                                             Bonobo_UIContainer     uic);
 
 GnomeSelectorClient *
-gnome_selector_client_new_from_objref       (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);
+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);
+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,
+                                             GnomeAsyncHandle     **handle_return,
+                                             const gchar           *uri,
+                                             guint                  timeout_msec,
+                                             GnomeAsyncFunc         async_func,
+                                             gpointer               user_data);
 
 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_add_uri               (GnomeSelectorClient   *client,
+                                             GnomeAsyncHandle     **handle_return,
+                                             const gchar           *uri,
+					     glong                  position,
+					     guint                  list_id, 
+                                             guint                  timeout_msec,
+                                             GnomeAsyncFunc         async_func,
+                                             gpointer               user_data);
 
 G_END_DECLS
 



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