]> Pileus Git - ~andy/gtk/commitdiff
Change the api for separators to use a separator function instead of a
authorMatthias Clasen <mclasen@redhat.com>
Fri, 30 Jul 2004 20:55:17 +0000 (20:55 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 30 Jul 2004 20:55:17 +0000 (20:55 +0000)
2004-07-30  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkcombobox.h:
* gtk/gtkcombobox.c: Change the api for separators to use a
separator function instead of a boolean column.

* tests/testcombo.c: Update to match the api change.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtkcombobox.c
gtk/gtkcombobox.h
tests/testcombo.c

index 618eba713a6f2d4d1e0cf0cb73e017f6d238fca9..e260f9144528081ed86aec46bde856a7a2bdfca0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-07-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkcombobox.h: 
+       * gtk/gtkcombobox.c: Change the api for separators to use a 
+       separator function instead of a boolean column.
+
+       * tests/testcombo.c: Update to match the api change.
+
 Fri Jul 30 02:21:41 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): 
index 618eba713a6f2d4d1e0cf0cb73e017f6d238fca9..e260f9144528081ed86aec46bde856a7a2bdfca0 100644 (file)
@@ -1,3 +1,11 @@
+2004-07-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkcombobox.h: 
+       * gtk/gtkcombobox.c: Change the api for separators to use a 
+       separator function instead of a boolean column.
+
+       * tests/testcombo.c: Update to match the api change.
+
 Fri Jul 30 02:21:41 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): 
index 618eba713a6f2d4d1e0cf0cb73e017f6d238fca9..e260f9144528081ed86aec46bde856a7a2bdfca0 100644 (file)
@@ -1,3 +1,11 @@
+2004-07-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkcombobox.h: 
+       * gtk/gtkcombobox.c: Change the api for separators to use a 
+       separator function instead of a boolean column.
+
+       * tests/testcombo.c: Update to match the api change.
+
 Fri Jul 30 02:21:41 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): 
index 618eba713a6f2d4d1e0cf0cb73e017f6d238fca9..e260f9144528081ed86aec46bde856a7a2bdfca0 100644 (file)
@@ -1,3 +1,11 @@
+2004-07-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkcombobox.h: 
+       * gtk/gtkcombobox.c: Change the api for separators to use a 
+       separator function instead of a boolean column.
+
+       * tests/testcombo.c: Update to match the api change.
+
 Fri Jul 30 02:21:41 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): 
index 14d9e39cbac26508c9f8378cd1cda9ada3e023c5..b180d6aa7befd942e333f63d874a8e7add8f45e1 100644 (file)
@@ -1,3 +1,7 @@
+2004-07-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtk-sections.txt: Update to combo box api changes.
+
 2004-07-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtk-sections.txt: Add gtk_combo_box_get_popup_accessible.
index ef6c0e6634a0b6d8fc6758686f8ebf93ea786dfe..6bce20a25661724a380076d5e8a00c5696977da3 100644 (file)
@@ -735,8 +735,8 @@ gtk_combo_box_get_active_text
 gtk_combo_box_popup
 gtk_combo_box_popdown
 gtk_combo_box_get_popup_accessible
-gtk_combo_box_get_row_separator_column
-gtk_combo_box_set_row_separator_column
+gtk_combo_box_get_row_separator_func
+gtk_combo_box_set_row_separator_func
 gtk_combo_box_set_add_tearoffs
 gtk_combo_box_get_add_tearoffs
 <SUBSECTION Standard>
index 16f5f7bb2c1848870df1234843563c964e36f070..bfae4b0e7350e476d3c8964d32c2886ecc7899be 100644 (file)
@@ -74,7 +74,6 @@ struct _GtkComboBoxPrivate
 
   gint col_column;
   gint row_column;
-  gint separator_column;
 
   gint wrap_width;
 
@@ -113,6 +112,10 @@ struct _GtkComboBoxPrivate
   guint is_cell_renderer : 1;
   guint editing_canceled : 1;
   guint auto_scroll : 1;
