Commit 2ed76714 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Fixed conversions for combo boxes.


	* plugins/gtk+/glade-convert.c: Fixed conversions for combo boxes.

	* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: 
	  - Added editor support for Combo Box


svn path=/trunk/; revision=2052
parent 21605e92
......@@ -8,7 +8,9 @@
* gladeui/glade-command.c: Fixed check for wrapperless objects returned by adaptor_get_children().
* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Added editor support for Icon View.
* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in:
- Added editor support for Icon View.
- Added editor support for Combo Box
* plugins/gtk+/glade-cell-renderer-editor.c: Export a new function to get the model from
the renderer regardless of the layout type.
......@@ -16,6 +18,8 @@
* plugins/gtk+/glade-treeview-editor.c: Now supports editing any view that can have a model,
and pops up the store editor automatically on the right of the normal widget editor.
* plugins/gtk+/glade-convert.c: Fixed conversions for combo boxes.
2008-11-23 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-widget.c:
......
......@@ -548,6 +548,14 @@ glade_cell_renderer_get_model (GladeWidget *renderer)
if (real_model)
model = glade_widget_get_from_gobject (real_model);
}
else if (renderer->parent && GTK_IS_COMBO_BOX (renderer->parent->object))
{
GladeWidget *combo = renderer->parent;
GtkTreeModel *real_model = NULL;
glade_widget_property_get (combo, "model", &real_model);
if (real_model)
model = glade_widget_get_from_gobject (real_model);
}
return model;
}
......
......@@ -383,7 +383,7 @@ combos_data_tree_from_items (gchar **items)
for (i = 0; items[i]; i++)
{
GladeModelData *data = glade_model_data_new (G_TYPE_STRING, "item");
GladeModelData *data = glade_model_data_new (G_TYPE_STRING, "item text");
g_value_set_string (&data->value, items[i]);
......@@ -424,6 +424,39 @@ combos_items_from_data_tree (GNode *data_tree)
return (gchar **)g_ptr_array_free (array, FALSE);
}
static void
combo_box_convert_setup (GladeWidget *widget, GladeProjectFormat fmt)
{
GtkListStore *store;
GtkComboBox *combo = GTK_COMBO_BOX (widget->object);
GtkCellRenderer *cell;
if (fmt == GLADE_PROJECT_FORMAT_GTKBUILDER)
{
/* Get rid of any custom */
gtk_combo_box_set_model (combo, NULL);
/* remove every cell (its only the libglade special case cell that is here) */
gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
}
else if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE)
{
if (!gtk_combo_box_get_model (GTK_COMBO_BOX (combo)))
{
/* Add store for text items */
store = gtk_list_store_new (1, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
g_object_unref (store);
}
/* Add cell renderer for text items */
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
"text", 0, NULL);
}
}
static void
convert_combos (GladeProject *project,
GladeProjectFormat new_format,
......@@ -448,7 +481,9 @@ convert_combos (GladeProject *project,
items = NULL;
property = glade_widget_get_property (widget, "items");
glade_property_get (property, &items);
combo_box_convert_setup (widget, new_format);
if (items)
{
cdata = g_new0 (ComboData, 1);
......@@ -497,6 +532,7 @@ convert_combos_finished (GladeProject *project,
{
GladeProjectFormat new_format = glade_project_get_format (project);
GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LIST_STORE);
GladeWidgetAdaptor *cell_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_CELL_RENDERER_TEXT);
GladeProperty *property;
GladeWidget *widget;
ComboData *cdata;
......@@ -511,7 +547,9 @@ convert_combos_finished (GladeProject *project,
{
GList *columns = NULL;
GladeColumnType *column = g_new0 (GladeColumnType, 1);
column->type = G_TYPE_STRING;
column->column_name = g_strdup_printf ("item text");
columns = g_list_append (columns, column);
property = glade_widget_get_property (cdata->widget, "model");
......@@ -527,9 +565,17 @@ convert_combos_finished (GladeProject *project,
glade_command_set_property (property, widget->object);
glade_column_list_free (columns);
glade_model_data_tree_free (data_tree);
/* Add a cell renderer after creating and setting the mode.... */
widget = glade_command_create (cell_adaptor, cdata->widget, NULL, project);
glade_widget_property_set (widget, "attr-text", 0);
}
else
{
combo_box_convert_setup (cdata->widget, new_format);
property = glade_widget_get_property (cdata->widget, "items");
glade_command_set_property (property, cdata->items);
}
......
......@@ -8237,28 +8237,31 @@ glade_gtk_combo_box_post_create (GladeWidgetAdaptor *adaptor,
GladeCreateReason reason)
{
GtkCellRenderer *cell;
GladeWidget *widget = glade_widget_get_from_gobject (object);
g_return_if_fail (GTK_IS_COMBO_BOX (object));
if (glade_project_get_format (widget->project) == GLADE_PROJECT_FORMAT_LIBGLADE)
{
combo_ensure_model (object);
combo_ensure_model (object);
/* Add cell renderer */
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell,
"text", 0, NULL);
/* Add cell renderer */
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell,
"text", 0, NULL);
}
}
static void
glade_gtk_combo_box_set_items (GObject *object, const GValue *value)
{
GtkComboBox *combo;
GtkComboBox *combo = GTK_COMBO_BOX (object);
GladeWidget *widget = glade_widget_get_from_gobject (object);
gchar **split;
gint i;
g_return_if_fail (GTK_IS_COMBO_BOX (object));
combo = GTK_COMBO_BOX (object);
if (glade_project_get_format (widget->project) != GLADE_PROJECT_FORMAT_LIBGLADE)
return;
combo_ensure_model (object);
......
......@@ -5,6 +5,7 @@
#include <gladeui/glade.h>
#include <gtk/gtk.h>
/* Types */
GParamSpec *glade_gtk_gnome_ui_info_spec (void);
......
......@@ -1000,6 +1000,19 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkComboBox" generic-name="combobox" _title="Combo Box">
<post-create-function>glade_gtk_combo_box_post_create</post-create-function>
<set-property-function>glade_gtk_combo_box_set_property</set-property-function>
<add-child-function>glade_gtk_cell_layout_add_child</add-child-function>
<remove-child-function>glade_gtk_cell_layout_remove_child</remove-child-function>
<get-children-function>glade_gtk_cell_layout_get_children</get-children-function>
<read-child-function>glade_gtk_cell_layout_read_child</read-child-function>
<write-child-function>glade_gtk_cell_layout_write_child</write-child-function>
<action-activate-function>glade_gtk_cell_layout_action_activate</action-activate-function>
<child-set-property-function>glade_gtk_cell_layout_set_child_property</child-set-property-function>
<child-get-property-function>glade_gtk_cell_layout_get_child_property</child-get-property-function>
<actions>
<action id="launch_editor" _name="Edit&#8230;" stock="gtk-edit" important="True"/>
</actions>
<signals>
<signal id="move-action" since="2.12"/>
<signal id="popdown" since="2.12"/>
......@@ -1938,6 +1951,7 @@ embedded in another object</_tooltip>
<property id="markup-column" disabled="True"/>
<property id="pixbuf-column" disabled="True"/>
<property id="reorderable" ignore="True"/>
<property id="model" create-type="GtkListStore" query="True" libglade-unsupported="True"/>
</properties>
<packing-properties>
......@@ -1949,7 +1963,6 @@ embedded in another object</_tooltip>
</packing-properties>
</glade-widget-class>
<glade-widget-class name="GtkCellRenderer" _title="Cell Renderer">
<post-create-function>glade_gtk_cell_renderer_post_create</post-create-function>
<create-editor-property-function>glade_gtk_cell_renderer_create_eprop</create-editor-property-function>
......
Markdown is supported
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