[gnome-flashback] input-sources: add an interactive argument to input source activation



commit 020e7be87b3dbeac395dea70d444ac7fc2fd50db
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Jun 11 15:48:44 2016 +0300

    input-sources: add an interactive argument to input source activation
    
    This is useful to differentiate between a change due to user
    interaction or automatic loading.

 .../libinput-sources/gf-input-source-manager.c     |   11 +++++------
 .../libinput-sources/gf-input-source-popup.c       |    2 +-
 gnome-flashback/libinput-sources/gf-input-source.c |    8 +++++---
 gnome-flashback/libinput-sources/gf-input-source.h |    3 ++-
 .../libinput-sources/gf-input-sources.c            |   12 ++++++++----
 5 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c 
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index 62c9451..24e019c 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -296,7 +296,7 @@ modifiers_accelerator_activated_cb (GfKeybindings *keybindings,
   source = (GfInputSource *) g_hash_table_lookup (manager->input_sources,
                                                   GUINT_TO_POINTER (next_index));
 
-  gf_input_source_activate (source);
+  gf_input_source_activate (source, TRUE);
   g_list_free (keys);
 
   return TRUE;
@@ -558,15 +558,14 @@ engine_set_cb (GfIBusManager *manager,
 }
 
 static void
-activate_cb (GfInputSource *source,
-             gpointer       user_data)
+activate_cb (GfInputSource        *source,
+             gboolean              interactive,
+             GfInputSourceManager *manager)
 {
-  GfInputSourceManager *manager;
   const gchar *xkb_id;
   const gchar *type;
   const gchar *engine;
 
-  manager = GF_INPUT_SOURCE_MANAGER (user_data);
   xkb_id = gf_input_source_get_xkb_id (source);
 
   gf_keyboard_manager_grab (manager->keyboard_manager, GDK_CURRENT_TIME);
@@ -749,7 +748,7 @@ update_mru_sources_list (GfInputSourceManager *manager)
 
       source = (GfInputSource *) g_list_nth_data (manager->mru_sources, 0);
 
-      gf_input_source_activate (source);
+      gf_input_source_activate (source, FALSE);
     }
 }
 
diff --git a/gnome-flashback/libinput-sources/gf-input-source-popup.c 
b/gnome-flashback/libinput-sources/gf-input-source-popup.c
index 0602992..b7c93b9 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-popup.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-popup.c
@@ -207,7 +207,7 @@ activate_selected_input_source (GfInputSourcePopup *popup)
   ungrab (popup);
 
   gf_popup_window_fade_start (popup_window);
-  gf_input_source_activate (source);
+  gf_input_source_activate (source, TRUE);
 }
 
 static void
diff --git a/gnome-flashback/libinput-sources/gf-input-source.c 
b/gnome-flashback/libinput-sources/gf-input-source.c
index d249cd4..8ed404d 100644
--- a/gnome-flashback/libinput-sources/gf-input-source.c
+++ b/gnome-flashback/libinput-sources/gf-input-source.c
@@ -229,7 +229,8 @@ gf_input_source_class_init (GfInputSourceClass *source_class)
 
   signals[SIGNAL_ACTIVATE] =
     g_signal_new ("activate", G_OBJECT_CLASS_TYPE (source_class),
-                  G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
+                  G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
+                  G_TYPE_BOOLEAN);
 
   signals[SIGNAL_CHANGED] =
     g_signal_new ("changed", G_OBJECT_CLASS_TYPE (source_class),
@@ -346,9 +347,10 @@ gf_input_source_get_xkb_id (GfInputSource *source)
 }
 
 void
-gf_input_source_activate (GfInputSource *source)
+gf_input_source_activate (GfInputSource *source,
+                          gboolean       interactive)
 {
-  g_signal_emit (source, signals[SIGNAL_ACTIVATE], 0);
+  g_signal_emit (source, signals[SIGNAL_ACTIVATE], 0, interactive);
 }
 
 IBusPropList *
diff --git a/gnome-flashback/libinput-sources/gf-input-source.h 
b/gnome-flashback/libinput-sources/gf-input-source.h
index a42359f..6388d11 100644
--- a/gnome-flashback/libinput-sources/gf-input-source.h
+++ b/gnome-flashback/libinput-sources/gf-input-source.h
@@ -49,7 +49,8 @@ guint          gf_input_source_get_index        (GfInputSource *source);
 
 const gchar   *gf_input_source_get_xkb_id       (GfInputSource *source);
 
-void           gf_input_source_activate         (GfInputSource *source);
+void           gf_input_source_activate         (GfInputSource *source,
+                                                 gboolean       interactive);
 
 IBusPropList  *gf_input_source_get_properties   (GfInputSource *source);
 
diff --git a/gnome-flashback/libinput-sources/gf-input-sources.c 
b/gnome-flashback/libinput-sources/gf-input-sources.c
index 95765eb..f6aa2da 100644
--- a/gnome-flashback/libinput-sources/gf-input-sources.c
+++ b/gnome-flashback/libinput-sources/gf-input-sources.c
@@ -238,6 +238,13 @@ spawn_kayboard_display (const gchar *description)
 }
 
 static void
+activate_cb (GtkMenuItem   *menuitem,
+             GfInputSource *source)
+{
+  gf_input_source_activate (source, TRUE);
+}
+
+static void
 show_layout_cb (GtkMenuItem *menuitem,
                 gpointer     user_data)
 {
@@ -341,10 +348,7 @@ status_icon_activate_cb (GtkStatusIcon *status_icon,
         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
       gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
-      g_signal_connect_swapped (item, "activate",
-                                G_CALLBACK (gf_input_source_activate),
-                                source);
-
+      g_signal_connect (item, "activate", G_CALLBACK (activate_cb), source);
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
     }
 


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