]> Pileus Git - ~andy/gtk/commitdiff
Fixes #108458.
authorKristian Rietveld <kris@gtk.org>
Fri, 19 Dec 2003 22:47:20 +0000 (22:47 +0000)
committerKristian Rietveld <kristian@src.gnome.org>
Fri, 19 Dec 2003 22:47:20 +0000 (22:47 +0000)
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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcelllayout.c
gtk/gtkcelllayout.h
gtk/gtkcellview.c
gtk/gtkcombobox.c
gtk/gtkentrycompletion.c
gtk/gtktreeviewcolumn.c

index 5e701375dc02b87f0c139a1b20695e35120eee3e..a8ad19a0f846b025f48587cfa6e873baffcbf264 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+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.
+
 Fri Dec 19 22:18:19 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): use strstr
index 5e701375dc02b87f0c139a1b20695e35120eee3e..a8ad19a0f846b025f48587cfa6e873baffcbf264 100644 (file)
@@ -1,3 +1,21 @@
+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.
+
 Fri Dec 19 22:18:19 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): use strstr
index 5e701375dc02b87f0c139a1b20695e35120eee3e..a8ad19a0f846b025f48587cfa6e873baffcbf264 100644 (file)
@@ -1,3 +1,21 @@
+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.
+
 Fri Dec 19 22:18:19 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): use strstr
index 5e701375dc02b87f0c139a1b20695e35120eee3e..a8ad19a0f846b025f48587cfa6e873baffcbf264 100644 (file)
@@ -1,3 +1,21 @@
+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.
+
 Fri Dec 19 22:18:19 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): use strstr
index 5e701375dc02b87f0c139a1b20695e35120eee3e..a8ad19a0f846b025f48587cfa6e873baffcbf264 100644 (file)
@@ -1,3 +1,21 @@
+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.
+
 Fri Dec 19 22:18:19 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): use strstr
index 29ccc8936278076460d605f9fc3b2b0b04b0a5d4..6dff24412289f49bc15d2ba6d738f5fc5872521c 100644 (file)
@@ -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);
+}
index 5e60e2e361da3fac7003beed473a7dcb9439321e..2458df3a7660d25292c7ecf79e2798e1f41e580e 100644 (file)
@@ -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
index b307573d609675117a9b447f74c33c01af043c45..7f46555696999b1c308e5e4c691593e0f5c93bb9 100644 (file)
@@ -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 *
index 1155a46d5a920949f9b90536a6d1564dbf64c07b..ab2b9ea99624201be7fb80aa7090b27a404df504 100644 (file)
@@ -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
  */
index de8664e5202efa293a52c363a2ddbb0ae9a68bb0..1bedfe027317bdd779083428c60bacb98fdb185a 100644 (file)
@@ -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,
index 6bd4000e6f0daea757aa3cce12bd55ad979cc5da..6a5d80e4e6771241012f8ef75e502e7511a19b1d 100644 (file)
@@ -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
@@ -739,6 +743,33 @@ gtk_tree_view_column_cell_layout_clear_attributes (GtkCellLayout    *cell_layout
   gtk_tree_view_column_clear_attributes_by_info (column, info);
 }
 
+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)