[gtk+/wip/combo: 11/11] Some more fixes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/combo: 11/11] Some more fixes
- Date: Fri, 26 Dec 2014 05:21:22 +0000 (UTC)
commit 5c9bd73125e3570c76ddebcf99a1d97024ee241f
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Dec 26 00:19:17 2014 -0500
Some more fixes
gtk/gtkcombo.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c
index 684a31d..cec099a 100644
--- a/gtk/gtkcombo.c
+++ b/gtk/gtkcombo.c
@@ -229,13 +229,13 @@ gtk_combo_row_class_init (GtkComboRowClass *class)
static GtkWidget *
gtk_combo_row_new (const gchar *id,
- const gchar *sort,
- const gchar *text)
+ const gchar *text,
+ const gchar *sort)
{
return g_object_new (GTK_TYPE_COMBO_ROW,
"id", id,
- "sort", sort,
"text", text,
+ "sort", sort,
NULL);
}
@@ -268,7 +268,7 @@ gtk_combo_row_get_id (GtkComboRow *row)
static const gchar *
gtk_combo_row_get_text (GtkComboRow *row)
{
- return row->text ? row->text : row->id;
+ return row->text;
}
static const gchar *
@@ -527,6 +527,7 @@ typedef struct {
const gchar *domain;
gchar *id;
gchar *sort;
+ gchar *group;
GString *string;
@@ -570,6 +571,8 @@ item_start_element (GMarkupParseContext *context,
data->id = g_strdup (values[i]);
else if (strcmp (names[i], "sort") == 0)
data->sort = g_strdup (values[i]);
+ else if (strcmp (names[i], "group") == 0)
+ data->group = g_strdup (values[i]);
else
g_warning ("Unknown custom combo item attribute: %s", names[i]);
}
@@ -609,7 +612,7 @@ item_end_element (GMarkupParseContext *context,
g_string_assign (data->string, translated);
}
- gtk_combo_add_item (GTK_COMBO (data->object), data->id, data->string->str, data->sort, NULL);
+ gtk_combo_add_item (GTK_COMBO (data->object), data->id, data->string->str, data->sort, data->group);
}
data->translatable = FALSE;
@@ -618,6 +621,10 @@ item_end_element (GMarkupParseContext *context,
data->context = NULL;
g_free (data->id);
data->id = NULL;
+ g_free (data->sort);
+ data->sort = NULL;
+ g_free (data->group);
+ data->group = NULL;
data->is_text = FALSE;
}
@@ -916,20 +923,23 @@ add_to_list (GtkWidget *list,
GtkWidget *row;
ForeachData data;
+ if (text == NULL)
+ text = id;
+
data.id = id;
data.row = NULL;
gtk_container_foreach (GTK_CONTAINER (list), find_row, &data);
if (data.row)
{
- gtk_combo_row_set_sort (GTK_COMBO_ROW (data.row), sort);
gtk_combo_row_set_text (GTK_COMBO_ROW (data.row), text);
+ gtk_combo_row_set_sort (GTK_COMBO_ROW (data.row), sort);
gtk_list_box_invalidate_sort (GTK_LIST_BOX (list));
gtk_list_box_invalidate_filter (GTK_LIST_BOX (list));
}
else
{
- row = gtk_combo_row_new (id, sort, text);
+ row = gtk_combo_row_new (id, text, sort);
gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]