Commit 867115d5 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

Fixed a warning.


	* plugins/gtk+/glade-cell-renderer-button.c: Fixed a warning.

	* plugins/gtk+/glade-column-types.c, plugins/gtk+/glade-model-data.c,
	plugins/gtk+/glade-icon-sources.c: Made sure add/remove works when
	deleting unedited icon sources, all add buttons result in focus and
	start-editing of an important cell in the underlying treeview.

	* gladeui/glade-utils.c: Fixed generic enum types to use enum_class->minimum
	as the default value.


svn path=/trunk/; revision=1999
parent 7e67585e
2008-10-24 Tristan Van Berkom <tvb@gnome.org>
2008-10-25 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-property-class.c: Fixed glade_property_class_make_adjustment()
for floating and double values (page inc and size were not properly set) (bug 553200)
......@@ -12,6 +12,16 @@
* plugins/gtk+/gtk+.xml.in: mark some props save-always for overridden
defaults in children (this one is bug 555726)
* plugins/gtk+/glade-cell-renderer-button.c: Fixed a warning.
* plugins/gtk+/glade-column-types.c, plugins/gtk+/glade-model-data.c,
plugins/gtk+/glade-icon-sources.c: Made sure add/remove works when
deleting unedited icon sources, all add buttons result in focus and
start-editing of an important cell in the underlying treeview.
* gladeui/glade-utils.c: Fixed generic enum types to use enum_class->minimum
as the default value.
2008-10-24 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/Makefile.am, plugins/gtk+/glade-button-editor.[ch]:
......
......@@ -2127,8 +2127,12 @@ pclass_from_gtype (GType type)
pspec = g_param_spec_object ("dummy", "dummy", "dummy",
type, G_PARAM_READABLE|G_PARAM_WRITABLE);
else if (G_TYPE_IS_ENUM (type))
{
GEnumClass *eclass = g_type_class_ref (type);
pspec = g_param_spec_enum ("dummy", "dummy", "dummy",
type, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
type, eclass->minimum, G_PARAM_READABLE|G_PARAM_WRITABLE);
g_type_class_unref (eclass);
}
else if (G_TYPE_IS_FLAGS (type))
pspec = g_param_spec_flags ("dummy", "dummy", "dummy",
type, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
......
......@@ -239,7 +239,7 @@ glade_cell_renderer_button_start_editing (GtkCellRenderer *cell,
return NULL;
text_button = (GladeTextButton *)glade_text_button_new ();
gtk_entry_set_text (GTK_ENTRY (text_button->entry), cell_text->text);
gtk_entry_set_text (GTK_ENTRY (text_button->entry), cell_text->text ? cell_text->text : "");
gtk_entry_set_editable (GTK_ENTRY (text_button->entry), priv->entry_editable);
g_object_set (text_button->entry,
......
......@@ -274,11 +274,15 @@ typedef struct
{
GladeEditorProperty parent_instance;
GtkComboBox *combo;
GtkListStore *store;
GtkComboBox *combo;
GtkListStore *store;
GtkTreeView *view;
GtkTreeSelection *selection;
GladeNameContext *context;
gboolean adding_column;
GtkTreeViewColumn *name_column;
} GladeEPropColumnTypes;
GLADE_MAKE_EPROP (GladeEPropColumnTypes, glade_eprop_column_types)
......@@ -382,7 +386,7 @@ eprop_column_append (GladeEditorProperty *eprop,
columns = g_list_append (columns, data);
eprop_types->adding_column = TRUE;
glade_command_push_group (_("Setting columns on %s"),
glade_widget_get_name (eprop->property->widget));
......@@ -394,6 +398,8 @@ eprop_column_append (GladeEditorProperty *eprop,
g_value_unset (&value);
glade_command_pop_group ();
eprop_types->adding_column = FALSE;
}
static void
......@@ -538,6 +544,37 @@ eprop_column_load (GladeEPropColumnTypes *eprop_types,
-1);
}
static gboolean
eprop_types_focus_idle (GladeEPropColumnTypes *eprop_types)
{
/* Focus and edit the first column of a newly added row */
if (eprop_types->store)
{
GtkTreePath *new_item_path;
GtkTreeIter iter, *last_iter = NULL;
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_types->store), &iter))
{
do {
if (last_iter)
gtk_tree_iter_free (last_iter);
last_iter = gtk_tree_iter_copy (&iter);
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_types->store), &iter));
new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_types->store), last_iter);
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,
eprop_types->name_column, TRUE);
gtk_tree_path_free (new_item_path);
gtk_tree_iter_free (last_iter);
}
}
return FALSE;
}
static void
glade_eprop_column_types_load (GladeEditorProperty *eprop, GladeProperty *property)
{
......@@ -573,6 +610,9 @@ glade_eprop_column_types_load (GladeEditorProperty *eprop, GladeProperty *proper
glade_name_context_add_name (eprop_types->context, data->column_name);
}
if (eprop_types->adding_column && list)
g_idle_add ((GSourceFunc)eprop_types_focus_idle, eprop);
g_signal_handlers_unblock_by_func (G_OBJECT (eprop_types->store),
eprop_treeview_row_deleted, eprop);
}
......@@ -649,7 +689,7 @@ static GtkWidget *
glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
{
GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
GtkWidget *vbox, *hbox, *button, *swin, *treeview, *label;
GtkWidget *vbox, *hbox, *button, *swin, *label;
GtkCellRenderer *cell;
GtkTreeViewColumn *col;
gchar *string;
......@@ -710,11 +750,11 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
G_CALLBACK (eprop_treeview_row_deleted),
eprop);
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (eprop_types->store));
eprop_types->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
eprop_types->view = (GtkTreeView *)gtk_tree_view_new_with_model (GTK_TREE_MODEL (eprop_types->store));
eprop_types->selection = gtk_tree_view_get_selection (eprop_types->view);
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), TRUE);
gtk_tree_view_set_reorderable (eprop_types->view, TRUE);
//gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
/* type column */
......@@ -722,7 +762,7 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
gtk_cell_renderer_text_new (),
"text", COLUMN_NAME,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
gtk_tree_view_append_column (eprop_types->view, col);
/* name column */
......@@ -732,12 +772,13 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
g_signal_connect (G_OBJECT (cell), "edited",
G_CALLBACK (column_name_edited), eprop);
col = gtk_tree_view_column_new_with_attributes ("Column name",
cell,
"text", COLUMN_COLUMN_NAME,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
gtk_container_add (GTK_CONTAINER (swin), treeview);
eprop_types->name_column =
gtk_tree_view_column_new_with_attributes ("Column name",
cell,
"text", COLUMN_COLUMN_NAME,
NULL);
gtk_tree_view_append_column (eprop_types->view, eprop_types->name_column);
gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_types->view));
g_object_set (G_OBJECT (vbox), "height-request", 200, NULL);
......
......@@ -351,6 +351,7 @@ add_clicked (GtkWidget *button,
GtkTreePath *new_item_path;
gchar *icon_name;
gchar *selected_icon_name;
gint index;
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (eprop_sources->combo), &iter))
gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->icon_names_store), &iter,
......@@ -377,6 +378,23 @@ add_clicked (GtkWidget *button,
gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_sources->store), &iter));
}
/* check if we're already adding one here... */
if (parent_iter &&
gtk_tree_model_iter_children (GTK_TREE_MODEL (eprop_sources->store), &iter, parent_iter))
{
do {
gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
COLUMN_LIST_INDEX, &index,
-1);
/* Iter is set, expand and return. */
if (index < 0)
goto expand_to_path_and_focus;
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_sources->store), &iter));
}
if (!parent_iter)
{
/* Dont set COLUMN_ICON_NAME here */
......@@ -397,6 +415,8 @@ add_clicked (GtkWidget *button,
COLUMN_LIST_INDEX, -1,
-1);
/* By now iter is valid. */
expand_to_path_and_focus:
new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_sources->store), &iter);
gtk_widget_grab_focus (GTK_WIDGET (eprop_sources->view));
......@@ -459,6 +479,15 @@ delete_clicked (GtkWidget *button,
COLUMN_LIST_INDEX, &index,
-1);
/* Could be the user pressed add and then delete without touching the
* new item.
*/
if (index < 0)
{
g_idle_add ((GSourceFunc)reload_icon_sources_idle, eprop);
return;
}
glade_property_get (eprop->property, &icon_sources);
if (icon_sources)
{
......
......@@ -315,6 +315,10 @@ typedef struct
GtkListStore *store;
GtkTreeSelection *selection;
GNode *pending_data_tree;
/* Used for setting focus on newly added rows */
gboolean adding_row;
GtkTreeViewColumn *first_column;
} GladeEPropModelData;
GLADE_MAKE_EPROP (GladeEPropModelData, glade_eprop_model_data)
......@@ -382,6 +386,7 @@ static void
glade_eprop_model_data_add_clicked (GtkWidget *button,
GladeEditorProperty *eprop)
{
GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
GValue value = { 0, };
GNode *node = NULL;
GList *columns = NULL;
......@@ -401,11 +406,14 @@ glade_eprop_model_data_add_clicked (GtkWidget *button,
append_row (node, columns);
eprop_data->adding_row = TRUE;
g_value_init (&value, GLADE_TYPE_MODEL_DATA_TREE);
g_value_take_boxed (&value, node);
glade_editor_property_commit (eprop, &value);
g_value_unset (&value);
eprop_data->adding_row = FALSE;
}
/* User pressed delete: remove selected row and commit values */
......@@ -849,6 +857,8 @@ eprop_model_data_generate_columns (GladeEditorProperty *eprop)
if (!data_tree || !data_tree->children || !data_tree->children->children)
return;
eprop_data->first_column = NULL;
/* Append new columns */
for (colnum = 0, iter_node = data_tree->children->children; iter_node;
colnum++, iter_node = iter_node->next)
......@@ -857,7 +867,41 @@ eprop_model_data_generate_columns (GladeEditorProperty *eprop)
column = eprop_model_generate_column (eprop, colnum, iter_data);
gtk_tree_view_append_column (eprop_data->view, column);
if (!eprop_data->first_column)
eprop_data->first_column = column;
}
}
static gboolean
eprop_data_focus_idle (GladeEPropModelData *eprop_data)
{
/* Focus and edit the first column of a newly added row */
if (eprop_data->store && eprop_data->first_column)
{
GtkTreePath *new_item_path;
GtkTreeIter iter, *last_iter = NULL;
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_data->store), &iter))
{
do {
if (last_iter)
gtk_tree_iter_free (last_iter);
last_iter = gtk_tree_iter_copy (&iter);
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_data->store), &iter));
new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_data->store), last_iter);
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,
eprop_data->first_column, TRUE);
gtk_tree_path_free (new_item_path);
gtk_tree_iter_free (last_iter);
}
}
return FALSE;
}
static void
......@@ -892,6 +936,9 @@ glade_eprop_model_data_load (GladeEditorProperty *eprop,
/* Create new columns with renderers */
eprop_model_data_generate_columns (eprop);
if (eprop_data->adding_row && eprop_data->store && eprop_data->first_column)
g_idle_add ((GSourceFunc)eprop_data_focus_idle, eprop_data);
}
static GtkWidget *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment