[gnome-dictionary] gdict: Split lookup-start/end signals
- From: Juan R. Garcia Blanco <juanrgar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-dictionary] gdict: Split lookup-start/end signals
- Date: Tue, 18 Aug 2015 11:49:18 +0000 (UTC)
commit 3a610a0e02569b5967909b1e1efdaab6afdf6de7
Author: Juan R. GarcĂa Blanco <juanrgar gmail com>
Date: Fri Aug 7 09:25:31 2015 +0200
gdict: Split lookup-start/end signals
Create separate definition-lookup-start/end signals when searching
for definitions.
libgdict/gdict-client-context.c | 16 ++++++++++------
libgdict/gdict-context.c | 36 ++++++++++++++++++++++++++++++++++++
libgdict/gdict-context.h | 2 ++
libgdict/gdict-defbox.c | 4 ++--
src/gdict-window.c | 4 ++--
5 files changed, 52 insertions(+), 10 deletions(-)
---
diff --git a/libgdict/gdict-client-context.c b/libgdict/gdict-client-context.c
index 1a960f2..d6376c3 100644
--- a/libgdict/gdict-client-context.c
+++ b/libgdict/gdict-client-context.c
@@ -1347,10 +1347,14 @@ 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");
+ {
+ if (last_cmd == CMD_SHOW_DB)
+ g_signal_emit_by_name (context, "database-lookup-end");
+ else if (last_cmd == CMD_DEFINE)
+ g_signal_emit_by_name (context, "definition-lookup-end");
+ else
+ g_signal_emit_by_name (context, "lookup-end");
+ }
/* pop the next command from the queue */
new_command = gdict_client_context_pop_command (context);
@@ -2107,7 +2111,7 @@ gdict_client_context_define_word (GdictContext *context,
client_ctx = GDICT_CLIENT_CONTEXT (context);
- g_signal_emit_by_name (context, "lookup-start");
+ g_signal_emit_by_name (context, "definition-lookup-start");
if (!gdict_client_context_is_connected (client_ctx))
{
@@ -2116,7 +2120,7 @@ gdict_client_context_define_word (GdictContext *context,
gdict_client_context_connect (client_ctx, &connect_error);
if (connect_error)
{
- g_signal_emit_by_name (context, "lookup-end");
+ g_signal_emit_by_name (context, "definition-lookup-end");
g_propagate_error (error, connect_error);
diff --git a/libgdict/gdict-context.c b/libgdict/gdict-context.c
index 639c82e..39277bd 100644
--- a/libgdict/gdict-context.c
+++ b/libgdict/gdict-context.c
@@ -224,6 +224,42 @@ gdict_context_class_init (gpointer g_iface)
G_TYPE_NONE, 1,
GDICT_TYPE_MATCH);
/**
+ * GdictContext::definition-lookup-start
+ * @context: the object which received the signal
+ *
+ * This signal is emitted when a definition 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 ("definition-lookup-start",
+ iface_type,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdictContextIface, definition_lookup_start),
+ NULL, NULL,
+ gdict_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ /**
+ * GdictContext::definition-lookup-end
+ * @context: the object which received the signal
+ *
+ * This signal is emitted when a definition 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 ("definition-lookup-end",
+ iface_type,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdictContextIface, definition_lookup_end),
+ NULL, NULL,
+ gdict_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ /**
* GdictContext::definition-found
* @context: the object which received the signal
* @definition: a #GdictDefinition
diff --git a/libgdict/gdict-context.h b/libgdict/gdict-context.h
index 3b103af..b0e8735 100644
--- a/libgdict/gdict-context.h
+++ b/libgdict/gdict-context.h
@@ -168,6 +168,8 @@ struct _GdictContextIface
GdictStrategy *strategy);
void (*match_found) (GdictContext *context,
GdictMatch *match);
+ void (*definition_lookup_start) (GdictContext *context);
+ void (*definition_lookup_end) (GdictContext *context);
void (*definition_found) (GdictContext *context,
GdictDefinition *definition);
diff --git a/libgdict/gdict-defbox.c b/libgdict/gdict-defbox.c
index f16220d..c1b7b24 100644
--- a/libgdict/gdict-defbox.c
+++ b/libgdict/gdict-defbox.c
@@ -2439,13 +2439,13 @@ gdict_defbox_lookup (GdictDefbox *defbox,
if (!priv->start_id)
{
- priv->start_id = g_signal_connect (priv->context, "lookup-start",
+ priv->start_id = g_signal_connect (priv->context, "definition-lookup-start",
G_CALLBACK (lookup_start_cb),
defbox);
priv->define_id = g_signal_connect (priv->context, "definition-found",
G_CALLBACK (definition_found_cb),
defbox);
- priv->end_id = g_signal_connect (priv->context, "lookup-end",
+ priv->end_id = g_signal_connect (priv->context, "definition-lookup-end",
G_CALLBACK (lookup_end_cb),
defbox);
}
diff --git a/src/gdict-window.c b/src/gdict-window.c
index 11a6ada..3304cd5 100644
--- a/src/gdict-window.c
+++ b/src/gdict-window.c
@@ -544,10 +544,10 @@ gdict_window_set_context (GdictWindow *window,
window->definition_id = g_signal_connect (context, "definition-found",
G_CALLBACK (gdict_window_definition_cb),
window);
- window->lookup_start_id = g_signal_connect (context, "lookup-start",
+ window->lookup_start_id = g_signal_connect (context, "definition-lookup-start",
G_CALLBACK (gdict_window_lookup_start_cb),
window);
- window->lookup_end_id = g_signal_connect (context, "lookup-end",
+ window->lookup_end_id = g_signal_connect (context, "definition-lookup-end",
G_CALLBACK (gdict_window_lookup_end_cb),
window);
window->error_id = g_signal_connect (context, "error",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]