#include "egg-recent-view-gtk.h"
#include "egg-recent-view.h"
#include "egg-recent-model.h"
+#include "egg-toolbar-editor.h"
+#include "egg-toolbars-model.h"
+#include "egg-editable-toolbar.h"
+#include "ephy-zoom.h"
+#include "ephy-zoom-action.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomeprintui/gnome-print-dialog.h>
#include "ev-application.h"
#include "ev-stock-icons.h"
-typedef enum {
- EV_SIZING_BEST_FIT,
- EV_SIZING_FIT_WIDTH,
- EV_SIZING_FREE,
-} EvSizingMode;
-
typedef enum {
PAGE_MODE_SINGLE_PAGE,
PAGE_MODE_CONTINUOUS_PAGE,
GtkWidget *toolbar;
GtkWidget *hpaned;
GtkWidget *sidebar;
- GtkWidget *thumbs_sidebar;
GtkWidget *find_bar;
GtkWidget *scrolled_window;
GtkWidget *view;
GtkWidget *page_view;
GtkWidget *password_view;
+
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
+
+ gchar *toolbar_file;
+ EggToolbarsModel *toolbar_model;
+
GtkWidget *statusbar;
guint help_message_cid;
guint view_message_cid;
char *password_uri;
EvChrome chrome;
- gboolean fullscreen_mode;
- EvSizingMode sizing_mode;
GSource *fullscreen_timeout_source;
/* recent file stuff */
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
#define PAGE_SELECTOR_ACTION "PageSelector"
+#define ZOOM_CONTROL_ACTION "ViewZoom"
#define GCONF_CHROME_TOOLBAR "/apps/evince/show_toolbar"
#define GCONF_CHROME_SIDEBAR "/apps/evince/show_sidebar"
#define GCONF_SIDEBAR_SIZE "/apps/evince/sidebar_size"
#define SIDEBAR_DEFAULT_SIZE 132
-#define VIEW_SPACING 10
-static void ev_window_update_fullscreen_popup (EvWindow *window);
-static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
- EvWindow *ev_window);
-static void ev_window_set_page_mode (EvWindow *window,
- EvWindowPageMode page_mode);
-static gboolean start_loading_document (EvWindow *ev_window,
- EvDocument *document,
- const char *uri);
-static void ev_window_set_sizing_mode (EvWindow *ev_window,
- EvSizingMode sizing_mode);
+static void ev_window_update_fullscreen_popup (EvWindow *window);
+static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
+ GParamSpec *pspec,
+ EvWindow *ev_window);
+static void ev_window_set_page_mode (EvWindow *window,
+ EvWindowPageMode page_mode);
+static gboolean start_loading_document (EvWindow *ev_window,
+ EvDocument *document,
+ const char *uri);
+static void ev_window_sizing_mode_changed_cb (EvView *view,
+ GParamSpec *pspec,
+ EvWindow *ev_window);
+static void ev_window_add_recent (EvWindow *window,
+ const char *filename);
+static void ev_window_fullscreen (EvWindow *window);
+static void ev_window_unfullscreen (EvWindow *window);
+static void ev_window_cmd_view_fullscreen (GtkAction *action,
+ EvWindow *window);
+static void ev_window_run_presentation (EvWindow *window);
+static void ev_window_stop_presentation (EvWindow *window);
+static void ev_window_cmd_view_presentation (GtkAction *action,
+ EvWindow *window);
-static void ev_window_add_recent (EvWindow *window, const char *filename);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
static void
update_action_sensitivity (EvWindow *ev_window)
{
+ EvView *view;
EvDocument *document;
EvWindowPageMode page_mode;
gboolean sensitive, has_pages = FALSE, has_document;
int n_pages = 0, page = -1;
+ view = EV_VIEW (ev_window->priv->view);
document = ev_window->priv->document;
page_mode = ev_window->priv->page_mode;
has_document = document != NULL;
set_action_sensitive (ev_window, "EditFind",
has_pages && EV_IS_DOCUMENT_FIND (document));
set_action_sensitive (ev_window, "EditFindNext",
- ev_view_can_find_next (EV_VIEW (ev_window->priv->view)));
+ ev_view_can_find_next (view));
/* View menu */
- set_action_sensitive (ev_window, "ViewZoomIn", has_pages);
- set_action_sensitive (ev_window, "ViewZoomOut", has_pages);
+ set_action_sensitive (ev_window, "ViewContinuous", has_pages);
+ set_action_sensitive (ev_window, "ViewDual", has_pages);
+ set_action_sensitive (ev_window, "ViewZoomIn",
+ has_pages && ev_view_can_zoom_in (view));
+ set_action_sensitive (ev_window, "ViewZoomOut",
+ has_pages && ev_view_can_zoom_out (view));
set_action_sensitive (ev_window, "ViewNormalSize", has_pages);
set_action_sensitive (ev_window, "ViewBestFit", has_pages);
set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
/* Toolbar-specific actions: */
set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
+ set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
+
+ if (has_pages && ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ GtkAction *action;
+ float zoom;
+ float real_zoom;
+
+ action = gtk_action_group_get_action (ev_window->priv->action_group,
+ ZOOM_CONTROL_ACTION);
+
+ real_zoom = ev_view_get_zoom (EV_VIEW (ev_window->priv->view));
+ zoom = ephy_zoom_get_nearest_zoom_level (real_zoom);
+
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action), zoom);
+ }
}
static void
{
EvWindowPrivate *priv = window->priv;
gboolean menubar, toolbar, sidebar, findbar, statusbar, fullscreen_toolbar;
+ gboolean fullscreen_mode, presentation, fullscreen;
+
+ presentation = ev_view_get_presentation (EV_VIEW (priv->view));
+ fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
+ fullscreen_mode = fullscreen || presentation;
- menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !priv->fullscreen_mode;
- toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !priv->fullscreen_mode;
- sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !priv->fullscreen_mode;
+ menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
+ toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !fullscreen_mode;
+ sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
fullscreen_toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
- statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !priv->fullscreen_mode;
+ statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !fullscreen_mode;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
set_widget_visibility (priv->menubar, menubar);
+
set_widget_visibility (priv->toolbar_dock, toolbar);
+ set_action_sensitive (window, "EditToolbar", toolbar);
+
set_widget_visibility (priv->sidebar, sidebar);
set_widget_visibility (priv->find_bar, findbar);
set_widget_visibility (priv->statusbar, statusbar);
set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
if (priv->fullscreen_popup != NULL) {
- set_widget_visibility (priv->fullscreen_popup, priv->fullscreen_mode);
+ set_widget_visibility (priv->fullscreen_popup, fullscreen);
}
}
update_chrome_visibility (window);
}
+static void
+ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean continuous;
+
+ ev_window_stop_presentation (ev_window);
+ continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "continuous", continuous,
+ NULL);
+ update_action_sensitivity (ev_window);
+}
+
+static void
+ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean dual_page;
+
+ ev_window_stop_presentation (ev_window);
+ dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "dual-page", dual_page,
+ NULL);
+ update_action_sensitivity (ev_window);
+}
+
static void
ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
{
+ ev_window_stop_presentation (ev_window);
+
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
- ev_window_set_sizing_mode (ev_window, EV_SIZING_BEST_FIT);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
} else {
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
}
+ update_action_sensitivity (ev_window);
}
static void
ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
{
+ ev_window_stop_presentation (ev_window);
+
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
} else {
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
}
+ update_action_sensitivity (ev_window);
}
static void
GtkActionGroup *action_group = window->priv->action_group;
GtkAction *action;
gboolean best_fit, page_width;
+ EvSizingMode sizing_mode;
+
+ if (window->priv->view == NULL)
+ return;
- switch (window->priv->sizing_mode) {
+ g_object_get (window->priv->view,
+ "sizing_mode", &sizing_mode,
+ NULL);
+
+ switch (sizing_mode) {
case EV_SIZING_BEST_FIT:
best_fit = TRUE;
page_width = FALSE;
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), page_width);
g_signal_handlers_unblock_by_func
(action, G_CALLBACK (ev_window_cmd_view_page_width), window);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ ZOOM_CONTROL_ACTION);
+ if (best_fit) {
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
+ EPHY_ZOOM_BEST_FIT);
+ } else if (page_width) {
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
+ EPHY_ZOOM_FIT_WIDTH);
+ }
}
void
g_free (title);
}
-static void
-hide_sidebar_and_actions (EvWindow *ev_window)
-{
- GtkAction *action;
- /* Alsthough we update the hiddenness of the sidebar, we don't want to
- * store the value */
- g_signal_handlers_disconnect_by_func (ev_window->priv->sidebar,
- ev_window_sidebar_visibility_changed_cb,
- ev_window);
- gtk_widget_hide (ev_window->priv->sidebar);
- action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
- gtk_action_set_sensitive (action, FALSE);
-
-}
-
static void
find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
{
update_action_sensitivity (ev_window);
}
+static void
+update_document_mode (EvWindow *window, EvDocumentMode mode)
+{
+ if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
+ ev_window_fullscreen (window);
+ } else if (mode == EV_DOCUMENT_MODE_PRESENTATION) {
+ ev_window_run_presentation (window);
+ }
+}
+
static void
ev_window_setup_document (EvWindow *ev_window)
{
+ EvDocumentInfo *info;
EvDocument *document;
EvView *view = EV_VIEW (ev_window->priv->view);
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
- if (ev_sidebar_supports_document (sidebar, document))
- ev_sidebar_set_document (sidebar, document);
- else
- hide_sidebar_and_actions (ev_window);
+ ev_sidebar_set_document (sidebar, document);
if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
ev_view_set_document (view, document);
action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
ev_page_action_set_document (EV_PAGE_ACTION (action), document);
update_action_sensitivity (ev_window);
+
+ info = ev_document_get_info (document);
+ update_document_mode (ev_window, info->mode);
+ g_free (info);
}
static void
password = ev_password_dialog_get_password (password_dialog);
if (password) {
- g_mutex_lock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_lock ();
ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->password_document),
password);
- g_mutex_unlock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_unlock ();
}
g_free (password);
ev_window_open (EvWindow *ev_window, const char *uri)
{
EvDocument *document = NULL;
- char *mime_type;
+ GType document_type;
+ char *mime_type = NULL;
g_free (ev_window->priv->uri);
ev_window->priv->uri = g_strdup (uri);
- mime_type = gnome_vfs_get_mime_type (uri);
-
- if (mime_type == NULL)
- document = NULL;
- else {
- GType document_type = ev_document_type_lookup (mime_type);
-
- if (document_type!=G_TYPE_INVALID) {
- document = g_object_new (document_type, NULL);
- }
+ document_type = ev_document_type_lookup (uri, &mime_type);
+ if (document_type != G_TYPE_INVALID) {
+ document = g_object_new (document_type, NULL);
}
if (document) {
ev_window_open_uri_list (EvWindow *ev_window, GList *uri_list)
{
GList *list;
- gchar *uri, *mime_type;
+ gchar *uri;
g_return_if_fail (uri_list != NULL);
list = uri_list;
while (list) {
uri = gnome_vfs_uri_to_string (list->data, GNOME_VFS_URI_HIDE_NONE);
- mime_type = gnome_vfs_get_mime_type (uri);
- if (ev_document_type_lookup (mime_type)!=G_TYPE_INVALID) {
+ if (ev_document_type_lookup (uri, NULL) != G_TYPE_INVALID) {
if (ev_window_is_empty (EV_WINDOW (ev_window))) {
ev_window_open (ev_window, uri);
}
}
- g_free (mime_type);
g_free (uri);
list = g_list_next (list);
continue;
*/
- g_mutex_lock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_lock ();
success = ev_document_save (ev_window->priv->document, uri, NULL);
- g_mutex_unlock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_unlock ();
if (success)
break;
} else if (transport) {
if (!strcmp ((const gchar *)transport, "CUPS"))
return TRUE;
+ else if (!strcmp ((const gchar *)transport, "LPD"))
+ return TRUE;
}
return FALSE;
{
if (window->priv->fullscreen_popup != NULL)
{
- /* FIXME multihead */
- g_signal_handlers_disconnect_by_func
- (gdk_screen_get_default (),
- G_CALLBACK (screen_size_changed_cb), window);
-
gtk_widget_destroy (window->priv->fullscreen_popup);
window->priv->fullscreen_popup = NULL;
}
gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
/* FIXME multihead */
- g_signal_connect (gdk_screen_get_default (), "size-changed",
- G_CALLBACK (screen_size_changed_cb), window);
- g_signal_connect (popup, "size_request",
- G_CALLBACK (fullscreen_popup_size_request_cb), window);
+ g_signal_connect_object (gdk_screen_get_default (), "size-changed",
+ G_CALLBACK (screen_size_changed_cb),
+ window, 0);
+ g_signal_connect_object (popup, "size_request",
+ G_CALLBACK (fullscreen_popup_size_request_cb),
+ window, 0);
return popup;
}
+
static void
-ev_window_fullscreen (EvWindow *window)
+ev_window_update_fullscreen_action (EvWindow *window)
{
- window->priv->fullscreen_mode = TRUE;
+ GtkAction *action;
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_view_get_fullscreen (EV_VIEW (window->priv->view)));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
+}
+
+static void
+ev_window_fullscreen (EvWindow *window)
+{
+ ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
if (window->priv->fullscreen_popup == NULL)
window->priv->fullscreen_popup
= ev_window_create_fullscreen_popup (window);
fullscreen_set_timeout (window);
gtk_widget_grab_focus (window->priv->view);
-
+ ev_window_update_fullscreen_action (window);
+ gtk_window_fullscreen (GTK_WINDOW (window));
ev_window_update_fullscreen_popup (window);
}
{
EvView *view = EV_VIEW (window->priv->view);
- window->priv->fullscreen_mode = FALSE;
-
+ ev_view_set_fullscreen (view, FALSE);
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_IN,
NULL);
g_signal_handlers_disconnect_by_func (view,
(gpointer) fullscreen_motion_notify_cb,
window);
-
- ev_view_set_show_border (view, TRUE);
- ev_view_set_spacing (view, VIEW_SPACING);
+ g_signal_handlers_disconnect_by_func (view,
+ (gpointer) fullscreen_leave_notify_cb,
+ window);
+ ev_window_update_fullscreen_action (window);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
update_chrome_visibility (window);
}
static void
ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window)
{
- EvView *view;
gboolean fullscreen;
g_return_if_fail (EV_IS_WINDOW (window));
+ ev_window_stop_presentation (window);
- view = EV_VIEW (window->priv->view);
fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-
if (fullscreen) {
- gtk_window_fullscreen (GTK_WINDOW (window));
+ ev_window_fullscreen (window);
} else {
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ ev_window_unfullscreen (window);
}
+}
- ev_view_set_show_border (view, FALSE);
- ev_view_set_spacing (view, 0);
+static void
+ev_window_update_presentation_action (EvWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewPresentation");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_presentation), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_view_get_presentation (EV_VIEW (window->priv->view)));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_presentation), window);
}
-static gboolean
-ev_window_state_event_cb (GtkWidget *widget, GdkEventWindowState *event, EvWindow *window)
+static void
+ev_window_run_presentation (EvWindow *window)
{
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
- {
- GtkActionGroup *action_group;
- GtkAction *action;
- gboolean fullscreen;
+ g_object_set (G_OBJECT (window->priv->scrolled_window),
+ "shadow-type", GTK_SHADOW_NONE,
+ NULL);
- fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
+ gtk_widget_grab_focus (window->priv->view);
+ ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ ev_window_update_presentation_action (window);
+ update_chrome_visibility (window);
+}
- if (fullscreen)
- {
- ev_window_fullscreen (window);
- }
- else
- {
- ev_window_unfullscreen (window);
- }
+static void
+ev_window_stop_presentation (EvWindow *window)
+{
+ if (! ev_view_get_presentation (EV_VIEW (window->priv->view)))
+ return;
- action_group = window->priv->action_group;
+ g_object_set (G_OBJECT (window->priv->scrolled_window),
+ "shadow-type", GTK_SHADOW_IN,
+ NULL);
+ ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
+ ev_window_update_presentation_action (window);
+ update_chrome_visibility (window);
+}
- action = gtk_action_group_get_action (action_group, "ViewFullscreen");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), fullscreen);
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
+static void
+ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window)
+{
+ gboolean presentation;
+ g_return_if_fail (EV_IS_WINDOW (window));
+
+ presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ if (presentation) {
+ ev_window_run_presentation (window);
+ } else {
+ ev_window_stop_presentation (window);
+ }
+}
+
+static gboolean
+ev_window_state_event (GtkWidget *widget, GdkEventWindowState *event)
+{
+ EvWindow *window = EV_WINDOW (widget);
+
+ if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
+ gboolean show;
+
+ show = (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) == 0;
+
+ gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar),
+ show);
}
return FALSE;
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
+ gboolean fullscreen;
- if (priv->fullscreen_mode)
- {
+ g_object_get (priv->view,
+ "fullscreen", &fullscreen,
+ NULL);
+
+ if (fullscreen)
gtk_widget_show (priv->fullscreen_popup);
- }
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
}
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
+ gboolean fullscreen;
- if (priv->fullscreen_mode)
- {
+ g_object_get (priv->view,
+ "fullscreen", &fullscreen,
+ NULL);
+
+ if (fullscreen)
gtk_widget_hide (priv->fullscreen_popup);
- }
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
}
update_action_sensitivity (window);
}
+static void
+ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
+{
+ EvWindow *ev_window = EV_WINDOW (data);
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
+ egg_toolbars_model_save (ev_window->priv->toolbar_model, ev_window->priv->toolbar_file, "1.0");
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
+{
+ GtkWidget *dialog;
+ GtkWidget *editor;
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ dialog = gtk_dialog_new_with_buttons (_("Toolbar editor"), GTK_WINDOW (ev_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
+
+ editor = egg_toolbar_editor_new (ev_window->priv->ui_manager,
+ ev_window->priv->toolbar_model);
+ gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
+ gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
+
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
+ egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
+ DATADIR"/evince-toolbar.xml");
+
+ egg_editable_toolbar_set_edit_mode
+ (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE);
+
+ gtk_widget_show_all (dialog);
+
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (ev_window_cmd_edit_toolbar_cb),
+ ev_window);
+}
+
static void
ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
-
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
+ update_action_sensitivity (ev_window);
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
-
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
+ update_action_sensitivity (ev_window);
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_size (EV_VIEW (ev_window->priv->view), -1, -1);
+ ev_view_zoom_normal (EV_VIEW (ev_window->priv->view));
+ update_action_sensitivity (ev_window);
}
static void
if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
update_chrome_flag (window, EV_CHROME_FINDBAR, NULL, FALSE);
} else {
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ gboolean fullscreen;
+ gboolean presentation;
+
+ g_object_get (window->priv->view,
+ "fullscreen", &fullscreen,
+ "presentation", &presentation,
+ NULL);
+
+ if (fullscreen)
+ ev_window_unfullscreen (window);
+ if (presentation)
+ ev_window_stop_presentation (window);
+
+ if (fullscreen && presentation)
+ g_warning ("Both fullscreen and presentation set somehow");
}
}
{
int width, height;
GtkRequisition vsb_requisition;
+ GtkRequisition hsb_requisition;
int scrollbar_spacing;
+ /* Calculate the width available for the */
width = window->priv->scrolled_window->allocation.width;
height = window->priv->scrolled_window->allocation.height;
- if (gtk_scrolled_window_get_shadow_type
- (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)) == GTK_SHADOW_IN)
- {
+ if (gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)) == GTK_SHADOW_IN) {
width -= 2 * window->priv->view->style->xthickness;
height -= 2 * window->priv->view->style->ythickness;
}
- if (window->priv->sizing_mode == EV_SIZING_BEST_FIT) {
- ev_view_set_size (EV_VIEW (window->priv->view),
- MAX (1, width), MAX (1, height));
- } else if (window->priv->sizing_mode == EV_SIZING_FIT_WIDTH) {
- gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->vscrollbar,
- &vsb_requisition);
- gtk_widget_style_get (window->priv->scrolled_window,
- "scrollbar_spacing", &scrollbar_spacing,
- NULL);
- ev_view_set_size (EV_VIEW (window->priv->view),
- width - vsb_requisition.width - scrollbar_spacing, -1);
- }
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->vscrollbar,
+ &vsb_requisition);
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->hscrollbar,
+ &hsb_requisition);
+ gtk_widget_style_get (window->priv->scrolled_window,
+ "scrollbar_spacing", &scrollbar_spacing,
+ NULL);
+
+ ev_view_set_zoom_for_size (EV_VIEW (window->priv->view),
+ MAX (1, width),
+ MAX (1, height),
+ vsb_requisition.width + scrollbar_spacing,
+ hsb_requisition.height + scrollbar_spacing);
}
static void
update_view_size (window);
}
-static void
-ev_window_set_sizing_mode (EvWindow *ev_window,
- EvSizingMode sizing_mode)
+static void
+ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
+ EvWindow *ev_window)
{
GtkWidget *scrolled_window;
+ EvSizingMode sizing_mode;
- if (ev_window->priv->sizing_mode == sizing_mode)
- return;
+ g_object_get (ev_window->priv->view,
+ "sizing-mode", &sizing_mode,
+ NULL);
scrolled_window = ev_window->priv->scrolled_window;
- ev_window->priv->sizing_mode = sizing_mode;
g_signal_handlers_disconnect_by_func (scrolled_window, size_allocate_cb, ev_window);
- update_view_size (ev_window);
+ if (sizing_mode != EV_SIZING_FREE)
+ update_view_size (ev_window);
switch (sizing_mode) {
case EV_SIZING_BEST_FIT:
g_object_set (G_OBJECT (scrolled_window),
"hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_NEVER,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
NULL);
g_signal_connect (scrolled_window, "size-allocate",
G_CALLBACK (size_allocate_cb),
EvWindow *ev_window)
{
GtkAction *action;
- gboolean visible;
+ gboolean visible, fullscreen;
+ g_object_get (ev_window->priv->view,
+ "fullscreen", &fullscreen,
+ NULL);
visible = GTK_WIDGET_VISIBLE (ev_sidebar);
/* In fullscreen mode the sidebar is not visible,
* but we don't want to update the chrome
*/
- if (ev_window->priv->fullscreen_mode)
+ if (fullscreen)
return;
action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
if (visible && search_string && search_string[0]) {
- g_mutex_lock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_lock ();
ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
ev_page_cache_get_current_page (ev_window->priv->page_cache),
search_string,
case_sensitive);
- g_mutex_unlock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_unlock ();
} else {
- g_mutex_lock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_lock ();
ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
- g_mutex_unlock (EV_DOC_MUTEX);
+ ev_document_doc_mutex_unlock ();
egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
NULL);
}
}
+static void
+zoom_control_changed_cb (EphyZoomAction *action,
+ float zoom,
+ EvWindow *ev_window)
+{
+ EvSizingMode mode;
+
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ if (zoom == EPHY_ZOOM_BEST_FIT) {
+ mode = EV_SIZING_BEST_FIT;
+ } else if (zoom == EPHY_ZOOM_FIT_WIDTH) {
+ mode = EV_SIZING_FIT_WIDTH;
+ } else {
+ mode = EV_SIZING_FREE;
+ ev_view_set_zoom (EV_VIEW (ev_window->priv->view), zoom, FALSE);
+ }
+
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
+ update_action_sensitivity (ev_window);
+}
+
static void
ev_window_dispose (GObject *object)
{
EvWindow *window = EV_WINDOW (object);
EvWindowPrivate *priv = window->priv;
+ if (priv->toolbar_model) {
+ g_object_unref (priv->toolbar_model);
+ g_free (priv->toolbar_file);
+ priv->toolbar_model = NULL;
+ priv->toolbar_file = NULL;
+ }
+
if (priv->ui_manager) {
g_object_unref (priv->ui_manager);
priv->ui_manager = NULL;
priv->action_group = NULL;
}
+ if (priv->page_cache) {
+ g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
+ priv->page_cache = NULL;
+ }
+
if (priv->document) {
g_object_unref (priv->document);
priv->document = NULL;
}
-
+
if (priv->view) {
g_object_unref (priv->view);
priv->view = NULL;
g_object_class->dispose = ev_window_dispose;
+ widget_class->window_state_event = ev_window_state_event;
widget_class->focus_in_event = ev_window_focus_in_event;
widget_class->focus_out_event = ev_window_focus_out_event;
{ "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G",
N_("Find next occurrence of the word or phrase"),
G_CALLBACK (ev_window_cmd_edit_find_next) },
+ { "EditToolbar", NULL, N_("Toolbar..."), NULL,
+ N_("Open Toolbar Editor Dialog"),
+ G_CALLBACK (ev_window_cmd_edit_toolbar) },
/* View menu */
{ "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
N_("Leave fullscreen mode"),
G_CALLBACK (ev_window_cmd_leave_fullscreen) },
+ /* Accellerators */
{ "Escape", NULL, N_("Selection Caret"), "Escape", "",
- G_CALLBACK (ev_window_cmd_escape) }
+ G_CALLBACK (ev_window_cmd_escape) },
+ { "Slash", GTK_STOCK_FIND, NULL, "slash",
+ N_("Find a word or phrase in the document"),
+ G_CALLBACK (ev_window_cmd_edit_find) }
};
/* Toggle items */
{ "ViewSidebar", NULL, N_("Side _pane"), "F9",
N_("Show or hide the side pane"),
G_CALLBACK (ev_window_view_sidebar_cb), TRUE },
+ { "ViewContinuous", NULL, N_("_Continuous"), NULL,
+ N_("Show the entire document"),
+ G_CALLBACK (ev_window_cmd_continuous), TRUE },
+ { "ViewDual", NULL, N_("_Dual"), NULL,
+ N_("Show two pages at once"),
+ G_CALLBACK (ev_window_cmd_dual), FALSE },
{ "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
N_("Expand the window to fill the screen"),
G_CALLBACK (ev_window_cmd_view_fullscreen) },
+ { "ViewPresentation", NULL, N_("_Presentation"), "F12",
+ N_("Run document as a presentation"),
+ G_CALLBACK (ev_window_cmd_view_presentation) },
{ "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
N_("Make the current document fill the window"),
G_CALLBACK (ev_window_cmd_view_best_fit) },
"name", PAGE_SELECTOR_ACTION,
"label", _("Page"),
"tooltip", _("Select Page"),
+ "visible_overflown", FALSE,
+ NULL);
+ gtk_action_group_add_action (group, action);
+ g_object_unref (action);
+
+ action = g_object_new (EPHY_TYPE_ZOOM_ACTION,
+ "name", ZOOM_CONTROL_ACTION,
+ "label", _("Zoom"),
+ "stock_id", GTK_STOCK_ZOOM_IN,
+ "tooltip", _("Adjust the zoom level"),
+ "zoom", 1.0,
NULL);
+ g_signal_connect (action, "zoom_to_level",
+ G_CALLBACK (zoom_control_changed_cb), window);
gtk_action_group_add_action (group, action);
g_object_unref (action);
}
ev_window->priv->menubar,
FALSE, FALSE, 0);
+ /* Toolbar editor */
+ ev_window->priv->toolbar_model = egg_toolbars_model_new ();
+
+ ev_window->priv->toolbar_file = g_build_filename
+ (g_get_home_dir (), ".gnome2/evince_toolbar.xml", NULL);
+
+ if (!g_file_test (ev_window->priv->toolbar_file, G_FILE_TEST_EXISTS)) {
+ egg_toolbars_model_load (ev_window->priv->toolbar_model,
+ DATADIR"/evince-toolbar.xml");
+ } else {
+ egg_toolbars_model_load (ev_window->priv->toolbar_model,
+ ev_window->priv->toolbar_file);
+ }
+
/* This sucks, but there is no way to have a draw=no, expand=true separator
* in a GtkUIManager-built toolbar. So, just add another toolbar.
* See gtk+ bug 166489.
FALSE, FALSE, 0);
gtk_widget_show (toolbar_dock);
- ev_window->priv->toolbar =
- gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
- "/ToolBar");
+ ev_window->priv->toolbar = egg_editable_toolbar_new_with_model
+ (ev_window->priv->ui_manager, ev_window->priv->toolbar_model);
+ egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
+ "DefaultToolBar");
gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
TRUE, TRUE, 0);
gtk_widget_show (ev_window->priv->toolbar);
ev_window->priv->fullscreen_toolbar =
gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/LeaveFullscreenToolbar");
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (ev_window->priv->fullscreen_toolbar), TRUE);
- gtk_toolbar_set_style (GTK_TOOLBAR (ev_window->priv->fullscreen_toolbar), GTK_TOOLBAR_BOTH_HORIZ);
+
/* Add the main area */
ev_window->priv->hpaned = gtk_hpaned_new ();
ev_window);
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
- "index",
- _("Index"),
sidebar_widget);
- ev_window->priv->thumbs_sidebar = ev_sidebar_thumbnails_new ();
- gtk_widget_show (ev_window->priv->thumbs_sidebar);
+ sidebar_widget = ev_sidebar_thumbnails_new ();
+ gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
- "thumbnails",
- _("Thumbnails"),
- ev_window->priv->thumbs_sidebar);
+ sidebar_widget);
ev_window->priv->scrolled_window =
GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
ev_window->priv->scrolled_window);
ev_window->priv->view = ev_view_new ();
- ev_view_set_spacing (EV_VIEW (ev_window->priv->view), VIEW_SPACING);
ev_window->priv->password_view = ev_password_view_new ();
g_signal_connect_swapped (ev_window->priv->password_view,
"unlock",
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
ev_window->priv->view);
+
g_signal_connect (ev_window->priv->view,
"notify::find-status",
G_CALLBACK (view_find_status_changed_cb),
"notify::status",
G_CALLBACK (view_status_changed_cb),
ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::sizing-mode",
+ G_CALLBACK (ev_window_sizing_mode_changed_cb),
+ ev_window);
ev_window->priv->statusbar = gtk_statusbar_new ();
gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
G_CALLBACK (find_bar_search_changed_cb),
ev_window);
- g_signal_connect (ev_window, "window-state-event",
- G_CALLBACK (ev_window_state_event_cb),
- ev_window);
-
/* Give focus to the scrolled window */
gtk_widget_grab_focus (ev_window->priv->scrolled_window);
G_CALLBACK (drag_data_received_cb), NULL);
/* Set it to something random to force a change */
- ev_window->priv->sizing_mode = EV_SIZING_FREE;
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH);
+
+ ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
update_action_sensitivity (ev_window);
}