glade3 r2052 - in trunk: . plugins/gtk+
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r2052 - in trunk: . plugins/gtk+
- Date: Tue, 25 Nov 2008 18:36:41 +0000 (UTC)
Author: tvb
Date: Tue Nov 25 18:36:41 2008
New Revision: 2052
URL: http://svn.gnome.org/viewvc/glade3?rev=2052&view=rev
Log:
* 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
Modified:
trunk/ChangeLog
trunk/plugins/gtk+/glade-cell-renderer-editor.c
trunk/plugins/gtk+/glade-convert.c
trunk/plugins/gtk+/glade-gtk.c
trunk/plugins/gtk+/glade-gtk.h
trunk/plugins/gtk+/gtk+.xml.in
Modified: trunk/plugins/gtk+/glade-cell-renderer-editor.c
==============================================================================
--- trunk/plugins/gtk+/glade-cell-renderer-editor.c (original)
+++ trunk/plugins/gtk+/glade-cell-renderer-editor.c Tue Nov 25 18:36:41 2008
@@ -548,6 +548,14 @@
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;
}
Modified: trunk/plugins/gtk+/glade-convert.c
==============================================================================
--- trunk/plugins/gtk+/glade-convert.c (original)
+++ trunk/plugins/gtk+/glade-convert.c Tue Nov 25 18:36:41 2008
@@ -383,7 +383,7 @@
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]);
@@ -425,6 +425,39 @@
}
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,
ConvertData *data)
@@ -448,7 +481,9 @@
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 @@
{
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 @@
{
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 @@
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);
}
Modified: trunk/plugins/gtk+/glade-gtk.c
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.c (original)
+++ trunk/plugins/gtk+/glade-gtk.c Tue Nov 25 18:36:41 2008
@@ -8237,28 +8237,31 @@
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);
Modified: trunk/plugins/gtk+/glade-gtk.h
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.h (original)
+++ trunk/plugins/gtk+/glade-gtk.h Tue Nov 25 18:36:41 2008
@@ -5,6 +5,7 @@
#include <gladeui/glade.h>
#include <gtk/gtk.h>
+
/* Types */
GParamSpec *glade_gtk_gnome_ui_info_spec (void);
Modified: trunk/plugins/gtk+/gtk+.xml.in
==============================================================================
--- trunk/plugins/gtk+/gtk+.xml.in (original)
+++ trunk/plugins/gtk+/gtk+.xml.in Tue Nov 25 18:36:41 2008
@@ -1000,6 +1000,19 @@
<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…" stock="gtk-edit" important="True"/>
+ </actions>
+
<signals>
<signal id="move-action" since="2.12"/>
<signal id="popdown" since="2.12"/>
@@ -1938,6 +1951,7 @@
<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 @@
</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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]