diff options
author | Michael Terry <mike@mterry.name> | 2011-02-23 15:13:11 -0600 |
---|---|---|
committer | Michael Terry <mike@mterry.name> | 2011-02-23 15:13:11 -0600 |
commit | e2fa62d9ad271f26f2a8e4d9297190e0250bb967 (patch) | |
tree | 2e09a5400523bc91d95f4d985e8f1afcea763d93 /src | |
parent | d38ff688556788a5d6c8e3f033b460c8ac849039 (diff) | |
download | ayatana-indicator-datetime-e2fa62d9ad271f26f2a8e4d9297190e0250bb967.tar.gz ayatana-indicator-datetime-e2fa62d9ad271f26f2a8e4d9297190e0250bb967.tar.bz2 ayatana-indicator-datetime-e2fa62d9ad271f26f2a8e4d9297190e0250bb967.zip |
show admin1 and country in completion dropdown
Diffstat (limited to 'src')
-rw-r--r-- | src/timezone-completion.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/timezone-completion.c b/src/timezone-completion.c index 7f5ad68..ab7ae5e 100644 --- a/src/timezone-completion.c +++ b/src/timezone-completion.c @@ -299,6 +299,35 @@ get_initial_model (void) } static void +data_func (GtkCellLayout *cell_layout, GtkCellRenderer *cell, + GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer user_data) +{ + GValue name_val = {0}, admin1_val = {0}, country_val = {0}; + const gchar * name, * admin1, * country; + + gtk_tree_model_get_value (GTK_TREE_MODEL (tree_model), iter, TIMEZONE_COMPLETION_NAME, &name_val); + gtk_tree_model_get_value (GTK_TREE_MODEL (tree_model), iter, TIMEZONE_COMPLETION_ADMIN1, &admin1_val); + gtk_tree_model_get_value (GTK_TREE_MODEL (tree_model), iter, TIMEZONE_COMPLETION_COUNTRY, &country_val); + + name = g_value_get_string (&name_val); + admin1 = g_value_get_string (&admin1_val); + country = g_value_get_string (&country_val); + + gchar * user_name; + if (admin1 == NULL || admin1[0] == 0) { + user_name = g_strdup_printf ("%s <small>(%s)</small>", name, country); + } else { + user_name = g_strdup_printf ("%s <small>(%s, %s)</small>", name, admin1, country); + } + + g_object_set (G_OBJECT (cell), "markup", user_name, NULL); + + g_value_unset (&name_val); + g_value_unset (&admin1_val); + g_value_unset (&country_val); +} + +static void timezone_completion_class_init (TimezoneCompletionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -318,12 +347,16 @@ timezone_completion_init (TimezoneCompletion * self) GtkListStore * model = get_initial_model (); gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (self), GTK_TREE_MODEL (model)); - gtk_entry_completion_set_text_column (GTK_ENTRY_COMPLETION (self), TIMEZONE_COMPLETION_NAME); + g_object_set (G_OBJECT (self), "text-column", TIMEZONE_COMPLETION_NAME, NULL); priv->cancel = g_cancellable_new (); priv->request_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + GtkCellRenderer * cell = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), cell, TRUE); + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (self), cell, data_func, NULL, NULL); + return; } |