[epiphany] Replace Move Tab Left/Right with Close Tabs to the Left/Right
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Replace Move Tab Left/Right with Close Tabs to the Left/Right
- Date: Tue, 30 Oct 2018 18:19:38 +0000 (UTC)
commit 805912bd89917ce6e56637570afb038dfffb055a
Author: Kieran Elmes <kieran elmes kolabnow com>
Date: Fri Oct 26 16:58:19 2018 +1300
Replace Move Tab Left/Right with Close Tabs to the Left/Right
src/ephy-window.c | 10 +++---
src/resources/gtk/notebook-context-menu.ui | 16 ++++-----
src/window-commands.c | 56 ++++++++++++++++++++++++++++++
src/window-commands.h | 8 ++++-
4 files changed, 76 insertions(+), 14 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index d8d0e5b99..add022ea9 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -768,11 +768,11 @@ static const GActionEntry window_entries [] =
static const GActionEntry tab_entries [] = {
{ "previous", window_cmd_tabs_previous },
{ "next", window_cmd_tabs_next },
- { "move-left", window_cmd_tabs_move_left },
- { "move-right", window_cmd_tabs_move_right },
{ "duplicate", window_cmd_tabs_duplicate },
{ "detach", window_cmd_tabs_detach },
{ "close", window_cmd_tabs_close },
+ { "close-left", window_cmd_tabs_close_left },
+ { "close-right", window_cmd_tabs_close_right },
{ "close-others", window_cmd_tabs_close_others }
};
@@ -2402,13 +2402,13 @@ show_notebook_popup_menu (GtkNotebook *notebook,
n_pages = gtk_notebook_get_n_pages (notebook);
page_num = gtk_notebook_page_num (notebook, tab);
- /* enable/disable move left/right items*/
+ /* enable/disable close others/left/right */
action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "move-left");
+ "close-left");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), page_num > 0);
action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "move-right");
+ "close-right");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), page_num < n_pages - 1);
action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
diff --git a/src/resources/gtk/notebook-context-menu.ui b/src/resources/gtk/notebook-context-menu.ui
index b6255bfd7..3c79791bd 100644
--- a/src/resources/gtk/notebook-context-menu.ui
+++ b/src/resources/gtk/notebook-context-menu.ui
@@ -3,14 +3,6 @@
<!-- interface-requires gtk+ 3.0 -->
<menu id="notebook-menu">
<section>
- <item>
- <attribute name="label" translatable="yes">Move Tab _Left</attribute>
- <attribute name="action">tab.move-left</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Move Tab _Right</attribute>
- <attribute name="action">tab.move-right</attribute>
- </item>
<item>
<attribute name="label" translatable="yes">Du_plicate</attribute>
<attribute name="action">tab.duplicate</attribute>
@@ -19,6 +11,14 @@
<attribute name="label" translatable="yes">_Close</attribute>
<attribute name="action">tab.close</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">Close Tabs to the _Left</attribute>
+ <attribute name="action">tab.close-left</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Close Tabs to the _Right</attribute>
+ <attribute name="action">tab.close-right</attribute>
+ </item>
<item>
<attribute name="label" translatable="yes">Close _Other Tabs</attribute>
<attribute name="action">tab.close-others</attribute>
diff --git a/src/window-commands.c b/src/window-commands.c
index 82906d361..177af0924 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -2358,6 +2358,62 @@ window_cmd_tabs_close (GSimpleAction *action,
g_signal_emit_by_name (notebook, "tab-close-request", embed);
}
+void
+window_cmd_tabs_close_left (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ EphyWindow *window = user_data;
+ GtkWidget *notebook;
+ EphyEmbed *embed;
+ int n_pages, current_page_no;
+ GSList *pages_to_close = NULL;
+
+ notebook = ephy_window_get_notebook (window);
+ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+ current_page_no = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+
+ for (int i = 0; i < current_page_no; i++) {
+ embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
+ pages_to_close = g_slist_prepend (pages_to_close, embed);
+ }
+
+ for (GSList *l = pages_to_close; l != NULL; l = l->next) {
+ g_assert (l->data != NULL);
+ g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", l->data);
+ }
+
+ g_slist_free (pages_to_close);
+}
+
+void
+window_cmd_tabs_close_right (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ EphyWindow *window = user_data;
+ GtkWidget *notebook;
+ EphyEmbed *embed;
+ int n_pages, current_page_no;
+ GSList *pages_to_close = NULL;
+
+ notebook = ephy_window_get_notebook (window);
+ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+ current_page_no = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+
+ for (int i = current_page_no + 1; i < n_pages; i++) {
+ embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
+ pages_to_close = g_slist_prepend (pages_to_close, embed);
+ }
+
+ for (GSList *l = pages_to_close; l != NULL; l = l->next) {
+ g_assert (l->data != NULL);
+ g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", l->data);
+ }
+
+ g_slist_free (pages_to_close);
+}
+
void
window_cmd_tabs_close_others (GSimpleAction *action,
GVariant *parameter,
diff --git a/src/window-commands.h b/src/window-commands.h
index fea215ae1..f02183787 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -169,7 +169,7 @@ void window_cmd_tabs_next (GSimpleAction *action,
gpointer user_data);
void window_cmd_tabs_move_left (GSimpleAction *action,
GVariant *state,
- gpointer user_data);
+ gpointer user_data);
void window_cmd_tabs_move_right (GSimpleAction *action,
GVariant *state,
gpointer user_data);
@@ -182,6 +182,12 @@ void window_cmd_tabs_detach (GSimpleAction *action,
void window_cmd_tabs_close (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
+void window_cmd_tabs_close_left (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+void window_cmd_tabs_close_right (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
void window_cmd_tabs_close_others (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]