[epiphany/wip/gtkaction-to-gaction] Use GAction for the combined stop/reload button



commit e3be7e9bc21ba8496063ae57f9e339f31c664aec
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Tue Jun 28 00:11:27 2016 +0300

    Use GAction for the combined stop/reload button

 src/Makefile.am                        |    2 -
 src/ephy-combined-stop-reload-action.c |  150 --------------------------------
 src/ephy-combined-stop-reload-action.h |   60 -------------
 src/ephy-toolbar.c                     |   42 +++++++---
 src/ephy-toolbar.h                     |   16 ++--
 src/ephy-window.c                      |  108 +++++++++++------------
 src/ephy-window.h                      |    2 +
 src/resources/epiphany-ui.xml          |    2 -
 src/window-commands.c                  |  138 +++++++++++++++++------------
 src/window-commands.h                  |   13 ++-
 10 files changed, 183 insertions(+), 350 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ba36b55..c82c63b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,8 +32,6 @@ libephymain_la_SOURCES = \
        ephy-action-helper.h                    \
        ephy-completion-model.c                 \
        ephy-completion-model.h                 \
-       ephy-combined-stop-reload-action.c      \
-       ephy-combined-stop-reload-action.h      \
        ephy-encoding-dialog.c                  \
        ephy-encoding-dialog.h                  \
        ephy-encoding-row.c                     \
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 7eb1b4c..f19b312 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -35,6 +35,7 @@
 #include "ephy-private.h"
 #include "ephy-shell.h"
 
+#include <glib/gi18n.h>
 #include <webkit2/webkit2.h>
 
 enum {
@@ -55,8 +56,9 @@ struct _EphyToolbar {
   EphyTitleBox *title_box;
   GtkWidget *entry;
   GtkWidget *navigation_box;
-  GtkWidget *page_menu_button;
   GtkWidget *new_tab_button;
+  GtkWidget *combined_stop_reload_button;
+  GtkWidget *page_menu_button;
   GtkWidget *downloads_revealer;
   GtkWidget *downloads_button;
   GtkWidget *downloads_popover;
@@ -545,12 +547,31 @@ navigation_leave_notify_event_cb (GtkButton *button,
   return G_SOURCE_REMOVE;
 }
 
+void
+ephy_toolbar_change_combined_stop_reload_state (GSimpleAction *action,
+                                                GVariant      *loading,
+                                                gpointer       user_data)
+{
+  EphyWindow *window = EPHY_WINDOW (user_data);
+  EphyToolbar *toolbar;
+  GtkWidget *image;
+
+  if (g_variant_get_boolean (loading))
+    image = gtk_image_new_from_icon_name ("process-stop-symbolic",
+                                          GTK_ICON_SIZE_BUTTON);
+  else
+    image = gtk_image_new_from_icon_name ("view-refresh-symbolic",
+                                          GTK_ICON_SIZE_BUTTON);
+
+  toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window));
+  gtk_button_set_image (GTK_BUTTON (toolbar->combined_stop_reload_button),
+                        image);
+}
+
 static void
 ephy_toolbar_constructed (GObject *object)
 {
   EphyToolbar *toolbar = EPHY_TOOLBAR (object);
-  GtkActionGroup *action_group;
-  GtkAction *action;
   GtkWidget *box, *button;
   GtkMenu *menu;
   EphyDownloadsManager *downloads_manager;
@@ -616,16 +637,14 @@ ephy_toolbar_constructed (GObject *object)
   gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), box);
 
   /* Reload/Stop */
-  action_group = ephy_window_get_toolbar_action_group (toolbar->window);
-
   button = gtk_button_new ();
-  /* 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 ());
+  toolbar->combined_stop_reload_button = button;
+  gtk_button_set_image (GTK_BUTTON (button),
+                        gtk_image_new_from_icon_name ("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON));
   gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-  action = gtk_action_group_get_action (action_group, "ViewCombinedStopReload");
-  gtk_activatable_set_related_action (GTK_ACTIVATABLE (button),
-                                      action);
+  gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
+                                  "toolbar.combined-stop-reload");
+  gtk_widget_show (GTK_WIDGET (button));
   gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), button);
 
   /* New Tab */
@@ -638,7 +657,6 @@ ephy_toolbar_constructed (GObject *object)
   gtk_button_set_label (GTK_BUTTON (button), NULL);
   gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), button);
 
