diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | gladeui/glade-displayable-values.c | 20 | ||||
-rw-r--r-- | gladeui/glade-inspector.c | 26 | ||||
-rw-r--r-- | plugins/gtk+/glade-cell-renderer-button.c | 30 | ||||
-rw-r--r-- | plugins/gtk+/glade-column-types.c | 175 | ||||
-rw-r--r-- | plugins/gtk+/glade-model-data.c | 132 | ||||
-rw-r--r-- | plugins/gtk+/gtk+.xml.in | 85 |
7 files changed, 363 insertions, 121 deletions
@@ -1,6 +1,18 @@ +2008-12-13 Tristan Van Berkom <tvb@gnome.org> + + * gladeui/glade-inspector.c: Removed old search code. + + * plugins/gtk+/gtk+.xml.in: Added missing displayable values. + + * plugins/gtk+/glade-column-types.c: Fixed crashers on empty input, keep focus on + current cell when editing is canceled. + + * plugins/gtk+/glade-model-data.c: keep focus on current cell when editing is canceled. + 2008-12-10 Tristan Van Berkom <tvb@gnome.org> - * gladeui/glade-name-context.[ch], gladeui/glade-editable.[ch]: Relicensed LGPL. + * gladeui/glade-name-context.[ch], gladeui/glade-editable.[ch], + gladeui/glade-displayable-values.c: Relicensed LGPL. * plugins/gtk+/glade-image-editor.c, plugins/gtk+/glade-image-item-editor.c, plugins/gtk+/glade-button-editor.c, plugins/gtk+/glade-label-editor.c, @@ -11,7 +23,7 @@ * gladeui/glade-widget-adaptor.c: Fixed regression, now disabled classes are not reinstalled in subclasses. - + 2008-12-09 Tristan Van Berkom <tvb@gnome.org> * NEWS, configure.ac: Rolling 3.5.3 diff --git a/gladeui/glade-displayable-values.c b/gladeui/glade-displayable-values.c index 7e77bfeb..35db8a5a 100644 --- a/gladeui/glade-displayable-values.c +++ b/gladeui/glade-displayable-values.c @@ -7,18 +7,18 @@ * Authors: * Tristan Van Berkom <tvb@gnome.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ diff --git a/gladeui/glade-inspector.c b/gladeui/glade-inspector.c index 2722352a..1630ebb3 100644 --- a/gladeui/glade-inspector.c +++ b/gladeui/glade-inspector.c @@ -1008,25 +1008,6 @@ glade_inspector_cell_function (GtkTreeViewColumn *tree_column, } } -static gboolean -glade_inspector_search_func (GtkTreeModel *model, - gint column, - const gchar *key, - GtkTreeIter *iter, - gpointer search_data) -{ - GladeWidget *widget; - - gtk_tree_model_get (model, iter, WIDGET_COLUMN, &widget, -1); - - if (!widget) - return TRUE; - - g_return_val_if_fail (widget->name != NULL, TRUE); - - return ! g_str_has_prefix (widget->name, key); -} - static void add_columns (GtkTreeView *view) { @@ -1062,12 +1043,7 @@ add_columns (GtkTreeView *view) GINT_TO_POINTER (CELL_MISC), NULL); gtk_tree_view_append_column (view, column); - - /* Set search column */ - gtk_tree_view_set_search_equal_func (view, glade_inspector_search_func, NULL, NULL); - gtk_tree_view_set_enable_search (view, TRUE); - gtk_tree_view_set_search_column (view, WIDGET_COLUMN); - + gtk_tree_view_set_headers_visible (view, FALSE); } diff --git a/plugins/gtk+/glade-cell-renderer-button.c b/plugins/gtk+/glade-cell-renderer-button.c index 765669e1..27968f45 100644 --- a/plugins/gtk+/glade-cell-renderer-button.c +++ b/plugins/gtk+/glade-cell-renderer-button.c @@ -219,6 +219,31 @@ glade_cell_renderer_button_activate (GtkCellEditable *entry, g_signal_emit_by_name (cell_text, "edited", path, new_text); } +static void +glade_cell_renderer_button_editing_done (GtkCellEditable *entry, + GtkCellRendererText *cell_text) +{ + const gchar *path; + const gchar *new_text; + GladeCellRendererButtonPrivate *priv; + + priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (cell_text); + + g_signal_handlers_disconnect_by_func (entry, glade_cell_renderer_button_focus_out_event, cell_text); + + gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell_text), + GTK_ENTRY (entry)->editing_canceled); + + if (GTK_ENTRY (entry)->editing_canceled) + return; + + path = g_object_get_data (G_OBJECT (entry), GLADE_CELL_RENDERER_BUTTON_PATH); + new_text = gtk_entry_get_text (GTK_ENTRY (entry)); + + g_signal_emit_by_name (cell_text, "edited", path, new_text); +} + + static GtkCellEditable * glade_cell_renderer_button_start_editing (GtkCellRenderer *cell, GdkEvent *event, @@ -260,6 +285,11 @@ glade_cell_renderer_button_start_editing (GtkCellRenderer *cell, G_CALLBACK (glade_cell_renderer_button_activate), cell); + g_signal_connect (text_button->entry, + "editing-done", + G_CALLBACK (glade_cell_renderer_button_editing_done), + cell); + g_signal_connect_after (text_button->entry, "focus-out-event", G_CALLBACK (glade_cell_renderer_button_focus_out_event), cell); diff --git a/plugins/gtk+/glade-column-types.c b/plugins/gtk+/glade-column-types.c index 18e00021..4ded5da4 100644 --- a/plugins/gtk+/glade-column-types.c +++ b/plugins/gtk+/glade-column-types.c @@ -63,7 +63,7 @@ lookup_type (const gchar *type_name) { GtkTreeIter iter; gchar *iter_type_name; - GType type = 0; + GType type = 0, iter_type; if (gtk_tree_model_get_iter_first (types_model, &iter)) { @@ -72,17 +72,19 @@ lookup_type (const gchar *type_name) iter_type_name = NULL; gtk_tree_model_get (types_model, &iter, COLUMN_NAME, &iter_type_name, - COLUMN_GTYPE, &type, + COLUMN_GTYPE, &iter_type, -1); g_assert (iter_type_name); if (strcmp (iter_type_name, type_name) == 0) { + type = iter_type; g_free (iter_type_name); break; } g_free (iter_type_name); + } while (gtk_tree_model_iter_next (types_model, &iter)); } @@ -90,18 +92,13 @@ lookup_type (const gchar *type_name) } static void -column_types_store_populate_enums_flags (GtkTreeStore *store, +column_types_store_populate_enums_flags (GtkListStore *store, gboolean enums) { - GtkTreeIter iter, parent_iter; + GtkTreeIter iter; GList *types = NULL, *list, *l; GList *adaptors = glade_widget_adaptor_list_adaptors (); - gtk_tree_store_append (store, &parent_iter, NULL); - gtk_tree_store_set (store, &parent_iter, - COLUMN_NAME, enums ? _("Enumerations") : _("Flags"), - -1); - for (list = adaptors; list; list = list->next) { GladeWidgetAdaptor *adaptor = list->data; @@ -141,8 +138,8 @@ column_types_store_populate_enums_flags (GtkTreeStore *store, { GType *type = l->data; - gtk_tree_store_append (store, &iter, &parent_iter); - gtk_tree_store_set (store, &iter, + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, COLUMN_NAME, g_type_name (*type), COLUMN_GTYPE, *type, -1); @@ -152,7 +149,7 @@ column_types_store_populate_enums_flags (GtkTreeStore *store, } static void -column_types_store_populate (GtkTreeStore *store) +column_types_store_populate (GtkListStore *store) { GtkTreeIter iter; gint i; @@ -175,8 +172,8 @@ column_types_store_populate (GtkTreeStore *store) for (i = 0; i < sizeof (types) / sizeof (GType); i++) { - gtk_tree_store_append (store, &iter, NULL); - gtk_tree_store_set (store, &iter, + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, COLUMN_NAME, g_type_name (types[i]), COLUMN_GTYPE, types[i], -1); @@ -267,6 +264,8 @@ typedef struct gboolean adding_column; gboolean want_focus; + gboolean setting_cursor; + GtkTreeViewColumn *name_column; GtkTreeViewColumn *type_column; } GladeEPropColumnTypes; @@ -512,7 +511,7 @@ static void eprop_column_add_new (GladeEPropColumnTypes *eprop_types) { gtk_list_store_insert_with_values (eprop_types->store, NULL, -1, - COLUMN_NAME, _("<type here to define a new column>"), + COLUMN_NAME, _("< define a new column >"), COLUMN_TYPE_EDITABLE, TRUE, COLUMN_NAME_EDITABLE, FALSE, COLUMN_TYPE_FOREGROUND, "Gray", @@ -538,7 +537,7 @@ eprop_column_load (GladeEPropColumnTypes *eprop_types, static void -eprop_types_focus_cell (GladeEPropColumnTypes *eprop_types, gboolean add_cell) +eprop_types_focus_cell (GladeEPropColumnTypes *eprop_types, gboolean use_path, gboolean add_cell, gboolean edit_cell) { /* Focus and edit the first column of a newly added row */ if (eprop_types->store) @@ -546,39 +545,54 @@ eprop_types_focus_cell (GladeEPropColumnTypes *eprop_types, gboolean add_cell) GtkTreePath *new_item_path; GtkTreeIter iter; gint n_children; + gint needed_row; n_children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (eprop_types->store), NULL); - if (n_children > (add_cell ? 0 : 1) && - gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (eprop_types->store), - &iter, - NULL, - n_children - (add_cell ? 1 : 2))) - { + + needed_row = n_children - (add_cell ? 1 : 2); + + if (use_path) + new_item_path = gtk_tree_path_new_from_string + (g_object_get_data (G_OBJECT (eprop_types), "current-path-str")); + else if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (eprop_types->store), + &iter, NULL, needed_row)) new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_types->store), &iter); + else + return; - gtk_widget_grab_focus (GTK_WIDGET (eprop_types->view)); - gtk_tree_view_expand_to_path (eprop_types->view, new_item_path); + eprop_types->setting_cursor = TRUE; - gtk_tree_view_set_cursor (eprop_types->view, new_item_path, - add_cell ? eprop_types->type_column : eprop_types->name_column, - add_cell ? FALSE : TRUE); - - gtk_tree_path_free (new_item_path); - } + gtk_widget_grab_focus (GTK_WIDGET (eprop_types->view)); + gtk_tree_view_expand_to_path (eprop_types->view, new_item_path); + + gtk_tree_view_set_cursor (eprop_types->view, new_item_path, + add_cell ? eprop_types->type_column : eprop_types->name_column, + edit_cell); + + eprop_types->setting_cursor = FALSE; + + gtk_tree_path_free (new_item_path); } } static gboolean eprop_types_focus_new (GladeEPropColumnTypes *eprop_types) { - eprop_types_focus_cell (eprop_types, TRUE); + eprop_types_focus_cell (eprop_types, FALSE, TRUE, FALSE); return FALSE; } static gboolean eprop_types_focus_name (GladeEPropColumnTypes *eprop_types) { - eprop_types_focus_cell (eprop_types, FALSE); + eprop_types_focus_cell (eprop_types, FALSE, FALSE, TRUE); + return FALSE; +} + +static gboolean +eprop_types_focus_name_no_edit (GladeEPropColumnTypes *eprop_types) +{ + eprop_types_focus_cell (eprop_types, TRUE, FALSE, FALSE); return FALSE; } @@ -620,9 +634,9 @@ glade_eprop_column_types_load (GladeEditorProperty *eprop, GladeProperty *proper eprop_column_add_new (eprop_types); if (eprop_types->adding_column && list) - eprop_types_focus_name (eprop_types); + g_idle_add ((GSourceFunc)eprop_types_focus_name, eprop_types); else if (eprop_types->want_focus) - eprop_types_focus_new (eprop_types); + g_idle_add ((GSourceFunc)eprop_types_focus_new, eprop_types); g_signal_handlers_unblock_by_func (G_OBJECT (eprop_types->store), eprop_treeview_row_deleted, eprop); @@ -643,11 +657,18 @@ column_name_edited (GtkCellRendererText *cell, GNode *data_tree = NULL; GladeProperty *property; + if (eprop_types->adding_column) + return; + if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_types->store), &iter, path)) return; gtk_tree_model_get (GTK_TREE_MODEL (eprop_types->store), &iter, COLUMN_COLUMN_NAME, &old_column_name, -1); + if (new_column_name && old_column_name && + strcmp (new_column_name, old_column_name) == 0) + return; + /* Attempt to rename the column, and commit if successfull... */ glade_property_get (eprop->property, &columns); if (columns) @@ -657,8 +678,11 @@ column_name_edited (GtkCellRendererText *cell, column = glade_column_list_find_column (columns, old_column_name); /* Bookkeep the exclusive names... */ - if (glade_name_context_has_name (eprop_types->context, new_column_name)) - column_name = glade_name_context_new_name (eprop_types->context, new_column_name); + if (!new_column_name || !new_column_name[0] || + glade_name_context_has_name (eprop_types->context, new_column_name)) + column_name = glade_name_context_new_name (eprop_types->context, + new_column_name && new_column_name[0] ? + new_column_name : "column"); else column_name = g_strdup (new_column_name); @@ -714,7 +738,7 @@ column_type_edited (GtkCellRendererText *cell, if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_types->store), &iter, path)) return; - if ((type = lookup_type (type_name)) != 0) + if (type_name && (type = lookup_type (type_name)) != 0) { column_name = glade_name_context_new_name (eprop_types->context, type_name); eprop_column_append (eprop, type, column_name); @@ -737,6 +761,8 @@ types_combo_editing_started (GtkCellRenderer *renderer, { GtkEntryCompletion *completion = gtk_entry_completion_new (); + g_object_set_data_full (G_OBJECT (eprop), "current-path-str", g_strdup (path), g_free); + gtk_entry_completion_set_model (completion, types_model); gtk_entry_completion_set_text_column (completion, 0); gtk_entry_completion_set_inline_completion (completion, TRUE); @@ -744,6 +770,34 @@ types_combo_editing_started (GtkCellRenderer *renderer, g_object_unref (G_OBJECT (completion)); } +static void +types_combo_editing_canceled (GtkCellRenderer *renderer, + GladeEditorProperty *eprop) +{ + g_idle_add ((GSourceFunc)eprop_types_focus_new, eprop); +} + + +static void +types_name_editing_started (GtkCellRenderer *renderer, + GtkCellEditable *editable, + gchar *path_str, + GladeEditorProperty *eprop) +{ + g_object_set_data_full (G_OBJECT (eprop), "current-path-str", g_strdup (path_str), g_free); +} + +static void +types_name_editing_canceled (GtkCellRenderer *renderer, + GladeEditorProperty *eprop) +{ + GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop); + + if (eprop_types->adding_column || eprop_types->setting_cursor) + return; + + g_idle_add ((GSourceFunc)eprop_types_focus_name_no_edit, eprop); +} static GtkWidget * glade_eprop_column_types_create_input (GladeEditorProperty *eprop) @@ -762,11 +816,11 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop) /* We make sure to do this after all the adaptors are parsed * because we load the enums/flags from the adaptors */ - types_model = (GtkTreeModel *)gtk_tree_store_new (2, + types_model = (GtkTreeModel *)gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_GTYPE); - column_types_store_populate (GTK_TREE_STORE (types_model)); + column_types_store_populate (GTK_LIST_STORE (types_model)); } @@ -777,35 +831,6 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop) gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_misc_set_padding (GTK_MISC (label), 2, 4); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); - -/* gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); */ - -/* eprop_types->combo = GTK_COMBO_BOX (gtk_combo_box_new_with_model (types_model)); */ -/* cell = gtk_cell_renderer_text_new (); */ -/* gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (eprop_types->combo), */ -/* cell, TRUE); */ -/* gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (eprop_types->combo), */ -/* cell, "text", COLUMN_NAME, NULL); */ -/* gtk_combo_box_set_active (eprop_types->combo, 0); */ -/* gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (eprop_types->combo), TRUE, TRUE, 0); */ - -/* button = gtk_button_new (); */ -/* gtk_button_set_image (GTK_BUTTON (button), */ -/* gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON)); */ -/* gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); */ - -/* g_signal_connect (G_OBJECT (button), "clicked", */ -/* G_CALLBACK (glade_eprop_column_types_add_clicked), */ -/* eprop_types); */ - -/* button = gtk_button_new (); */ -/* gtk_button_set_image (GTK_BUTTON (button), */ -/* gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON)); */ -/* gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); */ - -/* g_signal_connect (G_OBJECT (button), "clicked", */ -/* G_CALLBACK (glade_eprop_column_types_delete_clicked), */ -/* eprop_types); */ swin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin), GTK_SHADOW_IN); @@ -829,6 +854,7 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop) eprop_types->selection = gtk_tree_view_get_selection (eprop_types->view); gtk_tree_view_set_reorderable (eprop_types->view, TRUE); + gtk_tree_view_set_enable_search (eprop_types->view, FALSE); //gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); g_signal_connect (eprop_types->view, "key-press-event", @@ -846,6 +872,9 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop) g_signal_connect (G_OBJECT (cell), "editing-started", G_CALLBACK (types_combo_editing_started), eprop); + g_signal_connect (G_OBJECT (cell), "editing-canceled", + G_CALLBACK (types_combo_editing_canceled), eprop); + g_signal_connect (G_OBJECT (cell), "edited", G_CALLBACK (column_type_edited), eprop); @@ -863,8 +892,14 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop) /* name column */ cell = gtk_cell_renderer_text_new (); g_signal_connect (G_OBJECT (cell), "edited", - G_CALLBACK (column_name_edited), eprop); - + G_CALLBACK (column_name_edited), eprop); + + g_signal_connect (G_OBJECT (cell), "editing-started", + G_CALLBACK (types_name_editing_started), eprop); + + g_signal_connect (G_OBJECT (cell), "editing-canceled", + G_CALLBACK (types_name_editing_canceled), eprop); + eprop_types->name_column = gtk_tree_view_column_new_with_attributes ("Column name", cell, "editable", COLUMN_NAME_EDITABLE, diff --git a/plugins/gtk+/glade-model-data.c b/plugins/gtk+/glade-model-data.c index c6de399f..6de7a214 100644 --- a/plugins/gtk+/glade-model-data.c +++ b/plugins/gtk+/glade-model-data.c @@ -253,6 +253,7 @@ typedef struct /* Used for setting focus on newly added rows */ gboolean adding_row; gboolean want_focus; + gboolean setting_focus; gint editing_row; gint editing_column; } GladeEPropModelData; @@ -265,6 +266,8 @@ GLADE_MAKE_EPROP (GladeEPropModelData, glade_eprop_model_data) #define GLADE_EPROP_MODEL_DATA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_MODEL_DATA, GladeEPropModelDataClass)) +static void eprop_data_focus_editing_cell (GladeEPropModelData *eprop_data); + static void append_row (GNode *node, GList *columns) { @@ -336,13 +339,25 @@ update_and_focus_data_tree_idle (GladeEditorProperty *eprop) return FALSE; } +static gboolean +focus_data_tree_idle (GladeEditorProperty *eprop) +{ + GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop); + + eprop_data->want_focus = TRUE; + eprop_data_focus_editing_cell (eprop_data); + eprop_data->want_focus = FALSE; + + return FALSE; +} + static void glade_eprop_model_data_add_row (GladeEditorProperty *eprop) { GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop); - GValue value = { 0, }; - GNode *node = NULL; - GList *columns = NULL; + GValue value = { 0, }; + GNode *node = NULL; + GList *columns = NULL; glade_property_get (eprop->property, &node); glade_widget_property_get (eprop->property->widget, "columns", &columns); @@ -690,10 +705,19 @@ value_text_edited (GtkCellRendererText *cell, data = glade_model_data_tree_get_data (data_tree, row, colnum); - /* Translate string and update value in tree. */ - value = glade_utils_value_from_string (G_VALUE_TYPE (&data->value), new_text, - eprop->property->widget->project, - eprop->property->widget); + /* Untranslate string and update value in tree. */ + if (G_VALUE_HOLDS_ENUM (&data->value) || G_VALUE_HOLDS_FLAGS (&data->value)) + value = glade_utils_value_from_string (G_VALUE_TYPE (&data->value), + glade_get_value_from_displayable + (G_VALUE_TYPE (&data->value), new_text), + eprop->property->widget->project, + eprop->property->widget); + else + value = glade_utils_value_from_string (G_VALUE_TYPE (&data->value), new_text, + eprop->property->widget->project, + eprop->property->widget); + + g_value_copy (value, &data->value); g_value_unset (value); g_free (value); @@ -707,6 +731,65 @@ value_text_edited (GtkCellRendererText *cell, g_idle_add ((GSourceFunc)update_and_focus_data_tree_idle, eprop); } + +static void +enum_flags_format_cell_data (GtkCellLayout *cell_layout, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) +{ + gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number")); + GValue value = { 0, }; + gchar *string; + + gtk_tree_model_get_value (tree_model, iter, + NUM_COLUMNS + colnum, &value); + + string = glade_utils_string_from_value (&value, GLADE_PROJECT_FORMAT_GTKBUILDER); + + g_object_set (cell, "text", glade_get_displayable_value (G_VALUE_TYPE (&value), string), NULL); + + g_free (string); + + g_value_unset (&value); +} + + +static void +data_editing_started (GtkCellRenderer *cell, + GtkCellEditable *editable, + gchar *path, + GladeEditorProperty *eprop) +{ + GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop); + gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number")); + gint row; + GtkTreeIter iter; + + if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_data->store), &iter, path)) + return; + + gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter, + COLUMN_ROW, &row, + -1); + + eprop_data->editing_row = row; + eprop_data->editing_column = colnum; +} + +static void +data_editing_canceled (GtkCellRenderer *renderer, + GladeEditorProperty *eprop) +{ + GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop); + + if (eprop_data->setting_focus) + return; + + g_idle_add ((GSourceFunc)focus_data_tree_idle, eprop); +} + static GtkTreeViewColumn * eprop_model_generate_column (GladeEditorProperty *eprop, gint colnum, @@ -815,6 +898,13 @@ eprop_model_generate_column (GladeEditorProperty *eprop, gtk_tree_view_column_set_attributes (column, renderer, "text", NUM_COLUMNS + colnum, NULL); + + + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), + renderer, + (GtkCellLayoutDataFunc)enum_flags_format_cell_data, + NULL, NULL); + g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (value_text_edited), eprop); @@ -822,12 +912,32 @@ eprop_model_generate_column (GladeEditorProperty *eprop, else if (G_TYPE_IS_FLAGS (type)) { /* Export a flags dialog from glade-editor-property... */ + renderer = gtk_cell_renderer_text_new (); + g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL); + gtk_tree_view_column_pack_start (column, renderer, FALSE); + gtk_tree_view_column_set_attributes (column, renderer, + "text", NUM_COLUMNS + colnum, + NULL); + } else if (type == G_TYPE_OBJECT || g_type_is_a (type, G_TYPE_OBJECT)) { /* text renderer and object dialog (or raw text for pixbuf) */; + renderer = gtk_cell_renderer_text_new (); + g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL); + gtk_tree_view_column_pack_start (column, renderer, FALSE); + gtk_tree_view_column_set_attributes (column, renderer, + "text", NUM_COLUMNS + colnum, + NULL); + } + g_signal_connect (G_OBJECT (renderer), "editing-started", + G_CALLBACK (data_editing_started), eprop); + + g_signal_connect (G_OBJECT (renderer), "editing-canceled", + G_CALLBACK (data_editing_canceled), eprop); + g_object_set_data (G_OBJECT (renderer), "column-number", GINT_TO_POINTER (colnum)); return column; @@ -881,10 +991,14 @@ eprop_data_focus_new (GladeEPropModelData *eprop_data) { new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_data->store), &iter); + eprop_data->setting_focus = TRUE; + gtk_widget_grab_focus (GTK_WIDGET (eprop_data->view)); gtk_tree_view_expand_to_path (eprop_data->view, new_item_path); gtk_tree_view_set_cursor (eprop_data->view, new_item_path, column, TRUE); + + eprop_data->setting_focus = FALSE; gtk_tree_path_free (new_item_path); } @@ -910,11 +1024,15 @@ eprop_data_focus_editing_cell (GladeEPropModelData *eprop_data) { item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_data->store), &iter); + eprop_data->setting_focus = TRUE; + gtk_widget_grab_focus (GTK_WIDGET (eprop_data->view)); gtk_tree_view_expand_to_path (eprop_data->view, item_path); gtk_tree_view_set_cursor (eprop_data->view, item_path, column, FALSE); gtk_tree_path_free (item_path); + + eprop_data->setting_focus = FALSE; } } } diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in index db68d645..75c0d824 100644 --- a/plugins/gtk+/gtk+.xml.in +++ b/plugins/gtk+/gtk+.xml.in @@ -1951,6 +1951,13 @@ embedded in another object</_tooltip> <properties> <property id="title" default="column"/> + <property id="sizing"> + <displayable-values> + <value id="GTK_TREE_VIEW_COLUMN_GROW_ONLY" _name="Grow Only"/> + <value id="GTK_TREE_VIEW_COLUMN_AUTOSIZE" _name="Automatic"/> + <value id="GTK_TREE_VIEW_COLUMN_FIXED" _name="Fixed"/> + </displayable-values> + </property> </properties> <packing-properties> @@ -2175,7 +2182,13 @@ embedded in another object</_tooltip> <property id="strikethrough-set" disabled="True"/> <property id="stretch-set" disabled="True"/> - <property id="alignment" save="False" custom-layout="True"/> + <property id="alignment" save="False" custom-layout="True"> + <displayable-values> + <value id="PANGO_ALIGN_LEFT" _name="Left"/> + <value id="PANGO_ALIGN_CENTER" _name="Center"/> + <value id="PANGO_ALIGN_RIGHT" _name="Right"/> + </displayable-values> + </property> <property id="attr-alignment" _name="Alignment column" save="False" default="-1" custom-layout="True"> <parameter-spec> <type>GParamInt</type> @@ -2432,7 +2445,20 @@ embedded in another object</_tooltip> </parameter-spec> </property> - <property id="stretch" save="False" custom-layout="True"/> + <property id="stretch" save="False" custom-layout="True"> + <displayable-values> + <value id="PANGO_STRETCH_ULTRA_CONDENSED" _name="Ultra Condensed"/> + <value id="PANGO_STRETCH_EXTRA_CONDENSED" _name="Extra Condensed"/> + <value id="PANGO_STRETCH_CONDENSED" _name="Condensed"/> + <value id="PANGO_STRETCH_SEMI_CONDENSED" _name="Semi Condensed"/> + <value id="PANGO_STRETCH_NORMAL" _name="Normal"/> + <value id="PANGO_STRETCH_SEMI_EXPANDED" _name="Semi Expanded"/> + <value id="PANGO_STRETCH_EXPANDED" _name="Expanded"/> + <value id="PANGO_STRETCH_EXTRA_EXPANDED" _name="Extra Expanded"/> + <value id="PANGO_STRETCH_ULTRA_EXPANDED" _name="Ultra Expanded"/> + </displayable-values> + </property> + <property id="attr-stretch" _name="Stretch column" save="False" default="-1" custom-layout="True"> <parameter-spec> <type>GParamInt</type> @@ -2460,7 +2486,13 @@ embedded in another object</_tooltip> </parameter-spec> </property> - <property id="style" save="False" custom-layout="True"/> + <property id="style" save="False" custom-layout="True"> + <displayable-values> + <value id="PANGO_STYLE_NORMAL" _name="Normal"/> + <value id="PANGO_STYLE_OBLIQUE" _name="Oblique"/> + <value id="PANGO_STYLE_ITALIC" _name="Italic"/> + </displayable-values> + </property> <property id="attr-style" _name="Style column" save="False" default="-1" custom-layout="True"> <parameter-spec> <type>GParamInt</type> @@ -2488,7 +2520,15 @@ embedded in another object</_tooltip> </parameter-spec> </property> - <property id="underline" save="False" custom-layout="True"/> + <property id="underline" save="False" custom-layout="True"> + <displayable-values> + <value id="PANGO_UNDERLINE_NONE" _name="None"/> + <value id="PANGO_UNDERLINE_SINGLE" _name="Single"/> + <value id="PANGO_UNDERLINE_DOUBLE" _name="Double"/> + <value id="PANGO_UNDERLINE_LOW" _name="Low"/> + <value id="PANGO_UNDERLINE_ERROR" _name="Error"/> + </displayable-values> + </property> <property id="attr-underline" _name="Underline column" save="False" default="-1" custom-layout="True"> <parameter-spec> <type>GParamInt</type> @@ -2502,7 +2542,12 @@ embedded in another object</_tooltip> </parameter-spec> </property> - <property id="variant" save="False" custom-layout="True"/> + <property id="variant" save="False" custom-layout="True"> + <displayable-values> + <value id="PANGO_VARIANT_NORMAL" _name="Normal"/> + <value id="PANGO_VARIANT_SMALL_CAPS" _name="Small Capitals"/> + </displayable-values> + </property> <property id="attr-variant" _name="Variant column" save="False" default="-1" custom-layout="True"> <parameter-spec> <type>GParamInt</type> @@ -2591,7 +2636,12 @@ embedded in another object</_tooltip> </parameter-spec> </property> - <property id="accel-mode" save="False" custom-layout="True"/> + <property id="accel-mode" save="False" custom-layout="True"> + <displayable-values> + <value id="GTK_CELL_RENDERER_ACCEL_MODE_GTK" _name="Gtk"/> + <value id="GTK_CELL_RENDERER_ACCEL_MODE_OTHER" _name="Other"/> + </displayable-values> + </property> <property id="attr-accel-mode" _name="Accelerator Mode column" save="False" default="-1" custom-layout="True"> <parameter-spec> <type>GParamInt</type> @@ -2605,7 +2655,28 @@ embedded in another object</_tooltip> </parameter-spec> </property> - <property id="accel-mods" save="False" custom-layout="True"/> + <property id="accel-mods" save="False" custom-layout="True"> + <displayable-values> + <value id="GDK_SHIFT_MASK" _name="Shift Key"/> + <value id="GDK_LOCK_MASK" _name="Lock Key"/> + <value id="GDK_CONTROL_MASK" _name="Control Key"/> + <value id="GDK_MOD1_MASK" _name="Alt Key"/> + <value id="GDK_MOD2_MASK" _name="Fifth Key"/> + <value id="GDK_MOD3_MASK" _name="Sixth Key"/> + <value id="GDK_MOD4_MASK" _name="Seventh Key"/> + <value id="GDK_MOD5_MASK" _name="Eighth Key"/> + <value id="GDK_BUTTON1_MASK" _name="First Mouse Button"/> + <value id="GDK_BUTTON2_MASK" _name="Second Mouse Button"/> + <value id="GDK_BUTTON3_MASK" _name="Third Mouse Button"/> + <value id="GDK_BUTTON4_MASK" _name="Forth Mouse Button"/> + <value id="GDK_BUTTON5_MASK" _name="Fifth Mouse Button"/> + <value id="GDK_SUPER_MASK" _name="Super Modifier"/> + <value id="GDK_HYPER_MASK" _name="Hyper Modifier"/> + <value id="GDK_META_MASK" _name="Meta Modifier"/> + <value id="GDK_RELEASE_MASK" _name="Release Modifier"/> + <value id="GDK_MODIFIER_MASK" _name="All Modifiers"/> + </displayable-values> + </property> <property id="attr-accel-mods" _name="Accelerator Modifiers column" save="False" default="-1" custom-layout="True"> <parameter-spec> <type>GParamInt</type> |