aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-01-06 04:58:45 +0800
committerChristian Persch <chpe@src.gnome.org>2005-01-06 04:58:45 +0800
commit40dafa4179a4349c73c2acce6330970698159767 (patch)
treea7100448433bd0f841a0c0237f6321e9a937b40c /src
parent4953a4bdb2cb833574b4188f6795e796b4ff9a2d (diff)
downloadgsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.tar
gsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.tar.gz
gsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.tar.bz2
gsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.tar.lz
gsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.tar.xz
gsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.tar.zst
gsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.zip
Add context menu on notebook. Fixes bug #132989.
2005-01-05 Christian Persch <chpe@cvs.gnome.org> * data/ui/epiphany-ui.xml: * src/ephy-notebook.c: (button_press_cb): * src/ephy-window.c: (show_notebook_popup_menu), (notebook_button_press_cb), (notebook_popup_menu_cb), (setup_notebook): Add context menu on notebook. Fixes bug #132989.
Diffstat (limited to 'src')
-rw-r--r--src/ephy-notebook.c15
-rw-r--r--src/ephy-window.c65
2 files changed, 78 insertions, 2 deletions
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 893880f13..48d8856ef 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -549,6 +549,21 @@ button_press_cb (EphyNotebook *notebook,
"motion-notify-event",
G_CALLBACK (motion_notify_cb), NULL);
}
+ else if (GDK_BUTTON_PRESS == event->type && 3 == event->button)
+ {
+ if (tab_clicked == -1)
+ {
+ /* consume event, so that we don't pop up the context menu when
+ * the mouse if not over a tab label
+ */
+ return TRUE;
+ }
+ else
+ {
+ /* switch to the page the mouse is over, but don't consume the event */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
+ }
+ }
return FALSE;
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 9b5ab4f69..323637ddb 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -130,8 +130,8 @@ static GtkActionEntry ephy_menu_entries [] = {
{ "FileSendTo", STOCK_SEND_MAIL, N_("S_end To..."), "<control>M",
N_("Send a link of the current page"),
G_CALLBACK (window_cmd_file_send_to) },
- { "FileCloseWindow", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
- N_("Close this window"),
+ { "FileCloseTab", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
+ N_("Close this tab"),
G_CALLBACK (window_cmd_file_close_window) },
/* Edit menu */
@@ -2046,6 +2046,62 @@ modal_alert_cb (EphyEmbed *embed,
return FALSE;
}
+static gboolean
+show_notebook_popup_menu (GtkNotebook *notebook,
+ EphyWindow *window,
+ GdkEventButton *event)
+{
+ GtkWidget *menu, *tab, *tab_label;
+
+ menu = gtk_ui_manager_get_widget (window->priv->manager, "/EphyNotebookPopup");
+ g_return_val_if_fail (menu != NULL, FALSE);
+
+ if (event != NULL)
+ {
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ NULL, NULL,
+ event->button, event->time);
+ }
+ else
+ {
+ tab = GTK_WIDGET (ephy_window_get_active_tab (window));
+ tab_label = gtk_notebook_get_tab_label (notebook, tab);
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ ephy_gui_menu_position_under_widget, tab_label,
+ 0, gtk_get_current_event_time ());
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+notebook_button_press_cb (GtkNotebook *notebook,
+ GdkEventButton *event,
+ EphyWindow *window)
+{
+ if (GDK_BUTTON_PRESS == event->type && 3 == event->button)
+ {
+ return show_notebook_popup_menu (notebook, window, event);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+notebook_popup_menu_cb (GtkNotebook *notebook,
+ EphyWindow *window)
+{
+ /* Only respond if the notebook is the actual focus */
+ if (EPHY_IS_NOTEBOOK (gtk_window_get_focus (GTK_WINDOW (window))))
+ {
+ return show_notebook_popup_menu (notebook, window, NULL);
+ }
+
+ return FALSE;
+}
+
static void
tab_added_cb (EphyNotebook *notebook,
EphyTab *tab,
@@ -2165,6 +2221,11 @@ setup_notebook (EphyWindow *window)
ephy_window_notebook_switch_page_cb),
window);
+ g_signal_connect (notebook, "popup-menu",
+ G_CALLBACK (notebook_popup_menu_cb), window);
+ g_signal_connect (notebook, "button-press-event",
+ G_CALLBACK(notebook_button_press_cb), window);
+
g_signal_connect (G_OBJECT (notebook), "tab_added",
G_CALLBACK (tab_added_cb), window);
g_signal_connect (G_OBJECT (notebook), "tab_removed",