summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2003-12-19 22:47:20 +0000
committerKristian Rietveld <kristian@src.gnome.org>2003-12-19 22:47:20 +0000
commit2f4326e40633536ffea31e266f1985ca0fb805f3 (patch)
tree5ae741b553cfad54a1969207659eb381693794cb /gtk
parent30d9f88996c6cf5148837063ea45cef3f17c96da (diff)
downloadgtk+-2f4326e40633536ffea31e266f1985ca0fb805f3.tar.gz
Fixes #108458.
Fri Dec 19 23:36:00 2003 Kristian Rietveld <kris@gtk.org> Fixes #108458. * gtk/gtkcelllayout.[ch]: added a reorder method. * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_layout_init), (gtk_tree_view_column_cell_layout_reorder): implement reorder. * gtk/gtkcellview.c (gtk_cell_view_cell_layout_init), (gtk_cell_view_cell_layout_reorder): ditto. * gtk/gtkcombobox.c (gtk_combo_box_cell_layout_init), (gtk_combo_box_cell_layout_reorder): ditto. * gtk/gtkentrycompletion.c (gtk_entry_completion_cell_layout_init), (gtk_entry_completion_reorder): ditto.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcelllayout.c24
-rw-r--r--gtk/gtkcelllayout.h6
-rw-r--r--gtk/gtkcellview.c32
-rw-r--r--gtk/gtkcombobox.c61
-rw-r--r--gtk/gtkentrycompletion.c18
-rw-r--r--gtk/gtktreeviewcolumn.c31
6 files changed, 172 insertions, 0 deletions
diff --git a/gtk/gtkcelllayout.c b/gtk/gtkcelllayout.c
index 29ccc89362..6dff244122 100644
--- a/gtk/gtkcelllayout.c
+++ b/gtk/gtkcelllayout.c
@@ -250,3 +250,27 @@ gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
(* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout,
cell);
}
+
+/**
+ * gtk_cell_layout_reorder:
+ * @cell_layout: A #GtkCellLayout.
+ * @cell: A #GtkCellRenderer to reorder.
+ * @position: New position to insert @cell at.
+ *
+ * Re-inserts @cell at @position. Note that @cell has already to be packed
+ * into @cell_layout for this to function properly.
+ *
+ * Since: 2.4
+ */
+void
+gtk_cell_layout_reorder (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ gint position)
+{
+ g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+
+ (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder) (cell_layout,
+ cell,
+ position);
+}
diff --git a/gtk/gtkcelllayout.h b/gtk/gtkcelllayout.h
index 5e60e2e361..2458df3a76 100644
--- a/gtk/gtkcelllayout.h
+++ b/gtk/gtkcelllayout.h
@@ -65,6 +65,9 @@ struct _GtkCellLayoutIface
GDestroyNotify destroy);
void (* clear_attributes) (GtkCellLayout *cell_layout,
GtkCellRenderer *cell);
+ void (* reorder) (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ gint position);
};
GType gtk_cell_layout_get_type (void);
@@ -89,6 +92,9 @@ void gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
GDestroyNotify destroy);
void gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
GtkCellRenderer *cell);
+void gtk_cell_layout_reorder (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ gint position);
G_END_DECLS
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index b307573d60..7f46555696 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -100,6 +100,9 @@ static void gtk_cell_view_cell_layout_set_cell_data_func (GtkCellLayout
GtkCellLayoutDataFunc func,
gpointer func_data,
GDestroyNotify destroy);
+static void gtk_cell_view_cell_layout_reorder (GtkCellLayout *layout,
+ GtkCellRenderer *cell,
+ gint position);
#define GTK_CELL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_VIEW, GtkCellViewPrivate))
@@ -203,6 +206,7 @@ gtk_cell_view_cell_layout_init (GtkCellLayoutIface *iface)
iface->add_attribute = gtk_cell_view_cell_layout_add_attribute;
iface->set_cell_data_func = gtk_cell_view_cell_layout_set_cell_data_func;
iface->clear_attributes = gtk_cell_view_cell_layout_clear_attributes;
+ iface->reorder = gtk_cell_view_cell_layout_reorder;
}
static void
@@ -698,6 +702,34 @@ gtk_cell_view_cell_layout_clear_attributes (GtkCellLayout *layout,
info->attributes = NULL;
}
+static void
+gtk_cell_view_cell_layout_reorder (GtkCellLayout *layout,
+ GtkCellRenderer *cell,
+ gint position)
+{
+ GList *link;
+ GtkCellViewCellInfo *info;
+ GtkCellView *cellview = GTK_CELL_VIEW (layout);
+
+ g_return_if_fail (GTK_IS_CELL_VIEW (cellview));
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+
+ info = gtk_cell_view_get_cell_info (cellview, cell);
+
+ g_return_if_fail (info != NULL);
+ g_return_if_fail (position >= 0);
+
+ link = g_list_find (cellview->priv->cell_list, info);
+
+ g_return_if_fail (link != NULL);
+
+ cellview->priv->cell_list = g_list_remove_link (cellview->priv->cell_list,
+ link);
+ cellview->priv->cell_list = g_list_insert (cellview->priv->cell_list,
+ info, position);
+
+ gtk_widget_queue_draw (GTK_WIDGET (cellview));
+}
/* public API */
GtkWidget *
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 1155a46d5a..ab2b9ea996 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -252,6 +252,9 @@ static void gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout
GDestroyNotify destroy);
static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
GtkCellRenderer *cell);
+static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
+ GtkCellRenderer *cell,
+ gint position);
GType
@@ -399,6 +402,7 @@ gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
iface->add_attribute = gtk_combo_box_cell_layout_add_attribute;
iface->set_cell_data_func = gtk_combo_box_cell_layout_set_cell_data_func;
iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes;
+ iface->reorder = gtk_combo_box_cell_layout_reorder;
}
static void
@@ -2294,6 +2298,63 @@ gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
gtk_widget_queue_resize (GTK_WIDGET (combo_box));
}
+static void
+gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
+ GtkCellRenderer *cell,
+ gint position)
+{
+ ComboCellInfo *info;
+ GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
+ GtkWidget *menu;
+ GSList *link;
+
+ g_return_if_fail (GTK_IS_COMBO_BOX (layout));
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+
+ info = gtk_combo_box_get_cell_info (combo_box, cell);
+
+ g_return_if_fail (info != NULL);
+ g_return_if_fail (position >= 0);
+
+ link = g_slist_find (combo_box->priv->cells, info);
+
+ g_return_if_fail (link != NULL);
+
+ combo_box->priv->cells = g_slist_remove_link (combo_box->priv->cells, link);
+ combo_box->priv->cells = g_slist_insert (combo_box->priv->cells, info,
+ position);
+
+ if (combo_box->priv->cell_view)
+ gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
+ cell, position);
+
+ if (combo_box->priv->column)
+ gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->column),
+ cell, position);
+
+ menu = combo_box->priv->popup_widget;
+ if (GTK_IS_MENU (menu))
+ {
+ GList *i, *list;
+
+ list = gtk_container_get_children (GTK_CONTAINER (menu));
+ for (i = list; i; i = i->next)
+ {
+ GtkCellView *view;
+
+ if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
+ view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
+ else
+ view = GTK_CELL_VIEW (i->data);
+
+ gtk_cell_layout_reorder (GTK_CELL_LAYOUT (view), cell, position);
+ }
+ g_list_free (list);
+ }
+
+ gtk_widget_queue_draw (GTK_WIDGET (combo_box));
+}
+
/*
* public API
*/
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index de8664e520..1bedfe0273 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -84,6 +84,9 @@ static void gtk_entry_completion_set_cell_data_func (GtkCellLayout
GDestroyNotify destroy);
static void gtk_entry_completion_clear_attributes (GtkCellLayout *cell_layout,
GtkCellRenderer *cell);
+static void gtk_entry_completion_reorder (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ gint position);
static gboolean gtk_entry_completion_visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
@@ -216,6 +219,7 @@ gtk_entry_completion_cell_layout_init (GtkCellLayoutIface *iface)
iface->add_attribute = gtk_entry_completion_add_attribute;
iface->set_cell_data_func = gtk_entry_completion_set_cell_data_func;
iface->clear_attributes = gtk_entry_completion_clear_attributes;
+ iface->reorder = gtk_entry_completion_reorder;
}
static void
@@ -467,6 +471,20 @@ gtk_entry_completion_clear_attributes (GtkCellLayout *cell_layout,
gtk_tree_view_column_clear_attributes (priv->column, cell);
}
+static void
+gtk_entry_completion_reorder (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ gint position)
+{
+ GtkEntryCompletionPrivate *priv;
+
+ g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
+
+ priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
+
+ gtk_cell_layout_reorder (GTK_CELL_LAYOUT (priv->column), cell, position);
+}
+
/* all those callbacks */
static gboolean
gtk_entry_completion_default_completion_func (GtkEntryCompletion *completion,
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 6bd4000e6f..6a5d80e4e6 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -107,6 +107,9 @@ static void gtk_tree_view_column_cell_layout_set_cell_data_func (GtkCellLayout
GDestroyNotify destroy);
static void gtk_tree_view_column_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
GtkCellRenderer *cell);
+static void gtk_tree_view_column_cell_layout_reorder (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ gint position);
/* Button handling code */
static void gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column);
@@ -356,6 +359,7 @@ gtk_tree_view_column_cell_layout_init (GtkCellLayoutIface *iface)
iface->add_attribute = gtk_tree_view_column_cell_layout_add_attribute;
iface->set_cell_data_func = gtk_tree_view_column_cell_layout_set_cell_data_func;
iface->clear_attributes = gtk_tree_view_column_cell_layout_clear_attributes;
+ iface->reorder = gtk_tree_view_column_cell_layout_reorder;
}
static void
@@ -740,6 +744,33 @@ gtk_tree_view_column_cell_layout_clear_attributes (GtkCellLayout *cell_layout
}
static void
+gtk_tree_view_column_cell_layout_reorder (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ gint position)
+{
+ GList *link;
+ GtkTreeViewColumn *column;
+ GtkTreeViewColumnCellInfo *info;
+
+ g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (cell_layout));
+ column = GTK_TREE_VIEW_COLUMN (cell_layout);
+
+ info = gtk_tree_view_column_get_cell_info (column, cell);
+
+ g_return_if_fail (info != NULL);
+ g_return_if_fail (position >= 0);
+
+ link = g_list_find (column->cell_list, info);
+
+ g_return_if_fail (link != NULL);
+
+ column->cell_list = g_list_remove_link (column->cell_list, link);
+ column->cell_list = g_list_insert (column->cell_list, info, position);
+
+ gtk_widget_queue_draw (column->tree_view);
+}
+
+static void
gtk_tree_view_column_clear_attributes_by_info (GtkTreeViewColumn *tree_column,
GtkTreeViewColumnCellInfo *info)
{