-
   /* Location bar + Title */
   toolbar->title_box = ephy_title_box_new (toolbar->window);
   toolbar->entry = ephy_title_box_get_location_entry (toolbar->title_box);
diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h
index 6f3a235..53434aa 100644
--- a/src/ephy-toolbar.h
+++ b/src/ephy-toolbar.h
@@ -30,13 +30,17 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EphyToolbar, ephy_toolbar, EPHY, TOOLBAR, GtkHeaderBar)
 
-GtkWidget *ephy_toolbar_new      (EphyWindow *window);
+GtkWidget    *ephy_toolbar_new                               (EphyWindow *window);
 
-GtkWidget *ephy_toolbar_get_location_entry (EphyToolbar *toolbar);
-EphyTitleBox *ephy_toolbar_get_title_box (EphyToolbar *toolbar);
-GMenu *ephy_toolbar_get_page_menu (EphyToolbar *toolbar);
-GtkWidget * ephy_toolbar_get_page_menu_button (EphyToolbar *toolbar);
-GtkWidget * ephy_toolbar_get_new_tab_button (EphyToolbar *toolbar);
+void          ephy_toolbar_change_combined_stop_reload_state (GSimpleAction *action,
+                                                              GVariant      *state,
+                                                              gpointer       user_data);
+
+GtkWidget    *ephy_toolbar_get_location_entry                (EphyToolbar *toolbar);
+EphyTitleBox *ephy_toolbar_get_title_box                     (EphyToolbar *toolbar);
+GMenu        *ephy_toolbar_get_page_menu                     (EphyToolbar *toolbar);
+GtkWidget    *ephy_toolbar_get_page_menu_button              (EphyToolbar *toolbar);
+GtkWidget    *ephy_toolbar_get_new_tab_button                (EphyToolbar *toolbar);
 
 G_END_DECLS
 
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 5123362..79c7fe1 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -23,7 +23,6 @@
 
 #include "ephy-action-helper.h"
 #include "ephy-bookmarks-ui.h"
-#include "ephy-combined-stop-reload-action.h"
 #include "ephy-debug.h"
 #include "ephy-embed-container.h"
 #include "ephy-embed-prefs.h"
