[epiphany/wip/gtkaction-to-gaction: 50/54] Port New Tab to GAction
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/gtkaction-to-gaction: 50/54] Port New Tab to GAction
- Date: Mon, 27 Jun 2016 11:36:39 +0000 (UTC)
commit ba55ec6bdc8e059810083d94a82af5e7db53f9e8
Author: Iulian Radu <iulian radu67 gmail com>
Date: Sun May 15 16:01:01 2016 +0300
Port New Tab to GAction
src/ephy-toolbar.c | 9 +++------
src/ephy-window.c | 21 +++++----------------
src/resources/epiphany-ui.xml | 1 -
src/resources/gtk/menus.ui | 4 ++--
src/window-commands.c | 13 +++++++++++++
src/window-commands.h | 3 +++
6 files changed, 26 insertions(+), 25 deletions(-)
---
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index fa9c6d8..b10790d 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -221,13 +221,10 @@ ephy_toolbar_constructed (GObject *object)
/* New Tab */
button = gtk_button_new ();
toolbar->new_tab_button = button;
- /* FIXME: apparently we need an image inside the button for the action
- * icon to appear. */
- gtk_button_set_image (GTK_BUTTON (button), gtk_image_new ());
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_icon_name ("tab-new-symbolic", GTK_ICON_SIZE_BUTTON));
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
- action = gtk_action_group_get_action (action_group, "FileNewTab");
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (button),
- action);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.new-tab");
gtk_button_set_label (GTK_BUTTON (button), NULL);
gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), button);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 62f98e1..810ebda 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -299,6 +299,7 @@ const struct {
const gchar *action_and_target;
const gchar *accelerators[5];
} accels [] = {
+ { "win.new-tab", { "<Primary>T", NULL } },
{ "win.open", { "<Primary>O", NULL } },
{ "win.save-as", { "<shift><Primary>S", "<Primary>S", NULL } },
{ "win.save-as-application", { "<shift><Primary>A", NULL } },
@@ -1098,14 +1099,6 @@ setup_ui_manager (EphyWindow *window)
"<alt>Right");
g_object_unref (action);
- action = g_object_new (EPHY_TYPE_HOME_ACTION,
- "name", "FileNewTab",
- "icon-name", "tab-new-symbolic",
- "label", _("New _Tab"),
- NULL);
- gtk_action_group_add_action_with_accel (action_group, action, "<control>T");
- g_object_unref (action);
-
action =
g_object_new (EPHY_TYPE_HOME_ACTION,
"name", "FileHome",
@@ -3041,11 +3034,6 @@ setup_toolbar (EphyWindow *window)
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), window);
- action = gtk_action_group_get_action (window->toolbar_action_group,
- "FileNewTab");
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), window);
-
title_box = ephy_toolbar_get_title_box (EPHY_TOOLBAR (toolbar));
g_signal_connect (title_box, "lock-clicked",
G_CALLBACK (title_box_lock_clicked_cb), window);
@@ -3136,7 +3124,7 @@ ephy_window_toggle_visibility_for_app_menu (EphyWindow *window)
static const GActionEntry new_ephy_page_menu_entries [] =
{
- // { "new-tab", },
+ { "new-tab", window_cmd_file_new_tab },
{ "open", window_cmd_file_open },
{ "save-as", window_cmd_file_save_as },
{ "save-as-application", window_cmd_file_save_as_application },
@@ -3268,8 +3256,9 @@ ephy_window_constructor (GType type,
/* Disable actions not needed for popup mode. */
toolbar_action_group = window->toolbar_action_group;
- action = gtk_action_group_get_action (toolbar_action_group, "FileNewTab");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
+ new_action = g_action_map_lookup_action (G_ACTION_MAP (window), "new-tab");
+ new_ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (new_action),
+ SENS_FLAG_CHROME,
window->is_popup);
action = gtk_action_group_get_action (window->popups_action_group, "OpenLinkInNewTab");
diff --git a/src/resources/epiphany-ui.xml b/src/resources/epiphany-ui.xml
index 91509a1..8f8dc5b 100644
--- a/src/resources/epiphany-ui.xml
+++ b/src/resources/epiphany-ui.xml
@@ -12,7 +12,6 @@
<popup name="PagePopup" action="PagePopupAction" accelerators="true">
<menuitem name="FileNewWindowMenu" action="FileNewWindow"/>
<menuitem name="FileNewWindowIncognitoMenu" action="FileNewWindowIncognito"/>
- <menuitem name="FileNewTabMenu" action="FileNewTab"/>
<separator name="FileSep2"/>
<menuitem name="EditPreferencesMenu" action="EditPreferences"/>
<separator name="FileSep4"/>
diff --git a/src/resources/gtk/menus.ui b/src/resources/gtk/menus.ui
index e237a70..559f88b 100644
--- a/src/resources/gtk/menus.ui
+++ b/src/resources/gtk/menus.ui
@@ -3,10 +3,10 @@
<!-- interface-requires gtk+ 3.0 -->
<menu id="page-menu">
<section>
- <!-- <item>
+ <item>
<attribute name="label" translatable="yes">New Tab</attribute>
<attribute name="action">win.new-tab</attribute>
- </item> -->
+ </item>
<item>
<attribute name="label" translatable="yes">_Open…</attribute>
<attribute name="action">win.open</attribute>
diff --git a/src/window-commands.c b/src/window-commands.c
index fe27f72..3bbc6d8 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -266,6 +266,19 @@ window_cmd_view_fullscreen (GtkAction *action,
gtk_window_unfullscreen (GTK_WINDOW (window));
}
+void
+window_cmd_file_new_tab (GSimpleAction *action,
+ GVariant *value,
+ gpointer user_data)
+{
+ EphyWindow *window = user_data;
+
+ ephy_link_open (EPHY_LINK (window),
+ "about:overview",
+ NULL,
+ EPHY_LINK_HOME_PAGE | EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);
+}
+
static void
open_response_cb (GtkDialog *dialog, int response, EphyWindow *window)
{
diff --git a/src/window-commands.h b/src/window-commands.h
index 5c7e229..cfe3f74 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -38,6 +38,9 @@ void window_cmd_file_send_to (GtkAction *action,
EphyWindow *window);
void window_cmd_view_fullscreen (GtkAction *action,
EphyWindow *window);
+void window_cmd_file_new_tab (GSimpleAction *action,
+ GVariant *value,
+ gpointer user_data);
void window_cmd_file_open (GSimpleAction *action,
GVariant *value,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]