diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-04-16 01:36:46 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-16 01:36:46 +0800 |
commit | 81cc9fc7c119b8d45c28b0cdf1351e330f445264 (patch) | |
tree | c134ece6621a2360675c52ead30f0efcda34cb5a /src | |
parent | 9d9872cea3a0bc588ee0d64f231d64510906efbb (diff) | |
download | gsoc2013-epiphany-81cc9fc7c119b8d45c28b0cdf1351e330f445264.tar gsoc2013-epiphany-81cc9fc7c119b8d45c28b0cdf1351e330f445264.tar.gz gsoc2013-epiphany-81cc9fc7c119b8d45c28b0cdf1351e330f445264.tar.bz2 gsoc2013-epiphany-81cc9fc7c119b8d45c28b0cdf1351e330f445264.tar.lz gsoc2013-epiphany-81cc9fc7c119b8d45c28b0cdf1351e330f445264.tar.xz gsoc2013-epiphany-81cc9fc7c119b8d45c28b0cdf1351e330f445264.tar.zst gsoc2013-epiphany-81cc9fc7c119b8d45c28b0cdf1351e330f445264.zip |
Fix context menu selection mess, tricky, tricky, tricky. It's all kris
2003-04-15 Marco Pesenti Gritti <marco@it.gnome.org>
* src/bookmarks/ephy-bookmarks-editor.c:
(ephy_bookmarks_editor_update_menu),
(ephy_bookmarks_editor_show_popup_cb),
(keyword_node_show_popup_cb), (menu_activate_cb):
* src/bookmarks/ephy-node-view.c:
(ephy_node_view_selection_changed_cb), (get_node_from_path),
(ephy_node_view_button_press_cb), (ephy_node_view_init),
(ephy_node_view_get_selection), (ephy_node_view_has_selection):
Fix context menu selection mess, tricky,
tricky, tricky. It's all kris fault.
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 50 | ||||
-rw-r--r-- | src/bookmarks/ephy-node-view.c | 80 |
2 files changed, 83 insertions, 47 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 885f034a8..3992cc0e1 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -454,18 +454,6 @@ ephy_bookmarks_editor_finalize (GObject *object) } static void -ephy_bookmarks_editor_show_popup_cb (GtkWidget *view, - EphyBookmarksEditor *editor) -{ - GtkWidget *widget; - - widget = egg_menu_merge_get_widget (editor->priv->ui_merge, - "/popups/EphyBookmarkEditorPopup"); - gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2, - gtk_get_current_event_time ()); -} - -static void ephy_bookmarks_editor_node_activated_cb (GtkWidget *view, EphyNode *node, EphyBookmarksEditor *editor) @@ -493,7 +481,8 @@ ephy_bookmarks_editor_node_activated_cb (GtkWidget *view, } static void -ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) +ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor, + GtkWidget *selected_view) { gboolean open_in_window, open_in_tab, rename, delete, properties; @@ -508,11 +497,19 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) GList *selected; GtkWidget *focus_widget; - bmk_focus = gtk_widget_is_focus (editor->priv->bm_view); - key_focus = gtk_widget_is_focus (editor->priv->key_view); - + 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); + } + focus_widget = gtk_window_get_focus (GTK_WINDOW (editor)); - + if (GTK_IS_EDITABLE (focus_widget)) { gboolean has_selection; @@ -539,7 +536,7 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) (EPHY_NODE_VIEW (editor->priv->key_view), NULL); selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view)); - if (selected) + if (key_focus && selected) { EphyNode *node = EPHY_NODE (selected->data); EphyBookmarksKeywordPriority priority;; @@ -594,6 +591,19 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) } static void +ephy_bookmarks_editor_show_popup_cb (GtkWidget *view, + EphyBookmarksEditor *editor) +{ + GtkWidget *widget; + + widget = egg_menu_merge_get_widget (editor->priv->ui_merge, + "/popups/EphyBookmarkEditorPopup"); + ephy_bookmarks_editor_update_menu (editor, view); + gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2, + gtk_get_current_event_time ()); +} + +static void ephy_bookmarks_editor_dispose (GObject *object) { EphyBookmarksEditor *editor; @@ -706,7 +716,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); + ephy_bookmarks_editor_update_menu (editor, view); gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2, gtk_get_current_event_time ()); } @@ -821,7 +831,7 @@ static void menu_activate_cb (EphyNodeView *view, EphyBookmarksEditor *editor) { - ephy_bookmarks_editor_update_menu (editor); + ephy_bookmarks_editor_update_menu (editor, NULL); } static void diff --git a/src/bookmarks/ephy-node-view.c b/src/bookmarks/ephy-node-view.c index dcadb13bc..0a4894d36 100644 --- a/src/bookmarks/ephy-node-view.c +++ b/src/bookmarks/ephy-node-view.c @@ -63,6 +63,8 @@ struct EphyNodeViewPrivate GtkTargetList *drag_targets; + EphyNode *selected_node; + gboolean editing; }; @@ -239,6 +241,8 @@ ephy_node_view_selection_changed_cb (GtkTreeSelection *selection, GList *list; EphyNode *node = NULL; + view->priv->selected_node = NULL; + list = ephy_node_view_get_selection (view); if (list) { @@ -269,6 +273,22 @@ ephy_node_view_row_activated_cb (GtkTreeView *treeview, g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node); } +static EphyNode * +get_node_from_path (EphyNodeView *view, GtkTreePath *path) +{ + EphyNode *node; + GtkTreeIter iter, iter2; + + gtk_tree_model_get_iter (view->priv->sortmodel, &iter, path); + gtk_tree_model_sort_convert_iter_to_child_iter + (GTK_TREE_MODEL_SORT (view->priv->sortmodel), &iter2, &iter); + egg_tree_model_filter_convert_iter_to_child_iter + (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2); + node = ephy_tree_model_node_node_from_iter (view->priv->nodemodel, &iter); + + return node; +} + static gboolean ephy_node_view_button_press_cb (GtkTreeView *treeview, GdkEventButton *event, @@ -276,10 +296,10 @@ ephy_node_view_button_press_cb (GtkTreeView *treeview, { GtkTreePath *path; GtkTreeSelection *selection; + gboolean result = FALSE; if (event->button == 3) { - g_signal_emit (G_OBJECT (view), ephy_node_view_signals[SHOW_POPUP], 0); if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview), event->x, event->y, @@ -292,12 +312,18 @@ ephy_node_view_button_press_cb (GtkTreeView *treeview, /* We handle the event (so the view won't be * changed by the user click) because the user * clicked on an already selected element */ - return TRUE; + result = TRUE; + } + else + { + view->priv->selected_node = get_node_from_path (view, path); } + + g_signal_emit (G_OBJECT (view), ephy_node_view_signals[SHOW_POPUP], 0); } } - return FALSE; + return result; } static void @@ -627,6 +653,7 @@ ephy_node_view_init (EphyNodeView *view) view->priv = g_new0 (EphyNodeViewPrivate, 1); view->priv->editable_renderer = NULL; view->priv->editing = TRUE; + view->priv->selected_node = NULL; } static void @@ -661,12 +688,20 @@ ephy_node_view_get_selection (EphyNodeView *view) GList *list = NULL; GtkTreeSelection *selection; - selection = gtk_tree_view_get_selection - (GTK_TREE_VIEW (view)); + if (view->priv->selected_node) + { + list = g_list_append (list, view->priv->selected_node); + } + else + { + selection = gtk_tree_view_get_selection + (GTK_TREE_VIEW (view)); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) get_selection, - (void **) &list); + gtk_tree_selection_selected_foreach + (selection, + (GtkTreeSelectionForeachFunc) get_selection, + (void **) &list); + } return list; } @@ -719,22 +754,6 @@ ephy_node_view_select_node (EphyNodeView *view, gtk_tree_path_free (path); } -static EphyNode * -get_node_from_path (EphyNodeView *view, GtkTreePath *path) -{ - EphyNode *node; - GtkTreeIter iter, iter2; - - gtk_tree_model_get_iter (view->priv->sortmodel, &iter, path); - gtk_tree_model_sort_convert_iter_to_child_iter - (GTK_TREE_MODEL_SORT (view->priv->sortmodel), &iter2, &iter); - egg_tree_model_filter_convert_iter_to_child_iter - (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2); - node = ephy_tree_model_node_node_from_iter (view->priv->nodemodel, &iter); - - return node; -} - static gboolean drag_motion_cb (GtkWidget *widget, GdkDragContext *context, @@ -923,10 +942,17 @@ ephy_node_view_has_selection (EphyNodeView *view, gboolean *multiple) GtkTreeSelection *selection; int rows; - selection = gtk_tree_view_get_selection - (GTK_TREE_VIEW (view)); + if (view->priv->selected_node) + { + rows = 1; + } + else + { + selection = gtk_tree_view_get_selection + (GTK_TREE_VIEW (view)); - rows = gtk_tree_selection_count_selected_rows (selection); + rows = gtk_tree_selection_count_selected_rows (selection); + } if (multiple) { |