[gtranslator] Notify the window when the selection of the active view changes
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Notify the window when the selection of the active view changes
- Date: Sun, 22 Apr 2012 10:58:59 +0000 (UTC)
commit 43a13ae2a7ceb40af718dad85c328dc382423460
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sun Apr 22 12:26:42 2012 +0200
Notify the window when the selection of the active view changes
https://bugzilla.gnome.org/show_bug.cgi?id=569650
src/gtr-tab.c | 17 +++++++++++++++++
src/gtr-tab.h | 1 +
src/gtr-window.c | 8 ++++++++
3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index 313992e..b8d55fc 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -125,6 +125,7 @@ enum
SHOWED_MESSAGE,
MESSAGE_CHANGED,
MESSAGE_EDITION_FINISHED,
+ SELECTION_CHANGED,
LAST_SIGNAL
};
@@ -543,6 +544,12 @@ emit_message_changed_signal (GtkTextBuffer * buf, GtrTab * tab)
}
static void
+emit_selection_changed (GtkTextBuffer * buf, GParamSpec * spec, GtrTab * tab)
+{
+ g_signal_emit (G_OBJECT (tab), signals[SELECTION_CHANGED], 0);
+}
+
+static void
update_status (GtrTab * tab, GtrMsg * msg, gpointer useless)
{
GtrMsgStatus status;
@@ -627,6 +634,8 @@ gtr_tab_add_msgstr_tabs (GtrTab * tab)
g_signal_connect_after (buf, "end_user_action",
G_CALLBACK (emit_message_changed_signal), tab);
+ g_signal_connect (buf, "notify::has-selection",
+ G_CALLBACK (emit_selection_changed), tab);
i++;
g_free (label);
}
@@ -1012,6 +1021,14 @@ gtr_tab_class_init (GtrTabClass * klass)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GTR_TYPE_MSG);
+ signals[SELECTION_CHANGED] =
+ g_signal_new ("selection-changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtrTabClass, selection_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
/* Properties */
g_object_class_install_property (object_class,
diff --git a/src/gtr-tab.h b/src/gtr-tab.h
index 9db9f41..16a61d0 100644
--- a/src/gtr-tab.h
+++ b/src/gtr-tab.h
@@ -70,6 +70,7 @@ struct _GtrTabClass
void (*showed_message) (GtrTab * tab, GtrMsg * msg);
void (*message_changed) (GtrTab * tab, GtrMsg * msg);
void (*message_edition_finished) (GtrTab * tab, GtrMsg * msg);
+ void (*selection_changed) (GtrTab * tab);
};
typedef enum
diff --git a/src/gtr-window.c b/src/gtr-window.c
index 017a2be..754c534 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -901,6 +901,12 @@ showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrWindow * window)
}
static void
+selection_changed_cb (GtrTab * tab, GtrWindow * window)
+{
+ set_sensitive_according_to_tab (window, tab);
+}
+
+static void
notebook_tab_added (GtkNotebook * notebook,
GtkWidget * child, guint page_num, GtrWindow * window)
{
@@ -948,6 +954,8 @@ notebook_tab_added (GtkNotebook * notebook,
window);
g_signal_connect_after (child, "showed_message",
G_CALLBACK (showed_message_cb), window);
+ g_signal_connect (child, "selection-changed",
+ G_CALLBACK (selection_changed_cb), window);
g_signal_connect (gtr_tab_get_po (tab),
"notify::state", G_CALLBACK (sync_state), window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]