From: Ben Pfaff Date: Thu, 5 Sep 2013 04:42:59 +0000 (-0700) Subject: psppire-var-sheet: Add icons for role column too. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fbuilds%2F20130905030502%2Fpspp;p=pspp psppire-var-sheet: Add icons for role column too. Some of the changes here reflect the way that all three combo box columns now include a pixbuf, allowing greater code reuse. Artwork contributed by Bastian Diaz. --- diff --git a/Smake b/Smake index a664d91aeb..306e115e42 100644 --- a/Smake +++ b/Smake @@ -152,7 +152,13 @@ src/ui/gui/icons/categories/16x16/variable-ordinal.png \ src/ui/gui/icons/categories/16x16/align-right.png \ src/ui/gui/icons/categories/16x16/variable-date-nominal.png \ src/ui/gui/icons/categories/16x16/variable-date-ordinal.png \ -src/ui/gui/icons/categories/16x16/variable-string-scale.png +src/ui/gui/icons/categories/16x16/variable-string-scale.png \ +src/ui/gui/icons/categories/16x16/variable-role-partition.png \ +src/ui/gui/icons/categories/16x16/variable-role-target.png \ +src/ui/gui/icons/categories/16x16/variable-role-split.png \ +src/ui/gui/icons/categories/16x16/variable-role-input.png \ +src/ui/gui/icons/categories/16x16/variable-role-none.png \ +src/ui/gui/icons/categories/16x16/variable-role-both.png MIMETYPE_ICONS = \ src/ui/gui/icons/mimetypes/32x32/application-x-spss-por.png \ diff --git a/src/ui/gui/artwork/categories/16x16/variable-role-both.svg b/src/ui/gui/artwork/categories/16x16/variable-role-both.svg new file mode 100644 index 0000000000..2e1791f1cb --- /dev/null +++ b/src/ui/gui/artwork/categories/16x16/variable-role-both.svg @@ -0,0 +1,114 @@ + + + + + role icons + + + + + + image/svg+xml + + role icons + + + Bastián Díaz + + + Iconos symbólicos para GNU PSPP, basados en los iconos del proyecto GNOME + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/gui/artwork/categories/16x16/variable-role-input.svg b/src/ui/gui/artwork/categories/16x16/variable-role-input.svg new file mode 100644 index 0000000000..dda324452f --- /dev/null +++ b/src/ui/gui/artwork/categories/16x16/variable-role-input.svg @@ -0,0 +1,111 @@ + + + + + role icons + + + + + + image/svg+xml + + role icons + + + Bastián Díaz + + + Iconos symbólicos para GNU PSPP, basados en los iconos del proyecto GNOME + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/gui/artwork/categories/16x16/variable-role-none.svg b/src/ui/gui/artwork/categories/16x16/variable-role-none.svg new file mode 100644 index 0000000000..811455f960 --- /dev/null +++ b/src/ui/gui/artwork/categories/16x16/variable-role-none.svg @@ -0,0 +1,109 @@ + + + + + role icons + + + + + + image/svg+xml + + role icons + + + Bastián Díaz + + + Iconos symbólicos para GNU PSPP, basados en los iconos del proyecto GNOME + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/gui/artwork/categories/16x16/variable-role-partition.svg b/src/ui/gui/artwork/categories/16x16/variable-role-partition.svg new file mode 100644 index 0000000000..e1473290ff --- /dev/null +++ b/src/ui/gui/artwork/categories/16x16/variable-role-partition.svg @@ -0,0 +1,120 @@ + + + + + role icons + + + + + + image/svg+xml + + role icons + + + Bastián Díaz + + + Iconos symbólicos para GNU PSPP, basados en los iconos del proyecto GNOME + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/gui/artwork/categories/16x16/variable-role-split.svg b/src/ui/gui/artwork/categories/16x16/variable-role-split.svg new file mode 100644 index 0000000000..41623fe8e1 --- /dev/null +++ b/src/ui/gui/artwork/categories/16x16/variable-role-split.svg @@ -0,0 +1,122 @@ + + + + + role icons + + + + + + + + image/svg+xml + + role icons + + + Bastián Díaz + + + Iconos symbólicos para GNU PSPP, basados en los iconos del proyecto GNOME + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/gui/artwork/categories/16x16/variable-role-target.svg b/src/ui/gui/artwork/categories/16x16/variable-role-target.svg new file mode 100644 index 0000000000..9c3e67df79 --- /dev/null +++ b/src/ui/gui/artwork/categories/16x16/variable-role-target.svg @@ -0,0 +1,119 @@ + + + + + role icons + + + + + + image/svg+xml + + role icons + + + Bastián Díaz + + + Iconos symbólicos para GNU PSPP, basados en los iconos del proyecto GNOME + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index e0f104db14..02e880db36 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -335,6 +335,22 @@ get_var_align_stock_id (enum alignment alignment) } } +const char * +get_var_role_stock_id (enum var_role role) +{ + switch (role) + { + case ROLE_INPUT: return "variable-role-input"; + case ROLE_OUTPUT: return "variable-role-target"; + case ROLE_BOTH: return "variable-role-both"; + case ROLE_NONE: return "variable-role-none"; + case ROLE_PARTITION: return "variable-role-partition"; + case ROLE_SPLIT: return "variable-role-split"; + default: + g_return_val_if_reached (""); + } +} + static void render_var_cell (PsppSheetViewColumn *tree_column, GtkCellRenderer *cell, @@ -483,10 +499,14 @@ render_var_cell (PsppSheetViewColumn *tree_column, break; case VS_ROLE: - g_object_set (cell, - "text", var_role_to_string (var_get_role (var)), - "editable", TRUE, - NULL); + if (GTK_IS_CELL_RENDERER_TEXT (cell)) + g_object_set (cell, + "text", var_role_to_string (var_get_role (var)), + "editable", TRUE, + NULL); + else + g_object_set (cell, "stock-id", + get_var_role_stock_id (var_get_role (var)), NULL); break; } } @@ -657,12 +677,18 @@ alignment_to_stock_id (enum fmt_type type, int alignment) return get_var_align_stock_id (alignment); } +static const char * +role_to_stock_id (enum fmt_type type, int role) +{ + return get_var_role_stock_id (role); +} + static void -render_measure (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) +render_var_pixbuf (GtkCellLayout *cell_layout, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) { const char *(*value_to_stock_id) (enum fmt_type, int value); enum fmt_type type = GPOINTER_TO_INT (data); @@ -698,18 +724,19 @@ on_combo_editing_started (GtkCellRenderer *renderer, "value-to-stock-id", value_to_stock_id); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (editable), cell, FALSE); gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (editable), cell, - render_measure, + render_var_pixbuf, GINT_TO_POINTER (format->type), NULL); } } -static PsppSheetViewColumn * +static void add_combo_column (PsppireVarSheet *var_sheet, enum vs_column column_id, const char *title, int width, const char *(*value_to_stock_id) (enum fmt_type, int value), ...) { + PsppSheetViewColumn *column; GtkCellRenderer *cell; GtkListStore *store; const char *name; @@ -742,7 +769,13 @@ add_combo_column (PsppireVarSheet *var_sheet, enum vs_column column_id, var_sheet); } - return add_var_sheet_column (var_sheet, cell, column_id, title, width); + column = add_var_sheet_column (var_sheet, cell, column_id, title, width); + + cell = gtk_cell_renderer_pixbuf_new (); + g_object_set (cell, "width", 16, "height", 16, NULL); + pspp_sheet_view_column_pack_end (column, cell, FALSE); + pspp_sheet_view_column_set_cell_data_func ( + column, cell, render_var_cell, var_sheet, NULL); } static void @@ -1315,7 +1348,6 @@ psppire_var_sheet_init (PsppireVarSheet *obj) { PsppSheetView *sheet_view = PSPP_SHEET_VIEW (obj); PsppSheetViewColumn *column; - GtkCellRenderer *cell; GtkAction *action; GList *list; @@ -1355,31 +1387,19 @@ psppire_var_sheet_init (PsppireVarSheet *obj) add_spin_column (obj, VS_COLUMNS, _("Columns"), 3); - column - = add_combo_column (obj, VS_ALIGN, _("Align"), 8, alignment_to_stock_id, - alignment_to_string (ALIGN_LEFT), ALIGN_LEFT, - alignment_to_string (ALIGN_CENTRE), ALIGN_CENTRE, - alignment_to_string (ALIGN_RIGHT), ALIGN_RIGHT, - NULL); - cell = gtk_cell_renderer_pixbuf_new (); - g_object_set (cell, "width", 16, "height", 16, NULL); - pspp_sheet_view_column_pack_end (column, cell, FALSE); - pspp_sheet_view_column_set_cell_data_func ( - column, cell, render_var_cell, obj, NULL); + add_combo_column (obj, VS_ALIGN, _("Align"), 8, alignment_to_stock_id, + alignment_to_string (ALIGN_LEFT), ALIGN_LEFT, + alignment_to_string (ALIGN_CENTRE), ALIGN_CENTRE, + alignment_to_string (ALIGN_RIGHT), ALIGN_RIGHT, + NULL); - column - = add_combo_column (obj, VS_MEASURE, _("Measure"), 12, measure_to_stock_id, - measure_to_string (MEASURE_NOMINAL), MEASURE_NOMINAL, - measure_to_string (MEASURE_ORDINAL), MEASURE_ORDINAL, - measure_to_string (MEASURE_SCALE), MEASURE_SCALE, - NULL); - cell = gtk_cell_renderer_pixbuf_new (); - g_object_set (cell, "width", 16, "height", 16, NULL); - pspp_sheet_view_column_pack_end (column, cell, FALSE); - pspp_sheet_view_column_set_cell_data_func ( - column, cell, render_var_cell, obj, NULL); + add_combo_column (obj, VS_MEASURE, _("Measure"), 12, measure_to_stock_id, + measure_to_string (MEASURE_NOMINAL), MEASURE_NOMINAL, + measure_to_string (MEASURE_ORDINAL), MEASURE_ORDINAL, + measure_to_string (MEASURE_SCALE), MEASURE_SCALE, + NULL); - add_combo_column (obj, VS_ROLE, _("Role"), 12, NULL, + add_combo_column (obj, VS_ROLE, _("Role"), 12, role_to_stock_id, var_role_to_string (ROLE_INPUT), ROLE_INPUT, var_role_to_string (ROLE_OUTPUT), ROLE_OUTPUT, var_role_to_string (ROLE_BOTH), ROLE_BOTH,