[gnome-initial-setup] language: Add a filter entry
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] language: Add a filter entry
- Date: Thu, 26 Jul 2012 06:40:51 +0000 (UTC)
commit 1dc5d281068cf45d7f52470566fc563a62ce4dcb
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Jul 23 22:00:21 2012 -0300
language: Add a filter entry
This filters the languages in the tree view by an entry. It doesn't
completely implement the design, as it's shown side-by-side to the
"Show All" checkbox, rather than replacing it.
HOLY FUCK THIS AIRPLANE TURBULANCE IS BAD
.../pages/language/gis-language-page.c | 33 +++++++++++++++++---
.../pages/language/gis-language-page.ui | 24 ++++++++++++--
2 files changed, 48 insertions(+), 9 deletions(-)
---
diff --git a/gnome-initial-setup/pages/language/gis-language-page.c b/gnome-initial-setup/pages/language/gis-language-page.c
index 4de027a..c3a4bb7 100644
--- a/gnome-initial-setup/pages/language/gis-language-page.c
+++ b/gnome-initial-setup/pages/language/gis-language-page.c
@@ -24,6 +24,7 @@ struct _LanguageData {
GtkWidget *show_all;
GtkWidget *page;
+ GtkWidget *filter_entry;
GtkTreeModel *liststore;
gchar *locale_id;
};
@@ -183,17 +184,33 @@ language_visible (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
{
+ gchar *locale_name;
+ const gchar *filter_contents;
LanguageData *data = user_data;
+ gboolean visible = TRUE;
gboolean is_extra;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->show_all)))
- return TRUE;
-
gtk_tree_model_get (model, iter,
+ COL_LOCALE_NAME, &locale_name,
COL_IS_EXTRA, &is_extra,
-1);
- return is_extra;
+ filter_contents = gtk_entry_get_text (GTK_ENTRY (data->filter_entry));
+ if (*filter_contents && strcasestr (locale_name, filter_contents) == NULL)
+ {
+ visible = FALSE;
+ goto out;
+ }
+
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->show_all)) && !is_extra)
+ {
+ visible = FALSE;
+ goto out;
+ }
+
+ out:
+ g_free (locale_name);
+ return visible;
}
static void
@@ -204,7 +221,8 @@ selection_changed (GtkTreeSelection *selection,
GtkTreeIter iter;
gchar *new_locale_id;
- gtk_tree_selection_get_selected (selection, &model, &iter);
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
g_free (data->locale_id);
@@ -237,6 +255,7 @@ gis_prepare_language_page (SetupData *setup)
data->locale_id = cc_common_language_get_current_language ();
data->page = WID ("language-page");
data->show_all = WID ("language-show-all");
+ data->filter_entry = WID ("language-filter-entry");
data->liststore = GTK_TREE_MODEL (liststore);
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (liststore),
sort_languages, NULL, NULL);
@@ -257,6 +276,10 @@ gis_prepare_language_page (SetupData *setup)
G_CALLBACK (gtk_tree_model_filter_refilter),
filter);
+ g_signal_connect_swapped (data->filter_entry, "changed",
+ G_CALLBACK (gtk_tree_model_filter_refilter),
+ filter);
+
g_signal_connect (gtk_tree_view_get_selection (treeview), "changed",
G_CALLBACK (selection_changed), data);
diff --git a/gnome-initial-setup/pages/language/gis-language-page.ui b/gnome-initial-setup/pages/language/gis-language-page.ui
index 0fe48d0..66516fd 100644
--- a/gnome-initial-setup/pages/language/gis-language-page.ui
+++ b/gnome-initial-setup/pages/language/gis-language-page.ui
@@ -5,6 +5,7 @@
<property name="name">language-page</property>
<property name="visible">True</property>
<property name="orientation">vertical</property>
+ <property name="spacing">10</property>
<child>
<object class="GtkScrolledWindow" id="language-scrolledwindow">
<property name="visible">True</property>
@@ -38,11 +39,26 @@
</object>
</child>
<child>
- <object class="GtkCheckButton" id="language-show-all">
+ <object class="GtkBox" id="hbox">
<property name="visible">True</property>
- <property name="label" translatable="yes">Show _all</property>
- <property name="use_underline">True</property>
- <property name="halign">fill</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkCheckButton" id="language-show-all">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Show _all</property>
+ <property name="use_underline">True</property>
+ <property name="halign">fill</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="language-filter-entry">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="secondary-icon-name">edit-find-symbolic</property>
+ <property name="secondary-icon-activatable">False</property>
+ <property name="secondary-icon-sensitive">False</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]