Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2006-07-17 19:44:13 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2006-07-17 19:44:13 (GMT)
commitdb4719bf8f445529477290060d64637f134329b2 (patch)
tree1023e8e97914f62260e0f7efdcbf70cab06526e2
parent2d7173f26d1fd901723592e9e56f63c79d4cb985 (diff)
Add preview toolbar (hidden by default)
2006-07-17 Carlos Garcia Campos <carlosgc@gnome.org> * data/evince-toolbar.xml: Add preview toolbar (hidden by default) * shell/ev-application-service.xml: * shell/ev-application.[ch]: * shell/ev-jobs.[ch]: * shell/ev-window.[ch]: (ev_window_run_preview): * shell/main.c: Add preview mode to use evince as a printing previewer. It also adds other command line options for fullscreen and presentation modes. Fixes bugs #347822, #317031
-rw-r--r--ChangeLog13
-rw-r--r--data/evince-toolbar.xml13
-rw-r--r--data/evince-ui.xml2
-rw-r--r--shell/ev-application-service.xml2
-rw-r--r--shell/ev-application.c38
-rw-r--r--shell/ev-application.h3
-rw-r--r--shell/ev-jobs.c4
-rw-r--r--shell/ev-jobs.h6
-rw-r--r--shell/ev-window.c56
-rw-r--r--shell/ev-window.h11
-rw-r--r--shell/main.c103
11 files changed, 215 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index b24e4b2..00b5589 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-07-17 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * data/evince-toolbar.xml: Add preview toolbar (hidden by default)
+ * shell/ev-application-service.xml:
+ * shell/ev-application.[ch]:
+ * shell/ev-jobs.[ch]:
+ * shell/ev-window.[ch]: (ev_window_run_preview):
+ * shell/main.c:
+
+ Add preview mode to use evince as a printing previewer. It also adds
+ other command line options for fullscreen and presentation modes.
+ Fixes bugs #347822, #317031
+
2006-07-11 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* NEWS:
diff --git a/data/evince-toolbar.xml b/data/evince-toolbar.xml
index fdfc695..d890276 100644
--- a/data/evince-toolbar.xml
+++ b/data/evince-toolbar.xml
@@ -26,5 +26,18 @@
<toolitem name="PageSelector"/>
<separator/>
<toolitem name="ViewZoom"/>
+ </toolbar>
+
+<toolbar name="PreviewTooBar" hidden="true" editable="false">
+ <toolitem name="GoPreviousPage"/>
+ <toolitem name="GoNextPage"/>
+ <separator/>
+ <toolitem name="PageSelector"/>
+ <separator/>
+ <toolitem name="ViewPageWidth"/>
+ <toolitem name="ViewBestFit"/>
+ <toolitem name="ViewZoomIn"/>
+ <toolitem name="ViewZoomOut"/>
</toolbar>
+
</toolbars>
diff --git a/data/evince-ui.xml b/data/evince-ui.xml
index 213a276..1470f8b 100644
--- a/data/evince-ui.xml
+++ b/data/evince-ui.xml
@@ -99,5 +99,5 @@
<accelerator name="KpMinusAccel" action="KpMinus"/>
<accelerator name="CtrlKpPlusAccel" action="CtrlKpPlus"/>
<accelerator name="CtrlKpMinusAccel" action="CtrlKpMinus"/>
-
+
</ui>
diff --git a/shell/ev-application-service.xml b/shell/ev-application-service.xml
index 65bd1ec..4ef2cfa 100644
--- a/shell/ev-application-service.xml
+++ b/shell/ev-application-service.xml
@@ -13,7 +13,7 @@
<method name="OpenURI">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="ev_application_open_uri"/>
<arg type="s" name="uri" direction="in"/>
- <arg type="s" name="page_label" direction="in"/>
+ <arg type="a{sv}" name="args" direction="in"/>
<arg type="u" name="timestamp" direction="in"/>
</method>
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 381b4e3..b7002a7 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -239,6 +239,7 @@ void
ev_application_open_uri_at_dest (EvApplication *application,
const char *uri,
EvLinkDest *dest,
+ EvWindowRunMode mode,
guint timestamp)
{
EvWindow *new_window;
@@ -263,7 +264,7 @@ ev_application_open_uri_at_dest (EvApplication *application,
/* We need to load uri before showing the window, so
we can restore window size without flickering */
- ev_window_open_uri (new_window, uri, dest);
+ ev_window_open_uri (new_window, uri, dest, mode);
gtk_widget_show (GTK_WIDGET (new_window));
@@ -274,21 +275,34 @@ ev_application_open_uri_at_dest (EvApplication *application,
gboolean
ev_application_open_uri (EvApplication *application,
const char *uri,
- const char *page_label,
+ GHashTable *args,
guint timestamp,
GError **error)
{
-
- if (page_label && strcmp (page_label, "") != 0) {
- EvLinkDest *dest;
+ EvLinkDest *dest = NULL;
+ EvWindowRunMode mode = EV_WINDOW_MODE_NORMAL;
+
+ if (args) {
+ GValue *value = NULL;
+
+ value = g_hash_table_lookup (args, "page-label");
+ if (value) {
+ const gchar *page_label;
+
+ page_label = g_value_get_string (value);
+ dest = ev_link_dest_new_page_label (page_label);
+ }
- dest = ev_link_dest_new_page_label (page_label);
+ value = g_hash_table_lookup (args, "mode");
+ if (value) {
+ mode = g_value_get_uint (value);
+ }
+ }
+
+ ev_application_open_uri_at_dest (application, uri, dest, mode, timestamp);
- ev_application_open_uri_at_dest (application, uri, dest, timestamp);
+ if (dest)
g_object_unref (dest);
- } else {
- ev_application_open_uri_at_dest (application, uri, NULL, timestamp);
- }
return TRUE;
}
@@ -346,9 +360,9 @@ ev_application_init (EvApplication *ev_application)
DATADIR "/evince-toolbar.xml");
if (!egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
- ev_application->toolbars_file)) {
+ ev_application->toolbars_file)) {
egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
- DATADIR"/evince-toolbar.xml");
+ DATADIR"/evince-toolbar.xml");
}
egg_toolbars_model_set_flags (ev_application->toolbars_model, 0,
diff --git a/shell/ev-application.h b/shell/ev-application.h
index 0c562c0..9388612 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -71,12 +71,13 @@ gboolean ev_application_open_window (EvApplication *applicati
GError **error);
gboolean ev_application_open_uri (EvApplication *application,
const char *uri,
- const char *page_label,
+ GHashTable *args,
guint timestamp,
GError **error);
void ev_application_open_uri_at_dest (EvApplication *application,
const char *uri,
EvLinkDest *dest,
+ EvWindowRunMode mode,
guint32 timestamp);
void ev_application_open_uri_list (EvApplication *application,
GSList *uri_list,
diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c
index c88c011..bc0a15a 100644
--- a/shell/ev-jobs.c
+++ b/shell/ev-jobs.c
@@ -409,7 +409,7 @@ ev_job_xfer_class_init (EvJobXferClass *class)
EvJob *
-ev_job_xfer_new (const gchar *uri, EvLinkDest *dest)
+ev_job_xfer_new (const gchar *uri, EvLinkDest *dest, EvWindowRunMode mode)
{
EvJobXfer *job;
@@ -419,6 +419,8 @@ ev_job_xfer_new (const gchar *uri, EvLinkDest *dest)
if (dest)
job->dest = g_object_ref (dest);
+ job->mode = mode;
+
return EV_JOB (job);
}
diff --git a/shell/ev-jobs.h b/shell/ev-jobs.h
index bf9c86b..d57f9c0 100644
--- a/shell/ev-jobs.h
+++ b/shell/ev-jobs.h
@@ -22,6 +22,7 @@
#include <gtk/gtk.h>
#include "ev-document.h"
+#include "ev-window.h"
G_BEGIN_DECLS
@@ -163,6 +164,7 @@ struct _EvJobXfer
{
EvJob parent;
EvLinkDest *dest;
+ EvWindowRunMode mode;
GError *error;
char *uri;
char *local_uri;
@@ -211,7 +213,9 @@ void ev_job_fonts_run (EvJobFonts *fonts);
/* EvJobXfer */
GType ev_job_xfer_get_type (void);
-EvJob *ev_job_xfer_new (const gchar *uri, EvLinkDest *dest);
+EvJob *ev_job_xfer_new (const gchar *uri,
+ EvLinkDest *dest,
+ EvWindowRunMode mode);
void ev_job_xfer_run (EvJobXfer *xfer);
G_END_DECLS
diff --git a/shell/ev-window.c b/shell/ev-window.c
index b285ca0..9eab28a 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -204,6 +204,7 @@ static void ev_window_run_presentation (EvWindow *windo
static void ev_window_stop_presentation (EvWindow *window);
static void ev_window_cmd_view_presentation (GtkAction *action,
EvWindow *window);
+static void ev_window_run_preview (EvWindow *window);
static void ev_view_popup_cmd_open_link (GtkAction *action,
EvWindow *window);
static void ev_view_popup_cmd_copy_link_address (GtkAction *action,
@@ -926,6 +927,20 @@ ev_window_xfer_job_cb (EvJobXfer *job,
if (job->dest)
ev_window_goto_dest (ev_window, job->dest);
+ switch (job->mode) {
+ case EV_WINDOW_MODE_FULLSCREEN:
+ ev_window_run_fullscreen (ev_window);
+ break;
+ case EV_WINDOW_MODE_PRESENTATION:
+ ev_window_run_presentation (ev_window);
+ break;
+ case EV_WINDOW_MODE_PREVIEW:
+ ev_window_run_preview (ev_window);
+ break;
+ default:
+ break;
+ }
+
ev_window_clear_xfer_job (ev_window);
return;
}
@@ -986,14 +1001,17 @@ ev_window_close_dialogs (EvWindow *ev_window)
}
void
-ev_window_open_uri (EvWindow *ev_window, const char *uri, EvLinkDest *dest)
+ev_window_open_uri (EvWindow *ev_window,
+ const char *uri,
+ EvLinkDest *dest,
+ EvWindowRunMode mode)
{
ev_window_close_dialogs (ev_window);
ev_window_clear_xfer_job (ev_window);
ev_window_clear_local_uri (ev_window);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
- ev_window->priv->xfer_job = ev_job_xfer_new (uri, dest);
+ ev_window->priv->xfer_job = ev_job_xfer_new (uri, dest, mode);
g_signal_connect (ev_window->priv->xfer_job,
"finished",
G_CALLBACK (ev_window_xfer_job_cb),
@@ -1830,6 +1848,35 @@ ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window)
}
}
+static void
+ev_window_run_preview (EvWindow *window)
+{
+ EggToolbarsModel *model;
+ EggTbModelFlags flags;
+
+ model = egg_toolbars_model_new ();
+
+ egg_toolbars_model_load_toolbars (model,
+ DATADIR"/evince-toolbar.xml");
+
+ flags = egg_toolbars_model_get_flags (model, 1);
+ egg_toolbars_model_set_flags (model, 1, flags &= ~(EGG_TB_MODEL_HIDDEN));
+
+ egg_editable_toolbar_set_model (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ model);
+
+ egg_editable_toolbar_hide (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ "DefaultToolBar");
+ egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ "PreviewToolBar");
+
+ ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
+
+ update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
+ update_chrome_visibility (window);
+}
+
static gboolean
ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
{
@@ -2061,7 +2108,7 @@ ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window)
uri = g_strdup (ev_window->priv->uri);
- ev_window_open_uri (ev_window, uri, NULL);
+ ev_window_open_uri (ev_window, uri, NULL, 0);
g_free (uri);
}
@@ -3237,6 +3284,7 @@ open_remote_link (EvWindow *window, EvLinkAction *action)
ev_application_open_uri_at_dest (EV_APP, uri,
ev_link_action_get_dest (action),
+ 0,
GDK_CURRENT_TIME);
g_free (uri);
@@ -3553,6 +3601,7 @@ ev_window_init (EvWindow *ev_window)
"popup",
G_CALLBACK (attachment_bar_menu_popup_cb),
ev_window, 0);
+ gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
@@ -3712,6 +3761,7 @@ ev_window_init (EvWindow *ev_window)
update_chrome_visibility (ev_window);
gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600);
+
setup_view_from_metadata (ev_window);
setup_sidebar_from_metadata (ev_window, NULL);
diff --git a/shell/ev-window.h b/shell/ev-window.h
index e54a62e..d2d5846 100644
--- a/shell/ev-window.h
+++ b/shell/ev-window.h
@@ -31,6 +31,13 @@
G_BEGIN_DECLS
+typedef enum {
+ EV_WINDOW_MODE_NORMAL,
+ EV_WINDOW_MODE_FULLSCREEN,
+ EV_WINDOW_MODE_PRESENTATION,
+ EV_WINDOW_MODE_PREVIEW
+} EvWindowRunMode;
+
typedef struct _EvWindow EvWindow;
typedef struct _EvWindowClass EvWindowClass;
typedef struct _EvWindowPrivate EvWindowPrivate;
@@ -42,6 +49,7 @@ typedef struct _EvWindowPrivate EvWindowPrivate;
#define EV_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_WINDOW))
#define EV_WINDOW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_WINDOW, EvWindowClass))
+
struct _EvWindow {
GtkWindow base_instance;
EvWindowPrivate *priv;
@@ -56,7 +64,8 @@ GtkWidget *ev_window_new (void);
const char *ev_window_get_uri (EvWindow *ev_window);
void ev_window_open_uri (EvWindow *ev_window,
const char *uri,
- EvLinkDest *dest);
+ EvLinkDest *dest,
+ EvWindowRunMode mode);
void ev_window_goto_dest (EvWindow *ev_window,
EvLinkDest *dest);
gboolean ev_window_is_empty (const EvWindow *ev_window);
diff --git a/shell/main.c b/shell/main.c
index 1f3da85..a8903f7 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -43,18 +43,70 @@
#include "ev-job-queue.h"
#include "ev-file-helpers.h"
-static char *ev_page_label;
+static gchar *ev_page_label;
+static gboolean preview_mode = FALSE;
+static gboolean fullscren_mode = FALSE;
+static gboolean presentation_mode = FALSE;
static const char **file_arguments = NULL;
static const GOptionEntry goption_options[] =
{
{ "page-label", 'p', 0, G_OPTION_ARG_STRING, &ev_page_label, N_("The page of the document to display."), N_("PAGE")},
+ { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscren_mode, N_("Run evince in fullscreen mode"), NULL },
+ { "presentation", 's', 0, G_OPTION_ARG_NONE, &presentation_mode, N_("Run evince in presentation mode"), NULL },
+ { "preview", 'w', 0, G_OPTION_ARG_NONE, &preview_mode, N_("Run evince as a previewer"), NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments, NULL, N_("[FILE...]") },
{ NULL }
};
static void
-load_files (const char **files)
+value_free (GValue *value)
+{
+ g_value_unset (value);
+ g_free (value);
+}
+
+static GHashTable *
+arguments_parse (void)
+{
+ GHashTable *args;
+ GValue *value;
+ EvWindowRunMode mode;
+
+ args = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)value_free);
+
+ if (ev_page_label) {
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, ev_page_label);
+
+ g_hash_table_insert (args, g_strdup ("page-label"), value);
+ }
+
+ if (fullscren_mode)
+ mode = EV_WINDOW_MODE_FULLSCREEN;
+ else if (presentation_mode)
+ mode = EV_WINDOW_MODE_PRESENTATION;
+ else if (preview_mode)
+ mode = EV_WINDOW_MODE_PREVIEW;
+ else
+ return args;
+
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_UINT);
+ g_value_set_uint (value, mode);
+
+ g_hash_table_insert (args, g_strdup ("mode"), value);
+
+ return args;
+}
+
+static void
+load_files (const char **files,
+ GHashTable *args)
{
int i;
@@ -64,21 +116,35 @@ load_files (const char **files)
}
for (i = 0; files[i]; i++) {
- char *uri;
- char *label;
+ char *uri;
+ char *label;
+ GValue *old = NULL;
uri = gnome_vfs_make_uri_from_shell_arg (files[i]);
label = strchr (uri, GNOME_VFS_URI_MAGIC_CHR);
-
+
if (label) {
+ GValue *new;
+
*label = 0; label++;
- ev_application_open_uri (EV_APP, uri, label,
- GDK_CURRENT_TIME, NULL);
- } else {
- ev_application_open_uri (EV_APP, uri, ev_page_label,
- GDK_CURRENT_TIME, NULL);
+
+ old = g_hash_table_lookup (args, "page-label");
+
+ new = g_new0 (GValue, 1);
+ g_value_init (new, G_TYPE_STRING);
+ g_value_set_string (new, label);
+
+ g_hash_table_insert (args, g_strdup ("page-label"), new);
+
}
+
+ ev_application_open_uri (EV_APP, uri, args,
+ GDK_CURRENT_TIME, NULL);
+
+ if (old)
+ g_hash_table_insert (args, g_strdup ("page-label"), old);
+
g_free (uri);
}
}
@@ -86,7 +152,8 @@ load_files (const char **files)
#ifdef ENABLE_DBUS
static gboolean
-load_files_remote (const char **files)
+load_files_remote (const char **files,
+ GHashTable *args)
{
int i;
GError *error = NULL;
@@ -192,7 +259,7 @@ load_files_remote (const char **files)
#else
if (!dbus_g_proxy_call (remote_object, "OpenURI", &error,
G_TYPE_STRING, uri,
- G_TYPE_STRING, page_label,
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), args,
G_TYPE_UINT, timestamp,
G_TYPE_INVALID,
G_TYPE_INVALID)) {
@@ -220,6 +287,7 @@ main (int argc, char *argv[])
{
gboolean enable_metadata = FALSE;
GOptionContext *context;
+ GHashTable *args;
GnomeProgram *program;
context = g_option_context_new (_("GNOME Document Viewer"));
@@ -241,9 +309,13 @@ main (int argc, char *argv[])
GNOME_PARAM_APP_DATADIR, GNOMEDATADIR,
NULL);
+ args = arguments_parse ();
+
#ifdef ENABLE_DBUS
if (!ev_application_register_service (EV_APP)) {
- if (load_files_remote (file_arguments)) {
+ if (load_files_remote (file_arguments, args)) {
+ g_hash_table_destroy (args);
+
return 0;
}
} else {
@@ -266,7 +338,8 @@ main (int argc, char *argv[])
ev_stock_icons_init ();
gtk_window_set_default_icon_name ("evince");
- load_files (file_arguments);
+ load_files (file_arguments, args);
+ g_hash_table_destroy (args);
gtk_main ();
@@ -276,7 +349,7 @@ main (int argc, char *argv[])
if (enable_metadata) {
ev_metadata_manager_shutdown ();
}
- g_object_unref(program);
+ g_object_unref (program);
return 0;
}