From 7d3ac8fa3791e4f5a9e07dda32c2e14596693641 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 28 Jan 2009 01:08:51 +0100 Subject: [PATCH] Move {sokoke,katze}_tree_view_get_selected_iter proper --- katze/katze-utils.c | 34 ++++++++++++++++++++++++++++++++++ katze/katze-utils.h | 5 +++++ midori/midori-browser.c | 22 +++++++++++----------- midori/sokoke.c | 33 --------------------------------- midori/sokoke.h | 5 ----- panels/midori-extensions.c | 2 +- 6 files changed, 51 insertions(+), 50 deletions(-) diff --git a/katze/katze-utils.c b/katze/katze-utils.c index df5be8f3..cebbf074 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -572,6 +572,40 @@ katze_pixbuf_new_from_buffer (const guchar* buffer, return pixbuf; } +/** + * katze_tree_view_get_selected_iter: + * @treeview: a #GtkTreeView + * @model: a pointer to store the model, or %NULL + * @iter: a pointer to store the iter, or %NULL + * + * Determines whether there is a selection in @treeview + * and sets the @iter to the current selection. + * + * If there is a selection and @model is not %NULL, it is + * set to the model, mainly for convenience. + * + * Either @model or @iter or both can be %NULL in which case + * no value will be assigned in any case. + * + * Return value: %TRUE if there is a selection + * + * Since: 0.1.3 + **/ +gboolean +katze_tree_view_get_selected_iter (GtkTreeView* treeview, + GtkTreeModel** model, + GtkTreeIter* iter) +{ + GtkTreeSelection* selection; + + g_return_val_if_fail (GTK_IS_TREE_VIEW (treeview), FALSE); + + if ((selection = gtk_tree_view_get_selection (treeview))) + if (gtk_tree_selection_get_selected (selection, model, iter)) + return TRUE; + return FALSE; +} + /** * katze_object_has_property: * @object: a #GObject diff --git a/katze/katze-utils.h b/katze/katze-utils.h index d38f8c92..f5f73b6c 100644 --- a/katze/katze-utils.h +++ b/katze/katze-utils.h @@ -84,6 +84,11 @@ katze_pixbuf_new_from_buffer (const guchar* buffer, const gchar* mime_type, GError** error); +gboolean +katze_tree_view_get_selected_iter (GtkTreeView* treeview, + GtkTreeModel** model, + GtkTreeIter* iter); + gboolean katze_object_has_property (gpointer object, const gchar* property); diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 6123046b..229e053c 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2371,7 +2371,7 @@ midori_panel_bookmarks_cursor_or_row_changed_cb (GtkTreeView* tree_view, KatzeItem* item; gboolean is_separator; - if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter)) + if (katze_tree_view_get_selected_iter (tree_view, &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); @@ -2527,7 +2527,7 @@ midori_browser_history_delete (MidoriBrowser* browser) GtkAction* location_action; treeview = GTK_TREE_VIEW (browser->panel_history); - if (sokoke_tree_view_get_selected_iter (treeview, &model, &iter)) + if (katze_tree_view_get_selected_iter (treeview, &model, &iter)) { location_action = _action_by_name (browser, "Location"); gtk_tree_model_get (model, &iter, 0, &item, -1); @@ -2617,7 +2617,7 @@ midori_panel_bookmarks_button_release_event_cb (GtkWidget* widget, if (event->button != 2 && event->button != 3) return FALSE; - if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter)) + if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); uri = katze_item_get_uri (item); @@ -2644,7 +2644,7 @@ midori_panel_bookmarks_popup_menu_cb (GtkWidget* widget, GtkTreeIter iter; KatzeItem* item; - if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter)) + if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); midori_browser_bookmark_popup (widget, NULL, item, FALSE, browser); @@ -2684,7 +2684,7 @@ midori_panel_history_cursor_or_row_changed_cb (GtkTreeView* tree_view, KatzeItem* item; gboolean is_page; - if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter)) + if (katze_tree_view_get_selected_iter (tree_view, &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); @@ -2720,7 +2720,7 @@ midori_panel_history_button_release_event_cb (GtkWidget* widget, if (event->button != 2 && event->button != 3) return FALSE; - if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), + if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); @@ -2757,7 +2757,7 @@ midori_panel_history_key_release_event_cb (GtkWidget* widget, return FALSE; treeview = GTK_TREE_VIEW (widget); - if (sokoke_tree_view_get_selected_iter (treeview, &model, &iter)) + if (katze_tree_view_get_selected_iter (treeview, &model, &iter)) { location_action = _action_by_name (browser, "Location"); gtk_tree_model_get (model, &iter, 0, &item, -1); @@ -2777,7 +2777,7 @@ midori_panel_history_popup_menu_cb (GtkWidget* widget, GtkTreeIter iter; KatzeItem* item; - if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), + if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); @@ -3213,7 +3213,7 @@ _action_history_add_bookmark_activate (GtkAction* action, KatzeItem* item; tree_view = GTK_TREE_VIEW (browser->panel_history); - if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter)) + if (katze_tree_view_get_selected_iter (tree_view, &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); if (!KATZE_IS_ARRAY (item)) @@ -3257,7 +3257,7 @@ _action_bookmark_edit_activate (GtkAction* action, KatzeItem* item; tree_view = GTK_TREE_VIEW (browser->panel_bookmarks); - if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter)) + if (katze_tree_view_get_selected_iter (tree_view, &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); if (KATZE_IS_ARRAY (item) || katze_item_get_uri (item)) @@ -3276,7 +3276,7 @@ _action_bookmark_delete_activate (GtkAction* action, KatzeArray* parent; tree_view = GTK_TREE_VIEW (browser->panel_bookmarks); - if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter)) + if (katze_tree_view_get_selected_iter (tree_view, &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); parent = katze_item_get_parent (item); diff --git a/midori/sokoke.c b/midori/sokoke.c index 3aa80561..78f822cd 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -629,39 +629,6 @@ sokoke_image_menu_item_new_ellipsized (const gchar* label) return katze_image_menu_item_new_ellipsized (label); } -/** - * sokoke_tree_view_get_selected_iter: - * @tree_view: a #GtkTreeView - * @model: a pointer to store the model, or %NULL - * @iter: a pointer to store the iter, or %NULL - * - * Determines whether there is a selection in the tree view - * and sets the @iter to the current selection. - * - * If there is a selection and @model is not %NULL, it is - * set to the model, mainly for convenience. - * - * Either @model or @iter or both can be %NULL in which case - * no value will be assigned in any case. - * - * Return value: %TRUE if there is a selection - **/ -gboolean -sokoke_tree_view_get_selected_iter (GtkTreeView* tree_view, - GtkTreeModel** model, - GtkTreeIter* iter) -{ - GtkTreeSelection* selection; - - g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE); - - selection = gtk_tree_view_get_selection (tree_view); - if (selection) - if (gtk_tree_selection_get_selected (selection, model, iter)) - return TRUE; - return FALSE; -} - /** * sokoke_time_t_to_julian: * @timestamp: a time_t timestamp value diff --git a/midori/sokoke.h b/midori/sokoke.h index 3f1fbb30..13190475 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -121,11 +121,6 @@ sokoke_action_create_popup_menu_item (GtkAction* action); GtkWidget* sokoke_image_menu_item_new_ellipsized (const gchar* label); -gboolean -sokoke_tree_view_get_selected_iter (GtkTreeView* tree_view, - GtkTreeModel** model, - GtkTreeIter* iter); - gint64 sokoke_time_t_to_julian (const time_t* timestamp); diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c index c615c0d7..3a9e96df 100644 --- a/panels/midori-extensions.c +++ b/panels/midori-extensions.c @@ -104,7 +104,7 @@ midori_extensions_button_status_clicked_cb (GtkToolItem* toolitem, treeview = GTK_TREE_VIEW (extensions->treeview); - if (sokoke_tree_view_get_selected_iter (treeview, &model, &iter)) + if (katze_tree_view_get_selected_iter (treeview, &model, &iter)) { GtkToolItem* button_enable = gtk_toolbar_get_nth_item ( GTK_TOOLBAR (extensions->toolbar), 1); -- 2.39.5