diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-01-06 04:58:45 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-01-06 04:58:45 +0800 |
commit | 40dafa4179a4349c73c2acce6330970698159767 (patch) | |
tree | a7100448433bd0f841a0c0237f6321e9a937b40c | |
parent | 4953a4bdb2cb833574b4188f6795e796b4ff9a2d (diff) | |
download | gsoc2013-epiphany-40dafa4179a4349c73c2acce6330970698159767.tar.gz 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.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | data/ui/epiphany-ui.xml | 10 | ||||
-rw-r--r-- | src/ephy-notebook.c | 15 | ||||
-rw-r--r-- | src/ephy-window.c | 65 |
4 files changed, 97 insertions, 3 deletions
@@ -1,5 +1,15 @@ 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. + +2005-01-05 Christian Persch <chpe@cvs.gnome.org> + * data/Makefile.am: Remove trailing whitespace. diff --git a/data/ui/epiphany-ui.xml b/data/ui/epiphany-ui.xml index 52aa5ccc9..788e088c7 100644 --- a/data/ui/epiphany-ui.xml +++ b/data/ui/epiphany-ui.xml @@ -13,7 +13,7 @@ <menuitem name="FileSendToMenu" action="FileSendTo"/> <separator name="FileSep3"/> <menuitem name="FileWorkOfflineItem" action="FileWorkOffline"/> - <menuitem name="FileCloseWindowMenu" action="FileCloseWindow"/> + <menuitem name="FileCloseTabMenu" action="FileCloseTab"/> </menu> <menu name="EditMenu" action="Edit"> @@ -181,6 +181,14 @@ <menuitem name="CopyImageLocationIELP" action="CopyImageLocation"/> </popup> + <popup name="EphyNotebookPopup" action="PopupAction"> + <menuitem name="TabCloseENP" action="FileCloseTab"/> + <menuitem name="TabDetachENP" action="TabsDetach"/> + <separator name="TabsSep1"/> + <menuitem name="TabMoveLeftENP" action="TabsMoveLeft"/> + <menuitem name="TabMoveRightENP" action="TabsMoveRight"/> +</popup> + <accelerator name="BrowseWithCaretAccel" action="BrowseWithCaret"/> <accelerator name="FileSaveAccel" action="FileSave"/> 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", |