[gnome-flashback/wip/segeiger/inputmethods: 8/8] input-sources: Partial implementation for GfInputSourceManager



commit f129376427b652d76eb996c0583934cbe320c208
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sat Sep 19 18:37:18 2015 +0200

    input-sources: Partial implementation for GfInputSourceManager

 .../libinput-sources/gf-input-source-manager.c     |  218 +++++++++++++++++++-
 .../libinput-sources/gf-input-source-manager.h     |   10 +-
 2 files changed, 225 insertions(+), 3 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c 
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index e070c8d..c64547a 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -22,11 +22,13 @@
 #include <glib/gi18n.h>
 #include <libcommon/gf-keybindings.h>
 
+#include "gf-ibus-manager.h"
+#include "gf-input-source.h"
 #include "gf-input-source-manager.h"
 #include "gf-input-source-settings.h"
-#include "gf-ibus-manager.h"
 #include "gf-keyboard-manager.h"
 
+
 #define DESKTOP_WM_KEYBINDINGS_SCHEMA "org.gnome.desktop.wm.keybindings"
 
 #define KEY_SWITCH_INPUT_SOURCE "switch-input-source"
@@ -59,8 +61,29 @@ struct _GfInputSourceManager
 
   GfKeyboardManager     *keyboard_manager;
 
+  gboolean               ibusReady;
   GfIBusManager         *ibus_manager;
   gboolean               disable_ibus;
+
+  /**
+   * All valid input sources currently in the GSettings KEY_INPUT_SOURCES list
+   * indexed by their index there
+   */
+  GHashTable            *input_sources;
+
+  /**
+   * All valid input sources currently in the GSettings KEY_INPUT_SOURCES list
+   * of type INPUT_SOURCE_TYPE_IBUS indexed by their IBus ID.
+   */
+  GHashTable *ibus_sources;
+
+  /**
+   * All valid input sources currently in the GSettings KEY_INPUT_SOURCES
+   * list ordered
+   */
+  GList *mruSources;
+
+  GfInputSource *currentSource;
 };
 
 enum
@@ -185,6 +208,48 @@ accelerator_activated_cb (GfKeybindings *keybindings,
                           GVariant      *parameters,
                           gpointer       user_data)
 {
+  GfInputSourceManager *manager;
+  GfInputSource *input_source;
+  GList *source_indexes;
+  GList *source_values;
+
+  manager = GF_INPUT_SOURCE_MANAGER (user_data);
+  source_indexes = g_hash_table_get_keys (manager->input_sources);
+  source_values = g_hash_table_get_values (manager->input_sources);
+
+  if (g_list_length (source_indexes) == 0)
+    {
+      //gf_keyboard_manager_release_keyboard (manager->keyboard_manager);
+      return;
+    }
+
+  input_source = gf_input_source_manager_get_current_source (manager);
+
+  if (input_source == NULL)
+    {
+      input_source = source_values->data;
+    }
+
+  if (action == manager->switch_source_action)
+    {
+      GList *next_source_value = source_values;
+      while (next_source_value != NULL && next_source_value->data == NULL)
+        {
+          next_source_value = next_source_value->next;
+        }
+      input_source = next_source_value->data;
+    }
+  else
+    {
+      GList *prev_source_value = source_values;
+      while (prev_source_value->data == NULL && prev_source_value->prev != NULL)
+      {
+        prev_source_value = prev_source_value->prev;
+      }
+      input_source = prev_source_value->data;
+    }
+
+  gf_input_source_activate (input_source);
 }
 
 static void
@@ -413,6 +478,107 @@ gf_input_source_manager_dispose (GObject *object)
 }
 
 static void
