diff options
author | Matthias Clasen <maclas@gmx.de> | 2004-08-07 22:21:25 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-08-07 22:21:25 +0000 |
commit | f82ca65b81d2200ba34a5d4ae70e522895bae342 (patch) | |
tree | c93c78a9cadee6ea620edf64909251eca4fc8143 /gtk/gtkcombobox.c | |
parent | 5f7fbb27c243c651dfecee5f9be22e1a6800e7b0 (diff) | |
download | gtk+-f82ca65b81d2200ba34a5d4ae70e522895bae342.tar.gz |
Use GtkTreeViewRowSeparatorFunc instead of GtkCellRendererSepText.
Sat Aug 7 18:19:03 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserdefault.c (save_folder_combo_create):
(shortcuts_list_create): Use GtkTreeViewRowSeparatorFunc
instead of GtkCellRendererSepText. (#147864)
* gtk/gtkcellrendererseptext.[hc]: Removed.
* gtk/Makefile.am: Remove gtkcellrendererseptext.[hc]
Sat Aug 7 18:15:15 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcombobox.c (gtk_combo_box_menu_row_deleted):
(gtk_combo_box_menu_row_inserted):
(gtk_combo_box_menu_row_changed): Correctly handle
insertion and deletion of separators in menu mode.
Diffstat (limited to 'gtk/gtkcombobox.c')
-rw-r--r-- | gtk/gtkcombobox.c | 108 |
1 files changed, 75 insertions, 33 deletions
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 01d79e86b5..351f72eb6d 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -2361,7 +2361,13 @@ gtk_combo_box_menu_fill_level (GtkComboBox *combo_box, is_separator = FALSE; if (is_separator) - item = gtk_separator_menu_item_new (); + { + item = gtk_separator_menu_item_new (); + g_object_set_data_full (G_OBJECT (item), + "gtk-combo-box-item-path", + gtk_tree_model_get_path (model, &iter), + (GDestroyNotify)gtk_tree_path_free); + } else { item = gtk_cell_view_menu_item_new (combo_box, model, &iter); @@ -2523,8 +2529,7 @@ static void gtk_combo_box_relayout (GtkComboBox *combo_box) { GList *list, *j; - GtkWidget *menu, *item; - gint row, col, width; + GtkWidget *menu; menu = combo_box->priv->popup_widget; @@ -2726,7 +2731,11 @@ find_menu_by_path (GtkWidget *menu, item = NULL; for (i = list; i; i = i->next) { - if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child)) + if (GTK_IS_SEPARATOR_MENU_ITEM (i->data)) + { + mpath = gtk_tree_path_copy (g_object_get_data (G_OBJECT (i->data), "gtk-combo-box-item-path")); + } + else if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child)) { if (skip) { @@ -2735,32 +2744,35 @@ find_menu_by_path (GtkWidget *menu, } mpath = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (GTK_BIN (i->data)->child)); - /* this case is necessary, since the row reference of - * the cell view may already be updated after a deletion - */ - if (!mpath) - { - item = i->data; - break; - } - if (gtk_tree_path_compare (mpath, path) == 0) + } + else + continue; + + /* this case is necessary, since the row reference of + * the cell view may already be updated after a deletion + */ + if (!mpath) + { + item = i->data; + break; + } + if (gtk_tree_path_compare (mpath, path) == 0) + { + gtk_tree_path_free (mpath); + item = i->data; + break; + } + if (gtk_tree_path_is_ancestor (mpath, path)) + { + submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data)); + if (submenu != NULL) { gtk_tree_path_free (mpath); - item = i->data; + item = find_menu_by_path (submenu, path, TRUE); break; } - if (gtk_tree_path_is_ancestor (mpath, path)) - { - submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data)); - if (submenu != NULL) - { - gtk_tree_path_free (mpath); - item = find_menu_by_path (submenu, path, TRUE); - break; - } - } - gtk_tree_path_free (mpath); } + gtk_tree_path_free (mpath); } g_list_free (list); @@ -2808,6 +2820,7 @@ gtk_combo_box_menu_row_inserted (GtkTreeModel *model, GtkTreePath *ppath; GtkTreeIter piter; gint depth, pos; + gboolean is_separator; if (!combo_box->priv->popup_widget) return; @@ -2854,13 +2867,30 @@ gtk_combo_box_menu_row_inserted (GtkTreeModel *model, pos += 1; } - item = gtk_cell_view_menu_item_new (combo_box, model, iter); - gtk_widget_show (item); + if (combo_box->priv->row_separator_func) + is_separator = (*combo_box->priv->row_separator_func) (model, iter, + combo_box->priv->row_separator_data); + else + is_separator = FALSE; - g_signal_connect (item, "activate", - G_CALLBACK (gtk_combo_box_menu_item_activate), - combo_box); + if (is_separator) + { + item = gtk_separator_menu_item_new (); + g_object_set_data_full (G_OBJECT (item), + "gtk-combo-box-item-path", + gtk_tree_path_copy (path), + (GDestroyNotify)gtk_tree_path_free); + } + else + { + item = gtk_cell_view_menu_item_new (combo_box, model, iter); + + g_signal_connect (item, "activate", + G_CALLBACK (gtk_combo_box_menu_item_activate), + combo_box); + } + gtk_widget_show (item); gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, pos); } @@ -2902,16 +2932,28 @@ gtk_combo_box_menu_row_changed (GtkTreeModel *model, GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); GtkWidget *item; gint width; + gboolean is_separator; if (!combo_box->priv->popup_widget) return; - if (combo_box->priv->wrap_width) + item = find_menu_by_path (combo_box->priv->popup_widget, path, FALSE); + + if (combo_box->priv->row_separator_func) + is_separator = (*combo_box->priv->row_separator_func) (model, iter, + combo_box->priv->row_separator_data); + else + is_separator = FALSE; + + if (is_separator != GTK_IS_SEPARATOR_MENU_ITEM (item)) { - item = find_menu_by_path (combo_box->priv->popup_widget, path, FALSE); - gtk_combo_box_relayout_item (combo_box, item, iter, NULL); + gtk_combo_box_menu_row_deleted (model, path, combo_box); + gtk_combo_box_menu_row_inserted (model, path, iter, combo_box); } + if (combo_box->priv->wrap_width) + gtk_combo_box_relayout_item (combo_box, item, iter, NULL); + width = gtk_combo_box_calc_requested_width (combo_box, path); if (width > combo_box->priv->width) |