[gnome-control-center] region: Never hide items from view
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] region: Never hide items from view
- Date: Mon, 16 Jul 2012 14:17:39 +0000 (UTC)
commit 03f08fd36c059c17f3af723ca29e0ad931fc6a26
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jul 16 15:15:28 2012 +0100
region: Never hide items from view
If IBus is unavailable to get the input source's display name,
just show the ID instead, and populate the display name when we get
a change (eg. when fetching the input sources from IBus is done).
panels/region/gnome-region-panel-input.c | 70 ++++++------------------------
1 files changed, 13 insertions(+), 57 deletions(-)
---
diff --git a/panels/region/gnome-region-panel-input.c b/panels/region/gnome-region-panel-input.c
index 3c588ca..8520e96 100644
--- a/panels/region/gnome-region-panel-input.c
+++ b/panels/region/gnome-region-panel-input.c
@@ -77,7 +77,6 @@ static GtkWidget *input_chooser_new (GtkWindow *main_window,
static gboolean input_chooser_get_selected (GtkWidget *chooser,
GtkTreeModel **model,
GtkTreeIter *iter);
-static GtkTreeModel *tree_view_get_actual_model (GtkTreeView *tv);
#ifdef HAVE_IBUS
static void
@@ -142,22 +141,17 @@ update_ibus_active_sources (GtkBuilder *builder)
if (g_str_equal (type, INPUT_SOURCE_TYPE_IBUS))
{
IBusEngineDesc *engine_desc = NULL;
- GDesktopAppInfo *app_info = NULL;
gchar *display_name = NULL;
engine_desc = g_hash_table_lookup (ibus_engines, id);
if (engine_desc)
{
display_name = engine_get_display_name (engine_desc);
- app_info = setup_app_info_for_id (id);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
NAME_COLUMN, display_name,
- SETUP_COLUMN, app_info,
-1);
g_free (display_name);
- if (app_info)
- g_object_unref (app_info);
}
}
@@ -343,10 +337,9 @@ populate_with_active_sources (GtkListStore *store)
engine_desc = g_hash_table_lookup (ibus_engines, id);
if (engine_desc)
- {
- display_name = engine_get_display_name (engine_desc);
- app_info = setup_app_info_for_id (id);
- }
+ display_name = engine_get_display_name (engine_desc);
+
+ app_info = setup_app_info_for_id (id);
#else
g_warning ("IBus input source type specified but IBus support was not compiled");
continue;
@@ -360,7 +353,7 @@ populate_with_active_sources (GtkListStore *store)
gtk_list_store_append (store, &tree_iter);
gtk_list_store_set (store, &tree_iter,
- NAME_COLUMN, display_name,
+ NAME_COLUMN, display_name ? display_name : id,
TYPE_COLUMN, type,
ID_COLUMN, id,
SETUP_COLUMN, app_info,
@@ -487,16 +480,6 @@ set_selected_path (GtkBuilder *builder,
gtk_tree_selection_select_path (selection, path);
}
-static GtkTreeModel *
-tree_view_get_actual_model (GtkTreeView *tv)
-{
- GtkTreeModel *filtered_store;
-
- filtered_store = gtk_tree_view_get_model (tv);
-
- return gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filtered_store));
-}
-
static void
chooser_response (GtkWidget *chooser, gint response_id, gpointer data)
{
@@ -510,7 +493,7 @@ chooser_response (GtkWidget *chooser, gint response_id, gpointer data)
if (input_chooser_get_selected (chooser, &model, &iter))
{
GtkTreeView *tv;
- GtkListStore *child_model;
+ GtkListStore *my_model;
GtkTreeIter child_iter, filter_iter;
gchar *name;
gchar *type;
@@ -529,11 +512,11 @@ chooser_response (GtkWidget *chooser, gint response_id, gpointer data)
#endif
tv = GTK_TREE_VIEW (WID ("active_input_sources"));
- child_model = GTK_LIST_STORE (tree_view_get_actual_model (tv));
+ my_model = GTK_LIST_STORE (gtk_tree_view_get_model (tv));
- gtk_list_store_append (child_model, &child_iter);
+ gtk_list_store_append (my_model, &child_iter);
- gtk_list_store_set (child_model, &child_iter,
+ gtk_list_store_set (my_model, &child_iter,
NAME_COLUMN, name,
TYPE_COLUMN, type,
ID_COLUMN, id,
@@ -551,7 +534,7 @@ chooser_response (GtkWidget *chooser, gint response_id, gpointer data)
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (tv), &filter_iter);
update_button_sensitivity (builder);
- update_configuration (GTK_TREE_MODEL (child_model));
+ update_configuration (GTK_TREE_MODEL (my_model));
}
else
{
@@ -575,7 +558,7 @@ add_input (GtkButton *button, gpointer data)
toplevel = gtk_widget_get_toplevel (WID ("region_notebook"));
treeview = WID ("active_input_sources");
- active_sources = GTK_LIST_STORE (tree_view_get_actual_model (GTK_TREE_VIEW (treeview)));
+ active_sources = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
chooser = input_chooser_new (GTK_WINDOW (toplevel), active_sources);
g_signal_connect (chooser, "response",
@@ -826,7 +809,7 @@ input_sources_changed (GSettings *settings,
GtkTreeModel *store;
treeview = WID("active_input_sources");
- store = tree_view_get_actual_model (GTK_TREE_VIEW (treeview));
+ store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
gtk_list_store_clear (GTK_LIST_STORE (store));
populate_with_active_sources (GTK_LIST_STORE (store));
}
@@ -876,23 +859,6 @@ update_shortcuts (GtkBuilder *builder)
g_free (next);
}
-static gboolean
-active_sources_visible_func (GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer data)
-{
- gchar *display_name;
-
- gtk_tree_model_get (model, iter, NAME_COLUMN, &display_name, -1);
-
- if (!display_name)
- return FALSE;
-
- g_free (display_name);
-
- return TRUE;
-}
-
void
setup_input_tabs (GtkBuilder *builder,
CcRegionPanel *panel)
@@ -901,7 +867,6 @@ setup_input_tabs (GtkBuilder *builder,
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
GtkListStore *store;
- GtkTreeModel *filtered_store;
GtkTreeSelection *selection;
input_sources_settings = g_settings_new (GNOME_DESKTOP_INPUT_SOURCES_DIR);
@@ -927,7 +892,7 @@ setup_input_tabs (GtkBuilder *builder,
gtk_tree_view_column_add_attribute (column, cell, "text", NAME_COLUMN);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- store = gtk_list_store_new (4,
+ store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
@@ -939,16 +904,7 @@ setup_input_tabs (GtkBuilder *builder,
g_signal_connect_swapped (selection, "changed",
G_CALLBACK (update_button_sensitivity), builder);
- /* Some input source types might have their info loaded
- * asynchronously. In that case we don't want to show them
- * immediately so we use a filter model on top of the real model
- * which mirrors the GSettings key. */
- filtered_store = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filtered_store),
- active_sources_visible_func,
- NULL,
- NULL);
- gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), filtered_store);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
/* set up the buttons */
g_signal_connect (WID("input_source_add"), "clicked",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]