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-08 15:44:47 +0500
commit83fd4c7376bf872b675e08d117d7f8949c98991b (patch)
treef63180abab50e6d971a8bad5902a1d737152b981
parentae3a9d1e34bfc1bcd319ae0919518b174962b3bb (diff)
downloadepiphany-wip/exalm/menu.tar.gz
Add mute and unmute items to the tab context menuwip/exalm/menu
The tab button is inaccessible from keyboard, so it must be in the menu.
-rw-r--r--src/ephy-window.c17
-rw-r--r--src/resources/gtk/notebook-context-menu.ui10
-rw-r--r--src/window-commands.c34
-rw-r--r--src/window-commands.h6
4 files changed, 67 insertions, 0 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 249adea6d..c5d785e38 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -887,6 +887,8 @@ static const GActionEntry tab_entries [] = {
{ "reload-all", window_cmd_tabs_reload_all_tabs },
{ "pin", window_cmd_tabs_pin },
{ "unpin", window_cmd_tabs_unpin },
+ { "mute", window_cmd_tabs_mute },
+ { "unmute", window_cmd_tabs_unmute },
};
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,14 @@ 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 && !muted);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "unmute");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), audio_playing && 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..710afb914 100644
--- a/src/resources/gtk/notebook-context-menu.ui
+++ b/src/resources/gtk/notebook-context-menu.ui
@@ -27,6 +27,16 @@
<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>
+ <item>
+ <attribute name="label" translatable="yes">Un_mute Tab</attribute>
+ <attribute name="action">tab.unmute</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..5f02bb861 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -3039,3 +3039,37 @@ window_cmd_tabs_unpin (GSimpleAction *action,
ephy_notebook_tab_set_pinned (notebook, GTK_WIDGET (embed), FALSE);
}
+
+void
+window_cmd_tabs_mute (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ EphyWindow *window = EPHY_WINDOW (user_data);
+ EphyEmbed *embed;
+ EphyWebView *view;
+
+ 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), TRUE);
+}
+
+void
+window_cmd_tabs_unmute (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ EphyWindow *window = EPHY_WINDOW (user_data);
+ EphyEmbed *embed;
+ EphyWebView *view;
+
+ 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), FALSE);
+}
diff --git a/src/window-commands.h b/src/window-commands.h
index c11a66cfe..ee9a1adc6 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -236,6 +236,12 @@ void window_cmd_tabs_pin (GSimpleAction *action,
void window_cmd_tabs_unpin (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
+void window_cmd_tabs_mute (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+void window_cmd_tabs_unmute (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
void window_cmd_import_passwords (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);