summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Mikhaylenko <alexm@gnome.org>2020-09-07 23:15:43 +0500
committerAlexander Mikhaylenko <alexm@gnome.org>2020-09-23 02:09:22 +0500
commitb38289718291afa5b06f4d048967b1c330317fd8 (patch)
tree83f1be935e66f2ab0092aeff8a9fe6f7cbfa490d
parentb7f5061d32d5319a3080a3858c0d1ba37a21fd48 (diff)
downloadepiphany-b38289718291afa5b06f4d048967b1c330317fd8.tar.gz
Add mute and unmute items to the tab context menu
The tab button is inaccessible from keyboard, so it must be in the menu.
-rw-r--r--src/ephy-window.c15
-rw-r--r--src/resources/gtk/notebook-context-menu.ui5
-rw-r--r--src/window-commands.c22
-rw-r--r--src/window-commands.h3
4 files changed, 45 insertions, 0 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 249adea6d..c494e6a5b 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -135,6 +135,7 @@ const struct {
{ "tab.move-right", { "<shift><Primary>Page_Down", NULL } },
{ "tab.duplicate", { "<shift><Primary>K", NULL } },
{ "tab.close", { "<Primary>W", NULL } },
+ { "tab.mute", { "<Primary>M", NULL } },
{ "tab.pin", { NULL } }
}, accels_navigation_ltr [] = {
{ "toolbar.navigation-back", { "<alt>Left", "<alt>KP_Left", "<alt>KP_4", "Back", NULL } },
@@ -887,6 +888,7 @@ static const GActionEntry tab_entries [] = {
{ "reload-all", window_cmd_tabs_reload_all_tabs },
{ "pin", window_cmd_tabs_pin },
{ "unpin", window_cmd_tabs_unpin },
+ { "mute", NULL, NULL, "false", window_cmd_change_tabs_mute_state },
};
static const GActionEntry toolbar_entries [] = {
@@ -2689,15 +2691,22 @@ show_notebook_popup_menu (GtkNotebook *notebook,
action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
if (event != NULL) {
+ EphyWebView *view;
int n_pages;
int page_num;
gboolean pinned;
+ gboolean audio_playing;
+ gboolean muted;
tab = GTK_WIDGET (window->active_embed);
n_pages = gtk_notebook_get_n_pages (notebook);
page_num = gtk_notebook_page_num (notebook, tab);
pinned = ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), EPHY_EMBED (tab));
+ view = ephy_embed_get_web_view (EPHY_EMBED (tab));
+ audio_playing = webkit_web_view_is_playing_audio (WEBKIT_WEB_VIEW (view));
+ muted = webkit_web_view_get_is_muted (WEBKIT_WEB_VIEW (view));
+
/* enable/disable close others/left/right */
action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
"close-left");
@@ -2724,6 +2733,12 @@ show_notebook_popup_menu (GtkNotebook *notebook,
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), pinned);
action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "mute");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), audio_playing);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action),
+ g_variant_new_boolean (muted));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
"close");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !pinned);
diff --git a/src/resources/gtk/notebook-context-menu.ui b/src/resources/gtk/notebook-context-menu.ui
index 7c61c2b7e..ed58b5ab4 100644
--- a/src/resources/gtk/notebook-context-menu.ui
+++ b/src/resources/gtk/notebook-context-menu.ui
@@ -27,6 +27,11 @@
<attribute name="action">tab.unpin</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">_Mute Tab</attribute>
+ <attribute name="action">tab.mute</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
</section>
<section>
<item>
diff --git a/src/window-commands.c b/src/window-commands.c
index a64107a80..31460d0a7 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -3039,3 +3039,25 @@ window_cmd_tabs_unpin (GSimpleAction *action,
ephy_notebook_tab_set_pinned (notebook, GTK_WIDGET (embed), FALSE);
}
+
+void
+window_cmd_change_tabs_mute_state (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ EphyWindow *window = EPHY_WINDOW (user_data);
+ EphyEmbed *embed;
+ EphyWebView *view;
+ gboolean mute;
+
+ mute = g_variant_get_boolean (state);
+
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_assert (embed != NULL);
+
+ view = ephy_embed_get_web_view (embed);
+
+ webkit_web_view_set_is_muted (WEBKIT_WEB_VIEW (view), mute);
+
+ g_simple_action_set_state (action, g_variant_new_boolean (mute));
+}
diff --git a/src/window-commands.h b/src/window-commands.h
index c11a66cfe..cab9e75f9 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -236,6 +236,9 @@ void window_cmd_tabs_pin (GSimpleAction *action,
void window_cmd_tabs_unpin (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
+void window_cmd_change_tabs_mute_state (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data);
void window_cmd_import_passwords (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);