+
+  GtkTreeViewRowSeparatorFunc row_separator_func;
+  gpointer                    row_separator_data;
+  GtkDestroyNotify            row_separator_destroy;
 };
 
 /* While debugging this evil code, I have learned that
@@ -184,7 +187,6 @@ enum {
   PROP_WRAP_WIDTH,
   PROP_ROW_SPAN_COLUMN,
   PROP_COLUMN_SPAN_COLUMN,
-  PROP_ROW_SEPARATOR_COLUMN,
   PROP_ACTIVE,
   PROP_ADD_TEAROFFS,
   PROP_HAS_FRAME
@@ -541,15 +543,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
                                                      -1,
                                                      G_PARAM_READWRITE));
 
-  g_object_class_install_property (object_class,
-                                   PROP_ROW_SEPARATOR_COLUMN,
-                                   g_param_spec_int ("row_separator_column",
-                                                     P_("Row separator column"),
-                                                     P_("Boolean TreeModel column specifying which rows are separators"),
-                                                     -1,
-                                                     G_MAXINT,
-                                                     -1,
-                                                     G_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                    PROP_ACTIVE,
@@ -639,7 +632,6 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   combo_box->priv->active_item = -1;
   combo_box->priv->col_column = -1;
   combo_box->priv->row_column = -1;
-  combo_box->priv->separator_column = -1;
 
   combo_box->priv->add_tearoffs = FALSE;
   combo_box->priv->has_frame = TRUE;
@@ -673,10 +665,6 @@ gtk_combo_box_set_property (GObject      *object,
         gtk_combo_box_set_column_span_column (combo_box, g_value_get_int (value));
         break;
 
-      case PROP_ROW_SEPARATOR_COLUMN:
-        gtk_combo_box_set_row_separator_column (combo_box, g_value_get_int (value));
-        break;
-
       case PROP_ACTIVE:
         gtk_combo_box_set_active (combo_box, g_value_get_int (value));
         break;
@@ -720,10 +708,6 @@ gtk_combo_box_get_property (GObject    *object,
         g_value_set_int (value, combo_box->priv->col_column);
         break;
 
-      case PROP_ROW_SEPARATOR_COLUMN:
-        g_value_set_int (value, combo_box->priv->separator_column);
-        break;
-
       case PROP_ACTIVE:
         g_value_set_int (value, gtk_combo_box_get_active (combo_box));
         break;
@@ -1334,16 +1318,10 @@ tree_column_row_is_sensitive (GtkComboBox *combo_box,
   if (!combo_box->priv->column)
     return TRUE;
 
-  if (combo_box->priv->separator_column != -1)
+  if (combo_box->priv->row_separator_func)
     {
-      gboolean is_separator;
-
-      gtk_tree_model_get (combo_box->priv->model,
-                         iter,
-                         combo_box->priv->separator_column, &is_separator,
-                         -1);
-
-      if (is_separator)
+      if ((*combo_box->priv->row_separator_func) (combo_box->priv->model, iter,
+                                                 combo_box->priv->row_separator_data))
        return FALSE;
     }
 
@@ -2093,12 +2071,12 @@ gtk_combo_box_menu_fill (GtkComboBox *combo_box)
       gboolean is_separator;
 
       path = gtk_tree_path_new_from_indices (i, -1);
-
-      if (combo_box->priv->separator_column != -1)
+      
+      if (combo_box->priv->row_separator_func)
        {
          gtk_tree_model_get_iter (combo_box->priv->model, &iter, path);
-         gtk_tree_model_get (combo_box->priv->model, &iter, 
-                             combo_box->priv->separator_column, &is_separator, -1);
+         is_separator = (*combo_box->priv->row_separator_func) (combo_box->priv->model, &iter,
+                                                                combo_box->priv->row_separator_data);
        }
       else
        is_separator = FALSE;
@@ -2563,21 +2541,6 @@ gtk_combo_box_menu_row_changed (GtkTreeModel *model,
  * list style
  */
 
-static gboolean
-row_is_separator (GtkTreeModel      *model,
-                 GtkTreeIter       *iter,
-                 gpointer           data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
-  gboolean is_separator = FALSE;
-
-  if (combo_box->priv->separator_column != -1)
-    gtk_tree_model_get (combo_box->priv->model, iter, 
-                       combo_box->priv->separator_column, &is_separator, -1);
-
-  return is_separator;
-}
-
 static void
 gtk_combo_box_list_setup (GtkComboBox *combo_box)
 {
@@ -2640,8 +2603,11 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
                                      FALSE);
   gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (combo_box->priv->tree_view),
                                     TRUE);
