summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2004-03-13 00:36:27 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-03-13 00:36:27 +0000
commit3186b9e76b393dc0a83ab6beb7271ddd0870045d (patch)
treef326660fab702353f38ee25ad36b04af181bb503
parent60780dc68dfd9347f8f3b1cae2e0544361ca8b05 (diff)
downloadgtk+-3186b9e76b393dc0a83ab6beb7271ddd0870045d.tar.gz
Add a remove implemenatation which restores the cell_view when the custom
Sat Mar 13 01:38:55 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove implemenatation which restores the cell_view when the custom child is removed. (#136555, Owen Taylor)
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.pre-2-106
-rw-r--r--ChangeLog.pre-2-46
-rw-r--r--ChangeLog.pre-2-66
-rw-r--r--ChangeLog.pre-2-86
-rw-r--r--gtk/gtkcombobox.c72
6 files changed, 98 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 238ec8d48c..4a40630ad1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Mar 13 01:38:55 2004 Matthias Clasen <maclas@gmx.de>
+
+ * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove
+ implemenatation which restores the cell_view when the custom
+ child is removed. (#136555, Owen Taylor)
+
Sat Mar 13 00:07:51 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_layout_clear):
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 238ec8d48c..4a40630ad1 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,9 @@
+Sat Mar 13 01:38:55 2004 Matthias Clasen <maclas@gmx.de>
+
+ * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove
+ implemenatation which restores the cell_view when the custom
+ child is removed. (#136555, Owen Taylor)
+
Sat Mar 13 00:07:51 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_layout_clear):
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 238ec8d48c..4a40630ad1 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,9 @@
+Sat Mar 13 01:38:55 2004 Matthias Clasen <maclas@gmx.de>
+
+ * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove
+ implemenatation which restores the cell_view when the custom
+ child is removed. (#136555, Owen Taylor)
+
Sat Mar 13 00:07:51 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_layout_clear):
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 238ec8d48c..4a40630ad1 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,9 @@
+Sat Mar 13 01:38:55 2004 Matthias Clasen <maclas@gmx.de>
+
+ * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove
+ implemenatation which restores the cell_view when the custom
+ child is removed. (#136555, Owen Taylor)
+
Sat Mar 13 00:07:51 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_layout_clear):
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 238ec8d48c..4a40630ad1 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,9 @@
+Sat Mar 13 01:38:55 2004 Matthias Clasen <maclas@gmx.de>
+
+ * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove
+ implemenatation which restores the cell_view when the custom
+ child is removed. (#136555, Owen Taylor)
+
Sat Mar 13 00:07:51 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_layout_clear):
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index f399d5d097..8126dd87fe 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -99,6 +99,7 @@ struct _GtkComboBoxPrivate
GSList *cells;
guint popup_in_progress : 1;
+ guint destroying : 1;
};
/* While debugging this evil code, I have learned that
@@ -199,6 +200,8 @@ static void gtk_combo_box_button_toggled (GtkWidget *widget,
gpointer data);
static void gtk_combo_box_add (GtkContainer *container,
GtkWidget *widget);
+static void gtk_combo_box_remove (GtkContainer *container,
+ GtkWidget *widget);
static ComboCellInfo *gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
GtkCellRenderer *cell);
@@ -414,6 +417,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
container_class = (GtkContainerClass *)klass;
container_class->forall = gtk_combo_box_forall;
container_class->add = gtk_combo_box_add;
+ container_class->remove = gtk_combo_box_remove;
widget_class = (GtkWidgetClass *)klass;
widget_class->size_allocate = gtk_combo_box_size_allocate;
@@ -521,7 +525,8 @@ gtk_combo_box_init (GtkComboBox *combo_box)
combo_box->priv = GTK_COMBO_BOX_GET_PRIVATE (combo_box);
combo_box->priv->cell_view = gtk_cell_view_new ();
- gtk_container_add (GTK_CONTAINER (combo_box), combo_box->priv->cell_view);
+ gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (combo_box));
+ GTK_BIN (combo_box)->child = combo_box->priv->cell_view;
gtk_widget_show (combo_box->priv->cell_view);
combo_box->priv->width = 0;
@@ -691,9 +696,14 @@ gtk_combo_box_add (GtkContainer *container,
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
if (combo_box->priv->cell_view && combo_box->priv->cell_view->parent)
- gtk_container_remove (container, combo_box->priv->cell_view);
-
- (* GTK_CONTAINER_CLASS (parent_class)->add) (container, widget);
+ {
+ gtk_widget_unparent (combo_box->priv->cell_view);
+ GTK_BIN (container)->child = NULL;
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+ }
+
+ gtk_widget_set_parent (widget, GTK_WIDGET (container));
+ GTK_BIN (container)->child = widget;
if (combo_box->priv->cell_view &&
widget != combo_box->priv->cell_view)
@@ -722,6 +732,56 @@ gtk_combo_box_add (GtkContainer *container,
}
}
+static void
+gtk_combo_box_remove (GtkContainer *container,
+ GtkWidget *widget)
+{
+ GtkComboBox *combo_box = GTK_COMBO_BOX (container);
+ gboolean appears_as_list;
+
+ gtk_widget_unparent (widget);
+ GTK_BIN (container)->child = NULL;
+
+ if (combo_box->priv->destroying)
+ return;
+
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+
+ if (!combo_box->priv->tree_view)
+ appears_as_list = FALSE;
+ else
+ appears_as_list = TRUE;
+
+ if (appears_as_list)
+ gtk_combo_box_list_destroy (combo_box);
+ else if (GTK_IS_MENU (combo_box->priv->popup_widget))
+ {
+ gtk_combo_box_menu_destroy (combo_box);
+ gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
+ combo_box->priv->popup_widget = NULL;
+ }
+
+ if (!combo_box->priv->cell_view)
+ {
+ combo_box->priv->cell_view = gtk_cell_view_new ();
+ gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container));
+ GTK_BIN (container)->child = combo_box->priv->cell_view;
+
+ gtk_widget_show (combo_box->priv->cell_view);
+ gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
+ combo_box->priv->model);
+ cell_view_sync_cells (combo_box, GTK_CELL_VIEW (combo_box->priv->cell_view));
+ }
+
+
+ if (appears_as_list)
+ gtk_combo_box_list_setup (combo_box);
+ else
+ gtk_combo_box_menu_setup (combo_box, TRUE);
+
+ gtk_combo_box_set_active_internal (combo_box, combo_box->priv->active_item);
+}
+
static ComboCellInfo *
gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
GtkCellRenderer *cell)
@@ -3343,9 +3403,13 @@ gtk_combo_box_destroy (GtkObject *object)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+ combo_box->priv->destroying = 1;
+
GTK_OBJECT_CLASS (parent_class)->destroy (object);
combo_box->priv->cell_view = NULL;
+
+ combo_box->priv->destroying = 0;
}
static void