[gnome-dictionary] gdict: Split lookup-start/end signals



commit 9e272d825433e92ec63dc2a24f15cde52acd25ed
Author: Juan R. GarcĂ­a Blanco <juanrgar gmail com>
Date:   Fri Aug 7 09:15:39 2015 +0200

    gdict: Split lookup-start/end signals
    
    Create separate database-lookup-start/end signals for notification
    of these events when searching for databases in a given source.

 libgdict/gdict-client-context.c   |    5 ++++-
 libgdict/gdict-context.c          |   36 ++++++++++++++++++++++++++++++++++++
 libgdict/gdict-context.h          |   22 ++++++++++++----------
 libgdict/gdict-database-chooser.c |    4 ++--
 4 files changed, 54 insertions(+), 13 deletions(-)
---
diff --git a/libgdict/gdict-client-context.c b/libgdict/gdict-client-context.c
index 407a6d0..1a960f2 100644
--- a/libgdict/gdict-client-context.c
+++ b/libgdict/gdict-client-context.c
@@ -1347,6 +1347,9 @@ gdict_client_context_parse_line (GdictClientContext *context,
        * we issue them ourselves
        */
       if ((last_cmd != CMD_CLIENT) && (last_cmd != CMD_QUIT))
+        if (last_cmd == CMD_SHOW_DB)
+          g_signal_emit_by_name (context, "database-lookup-end");
+
         g_signal_emit_by_name (context, "lookup-end");
       
       /* pop the next command from the queue */
@@ -2036,7 +2039,7 @@ gdict_client_context_get_databases (GdictContext  *context,
   
   client_ctx = GDICT_CLIENT_CONTEXT (context);
 
-  g_signal_emit_by_name (context, "lookup-start");
+  g_signal_emit_by_name (context, "database-lookup-start");
   
   if (!gdict_client_context_is_connected (client_ctx))
     {
diff --git a/libgdict/gdict-context.c b/libgdict/gdict-context.c
index 83783bd..639c82e 100644
--- a/libgdict/gdict-context.c
+++ b/libgdict/gdict-context.c
@@ -137,6 +137,42 @@ gdict_context_class_init (gpointer g_iface)
                 G_TYPE_NONE, 1,
                 G_TYPE_POINTER);
   /**
+   * GdictContext::database-lookup-start
+   * @context: the object which received the signal
+   *
+   * This signal is emitted when a database look up operation has been issued
+   * using a #GdictContext.  Since every operation using a context is
+   * asynchronous, you can use this signal to know if the request has been
+   * issued or not.
+   *
+   * Since: 1.0
+   */
+  g_signal_new ("database-lookup-start",
+                iface_type,
+                G_SIGNAL_RUN_LAST,
+                G_STRUCT_OFFSET (GdictContextIface, database_lookup_start),
+                NULL, NULL,
+                gdict_marshal_VOID__VOID,
+                G_TYPE_NONE, 0);
+  /**
+   * GdictContext::database-lookup-end
+   * @context: the object which received the signal
+   *
+   * This signal is emitted when a database look up operation that has been
+   * issued using a #GdictContext has been completed.  Since every operation
+   * using a context is asynchronous, you can use this signal to know if the
+   * request has been completed or not.
+   *
+   * Since: 1.0
+   */
+  g_signal_new ("database-lookup-end",
+                iface_type,
+                G_SIGNAL_RUN_LAST,
+                G_STRUCT_OFFSET (GdictContextIface, database_lookup_end),
+                NULL, NULL,
+                gdict_marshal_VOID__VOID,
+                G_TYPE_NONE, 0);
+  /**
    * GdictContext::database-found
    * @context: the object which received the signal
    * @database: a #GdictDatabase
diff --git a/libgdict/gdict-context.h b/libgdict/gdict-context.h
index 1c44faf..3b103af 100644
--- a/libgdict/gdict-context.h
+++ b/libgdict/gdict-context.h
@@ -157,17 +157,19 @@ struct _GdictContextIface
                                 GError       **error);  
   
   /* signals */
-  void (*lookup_start)     (GdictContext    *context);
-  void (*lookup_end)       (GdictContext    *context);
+  void (*lookup_start)              (GdictContext    *context);
+  void (*lookup_end)                (GdictContext    *context);
   
-  void (*database_found)   (GdictContext    *context,
-                           GdictDatabase   *database);
-  void (*strategy_found)   (GdictContext    *context,
-                           GdictStrategy   *strategy);
-  void (*match_found)      (GdictContext    *context,
-                           GdictMatch      *match);
-  void (*definition_found) (GdictContext    *context,
-                           GdictDefinition *definition);
+  void (*database_lookup_start)     (GdictContext    *context);
+  void (*database_lookup_end)       (GdictContext    *context);
+  void (*database_found)            (GdictContext    *context,
+                                    GdictDatabase   *database);
+  void (*strategy_found)            (GdictContext    *context,
+                                    GdictStrategy   *strategy);
+  void (*match_found)               (GdictContext    *context,
+                                    GdictMatch      *match);
+  void (*definition_found)          (GdictContext    *context,
+                                    GdictDefinition *definition);
   
   /* fired each time there's an error; the GError is owned
    * by the context, and should never be modified or freed
diff --git a/libgdict/gdict-database-chooser.c b/libgdict/gdict-database-chooser.c
index b1090b6..6bd8727 100644
--- a/libgdict/gdict-database-chooser.c
+++ b/libgdict/gdict-database-chooser.c
@@ -877,13 +877,13 @@ gdict_database_chooser_refresh (GdictDatabaseChooser *chooser)
 
   if (!priv->start_id)
     {
-      priv->start_id = g_signal_connect (priv->context, "lookup-start",
+      priv->start_id = g_signal_connect (priv->context, "database-lookup-start",
                                         G_CALLBACK (lookup_start_cb),
                                         chooser);
       priv->match_id = g_signal_connect (priv->context, "database-found",
                                         G_CALLBACK (database_found_cb),
                                         chooser);
-      priv->end_id = g_signal_connect (priv->context, "lookup-end",
+      priv->end_id = g_signal_connect (priv->context, "database-lookup-end",
                                       G_CALLBACK (lookup_end_cb),
                                       chooser);
     }


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