[gnome-flashback] input-sources: add GfInputSourcesIBus and GfInputSourcesXkb



commit 1d53dc33a0963b530cb10ac06229eab542125b89
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Jan 2 02:53:46 2020 +0200

    input-sources: add GfInputSourcesIBus and GfInputSourcesXkb

 gnome-flashback/libinput-sources/Makefile.am       |  4 +++
 .../libinput-sources/gf-input-source-ibus.c        | 36 ++++++++++++++++++++++
 .../libinput-sources/gf-input-source-ibus.h        | 31 +++++++++++++++++++
 .../libinput-sources/gf-input-source-manager.c     | 22 ++++++++++---
 .../libinput-sources/gf-input-source-xkb.c         | 36 ++++++++++++++++++++++
 .../libinput-sources/gf-input-source-xkb.h         | 31 +++++++++++++++++++
 gnome-flashback/libinput-sources/gf-input-source.c | 20 +-----------
 gnome-flashback/libinput-sources/gf-input-source.h |  9 ------
 8 files changed, 156 insertions(+), 33 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/Makefile.am b/gnome-flashback/libinput-sources/Makefile.am
index da61b32..eb58e8a 100644
--- a/gnome-flashback/libinput-sources/Makefile.am
+++ b/gnome-flashback/libinput-sources/Makefile.am
@@ -28,6 +28,10 @@ libinput_sources_la_SOURCES = \
        gf-candidate-popup.h \
        gf-ibus-manager.c \
        gf-ibus-manager.h \
+       gf-input-source-ibus.c \
+       gf-input-source-ibus.h \
+       gf-input-source-xkb.c \
+       gf-input-source-xkb.h \
        gf-input-source.c \
        gf-input-source.h \
        gf-input-sources.c \
diff --git a/gnome-flashback/libinput-sources/gf-input-source-ibus.c 
b/gnome-flashback/libinput-sources/gf-input-source-ibus.c
new file mode 100644
index 0000000..52e9f3c
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-input-source-ibus.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2019 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "gf-input-source-ibus.h"
+
+struct _GfInputSourceIBus
+{
+  GfInputSource parent;
+};
+
+G_DEFINE_TYPE (GfInputSourceIBus, gf_input_source_ibus, GF_TYPE_INPUT_SOURCE)
+
+static void
+gf_input_source_ibus_class_init (GfInputSourceIBusClass *self_class)
+{
+}
+
+static void
+gf_input_source_ibus_init (GfInputSourceIBus *self)
+{
+}
diff --git a/gnome-flashback/libinput-sources/gf-input-source-ibus.h 
b/gnome-flashback/libinput-sources/gf-input-source-ibus.h
new file mode 100644
index 0000000..2411389
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-input-source-ibus.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GF_INPUT_SOURCE_IBUS_H
+#define GF_INPUT_SOURCE_IBUS_H
+
+#include "gf-input-source.h"
+
+G_BEGIN_DECLS
+
+#define GF_TYPE_INPUT_SOURCE_IBUS (gf_input_source_ibus_get_type ())
+G_DECLARE_FINAL_TYPE (GfInputSourceIBus, gf_input_source_ibus,
+                      GF, INPUT_SOURCE_IBUS, GfInputSource)
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c 
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index 3e1b44d..87b8683 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -17,6 +17,7 @@
  */
 
 #include "config.h"
+#include "gf-input-source-manager.h"
 
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
@@ -26,10 +27,10 @@
 #include <X11/Xatom.h>
 
 #include "gf-ibus-manager.h"
-#include "gf-input-source.h"
-#include "gf-input-source-manager.h"
+#include "gf-input-source-ibus.h"
 #include "gf-input-source-popup.h"
 #include "gf-input-source-settings.h"
+#include "gf-input-source-xkb.h"
 #include "gf-keyboard-manager.h"
 
 #define DESKTOP_WM_KEYBINDINGS_SCHEMA "org.gnome.desktop.wm.keybindings"
