[gnome-flashback] input-sources: add function to get input sources
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] input-sources: add function to get input sources
- Date: Thu, 15 Oct 2015 03:53:21 +0000 (UTC)
commit e831edd6e0c7f73474facd42751a889dc60dc84f
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Oct 15 05:31:39 2015 +0300
input-sources: add function to get input sources
.../libinput-sources/gf-input-source-manager.c | 31 +++++++++++++++++++-
.../libinput-sources/gf-input-source-manager.h | 2 +
2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index 0f1d122..d94049c 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -100,6 +100,24 @@ static GParamSpec *properties[LAST_PROP] = { NULL };
G_DEFINE_TYPE (GfInputSourceManager, gf_input_source_manager, G_TYPE_OBJECT)
+static gint
+compare_sources_by_index (gconstpointer a,
+ gconstpointer b)
+{
+ GfInputSource *source1;
+ GfInputSource *source2;
+ guint index1;
+ guint index2;
+
+ source1 = (GfInputSource *) a;
+ source2 = (GfInputSource *) b;
+
+ index1 = gf_input_source_get_index (source1);
+ index2 = gf_input_source_get_index (source2);
+
+ return index1 - index2;
+}
+
static gchar *
get_symbol_from_char_code (gunichar code)
{
@@ -690,7 +708,7 @@ update_mru_sources_list (GfInputSourceManager *manager)
}
sources = g_hash_table_get_values (manager->input_sources);
- sources = g_list_reverse (sources);
+ sources = g_list_sort (sources, compare_sources_by_index);
mru_sources = NULL;
for (l1 = manager->mru_sources; l1 != NULL; l1 = g_list_next (l1))
@@ -1114,3 +1132,14 @@ gf_input_source_manager_get_current_source (GfInputSourceManager *manager)
{
return manager->current_source;
}
+
+GList *
+gf_input_source_manager_get_input_sources (GfInputSourceManager *manager)
+{
+ GList *sources;
+
+ sources = g_hash_table_get_values (manager->input_sources);
+ sources = g_list_sort (sources, compare_sources_by_index);
+
+ return sources;
+}
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.h
b/gnome-flashback/libinput-sources/gf-input-source-manager.h
index 67e87ae..af402f8 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.h
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.h
@@ -32,4 +32,6 @@ void gf_input_source_manager_reload (GfInputSourceM
GfInputSource *gf_input_source_manager_get_current_source (GfInputSourceManager *manager);
+GList *gf_input_source_manager_get_input_sources (GfInputSourceManager *manager);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]