-  gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (combo_box->priv->tree_view),
-                                       row_is_separator, combo_box, NULL);
+  if (combo_box->priv->row_separator_func)
+    gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (combo_box->priv->tree_view), 
+                                         combo_box->priv->row_separator_func, 
+                                         combo_box->priv->row_separator_data, 
+                                         NULL);
   if (combo_box->priv->model)
     gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view),
                             combo_box->priv->model);
@@ -4351,88 +4317,90 @@ gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
     }
 }
 
+gboolean
+_gtk_combo_box_editing_canceled (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), TRUE);
+
+  return combo_box->priv->editing_canceled;
+}
+
 /**
- * gtk_combo_box_set_row_separator_column:
+ * gtk_combo_box_get_popup_acceSsible:
  * @combo_box: a #GtkComboBox
- * @column: the index of a boolean model column, or -1 to 
- *   turn off separators
  * 
- * Sets the row separator column index. 
- * This model column contains boolean values which indicate 
- * whether a row is to be drawn as a separator or now. 
- * Setting the index to -1 turns off separators.
+ * Gets the accessible object corresponding to the combo box's popup.
+ *
+ * This function is mostly intended for use by accessibility technologies;
+ * applications should have little use for it.
  *
  * Since: 2.6
  **/
-void
-gtk_combo_box_set_row_separator_column (GtkComboBox *combo_box,
-                                       gint         column)
+AtkObject*
+gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box)
 {
-  gint col;
+  AtkObject *atk_obj;
 
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  col = gtk_tree_model_get_n_columns (combo_box->priv->model);
-  g_return_if_fail (column >= -1 && column < col);
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
 
-  if (combo_box->priv->separator_column != column)
+  if (combo_box->priv->popup_widget)
     {
-      combo_box->priv->separator_column = column;
-
-      gtk_widget_queue_draw (GTK_WIDGET (combo_box));
-
-      g_object_notify (G_OBJECT (combo_box), "row_separator_column");
+      atk_obj = gtk_widget_get_accessible (combo_box->priv->popup_widget);
+      return atk_obj;
     }
+
+  return NULL;
 }
 
 /**
- * gtk_combo_box_get_row_separator_column:
+ * gtk_combo_box_get_row_separator_func:
  * @combo_box: a #GtkComboBox
  * 
- * Returns the current row separator column index.
+ * Returns the current row separator function.
  * 
- * Return value: the row separator column index
+ * Return value: the current row separator function.
  *
  * Since: 2.6
  **/
-gint
-gtk_combo_box_get_row_separator_column (GtkComboBox *combo_box)
+GtkTreeViewRowSeparatorFunc 
+gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box)
 {
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
-
-  return combo_box->priv->separator_column;
-}
-
-gboolean
-_gtk_combo_box_editing_canceled (GtkComboBox *combo_box)
-{
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), TRUE);
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
 
-  return combo_box->priv->editing_canceled;
+  return combo_box->priv->row_separator_func;
 }
 
 /**
- * gtk_combo_box_get_popup_acceSsible:
+ * gtk_combo_box_set_row_separator_func:
  * @combo_box: a #GtkComboBox
+ * @func: a #GtkTreeViewRowSeparatorFunc
+ * @data: user data to pass to @func, or %NULL
+ * @destroy: destroy notifier for @data, or %NULL
  * 
- * Gets the accessible object corresponding to the combo box's popup.
- *
- * This function is mostly intended for use by accessibility technologies;
- * applications should have little use for it.
+ * Sets the row separator function, which is used to determine
+ * whether a row should be drawn as a separator. If the row separator
+ * function is %NULL, no separators are drawn. This is the default value.
  *
  * Since: 2.6
  **/
-AtkObject*
-gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box)
+void
+gtk_combo_box_set_row_separator_func (GtkComboBox                 *combo_box,
+                                     GtkTreeViewRowSeparatorFunc  func,
+                                     gpointer                     data,
+                                     GtkDestroyNotify             destroy)
 {
-  AtkObject *atk_obj;
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
 
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
+  if (combo_box->priv->row_separator_destroy)
+    (* combo_box->priv->row_separator_destroy) (combo_box->priv->row_separator_data);
 
-  if (combo_box->priv->popup_widget)
-    {
-      atk_obj = gtk_widget_get_accessible (combo_box->priv->popup_widget);
-      return atk_obj;
-    }
+  combo_box->priv->row_separator_func = func;
+  combo_box->priv->row_separator_data = data;
+  combo_box->priv->row_separator_destroy = destroy;
 
-  return NULL;
+  if (combo_box->priv->tree_view)
+    gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (combo_box->priv->tree_view), 
+                                         func, data, NULL);
+
+  gtk_widget_queue_draw (GTK_WIDGET (combo_box));
 }
