aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-node-view.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-04-16 01:36:46 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-04-16 01:36:46 +0800
commit81cc9fc7c119b8d45c28b0cdf1351e330f445264 (patch)
treec134ece6621a2360675c52ead30f0efcda34cb5a /src/bookmarks/ephy-node-view.c
parent9d9872cea3a0bc588ee0d64f231d64510906efbb (diff)
downloadgsoc2013-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/bookmarks/ephy-node-view.c')
-rw-r--r--src/bookmarks/ephy-node-view.c80
1 files changed, 53 insertions, 27 deletions
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)
{