[evince] shell: Move 'Open...' file from document to application
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] shell: Move 'Open...' file from document to application
- Date: Fri, 25 May 2018 13:35:12 +0000 (UTC)
commit 6e0dbaea93f84053cb72e36b2b3b33250004fb94
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Tue May 22 20:53:59 2018 -0400
shell: Move 'Open...' file from document to application
Opening a new document is not an action that applies to the active
document. Therefore, it is a global action which belongs to the
application rather than the window.
We move the visual cue ('menu') from the document window to the
application. Additionally, we remove the toolbar button from
'Recent view' window because it becomes redundant having the visual
action in two places.
However, we still leave available the shortcut (Ctrl-O), which is
done in each window, as it were a global shorcut.
In spite that the action in the UX mainly belongs to the application
rather than a document, we still need to know where to display the
dialog (a parent window), in which screen the document should be
opened, and if the active window is in Recent View mode, use that
window to open the document.
Because we remove the toolbar button in the Recent View, Issue #514
becomes obsolete or duplicated.
Closes #524
shell/ev-application.c | 14 ++++++++++++++
shell/ev-toolbar.c | 37 -------------------------------------
shell/ev-window.c | 32 +++++++++++++++++++++++++++-----
shell/ev-window.h | 1 +
shell/evince-menus.ui | 8 ++++----
5 files changed, 46 insertions(+), 46 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index e937e04b..fcbcaa75 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -937,6 +937,19 @@ ev_application_migrate_config_dir (EvApplication *application)
g_free (old_accels);
}
+static void
+app_file_open_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ EvApplication *application = user_data;
+ EvWindow *window;
+
+ window = EV_WINDOW (gtk_application_get_active_window (GTK_APPLICATION (application)));
+
+ ev_window_file_open_dialog (window);
+}
+
static void
app_new_cb (GSimpleAction *action,
GVariant *parameter,
@@ -1021,6 +1034,7 @@ static void
ev_application_startup (GApplication *gapplication)
{
const GActionEntry app_menu_actions[] = {
+ { "open", app_file_open_cb, NULL, NULL, NULL },
{ "new", app_new_cb, NULL, NULL, NULL },
{ "help", app_help_cb, NULL, NULL, NULL },
{ "about", app_about_cb, NULL, NULL, NULL }
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index fdc3fc18..2df5a75c 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -50,7 +50,6 @@ struct _EvToolbarPrivate {
GtkWidget *page_selector;
GtkWidget *navigation_action;
GtkWidget *find_button;
- GtkWidget *open_button;
GtkWidget *annots_button;
GMenu *bookmarks_section;
@@ -88,24 +87,6 @@ ev_toolbar_set_button_action (EvToolbar *ev_toolbar,
gtk_widget_set_tooltip_text (GTK_WIDGET (button), tooltip);
}
-static GtkWidget *
-ev_toolbar_create_button (EvToolbar *ev_toolbar,
- const gchar *action_name,
- const gchar *icon_name,
- const gchar *tooltip)
-{
- GtkWidget *button = gtk_button_new ();
- GtkWidget *image;
-
- image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
-
- gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
- gtk_button_set_image (GTK_BUTTON (button), image);
- ev_toolbar_set_button_action (ev_toolbar, GTK_BUTTON (button), action_name, tooltip);
-
- return button;
-}
-
static GtkWidget *
ev_toolbar_create_toggle_button (EvToolbar *ev_toolbar,
const gchar *action_name,
@@ -197,13 +178,6 @@ ev_toolbar_constructed (GObject *object)
builder = gtk_builder_new_from_resource ("/org/gnome/evince/gtk/menus.ui");
- button = ev_toolbar_create_button (ev_toolbar, "win.open",
- "document-open-symbolic",
- _("Open an existing document"));
- ev_toolbar->priv->open_button = button;
- gtk_container_add (GTK_CONTAINER (ev_toolbar), button);
- gtk_widget_set_margin_end (button, 6);
-
/* Page selector */
/* Use EvPageActionWidget for now, since the page selector action is also used by the previewer */
tool_item = GTK_WIDGET (g_object_new (EV_TYPE_PAGE_ACTION_WIDGET, NULL));
@@ -372,15 +346,6 @@ ev_toolbar_set_mode (EvToolbar *ev_toolbar,
switch (mode) {
case EV_TOOLBAR_MODE_NORMAL:
- gtk_widget_show (priv->view_menu_button);
- gtk_widget_show (priv->action_menu_button);
- gtk_widget_show (priv->history_action);
- gtk_widget_show (priv->zoom_action);
- gtk_widget_show (priv->page_selector);
- gtk_widget_show (priv->find_button);
- gtk_widget_show (priv->annots_button);
- gtk_widget_hide (priv->open_button);
- break;
case EV_TOOLBAR_MODE_FULLSCREEN:
gtk_widget_show (priv->view_menu_button);
gtk_widget_show (priv->action_menu_button);
@@ -389,7 +354,6 @@ ev_toolbar_set_mode (EvToolbar *ev_toolbar,
gtk_widget_show (priv->page_selector);
gtk_widget_show (priv->find_button);
gtk_widget_show (priv->annots_button);
- gtk_widget_hide (priv->open_button);
break;
case EV_TOOLBAR_MODE_RECENT_VIEW:
gtk_widget_hide (priv->view_menu_button);
@@ -399,7 +363,6 @@ ev_toolbar_set_mode (EvToolbar *ev_toolbar,
gtk_widget_hide (priv->page_selector);
gtk_widget_hide (priv->find_button);
gtk_widget_hide (priv->annots_button);
- gtk_widget_show (priv->open_button);
break;
}
}
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 85492313..36a6d031 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -2539,6 +2539,7 @@ ev_window_file_chooser_restore_folder (EvWindow *window,
g_settings_get (ev_window_ensure_settings (window),
get_settings_key_for_directory (directory),
"ms", &folder_uri);
+
if (folder_uri == NULL && uri != NULL) {
GFile *file, *parent;
@@ -2608,12 +2609,23 @@ file_open_dialog_response_cb (GtkWidget *chooser,
gtk_widget_destroy (chooser);
}
-static void
-ev_window_cmd_file_open (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+/**
+ * ev_window_file_open_dialog:
+ * @ev_window: The instance of the #EvWindow. Likely the active window.
+ *
+ * It requests to open a document through a dialog. It uses @ev_window to
+ * set the parent window, and to determine the screen on which the document
+ * should be opened.
+ *
+ * If @ev_window is displaying the recent documents, then the document will
+ * use that window. Otherwise, the document will be opened in a new window.
+ *
+ * It does look if there is any document loaded or if there is any job to load
+ * a document.
+ */
+void
+ev_window_file_open_dialog (EvWindow *window)
{
- EvWindow *window = user_data;
GtkWidget *chooser;
chooser = gtk_file_chooser_dialog_new (_("Open Document"),
@@ -2638,6 +2650,16 @@ ev_window_cmd_file_open (GSimpleAction *action,
gtk_widget_show (chooser);
}
+static void
+ev_window_cmd_file_open (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ EvWindow *window = user_data;
+
+ ev_window_file_open_dialog (window);
+}
+
static void
ev_window_open_copy_at_dest (EvWindow *window,
EvLinkDest *dest)
diff --git a/shell/ev-window.h b/shell/ev-window.h
index 7624caf1..28d031a8 100644
--- a/shell/ev-window.h
+++ b/shell/ev-window.h
@@ -94,6 +94,7 @@ EvHistory *ev_window_get_history (EvWindow *ev_win
EvDocumentModel *ev_window_get_document_model (EvWindow *ev_window);
void ev_window_focus_view (EvWindow *ev_window);
GtkWidget *ev_window_get_toolbar (EvWindow *ev_window);
+void ev_window_file_open_dialog (EvWindow *ev_window);
G_END_DECLS
diff --git a/shell/evince-menus.ui b/shell/evince-menus.ui
index 50285edd..73a8df18 100644
--- a/shell/evince-menus.ui
+++ b/shell/evince-menus.ui
@@ -20,6 +20,10 @@
<interface>
<menu id="app-menu">
<section>
+ <item>
+ <attribute name="label" translatable="yes">_Open…</attribute>
+ <attribute name="action">app.open</attribute>
+ </item>
<item>
<attribute name="label" translatable="yes">_New Window</attribute>
<attribute name="action">app.new</attribute>
@@ -133,10 +137,6 @@
<menu id="action-menu">
<section>
- <item>
- <attribute name="label" translatable="yes">_Open…</attribute>
- <attribute name="action">win.open</attribute>
- </item>
<item>
<attribute name="label" translatable="yes">Op_en a Copy</attribute>
<attribute name="action">win.open-copy</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]