diff options
Diffstat (limited to 'src/language-editor.c')
-rw-r--r-- | src/language-editor.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/language-editor.c b/src/language-editor.c index 28d09515f..b864bc75c 100644 --- a/src/language-editor.c +++ b/src/language-editor.c @@ -33,6 +33,7 @@ #include <gtk/gtkliststore.h> #include <gtk/gtkcellrenderertext.h> #include <glib/gi18n.h> +#include <string.h> enum { @@ -361,6 +362,28 @@ language_editor_add (LanguageEditor *editor, { GtkTreeIter iter; + g_return_if_fail (code != NULL && desc != NULL); + + /* first check that the code isn't already in the list */ + if (gtk_tree_model_get_iter_first (editor->priv->model, &iter)) + { + do + { + char *c; + + gtk_tree_model_get (editor->priv->model, &iter, + COL_DATA, &c, + -1); + + if (c && strcmp (code, c) == 0) + { + /* already in list, no need to add again */ + return; + } + } + while (gtk_tree_model_iter_next (editor->priv->model, &iter)); + } + gtk_list_store_append (GTK_LIST_STORE (editor->priv->model), &iter); gtk_list_store_set (GTK_LIST_STORE (editor->priv->model), &iter, |