@@ -94,15 +93,6 @@ static const GtkActionEntry ephy_menu_entries [] = {
   { "EditPreferences", NULL, N_("Pr_eferences"), "<control>e", NULL,
     G_CALLBACK (window_cmd_edit_preferences) },
 
-  /* View actions. */
-
-  { "ViewStop", NULL, N_("_Stop"), "Escape", NULL,
-    G_CALLBACK (window_cmd_view_stop) },
-  { "ViewAlwaysStop", NULL, N_("_Stop"), "Escape",
-    NULL, G_CALLBACK (window_cmd_view_stop) },
-  { "ViewReload", NULL, N_("_Reload"), "<control>R", NULL,
-    G_CALLBACK (window_cmd_view_reload) },
-
   /* Bookmarks actions. */
 
   { "FileBookmarkPage", NULL, N_("_Add Bookmark…"), "<control>D", NULL,
@@ -214,11 +204,6 @@ static const struct {
   /* FIXME: these are not in any menu for now, so add them here. */
   { GDK_KEY_F11, 0, "ViewFullscreen", FALSE },
 
-  { GDK_KEY_r, GDK_CONTROL_MASK, "ViewReload", FALSE },
-  { GDK_KEY_R, GDK_CONTROL_MASK, "ViewReload", FALSE },
-  { GDK_KEY_R, GDK_CONTROL_MASK |
-    GDK_SHIFT_MASK, "ViewReload", FALSE },
-
   /* Tab navigation */
   { GDK_KEY_Page_Up, GDK_CONTROL_MASK, "TabsPrevious", FALSE },
   { GDK_KEY_Page_Down, GDK_CONTROL_MASK, "TabsNext", FALSE },
@@ -230,11 +215,6 @@ static const struct {
   { GDK_KEY_l, GDK_CONTROL_MASK, "GoLocation", FALSE },
   { GDK_KEY_F6, 0, "GoLocation", FALSE },
   /* Support all the MSIE tricks as well ;) */
-  { GDK_KEY_F5, 0, "ViewReload", FALSE },
-  { GDK_KEY_F5, GDK_CONTROL_MASK, "ViewReload", FALSE },
-  { GDK_KEY_F5, GDK_SHIFT_MASK, "ViewReload", FALSE },
-  { GDK_KEY_F5, GDK_CONTROL_MASK |
-    GDK_SHIFT_MASK, "ViewReload", FALSE },
   /* These keys are a bit strange: when pressed with no modifiers, they emit
    * KP_PageUp/Down Control; when pressed with Control+Shift they are KP_9/3,
    * when NumLock is on they are KP_9/3 and with NumLock and Control+Shift
@@ -252,19 +232,16 @@ static const struct {
   { XF86XK_Go, 0, "GoLocation", FALSE },
   { XF86XK_OpenURL, 0, "GoLocation", FALSE },
   { XF86XK_AddFavorite, 0, "FileBookmarkPage", FALSE },
-  { XF86XK_Refresh, 0, "ViewReload", FALSE },
-  { XF86XK_Reload, 0, "ViewReload", FALSE },
   { XF86XK_Send, 0, "FileSendTo", FALSE },
-  { XF86XK_Stop, 0, "ViewStop", FALSE },
   /* FIXME: what about ScrollUp, ScrollDown, Menu*, Option, LogOff, Save,.. any others? */
 #endif /* HAVE_X11_XF86KEYSYM_H */
 };
 
 const struct {
   const gchar *action_and_target;
-  const gchar *accelerators[5];
+  const gchar *accelerators[9];
 } accels [] = {
-  /* Window accels */
+  /* Page Menu accels */
   { "win.new-tab", { "<Primary>T", NULL } },
   { "win.open", { "<Primary>O", NULL } },
   { "win.save-as", { "<shift><Primary>S", "<Primary>S", NULL } },
@@ -274,7 +251,6 @@ const struct {
   { "win.copy", { "<Primary>C", NULL } },
   { "win.cut", { "<Primary>X", NULL } },
   { "win.paste", { "<Primary>V", NULL } },
-  { "win.select-all", { "<Primary>A", NULL } },
   { "win.zoom-in", { "<Primary>plus", "<Primary>KP_Add", "<Primary>equal", "ZoomIn", NULL } },
   { "win.zoom-out", { "<Primary>minus", "<Primary>KP_Subtract", "ZoomOut", NULL } },
   { "win.zoom-normal", { "<Primary>0", "<Primary>KP_0", NULL } },
@@ -286,6 +262,13 @@ const struct {
   { "win.page-source", { "<Primary>U", NULL } },
   { "win.toggle-inspector", { "<shift><Primary>I", "F12", NULL } },
   { "win.close", { "<Primary>W", NULL } },
+
+  { "win.select-all", { "<Primary>A", NULL } },
+
+  /* Navigation */
+  { "toolbar.stop", { "Escape", "Stop", NULL } },
+  { "toolbar.reload", { "<Primary>R", "<shift><Primary>R", "F5", "<Primary>F5", "<shift>F5", 
"<shift><Primary>F5", "Refresh", "Reload", NULL } },
+  { "toolbar.combined-stop-reload", { NULL } }
 }, accels_navigation_ltr [] = {
   { "toolbar.navigation-back", { "<alt>Left", "<alt>KP_Left", "KP_4", "Back", NULL } },
   { "toolbar.navigation-forward", { "<alt>Right", "<alt>KP_Right", "KP_6", "Forward", NULL } }
@@ -627,31 +610,31 @@ sync_tab_load_status (EphyWebView    *view,
                       WebKitLoadEvent load_event,
                       EphyWindow     *window)
 {
-  GtkActionGroup *action_group = window->action_group;
-  GtkAction *action;
-  GActionGroup *new_action_group;
-  GAction *new_action;
+  GActionGroup *action_group;
+  GAction *action;
   gboolean loading;
 
   if (window->closing) return;
 
   loading = ephy_web_view_is_loading (view);
 
-  new_action_group = gtk_widget_get_action_group (GTK_WIDGET (window),
-                                              "win");
-
-  action = gtk_action_group_get_action (action_group, "ViewStop");
-  gtk_action_set_sensitive (action, loading);
+  action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "win");
 
   /* disable print while loading, see bug #116344 */
-  new_action = g_action_map_lookup_action (G_ACTION_MAP (new_action_group),
+  action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
                                        "print");
-  new_ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (new_action), SENS_FLAG_LOADING, loading);
+  new_ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (action),
+                                        SENS_FLAG_LOADING, loading);
 
-  action = gtk_action_group_get_action (window->toolbar_action_group,
-                                        "ViewCombinedStopReload");
-  ephy_combined_stop_reload_action_set_loading (EPHY_COMBINED_STOP_RELOAD_ACTION (action),
-                                                loading);
+  action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "toolbar");
+
+  action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+                                       "stop");
+  g_simple_action_set_enabled (G_SIMPLE_ACTION (action), loading);
+
+  action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+                                       "combined-stop-reload");
+  g_action_change_state (action, g_variant_new_boolean (loading));
 }
 
 static void
