summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-07-30 20:55:17 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-07-30 20:55:17 +0000
commit1f93c4359cee608ffd2914ae6ff6c5635bdce737 (patch)
tree0830f9be3f9e24839390406c15f4b2e3ca94e88f
parent9b7e23e9f6f1e89dd669e0ab145c4ce87b8becc2 (diff)
downloadgdk-pixbuf-1f93c4359cee608ffd2914ae6ff6c5635bdce737.tar.gz
Change the api for separators to use a separator function instead of a
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.
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.pre-2-108
-rw-r--r--ChangeLog.pre-2-68
-rw-r--r--ChangeLog.pre-2-88
-rw-r--r--docs/reference/ChangeLog4
-rw-r--r--docs/reference/gtk/gtk-sections.txt4
-rw-r--r--gtk/gtkcombobox.c168
-rw-r--r--gtk/gtkcombobox.h8
-rw-r--r--tests/testcombo.c27
9 files changed, 130 insertions, 113 deletions
diff --git a/ChangeLog b/ChangeLog
index 618eba713..e260f9144 100644
--- 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):
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 618eba713..e260f9144 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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):
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 618eba713..e260f9144 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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):
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 618eba713..e260f9144 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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):
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index 14d9e39cb..b180d6aa7 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -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.
diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt
index ef6c0e663..6bce20a25 100644
--- a/docs/reference/gtk/gtk-sections.txt
+++ b/docs/reference/gtk/gtk-sections.txt
@@ -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>
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 16f5f7bb2..bfae4b0e7 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -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));
}
diff --git a/gtk/gtkcombobox.h b/gtk/gtkcombobox.h
index bdbd38b80..79aea584c 100644
--- a/gtk/gtkcombobox.h
+++ b/gtk/gtkcombobox.h
@@ -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);
diff --git a/tests/testcombo.c b/tests/testcombo.c
index fd8555485..b666b9401 100644
--- a/tests/testcombo.c
+++ b/tests/testcombo.c
@@ -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);