summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Radu <iulian.radu67@gmail.com>2016-07-01 18:05:08 +0300
committerIulian Radu <iulian.radu67@gmail.com>2016-07-11 19:22:26 +0300
commit4ff411ba97b70bc4c1ed95787b3c876c4fd9963f (patch)
tree251524fa378cfec88c0fd09d0fd28577a2f2ffde
parent122fd6e24d72aa8a9ca8c0cfee586dfcd2ae057c (diff)
downloadepiphany-4ff411ba97b70bc4c1ed95787b3c876c4fd9963f.tar.gz
Use GAction for Send To
-rw-r--r--src/ephy-window.c44
-rw-r--r--src/window-commands.c84
-rw-r--r--src/window-commands.h5
3 files changed, 61 insertions, 72 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 487574596..262bb7263 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -75,11 +75,6 @@ static void ephy_window_view_popup_windows_cb (GtkAction *action,
EphyWindow *window);
static const GtkActionEntry ephy_menu_entries [] = {
- /* File actions. */
-
- { "FileSendTo", NULL, N_("S_end Link by Email…"), NULL, NULL,
- G_CALLBACK (window_cmd_file_send_to) },
-
/* Go actions. */
{ "GoLocation", NULL, N_("_Location…"), "<control>L", NULL,
@@ -164,7 +159,6 @@ static const struct {
#ifdef HAVE_X11_XF86KEYSYM_H
{ XF86XK_Go, 0, "GoLocation", FALSE },
{ XF86XK_OpenURL, 0, "GoLocation", FALSE },
- { XF86XK_Send, 0, "FileSendTo", FALSE },
#endif /* HAVE_X11_XF86KEYSYM_H */
};
@@ -196,6 +190,8 @@ const struct {
{ "win.select-all", { "<Primary>A", NULL } },
+ { "win.send-to", { "Send", NULL } },
+
/* Toggle actions */
{ "win.browse-with-caret", { "F7", NULL } },
{ "win.fullscreen", { "F11", NULL } },
@@ -963,6 +959,8 @@ static const GActionEntry window_entries [] =
{ "select-all", window_cmd_edit_select_all },
+ { "send-to", window_cmd_file_send_to },
+
/* Toggle actions */
{ "browse-with-caret", activate_toggle, NULL, "false", window_cmd_change_browse_with_caret },
{ "fullscreen", activate_toggle, NULL, "false", window_cmd_change_fullscreen_state }
@@ -1062,37 +1060,25 @@ _ephy_window_set_default_actions_sensitive (EphyWindow *window,
guint flags,
gboolean set)
{
- GActionGroup *new_action_group;
- GtkActionGroup *action_group;
+ GActionGroup *action_group;
GtkAction *action;
GAction *new_action;
int i;
- const char *action_group_actions[] = { "FileSendTo",
- NULL };
- const char *new_action_group_actions[] = { "save-as", "save-as-application",
+ const char *action_group_actions[] = { "save-as", "save-as-application",
"zoom-in", "zoom-out", "print",
"find", "find-prev", "find-next",
"bookmark-page", "encoding", "page-source",
+ "send-to",
NULL };
- action_group = window->action_group;
-
- /* Page menu */
- for (i = 0; action_group_actions[i] != NULL; i++) {
- action = gtk_action_group_get_action (action_group,
- action_group_actions[i]);
- ephy_action_change_sensitivity_flags (action,
- flags, set);
- }
-
- new_action_group = gtk_widget_get_action_group (GTK_WIDGET (window),
+ action_group = gtk_widget_get_action_group (GTK_WIDGET (window),
"win");
/* Page menu */
- for (i = 0; new_action_group_actions[i] != NULL; i++) {
- new_action = g_action_map_lookup_action (G_ACTION_MAP (new_action_group),
- new_action_group_actions[i]);
+ for (i = 0; action_group_actions[i] != NULL; i++) {
+ new_action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ action_group_actions[i]);
new_ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (new_action),
flags, set);
}
@@ -1104,8 +1090,8 @@ _ephy_window_set_default_actions_sensitive (EphyWindow *window,
flags, set);
/* Toolbar */
- 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),
+ action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "toolbar");
+ new_action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
"combined-stop-reload");
new_ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (new_action),
flags, set);
@@ -1810,8 +1796,8 @@ populate_context_menu (WebKitWebView *web_view,
if (is_document && !is_image && !is_media) {
webkit_context_menu_append (context_menu,
webkit_context_menu_item_new_separator ());
- add_action_to_context_menu (context_menu,
- window->action_group, "FileSendTo");
+ new_add_action_to_context_menu (context_menu, window_action_group,
+ "send-to", window->toolbar);
}
webkit_context_menu_append (context_menu,
diff --git a/src/window-commands.c b/src/window-commands.c
index 8203a03dd..6a3dd3b1e 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -231,47 +231,6 @@ window_cmd_undo_close_tab (GtkAction *action,
}
void
-window_cmd_file_send_to (GtkAction *action,
- EphyWindow *window)
-{
- 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);
- }
-
- g_free (command);
-}
-
-void
window_cmd_go_location (GtkAction *action,
EphyWindow *window)
{
@@ -1705,6 +1664,49 @@ window_cmd_edit_select_all (GSimpleAction *action,
}
void
+window_cmd_file_send_to (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);
+ }
+
+ g_free (command);
+}
+
+void
window_cmd_change_browse_with_caret (GSimpleAction *action,
GVariant *state,
gpointer user_data)
diff --git a/src/window-commands.h b/src/window-commands.h
index 21ad0311f..6d79b8416 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -43,8 +43,6 @@ void window_cmd_go_location (GtkAction *action,
EphyWindow *window);
void window_cmd_undo_close_tab (GtkAction *action,
EphyWindow *window);
-void window_cmd_file_send_to (GtkAction *action,
- EphyWindow *window);
void window_cmd_file_new_tab (GSimpleAction *action,
GVariant *value,
gpointer user_data);
@@ -134,6 +132,9 @@ void window_cmd_edit_preferences (GtkAction *action,
void window_cmd_edit_select_all (GSimpleAction *action,
GVariant *value,
gpointer user_data);
+void window_cmd_file_send_to (GSimpleAction *action,
+ GVariant *value,
+ gpointer user_data);
void window_cmd_change_browse_with_caret (GSimpleAction *action,
GVariant *state,
gpointer user_data);