@@ -1038,7 +1021,12 @@ static const GActionEntry ephy_toolbar_entries [] = {
   { "navigation-back", window_cmd_navigation, "s" },
   { "navigation-back-new-tab", window_cmd_navigation_new_tab, "s" },
   { "navigation-forward", window_cmd_navigation, "s" },
-  { "navigation-forward-new-tab", window_cmd_navigation_new_tab, "s" }
+  { "navigation-forward-new-tab", window_cmd_navigation_new_tab, "s" },
+
+  { "stop", window_cmd_view_stop },
+  { "reload", window_cmd_view_reload },
+  { "always-stop", window_cmd_view_stop },
+  { "combined-stop-reload", window_cmd_combined_stop_reload, NULL, "false", 
ephy_toolbar_change_combined_stop_reload_state }
 };
 
 static void
@@ -1096,14 +1084,6 @@ setup_ui_manager (EphyWindow *window)
                             G_CALLBACK (ephy_link_open), window);
   g_object_unref (action);
 
-  action = g_object_new (EPHY_TYPE_COMBINED_STOP_RELOAD_ACTION,
-                         "name", "ViewCombinedStopReload",
-                         "loading", FALSE,
-                         "window", window,
-                         NULL);
-  gtk_action_group_add_action (action_group, action);
-  g_object_unref (action);
-
   gtk_action_group_set_accel_group (action_group, accel_group);
   gtk_ui_manager_insert_action_group (manager, action_group, 0);
   window->toolbar_action_group = action_group;
@@ -1173,9 +1153,10 @@ _ephy_window_set_default_actions_sensitive (EphyWindow *window,
                                         flags, set);
 
   /* Toolbar */
-  action = gtk_action_group_get_action (window->toolbar_action_group,
-                                        "ViewCombinedStopReload");
-  ephy_action_change_sensitivity_flags (action,
+  new_action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "toolbar");
+  new_action = g_action_map_lookup_action (G_ACTION_MAP (new_action_group),
+                                       "combined-stop-reload");
+  new_ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (new_action),
                                         flags, set);
 }
 
@@ -1806,8 +1787,8 @@ populate_context_menu (WebKitWebView       *web_view,
                                       "navigation-back", window->toolbar);
       new_add_action_to_context_menu (context_menu, toolbar_action_group,
                                       "navigation-forward", window->toolbar);
-      add_action_to_context_menu (context_menu,
-                                  window->action_group, "ViewReload");
+      new_add_action_to_context_menu (context_menu, toolbar_action_group,
+                                      "reload", window->toolbar);
       webkit_context_menu_append (context_menu,
                                   webkit_context_menu_item_new_separator ());
     }