index bdbd38b80dffaec908117a07790cd8873ec01cb1..79aea584c3030e8efff01ede88a5c961bb709774 100644 (file)
@@ -94,9 +94,11 @@ void          gtk_combo_box_set_model        (GtkComboBox     *combo_box,
                                               GtkTreeModel    *model);
 GtkTreeModel *gtk_combo_box_get_model        (GtkComboBox     *combo_box);
 
-void          gtk_combo_box_set_row_separator_column (GtkComboBox *combo_box,
-                                                     gint         column);
-gint          gtk_combo_box_get_row_separator_column (GtkComboBox *combo_box);
+GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func (GtkComboBox                *combo_box);
+void                        gtk_combo_box_set_row_separator_func (GtkComboBox                *combo_box,
+                                                                 GtkTreeViewRowSeparatorFunc func,
+                                                                 gpointer                    data,
+                                                                 GtkDestroyNotify            destroy);
 
 /* convenience -- text */
 GtkWidget    *gtk_combo_box_new_text         (void);
index fd8555485acad0794a19f8a9f412e47cc863a2f3..b666b9401184509b4c7a21419fbc4c0b7465d76e 100644 (file)
@@ -128,7 +128,7 @@ create_blaat ()
 
         cellview = gtk_cell_view_new ();
 
-        store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN);
+        store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
 
         pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_DIALOG_WARNING,
                                          GTK_ICON_SIZE_BUTTON, NULL);
@@ -136,7 +136,6 @@ create_blaat ()
         gtk_list_store_set (store, &iter,
                             0, pixbuf,
                             1, "gtk-stock-dialog-warning",
-                           2, FALSE,
                             -1);
 
         pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_STOP,
@@ -145,7 +144,6 @@ create_blaat ()
         gtk_list_store_set (store, &iter,
                             0, pixbuf,
                             1, "gtk-stock-stop",
-                           2, FALSE,
                             -1);
 
         pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_NEW,
@@ -154,7 +152,6 @@ create_blaat ()
         gtk_list_store_set (store, &iter,
                             0, pixbuf,
                             1, "gtk-stock-new",
-                           2, FALSE,
                             -1);
 
         pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_CLEAR,
@@ -163,14 +160,12 @@ create_blaat ()
         gtk_list_store_set (store, &iter,
                             0, pixbuf,
                             1, "gtk-stock-clear",
-                           2, FALSE,
                             -1);
 
         gtk_list_store_append (store, &iter);
         gtk_list_store_set (store, &iter,
                             0, NULL,
                             1, "separator",
-                           2, TRUE,
                             -1);
 
         pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_OPEN,
@@ -179,7 +174,6 @@ create_blaat ()
         gtk_list_store_set (store, &iter,
                             0, pixbuf,
                             1, "gtk-stock-open",
-                           2, FALSE,
                             -1);
 
         gtk_widget_destroy (cellview);
@@ -223,6 +217,22 @@ set_sensitive (GtkCellLayout   *cell_layout,
   g_object_set (cell, "sensitive", sensitive, NULL);
 }
 
+static gboolean
+is_separator (GtkTreeModel *model,
+             GtkTreeIter  *iter,
+             gpointer      data)
+{
+  GtkTreePath *path;
+  gboolean result;
+
+  path = gtk_tree_model_get_path (model, iter);
+  result = gtk_tree_path_get_indices (path)[0] == 4;
+  gtk_tree_path_free (path);
+
+  return result;
+  
+}
+
 int
 main (int argc, char **argv)
 {
@@ -318,7 +328,8 @@ main (int argc, char **argv)
                                            renderer,
                                            set_sensitive,
                                            NULL, NULL);
-       gtk_combo_box_set_row_separator_column (GTK_COMBO_BOX (combobox), 2);
+       gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
+                                             is_separator, NULL, NULL);
                                                
         gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);