diff options
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 33 | ||||
-rw-r--r-- | src/bookmarks/ephy-node-view.c | 43 | ||||
-rw-r--r-- | src/bookmarks/ephy-node-view.h | 2 |
3 files changed, 58 insertions, 20 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 3992cc0e1..b9782120f 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -200,11 +200,11 @@ static void cmd_rename (EggAction *action, EphyBookmarksEditor *editor) { - if (gtk_widget_is_focus (editor->priv->bm_view)) + if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->bm_view))) { ephy_node_view_edit (EPHY_NODE_VIEW (editor->priv->bm_view)); } - else if (gtk_widget_is_focus (editor->priv->key_view)) + else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->key_view))) { ephy_node_view_edit (EPHY_NODE_VIEW (editor->priv->key_view)); } @@ -279,11 +279,11 @@ static void cmd_delete (EggAction *action, EphyBookmarksEditor *editor) { - if (gtk_widget_is_focus (editor->priv->bm_view)) + if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->bm_view))) { ephy_node_view_remove (EPHY_NODE_VIEW (editor->priv->bm_view)); } - else if (gtk_widget_is_focus (editor->priv->key_view)) + else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->key_view))) { ephy_node_view_remove (EPHY_NODE_VIEW (editor->priv->key_view)); } @@ -356,7 +356,7 @@ cmd_select_all (EggAction *action, { gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); } - else if (gtk_widget_is_focus (bm_view)) + else if (ephy_node_view_is_target (EPHY_NODE_VIEW (bm_view))) { GtkTreeSelection *sel; @@ -481,8 +481,7 @@ ephy_bookmarks_editor_node_activated_cb (GtkWidget *view, } static void -ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor, - GtkWidget *selected_view) +ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) { gboolean open_in_window, open_in_tab, rename, delete, properties; @@ -497,16 +496,10 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor, GList *selected; GtkWidget *focus_widget; - if (selected_view) - { - bmk_focus = (selected_view == editor->priv->bm_view); - key_focus = (selected_view == editor->priv->key_view); - } - else - { - bmk_focus = gtk_widget_is_focus (editor->priv->bm_view); - key_focus = gtk_widget_is_focus (editor->priv->key_view); - } + bmk_focus = ephy_node_view_is_target + (EPHY_NODE_VIEW (editor->priv->bm_view)); + key_focus = ephy_node_view_is_target + (EPHY_NODE_VIEW (editor->priv->key_view)); focus_widget = gtk_window_get_focus (GTK_WINDOW (editor)); @@ -598,7 +591,7 @@ ephy_bookmarks_editor_show_popup_cb (GtkWidget *view, widget = egg_menu_merge_get_widget (editor->priv->ui_merge, "/popups/EphyBookmarkEditorPopup"); - ephy_bookmarks_editor_update_menu (editor, view); + ephy_bookmarks_editor_update_menu (editor); gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2, gtk_get_current_event_time ()); } @@ -716,7 +709,7 @@ keyword_node_show_popup_cb (GtkWidget *view, EphyBookmarksEditor *editor) widget = egg_menu_merge_get_widget (editor->priv->ui_merge, "/popups/EphyBookmarkKeywordPopup"); - ephy_bookmarks_editor_update_menu (editor, view); + ephy_bookmarks_editor_update_menu (editor); gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2, gtk_get_current_event_time ()); } @@ -831,7 +824,7 @@ static void menu_activate_cb (EphyNodeView *view, EphyBookmarksEditor *editor) { - ephy_bookmarks_editor_update_menu (editor, NULL); + ephy_bookmarks_editor_update_menu (editor); } static void diff --git a/src/bookmarks/ephy-node-view.c b/src/bookmarks/ephy-node-view.c index f82b40228..cb96f72b1 100644 --- a/src/bookmarks/ephy-node-view.c +++ b/src/bookmarks/ephy-node-view.c @@ -22,6 +22,7 @@ #include <gtk/gtkcellrenderertext.h> #include <gtk/gtkcellrendererpixbuf.h> #include <gtk/gtkwindow.h> +#include <gdk/gdkkeysyms.h> #include <libgnome/gnome-i18n.h> #include "eggtreemodelfilter.h" @@ -84,6 +85,8 @@ enum PROP_FILTER }; +static EphyNodeView *target_view; + static GObjectClass *parent_class = NULL; static guint ephy_node_view_signals[LAST_SIGNAL] = { 0 }; @@ -290,6 +293,22 @@ get_node_from_path (EphyNodeView *view, GtkTreePath *path) } static gboolean +ephy_node_view_key_press_cb (GtkTreeView *treeview, + GdkEventKey *event, + EphyNodeView *view) +{ + if ((event->state & GDK_SHIFT_MASK) && + (event->keyval == GDK_F10)) + { + g_signal_emit (G_OBJECT (view), ephy_node_view_signals[SHOW_POPUP], 0); + + return TRUE; + } + + return FALSE; +} + +static gboolean ephy_node_view_button_press_cb (GtkTreeView *treeview, GdkEventButton *event, EphyNodeView *view) @@ -319,7 +338,9 @@ ephy_node_view_button_press_cb (GtkTreeView *treeview, view->priv->selected_node = get_node_from_path (view, path); } + target_view = view; g_signal_emit (G_OBJECT (view), ephy_node_view_signals[SHOW_POPUP], 0); + target_view = NULL; } } @@ -420,6 +441,11 @@ ephy_node_view_construct (EphyNodeView *view) view, 0); g_signal_connect_object (G_OBJECT (view), + "key_press_event", + G_CALLBACK (ephy_node_view_key_press_cb), + view, + 0); + g_signal_connect_object (G_OBJECT (view), "row_activated", G_CALLBACK (ephy_node_view_row_activated_cb), view, @@ -970,6 +996,23 @@ ephy_node_view_is_editing (EphyNodeView *view) } gboolean +ephy_node_view_is_target (EphyNodeView *view) +{ + if (target_view == view) + { + return TRUE; + } + else if (target_view != NULL) + { + return FALSE; + } + else + { + return gtk_widget_is_focus (GTK_WIDGET (view)); + } +} + +gboolean ephy_node_view_has_selection (EphyNodeView *view, gboolean *multiple) { GtkTreeSelection *selection; diff --git a/src/bookmarks/ephy-node-view.h b/src/bookmarks/ephy-node-view.h index f41b59489..43006449e 100644 --- a/src/bookmarks/ephy-node-view.h +++ b/src/bookmarks/ephy-node-view.h @@ -94,6 +94,8 @@ void ephy_node_view_edit (EphyNodeView *view); gboolean ephy_node_view_is_editing (EphyNodeView *view); +gboolean ephy_node_view_is_target (EphyNodeView *view); + G_END_DECLS #endif /* EPHY_NODE_VIEW_H */ |