[gnome-control-center] region: Don't add duplicate input sources



commit 00da5a115f6ea4c527f33c381e48c325386815c5
Author: Rui Matos <tiagomatos gmail com>
Date:   Thu Feb 14 00:24:06 2013 +0100

    region: Don't add duplicate input sources

 panels/region/cc-region-panel.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index ca36742..628cd46 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -884,6 +884,25 @@ apologize_for_no_ibus_login (CcRegionPanel *self)
         gtk_widget_destroy (dialog);
 }
 
+static gboolean
+input_source_already_added (CcRegionPanel *self,
+                            const gchar   *id)
+{
+        CcRegionPanelPrivate *priv = self->priv;
+        GList *list, *l;
+        gboolean retval = FALSE;
+
+        list = gtk_container_get_children (GTK_CONTAINER (priv->input_list));
+        for (l = list; l; l = l->next)
+                if (g_str_equal (id, (const gchar *) g_object_get_data (G_OBJECT (l->data), "id"))) {
+                        retval = TRUE;
+                        break;
+                }
+        g_list_free (list);
+
+        return retval;
+}
+
 static void
 input_response (GtkWidget *chooser, gint response_id, gpointer data)
 {
@@ -895,7 +914,8 @@ input_response (GtkWidget *chooser, gint response_id, gpointer data)
         GDesktopAppInfo *app_info = NULL;
 
         if (response_id == GTK_RESPONSE_OK) {
-                if (cc_input_chooser_get_selected (chooser, &type, &id, &name)) {
+                if (cc_input_chooser_get_selected (chooser, &type, &id, &name) &&
+                    !input_source_already_added (self, id)) {
 
                         gtk_widget_destroy (chooser);
 


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