+gf_input_source_manager_ibus_ready_callback (GfIBusManager* iBusManager, gboolean ready)
+{
+}
+
+static void
+gf_input_source_manager_modifiers_switch ()
+{
+
+}
+
+static void
+gf_input_source_manager_switch_input_source (void)
+{
+
+}
+
+static void
+gf_input_source_manager_keyboard_options_changed (void)
+{
+
+}
+
+static void
+gf_input_source_manager_current_input_source_changed (void)
+{
+
+}
+
+static void
+gf_input_source_manager_activate_input_source (void)
+{
+
+}
+
+static void
+gf_input_source_manager_input_sources_changed (void)
+{
+
+}
+
+static void
+gf_input_source_manager_make_engine_short_name (void)
+{
+
+}
+
+static void
+gf_input_source_manager_ibus_properties_registered (void)
+{
+
+}
+
+static void
+gf_input_source_manager_ibus_property_updated (void)
+{
+
+}
+
+static void
+gf_input_source_manager_update_sub_property (void)
+{
+
+}
+
+static void
+gf_input_source_manager_ibus_set_content_type (void)
+{
+
+}
+
+static void
+gf_input_source_manager_get_new_input_source (void)
+{
+
+}
+
+static void
+gf_input_source_manager_get_current_window (void)
+{
+
+}
+
+static void
+gf_input_source_manager_set_per_window_input_source (void)
+{
+
+}
+
+static void
+gf_input_source_manager_sources_per_window_changed (void)
+{
+
+}
+
+static void
+gf_input_source_manager_change_per_window_source (void)
+{
+
+}
+
+static void
 gf_input_source_manager_set_property (GObject      *object,
                                       guint         property_id,
                                       const GValue *value,
@@ -457,6 +623,36 @@ gf_input_source_manager_get_property (GObject    *object,
 }
 
 static void
+gf_input_source_manager_constructed (GObject *object)
+{
+  GfInputSourceManager *manager;
+
+  G_OBJECT_CLASS (gf_input_source_manager_parent_class)->constructed (object);
+
+  manager = GF_INPUT_SOURCE_MANAGER (object);
+
+  g_signal_connect (manager->ibus_manager,
+                    "ready",
+                    G_CALLBACK (gf_input_source_manager_ibus_ready_callback),
+                    manager);
+
+  g_signal_connect (manager->ibus_manager,
+                    "properties-registered",
+                    G_CALLBACK (gf_input_source_manager_ibus_properties_registered),
+                    manager);
+
+  g_signal_connect (manager->ibus_manager,
+                    "property-updated",
+                    G_CALLBACK (gf_input_source_manager_ibus_property_updated),
+                    manager);
+
+  g_signal_connect (manager->ibus_manager,
+                    "set-content-type",
+                    G_CALLBACK (gf_input_source_manager_ibus_set_content_type),
+                    manager);
+}
+
+static void
 gf_input_source_manager_class_init (GfInputSourceManagerClass *manager_class)
 {
   GObjectClass *object_class;
@@ -466,6 +662,7 @@ gf_input_source_manager_class_init (GfInputSourceManagerClass *manager_class)
   object_class->dispose = gf_input_source_manager_dispose;
   object_class->get_property = gf_input_source_manager_get_property;
   object_class->set_property = gf_input_source_manager_set_property;
+  object_class->constructed = gf_input_source_manager_constructed;
 
   properties[PROP_IBUS_MANAGER] =
     g_param_spec_object ("ibus-manager", "IBus Manager",
@@ -484,11 +681,15 @@ gf_input_source_manager_init (GfInputSourceManager *manager)
 
   keybindings_init (manager);
   input_source_settings_init (manager);
+  manager->input_sources = g_hash_table_new (g_str_hash, g_str_equal);
+  manager->ibus_sources = g_hash_table_new (g_str_hash, g_str_equal);
 }
 
+
 GfInputSourceManager *
 gf_input_source_manager_new (GfIBusManager *ibus_manager)
 {
+  g_return_val_if_fail (ibus_manager, NULL);
   return g_object_new (GF_TYPE_INPUT_SOURCE_MANAGER,
                        "ibus-manager", ibus_manager,
                        NULL);
@@ -506,3 +707,18 @@ 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->currentSource;
+}
+
+/**
+ * Returns: A #GHashTable of #GfInputSource objects
+ */
+GHashTable *
+gf_input_source_manager_input_sources (GfInputSourceManager *manager)
+{
+    return manager->input_sources;
+}
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.h 
b/gnome-flashback/libinput-sources/gf-input-source-manager.h
index 73dddde..9441991 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.h
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.h
@@ -19,14 +19,20 @@
 #define GF_INPUT_SOURCE_MANAGER_H
 
 #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);
+
+GfInputSource        *gf_input_source_manager_get_current_source (GfInputSourceManager *manager);
 
-void                  gf_input_source_manager_reload (GfInputSourceManager *manager);
+GHashTable           *gf_input_source_manager_input_sources      (GfInputSourceManager *manager);
 
 #endif


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