From 5d372c116dd32bcc76fa07d8758ba84304f50128 Mon Sep 17 00:00:00 2001 From: Tomasz Szatkowski Date: Sun, 17 Apr 2011 22:56:30 +0200 Subject: [PATCH] History panel buttons sensitive with selection Fixes: https://bugs.launchpad.net/midori/+bug/711482 --- panels/midori-bookmarks.c | 1 - panels/midori-history.c | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index 40e13fcf..adfe2cf9 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -434,7 +434,6 @@ midori_bookmarks_delete_clicked_cb (GtkWidget* toolitem, midori_bookmarks_remove_item_cb, bookmarks); g_object_unref (item); } - midori_bookmarks_toolbar_update (bookmarks); } static GtkWidget* diff --git a/panels/midori-history.c b/panels/midori-history.c index f8f432bb..d575e6e8 100644 --- a/panels/midori-history.c +++ b/panels/midori-history.c @@ -154,6 +154,16 @@ midori_history_format_date (KatzeItem *item) return sdate; } +static void +midori_history_toolbar_update (MidoriHistory *history) +{ + gboolean selected; + + selected = katze_tree_view_get_selected_iter ( + GTK_TREE_VIEW (history->treeview), NULL, NULL); + gtk_widget_set_sensitive (GTK_WIDGET (history->delete), selected); +} + static void midori_history_remove_item_from_db (MidoriHistory* history, KatzeItem* item) @@ -370,6 +380,7 @@ midori_history_get_toolbar (MidoriViewable* viewable) gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); gtk_widget_show (GTK_WIDGET (toolitem)); history->clear = GTK_WIDGET (toolitem); + midori_history_toolbar_update (history); g_signal_connect (history->bookmark, "destroy", G_CALLBACK (gtk_widget_destroyed), &history->bookmark); g_signal_connect (history->delete, "destroy", @@ -903,6 +914,12 @@ midori_history_filter_entry_clear_cb (GtkEntry* entry, gtk_entry_set_text (entry, ""); } +static void +midori_history_selection_changed_cb (GtkTreeView* treeview, + MidoriHistory* history) +{ + midori_history_toolbar_update (history); +} static void midori_history_init (MidoriHistory* history) @@ -914,6 +931,7 @@ midori_history_init (MidoriHistory* history) GtkTreeViewColumn* column; GtkCellRenderer* renderer_pixbuf; GtkCellRenderer* renderer_text; + GtkTreeSelection* selection; /* Create the filter entry */ entry = gtk_icon_entry_new (); @@ -968,6 +986,10 @@ midori_history_init (MidoriHistory* history) "signal::popup-menu", midori_history_popup_menu_cb, history, NULL); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); + g_signal_connect_after (selection, "changed", + G_CALLBACK (midori_history_selection_changed_cb), + history); gtk_widget_show (treeview); gtk_box_pack_start (GTK_BOX (history), treeview, TRUE, TRUE, 0); history->treeview = treeview;