[evolution-patches] handle popup-menu signal in em-folder-tree



The attached patch handles the popup-menu signal in the folder tree so
that the standard SHIFT+F10 accel brings up the menu.

ciao
	paolo
? emft-popup.patch
? tmp.patch
? calendar/common/Makefile
? calendar/common/Makefile.in
? calendar/gui/apps_evolution_calendar-1.5.schemas
? mail/evolution-mail-1.5.schemas
? shell/apps_evolution_shell-1.5.schemas
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3036
diff -u -p -r1.3036 ChangeLog
--- mail/ChangeLog	23 Jan 2004 22:25:59 -0000	1.3036
+++ mail/ChangeLog	25 Jan 2004 10:26:46 -0000
@@ -1,3 +1,9 @@
+2004-01-24  Paolo Borelli  <pborelli katamail com>
+
+	* em-folder-tree.c (em_folder_tree_construct): handle popup-menu.
+	(emft_tree_button_press): factor out a emft_do_popup_menu function.
+	(emft_tree_popup_menu): new callback for the popup-menu signal.
+
 2004-01-23  Jeffrey Stedfast  <fejj ximian com>
 
 	* em-folder-tree-model.c (em_folder_tree_model_get_type): Removed
Index: mail/em-folder-tree.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree.c,v
retrieving revision 1.47
diff -u -p -r1.47 em-folder-tree.c
--- mail/em-folder-tree.c	23 Jan 2004 22:26:01 -0000	1.47
+++ mail/em-folder-tree.c	25 Jan 2004 10:26:49 -0000
@@ -103,7 +103,9 @@ static void emft_queue_save_state (EMFol
 
 static void emft_tree_row_collapsed (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
 static void emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
+static void emft_do_popup_menu (GdkEventButton *event, EMFolderTree *emft);
 static gboolean emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft);
+static gboolean emft_tree_popup_menu (GtkWidget *treeview, EMFolderTree *emft);
 static void emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft);
 
 struct _emft_selection_data {
@@ -371,6 +373,7 @@ em_folder_tree_construct (EMFolderTree *
 	g_signal_connect (priv->treeview, "row-expanded", G_CALLBACK (emft_tree_row_expanded), emft);
 	g_signal_connect (priv->treeview, "row-collapsed", G_CALLBACK (emft_tree_row_collapsed), emft);
 	g_signal_connect (priv->treeview, "button-press-event", G_CALLBACK (emft_tree_button_press), emft);
+	g_signal_connect (priv->treeview, "popup-menu", G_CALLBACK (emft_tree_popup_menu), emft);
 	
 	selection = gtk_tree_view_get_selection ((GtkTreeView *) priv->treeview);
 	g_signal_connect (selection, "changed", G_CALLBACK (emft_tree_selection_changed), emft);
@@ -381,7 +384,6 @@ em_folder_tree_construct (EMFolderTree *
 	gtk_box_pack_start ((GtkBox *) emft, scrolled, TRUE, TRUE, 0);
 }
 
-
 GtkWidget *
 em_folder_tree_new (void)
 {
@@ -1776,8 +1778,8 @@ static EMPopupItem emft_popup_menu[] = {
 	{ EM_POPUP_ITEM, "80.emc.00", N_("_Properties..."), G_CALLBACK (emft_popup_properties), NULL, "configure_16_folder.xpm", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT },
 };
 
-static gboolean
-emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft)
+static void
+emft_do_popup_menu (GdkEventButton *event, EMFolderTree *emft)
 {
 	struct _EMFolderTreePrivate *priv = emft->priv;
 	GtkTreeSelection *selection;
@@ -1790,11 +1792,9 @@ emft_tree_button_press (GtkWidget *treev
 	char *uri;
 	gboolean isstore;
 	int i;
-	
-	if (event->button != 3)
-		return FALSE;
-	
-	/* handle right-click by opening a context menu */
+	int button;
+	int event_time;
+
 	emp = em_popup_new ("com.ximian.mail.storageset.popup.select");
 
 	/* FIXME: we really need the folderinfo to build a proper menu */
@@ -1802,28 +1802,50 @@ emft_tree_button_press (GtkWidget *treev
 	emft_selection_get_selected (selection, &model, &iter);
 	gtk_tree_model_get (model, &iter, COL_STRING_URI, &uri, COL_BOOL_IS_STORE, &isstore, -1);
 	target = em_popup_target_new_folder(uri, isstore);
-	
+
 	for (i = 0; i < sizeof (emft_popup_menu) / sizeof (emft_popup_menu[0]); i++) {
 		EMPopupItem *item = &emft_popup_menu[i];
 		
 		item->activate_data = emft;
 		menus = g_slist_prepend (menus, item);
 	}
-	
+
 	em_popup_add_items (emp, menus, (GDestroyNotify) g_slist_free);
 
 	menu = em_popup_create_menu_once (emp, target, 0, target->mask);
-	
-	if (event == NULL || event->type == GDK_KEY_PRESS) {
-		/* FIXME: menu pos function */
-		gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, event->time);
+
+	if (event) {
+		button = event->button;
+		event_time = event->time;
 	} else {
-		gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
+		button = 0;
+		event_time = gtk_get_current_event_time ();
 	}
-	
-	return TRUE;
+
+	gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button, event_time);
 }
 
+static gboolean
+emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft)
+{
+	/* Make sure to grab focus */
+	gtk_widget_grab_focus (treeview);
+
+	if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
+		emft_do_popup_menu (event, emft);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static gboolean
+emft_tree_popup_menu (GtkWidget *treeview, EMFolderTree *emft)
+{
+	emft_do_popup_menu (NULL, emft);
+
+	return TRUE;
+}
 
 static void
 emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]