@@ -3086,13 +3067,11 @@ ephy_window_constructor (GType                  type,
 {
   GObject *object;
   EphyWindow *window;
-  EphyToolbar *toolbar;
   GtkSettings *settings;
   GtkAction *action;
   GAction *new_action;
   GActionGroup *new_action_group;
   GSimpleActionGroup *new_simple_action_group;
-  GtkActionGroup *toolbar_action_group;
   GError *error = NULL;
   guint settings_connection;
   GtkCssProvider *css_provider;
@@ -3213,7 +3192,6 @@ ephy_window_constructor (GType                  type,
                                               "win");
 
   /* Disable actions not needed for popup mode. */
-  toolbar_action_group = window->toolbar_action_group;
   new_action = g_action_map_lookup_action (G_ACTION_MAP (new_action_group), "new-tab");
   new_ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (new_action),
                                         SENS_FLAG_CHROME,
@@ -3577,6 +3555,20 @@ ephy_window_get_location_controller (EphyWindow *window)
   return window->location_controller;
 }
 
+/**
+ * ephy_window_get_toolbar:
+ * @window: an #EphyWindow
+ *
+ * Returns the @window #EphyToolbar
+ *
+ * Returns: (transfer none): the @window #EphyToolbar
+ **/
+GtkWidget *
+ephy_window_get_toolbar (EphyWindow *window)
+{
+  return window->toolbar;
+}
+
 typedef struct {
   EphyWindow *window;
   GCancellable *cancellable;
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 8eb28dc..0279cec 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -52,6 +52,8 @@ void              ephy_window_set_zoom            (EphyWindow *window,
 void             ephy_window_activate_location   (EphyWindow *window);
 const char       *ephy_window_get_location        (EphyWindow *window);
 
+GtkWidget        *ephy_window_get_toolbar         (EphyWindow *window);
+
 gboolean          ephy_window_close               (EphyWindow *window);
 
 EphyWindowChrome  ephy_window_get_chrome          (EphyWindow *window);
diff --git a/src/resources/epiphany-ui.xml b/src/resources/epiphany-ui.xml
index 18b7dc6..1341651 100644
--- a/src/resources/epiphany-ui.xml
+++ b/src/resources/epiphany-ui.xml
@@ -16,7 +16,5 @@
                </menu>
        </popup>
 
-       <accelerator name="AlwaysStopAccel" action="ViewAlwaysStop"/>
        <accelerator name="BrowseWithCaretAccel" action="BrowseWithCaret"/>
-
 </ui>
diff --git a/src/window-commands.c b/src/window-commands.c
index 7826983..e733756 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -140,51 +140,20 @@ window_cmd_navigation_new_tab (GSimpleAction *action,
 }
 
 void
-window_cmd_undo_close_tab (GtkAction  *action,
-                           EphyWindow *window)
-{
-  ephy_session_undo_close_tab (ephy_shell_get_session (ephy_shell_get_default ()));
-}
-
-void
-window_cmd_file_send_to (GtkAction  *action,
-                         EphyWindow *window)
+window_cmd_view_stop (GSimpleAction *action,
+                      GVariant      *value,
+                      gpointer       user_data)
 {
+  EphyWindow *window = EPHY_WINDOW (user_data);
   EphyEmbed *embed;
-  char *command, *subject, *body;
-  const char *location, *title;
-  GdkScreen *screen;
-  GError *error = NULL;
 
   embed = ephy_embed_container_get_active_child
             (EPHY_EMBED_CONTAINER (window));
   g_return_if_fail (embed != NULL);
 
-  location = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
-  title = ephy_embed_get_title (embed);
-
-  subject = g_uri_escape_string (title, NULL, TRUE);
-  body = g_uri_escape_string (location, NULL, TRUE);
-
-  command = g_strconcat ("mailto:";,
-                         "?Subject=", subject,
-                         "&Body=", body, NULL);
-
-  g_free (subject);
-  g_free (body);
-
-  if (window) {
-    screen = gtk_widget_get_screen (GTK_WIDGET (window));
-  } else {
-    screen = gdk_screen_get_default ();
-  }
-
-  if (!gtk_show_uri (screen, command, gtk_get_current_event_time (), &error)) {
-    g_warning ("Unable to send link by email: %s\n", error->message);
-    g_error_free (error);
-  }
+  gtk_widget_grab_focus (GTK_WIDGET (embed));
 
-  g_free (command);
+  webkit_web_view_stop_loading (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
 }
 
 static gboolean
@@ -211,17 +180,13 @@ event_with_shift (void)
 }
 
 void
-window_cmd_go_location (GtkAction  *action,
-                        EphyWindow *window)
-{
-  ephy_window_activate_location (window);
-}
-
-void
-window_cmd_view_stop (GtkAction  *action,
-                      EphyWindow *window)
+window_cmd_view_reload (GSimpleAction *action,
+                        GVariant      *value,
+                        gpointer       user_data)
 {
+  EphyWindow *window = EPHY_WINDOW (user_data);
   EphyEmbed *embed;
+  WebKitWebView *view;
 
   embed = ephy_embed_container_get_active_child
             (EPHY_EMBED_CONTAINER (window));
@@ -229,27 +194,88 @@ window_cmd_view_stop (GtkAction  *action,
 
   gtk_widget_grab_focus (GTK_WIDGET (embed));
 
-  webkit_web_view_stop_loading (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
+  view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+  if (event_with_shift ())
+    webkit_web_view_reload_bypass_cache (view);
+  else
+    webkit_web_view_reload (view);
+}
+
+void window_cmd_combined_stop_reload (GSimpleAction *action,
+                                      GVariant      *parameter,
+                                      gpointer       user_data)
+{
+  GActionGroup *action_group;
+  GAction *gaction;
+  GVariant *state;
+
+  action_group = gtk_widget_get_action_group (GTK_WIDGET (user_data), "toolbar");
+
+  state = g_action_get_state (G_ACTION (action));
+  /* If loading */
+  if (g_variant_get_boolean (state))
+    gaction = g_action_map_lookup_action (G_ACTION_MAP (action_group), "stop");
+  else
+    gaction = g_action_map_lookup_action (G_ACTION_MAP (action_group), "reload");
+
+  g_action_activate (gaction, NULL);
+
+  g_variant_unref (state);
 }
 
 void
-window_cmd_view_reload (GtkAction  *action,
-                        EphyWindow *window)
+window_cmd_undo_close_tab (GtkAction  *action,
+                           EphyWindow *window)
+{
+  ephy_session_undo_close_tab (ephy_shell_get_session (ephy_shell_get_default ()));
+}
+
+void
+window_cmd_file_send_to (GtkAction  *action,
+                         EphyWindow *window)
 {
   EphyEmbed *embed;
-  WebKitWebView *view;
+  char *command, *subject, *body;
+  const char *location, *title;
+  GdkScreen *screen;
+  GError *error = NULL;
 
   embed = ephy_embed_container_get_active_child
             (EPHY_EMBED_CONTAINER (window));
   g_return_if_fail (embed != NULL);
 
-  gtk_widget_grab_focus (GTK_WIDGET (embed));
+  location = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
+  title = ephy_embed_get_title (embed);
 
-  view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
-  if (event_with_shift ())
-    webkit_web_view_reload_bypass_cache (view);
-  else
-    webkit_web_view_reload (view);
+  subject = g_uri_escape_string (title, NULL, TRUE);
+  body = g_uri_escape_string (location, NULL, TRUE);
+
+  command = g_strconcat ("mailto:";,
+                         "?Subject=", subject,
+                         "&Body=", body, NULL);
+
+  g_free (subject);
+  g_free (body);
+
+  if (window) {
+    screen = gtk_widget_get_screen (GTK_WIDGET (window));
+  } else {
+    screen = gdk_screen_get_default ();
+  }
+
+  if (!gtk_show_uri (screen, command, gtk_get_current_event_time (), &error)) {
+    g_warning ("Unable to send link by email: %s\n", error->message);
+    g_error_free (error);
+  }
+
+  g_free (command);
+}
+
+void
+window_cmd_go_location (GtkAction  *action,
+                        EphyWindow *window)
+{
+  ephy_window_activate_location (window);
 }
 
 void
diff --git a/src/window-commands.h b/src/window-commands.h
index 7c208e9..6108af0 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -30,12 +30,17 @@ void window_cmd_navigation                (GSimpleAction *action,
 void window_cmd_navigation_new_tab        (GSimpleAction *action,
                                            GVariant      *value,
                                            gpointer       user_data);
-void window_cmd_view_stop                 (GtkAction  *action,
-                                           EphyWindow *window);
+void window_cmd_view_stop                 (GSimpleAction *action,
+                                           GVariant      *value,
+                                           gpointer       user_data);
+void window_cmd_view_reload               (GSimpleAction *action,
+                                           GVariant      *value,
+                                           gpointer       user_data);
+void window_cmd_combined_stop_reload      (GSimpleAction *action,
+                                           GVariant      *parameter,
+                                           gpointer       user_data);
 void window_cmd_go_location               (GtkAction  *action,
                                            EphyWindow *window);
-void window_cmd_view_reload               (GtkAction  *action,
-                                           EphyWindow *window);
 void window_cmd_file_bookmark_page        (GtkAction  *action,
                                            EphyWindow *window);
 void window_cmd_undo_close_tab            (GtkAction *action,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]