[gnome-flashback] input-sources: add current-source-changed signal



commit b9734a69ec07887ad93dfbf751e7179ef5aeb48d
Author: Sebastian Geiger <sbastig gmx net>
Date:   Wed Sep 30 14:53:45 2015 +0200

    input-sources: add current-source-changed signal

 .../libinput-sources/gf-input-source-manager.c     |   17 +++++++++++++++++
 .../libinput-sources/gf-input-source-manager.h     |    7 +++++--
 2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c 
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index 67af7a8..b2cc110 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -80,6 +80,7 @@ struct _GfInputSourceManager
 enum
 {
   SIGNAL_SOURCES_CHANGED,
+  SIGNAL_CURRENT_SOURCE_CHANGED,
 
   LAST_SIGNAL
 };
@@ -491,10 +492,15 @@ static void
 current_input_source_changed (GfInputSourceManager *manager,
                               GfInputSource        *new_source)
 {
+  GfInputSource *old_source;
   GList *l;
 
+  old_source = manager->current_source;
   manager->current_source = new_source;
 
+  g_signal_emit (manager, signals[SIGNAL_CURRENT_SOURCE_CHANGED],
+                 0, old_source);
+
   for (l = manager->mru_sources; l != NULL; l = g_list_next (l))
     {
       GfInputSource *source;
@@ -1056,6 +1062,11 @@ gf_input_source_manager_class_init (GfInputSourceManagerClass *manager_class)
     g_signal_new ("sources-changed", G_TYPE_FROM_CLASS (manager_class),
                   G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
 
+  signals[SIGNAL_CURRENT_SOURCE_CHANGED] =
+    g_signal_new ("current-source-changed", G_TYPE_FROM_CLASS (manager_class),
+                  G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
+                  GF_TYPE_INPUT_SOURCE);
+
   properties[PROP_IBUS_MANAGER] =
     g_param_spec_object ("ibus-manager", "IBus Manager",
                          "An instance of GfIBusManager",
@@ -1095,3 +1106,9 @@ gf_input_source_manager_reload (GfInputSourceManager *manager)
 
   sources_changed_cb (manager->settings, manager);
 }
+
+GfInputSource *
+gf_input_source_manager_get_current_source (GfInputSourceManager *manager)
+{
+  return manager->current_source;
+}
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.h 
b/gnome-flashback/libinput-sources/gf-input-source-manager.h
index 73dddde..67e87ae 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.h
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.h
@@ -20,13 +20,16 @@
 
 #include <glib-object.h>
 #include "gf-ibus-manager.h"
+#include "gf-input-source.h"
 
 #define GF_TYPE_INPUT_SOURCE_MANAGER gf_input_source_manager_get_type ()
 G_DECLARE_FINAL_TYPE (GfInputSourceManager, gf_input_source_manager,
                       GF, INPUT_SOURCE_MANAGER, GObject)
 
-GfInputSourceManager *gf_input_source_manager_new    (GfIBusManager        *manager);
+GfInputSourceManager *gf_input_source_manager_new                (GfIBusManager        *manager);
 
-void                  gf_input_source_manager_reload (GfInputSourceManager *manager);
+void                  gf_input_source_manager_reload             (GfInputSourceManager *manager);
+
+GfInputSource        *gf_input_source_manager_get_current_source (GfInputSourceManager *manager);
 
 #endif


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