@@ -1188,6 +1189,7 @@ sources_changed_cb (GfInputSourceSettings *settings,
 
   for (l = source_infos; l != NULL; l = g_list_next (l))
     {
+      GType gtype;
       SourceInfo *info;
       gint position;
       GfInputSource *source;
@@ -1195,9 +1197,19 @@ sources_changed_cb (GfInputSourceSettings *settings,
       info = (SourceInfo *) l->data;
       position = g_list_position (source_infos, l);
 
-      source = gf_input_source_new (manager->ibus_manager, info->type,
-                                    info->id, info->display_name,
-                                    info->short_name, position);
+      if (g_strcmp0 (info->type, INPUT_SOURCE_TYPE_IBUS) == 0)
+        gtype = GF_TYPE_INPUT_SOURCE_IBUS;
+      else
+        gtype = GF_TYPE_INPUT_SOURCE_XKB;
+
+      source = g_object_new (gtype,
+                             "ibus-manager", manager->ibus_manager,
+                             "type", info->type,
+                             "id", info->id,
+                             "display-name", info->display_name,
+                             "short-name", info->short_name,
+                             "index", position,
+                             NULL);
 
       gf_input_source_set_icon_file (source, info->icon_file);
 
diff --git a/gnome-flashback/libinput-sources/gf-input-source-xkb.c 
b/gnome-flashback/libinput-sources/gf-input-source-xkb.c
new file mode 100644
index 0000000..a89ff1e
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-input-source-xkb.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2019 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "gf-input-source-xkb.h"
+
+struct _GfInputSourceXkb
+{
+  GfInputSource parent;
+};
+
+G_DEFINE_TYPE (GfInputSourceXkb, gf_input_source_xkb, GF_TYPE_INPUT_SOURCE)
+
+static void
+gf_input_source_xkb_class_init (GfInputSourceXkbClass *self_class)
+{
+}
+
+static void
+gf_input_source_xkb_init (GfInputSourceXkb *self)
+{
+}
diff --git a/gnome-flashback/libinput-sources/gf-input-source-xkb.h 
b/gnome-flashback/libinput-sources/gf-input-source-xkb.h
new file mode 100644
index 0000000..d428def
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-input-source-xkb.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GF_INPUT_SOURCE_XKB_H
+#define GF_INPUT_SOURCE_XKB_H
+
+#include "gf-input-source.h"
+
+G_BEGIN_DECLS
+
+#define GF_TYPE_INPUT_SOURCE_XKB (gf_input_source_xkb_get_type ())
+G_DECLARE_FINAL_TYPE (GfInputSourceXkb, gf_input_source_xkb,
+                      GF, INPUT_SOURCE_XKB, GfInputSource)
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libinput-sources/gf-input-source.c 
b/gnome-flashback/libinput-sources/gf-input-source.c
index c3d6de3..06e1656 100644
--- a/gnome-flashback/libinput-sources/gf-input-source.c
+++ b/gnome-flashback/libinput-sources/gf-input-source.c
@@ -67,7 +67,7 @@ enum
 
 static GParamSpec *properties[LAST_PROP] = { NULL };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GfInputSource, gf_input_source, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GfInputSource, gf_input_source, G_TYPE_OBJECT)
 
 static gchar *
 get_xkb_id (GfInputSource *source)
@@ -293,24 +293,6 @@ gf_input_source_init (GfInputSource *source)
 {
 }
 
-GfInputSource *
-gf_input_source_new (GfIBusManager *ibus_manager,
-                     const gchar   *type,
-                     const gchar   *id,
-                     const gchar   *display_name,
-                     const gchar   *short_name,
-                     guint          index)
-{
-  return g_object_new (GF_TYPE_INPUT_SOURCE,
-                       "ibus-manager", ibus_manager,
-                       "type", type,
-                       "id", id,
-                       "display-name", display_name,
-                       "short-name", short_name,
-                       "index", index,
-                       NULL);
-}
-
 const gchar *
 gf_input_source_get_source_type (GfInputSource *source)
 {
diff --git a/gnome-flashback/libinput-sources/gf-input-source.h 
b/gnome-flashback/libinput-sources/gf-input-source.h
index 75ac12f..a31f749 100644
--- a/gnome-flashback/libinput-sources/gf-input-source.h
+++ b/gnome-flashback/libinput-sources/gf-input-source.h
@@ -22,8 +22,6 @@
 #include <glib-object.h>
 #include <ibus-1.0/ibus.h>
 
-#include "gf-ibus-manager.h"
-
 G_BEGIN_DECLS
 
 #define GF_TYPE_INPUT_SOURCE gf_input_source_get_type ()
@@ -35,13 +33,6 @@ struct _GfInputSourceClass
   GObjectClass parent_class;
 };
 
-GfInputSource *gf_input_source_new              (GfIBusManager *ibus_manager,
-                                                 const gchar   *type,
-                                                 const gchar   *id,
-                                                 const gchar   *display_name,
-                                                 const gchar   *short_name,
-                                                 guint          index);
-
 const gchar   *gf_input_source_get_source_type  (GfInputSource *source);
 
 const gchar   *gf_input_source_get_id           (GfInputSource *source);


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