+ return FALSE;
+}
+
+
+static gboolean
+show_context_popup_menu (ModestMainWindow *window,
+ GtkTreeView *tree_view,
+ GdkEventButton *event,
+ GtkWidget *menu)
+{
+ g_return_val_if_fail (menu, FALSE);
+
+ if (event != NULL) {
+ /* Ensure that the header is selected */
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection (tree_view);
+
+ if (gtk_tree_selection_count_selected_rows (selection) <= 1) {
+ GtkTreePath *path;
+
+ /* Get tree path for row that was clicked */
+ if (gtk_tree_view_get_path_at_pos (tree_view,
+ (gint) event->x,
+ (gint) event->y,
+ &path,
+ NULL, NULL, NULL)) {
+ gtk_tree_selection_unselect_all (selection);
+ gtk_tree_selection_select_path (selection, path);
+ gtk_tree_path_free (path);
+ }
+ }
+
+ /* Show popup */
+ if (gtk_tree_selection_count_selected_rows(selection) == 1)
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ NULL, NULL,
+ event->button, event->time);
+ }