Move {sokoke,katze}_tree_view_get_selected_iter proper

This commit is contained in:
Christian Dywan 2009-01-28 01:08:51 +01:00
parent 7f5ad69b86
commit 7d3ac8fa37
6 changed files with 51 additions and 50 deletions

View file

@ -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

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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);