#include "ev-sidebar-links.h"
#include "ev-sidebar-thumbnails.h"
#include "ev-view.h"
-#include "ev-page-view.h"
#include "ev-password.h"
#include "ev-password-view.h"
#include "ev-print-job.h"
#include "ev-document-links.h"
#include "ev-document-find.h"
#include "ev-document-security.h"
+#include "ev-job-queue.h"
#include "eggfindbar.h"
+#include "egg-recent-view-gtk.h"
+#include "egg-recent-view.h"
+#include "egg-recent-model.h"
-#include "pdf-document.h"
+#include "ev-poppler.h"
#include "pixbuf-document.h"
#include "ps-document.h"
+#ifdef ENABLE_DVI
+#include "dvi-document.h"
+#endif
+#ifdef ENABLE_DJVU
+#include "djvu-document.h"
+#endif
#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 <gconf/gconf-client.h>
char *uri;
EvDocument *document;
+ EvPageCache *page_cache;
EvWindowPageMode page_mode;
/* These members are used temporarily when in PAGE_MODE_PASSWORD */
gboolean fullscreen_mode;
EvSizingMode sizing_mode;
GSource *fullscreen_timeout_source;
+
+ /* recent file stuff */
+ EggRecentModel *recent_model;
+ EggRecentViewGtk *recent_view;
};
static GtkTargetEntry ev_drop_types[] = {
#define GCONF_CHROME_SIDEBAR "/apps/evince/show_sidebar"
#define GCONF_CHROME_STATUSBAR "/apps/evince/show_statusbar"
+#define GCONF_SIDEBAR_SIZE "/apps/evince/sidebar_size"
+#define SIDEBAR_DEFAULT_SIZE 132
+
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_sizing_mode (EvWindow *ev_window,
EvSizingMode sizing_mode);
+static void ev_window_add_recent (EvWindow *window, const char *filename);
+
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
static void
{
EvDocument *document;
EvWindowPageMode page_mode;
- EvView *view;
+ gboolean sensitive, has_pages = FALSE, has_document;
+ int n_pages = 0, page = -1;
document = ev_window->priv->document;
page_mode = ev_window->priv->page_mode;
-
- view = EV_VIEW (ev_window->priv->view);
+ has_document = document != NULL;
+ if (has_document && ev_window->priv->page_cache) {
+ page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+ n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
+ has_pages = has_document && n_pages > 0;
+ }
/* File menu */
/* "FileOpen": always sensitive */
- set_action_sensitive (ev_window, "FileSaveAs", document!=NULL);
- set_action_sensitive (ev_window, "FilePrint", document!=NULL);
+ set_action_sensitive (ev_window, "FileSaveAs", has_document);
+ set_action_sensitive (ev_window, "FilePrint", has_pages);
/* "FileCloseWindow": always sensitive */
/* Edit menu */
- set_action_sensitive (ev_window, "EditCopy", document!=NULL);
- set_action_sensitive (ev_window, "EditSelectAll", document!=NULL);
- if (document)
- set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document));
- else
- set_action_sensitive (ev_window, "EditFind", FALSE);
+ sensitive = has_pages && ev_document_can_get_text (document);
+ set_action_sensitive (ev_window, "EditCopy", sensitive);
+ set_action_sensitive (ev_window, "EditSelectAll", sensitive);
+ 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)));
/* View menu */
- set_action_sensitive (ev_window, "ViewZoomIn", document!=NULL);
- set_action_sensitive (ev_window, "ViewZoomOut", document!=NULL);
- set_action_sensitive (ev_window, "ViewNormalSize", document!=NULL);
- set_action_sensitive (ev_window, "ViewBestFit", document!=NULL);
- set_action_sensitive (ev_window, "ViewPageWidth", document!=NULL);
- set_action_sensitive (ev_window, "ViewReload", document!=NULL);
+ set_action_sensitive (ev_window, "ViewZoomIn", has_pages);
+ set_action_sensitive (ev_window, "ViewZoomOut", has_pages);
+ set_action_sensitive (ev_window, "ViewNormalSize", has_pages);
+ set_action_sensitive (ev_window, "ViewBestFit", has_pages);
+ set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
+ set_action_sensitive (ev_window, "ViewReload", has_pages);
/* Go menu */
if (document) {
- int n_pages;
- int page;
-
- page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
- n_pages = ev_document_get_n_pages (document);
-
- set_action_sensitive (ev_window, "GoPreviousPage", page > 1);
- set_action_sensitive (ev_window, "GoNextPage", page < n_pages);
- set_action_sensitive (ev_window, "GoFirstPage", page > 1);
- set_action_sensitive (ev_window, "GoLastPage", page < n_pages);
+ set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
+ set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
+ set_action_sensitive (ev_window, "GoFirstPage", page > 0);
+ set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
} else {
set_action_sensitive (ev_window, "GoFirstPage", FALSE);
set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
/* "HelpAbout": always sensitive */
/* Toolbar-specific actions: */
- set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, document!=NULL);
+ set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
}
static void
set_widget_visibility (GtkWidget *widget, gboolean visible)
{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
if (visible)
gtk_widget_show (widget);
else
void
ev_window_open_page (EvWindow *ev_window, int page)
{
- ev_view_set_page (EV_VIEW (ev_window->priv->view), page);
+ if (ev_window->priv->page_cache) {
+ page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache));
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
+ }
}
void
gboolean password_needed;
password_needed = (ev_window->priv->password_document != NULL);
-
if (document) {
- doc_title = ev_document_get_title (document);
+ doc_title = ev_page_cache_get_title (ev_window->priv->page_cache);
/* Make sure we get a valid title back */
if (doc_title) {
}
if (doc_title == NULL && ev_window->priv->uri) {
- doc_title = g_path_get_basename (ev_window->priv->uri);
+ char *basename;
+
+ basename = g_path_get_basename (ev_window->priv->uri);
+ doc_title = gnome_vfs_unescape_string_for_display (basename);
+ g_free (basename);
}
if (password_needed) {
g_free (title);
}
-static void
-update_total_pages (EvWindow *ev_window)
-{
- GtkAction *action;
- int pages;
-
- pages = ev_document_get_n_pages (ev_window->priv->document);
- action = gtk_action_group_get_action
- (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
- ev_page_action_set_total_pages (EV_PAGE_ACTION (action), pages);
-}
-
-/* This function assumes that ev_window just had ev_window->document set.
- */
-static gboolean
-document_supports_sidebar (EvDocument *document)
-{
- return (EV_IS_DOCUMENT_THUMBNAILS (document) && EV_IS_DOCUMENT_LINKS (document));
-}
-
static void
hide_sidebar_and_actions (EvWindow *ev_window)
{
}
+static void
+find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
+{
+ update_action_sensitivity (ev_window);
+}
+
+static void
+page_changed_cb (EvPageCache *page_cache,
+ gint page,
+ EvWindow *ev_window)
+{
+ update_action_sensitivity (ev_window);
+}
+
static void
ev_window_setup_document (EvWindow *ev_window)
{
EvDocument *document;
EvView *view = EV_VIEW (ev_window->priv->view);
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
+ GtkAction *action;
document = ev_window->priv->document;
+ ev_window->priv->page_cache = ev_document_get_page_cache (ev_window->priv->document);
+ g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
g_signal_connect_object (G_OBJECT (document),
"notify::title",
G_CALLBACK (update_window_title),
ev_window, 0);
+ if (EV_IS_DOCUMENT_FIND (document)) {
+ g_signal_connect_object (G_OBJECT (document),
+ "find_changed",
+ G_CALLBACK (find_changed_cb),
+ ev_window, 0);
+ }
ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
- if (document_supports_sidebar (document))
+ if (ev_sidebar_supports_document (sidebar, document))
ev_sidebar_set_document (sidebar, document);
else
hide_sidebar_and_actions (ev_window);
- ev_view_set_document (view, document);
+
+ if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
+ ev_view_set_document (view, document);
+ }
update_window_title (document, NULL, ev_window);
- update_total_pages (ev_window);
+ 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);
}
gchar *uri;
password = ev_password_dialog_get_password (password_dialog);
- if (password)
+ if (password) {
+ g_mutex_lock (EV_DOC_MUTEX);
ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->password_document),
password);
+ g_mutex_unlock (EV_DOC_MUTEX);
+ }
g_free (password);
document = ev_window->priv->password_document;
update_window_title (ev_window->priv->password_document, NULL, ev_window);
if (ev_window->priv->password_dialog == NULL) {
- gchar *file_name;
+ gchar *basename, *file_name;
- file_name = g_path_get_basename (ev_window->priv->password_uri);
+ basename = g_path_get_basename (ev_window->priv->password_uri);
+ file_name = gnome_vfs_unescape_string_for_display (basename);
ev_window->priv->password_dialog =
ev_password_dialog_new (GTK_WIDGET (ev_window), file_name);
g_object_add_weak_pointer (G_OBJECT (ev_window->priv->password_dialog),
"response",
G_CALLBACK (password_dialog_response),
ev_window);
+ g_free (basename);
g_free (file_name);
gtk_widget_show (ev_window->priv->password_dialog);
} else {
g_object_unref (ev_window->priv->document);
ev_window->priv->document = g_object_ref (document);
ev_window_setup_document (ev_window);
+
+ ev_window_add_recent (ev_window, uri);
return TRUE;
}
static char *supported_types [] = {
"application/pdf",
"application/postscript",
+ "application/x-dvi",
+ "image/vnd.djvu",
"application/x-gzpostscript",
"image/x-eps",
NULL
!strcmp (mime_type, "application/x-gzpostscript") ||
!strcmp (mime_type, "image/x-eps"))
document = g_object_new (PS_TYPE_DOCUMENT, NULL);
+#ifdef ENABLE_DJVU
+ else if (!strcmp (mime_type, "image/vnd.djvu"))
+ document = g_object_new (DJVU_TYPE_DOCUMENT, NULL);
+#endif
else if (mime_type_supported_by_gdk_pixbuf (mime_type))
document = g_object_new (PIXBUF_TYPE_DOCUMENT, NULL);
+#ifdef ENABLE_DVI
+ else if (!strcmp (mime_type, "application/x-dvi"))
+ document = g_object_new (DVI_TYPE_DOCUMENT, NULL);
+#endif
if (document) {
start_loading_document (ev_window, document, uri);
ev_application_open (EV_APP, NULL);
}
+static void
+ev_window_cmd_recent_file_activate (EggRecentViewGtk *view, EggRecentItem *item,
+ EvWindow *ev_window)
+{
+ char *uri;
+ GtkWidget *window;
+
+ uri = egg_recent_item_get_uri (item);
+
+ window = GTK_WIDGET (ev_application_get_empty_window (EV_APP));
+ gtk_widget_show (window);
+ ev_window_open (EV_WINDOW (window), uri);
+
+ g_free (uri);
+}
+
+static void
+ev_window_add_recent (EvWindow *window, const char *filename)
+{
+ EggRecentItem *item;
+
+ if (strstr (filename, "file:///") == NULL)
+ return;
+
+ item = egg_recent_item_new_from_uri (filename);
+ egg_recent_item_add_group (item, "Evince");
+ egg_recent_model_add_full (window->priv->recent_model, item);
+}
+
+static void
+ev_window_setup_recent (EvWindow *ev_window)
+{
+ GtkWidget *menu_item;
+ GtkWidget *menu;
+
+ menu_item = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/MainMenu/FileMenu");
+ menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
+ menu_item = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/MainMenu/FileMenu/RecentFilesMenu");
+
+ g_return_if_fail (menu != NULL);
+ g_return_if_fail (menu_item != NULL);
+
+ /* it would be better if we just filtered by mime-type, but there
+ * doesn't seem to be an easy way to figure out which mime-types we
+ * can handle */
+ ev_window->priv->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
+
+ ev_window->priv->recent_view = egg_recent_view_gtk_new (menu, menu_item);
+ egg_recent_view_gtk_show_icons (EGG_RECENT_VIEW_GTK (ev_window->priv->recent_view), FALSE);
+ egg_recent_model_set_limit (ev_window->priv->recent_model, 5);
+
+ egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
+ ev_window->priv->recent_model);
+
+ egg_recent_model_set_filter_groups (ev_window->priv->recent_model,
+ "Evince", NULL);
+
+ egg_recent_view_gtk_set_trailing_sep (ev_window->priv->recent_view, TRUE);
+
+ g_signal_connect (ev_window->priv->recent_view, "activate",
+ G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
+}
+
/* FIXME
static gboolean
overwrite_existing_file (GtkWindow *window, const gchar *file_name)
GtkWidget *fc;
GtkFileFilter *pdf_filter, *all_filter;
gchar *uri = NULL;
+ gboolean success;
fc = gtk_file_chooser_dialog_new (
_("Save a Copy"),
!overwrite_existing_file (GTK_WINDOW (fc), uri))
continue;
*/
+
+ g_mutex_lock (EV_DOC_MUTEX);
+ success = ev_document_save (ev_window->priv->document, uri, NULL);
+ g_mutex_unlock (EV_DOC_MUTEX);
- if (ev_document_save (ev_window->priv->document, uri, NULL))
+ if (success)
break;
else
save_error_dialog (GTK_WINDOW (fc), uri);
config = gnome_print_config_default ();
job = gnome_print_job_new (config);
- print_dialog = gnome_print_dialog_new (job, _("Print"),
+ print_dialog = gnome_print_dialog_new (job, (guchar *) _("Print"),
(GNOME_PRINT_DIALOG_RANGE |
GNOME_PRINT_DIALOG_COPIES));
gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog),
GTK_MESSAGE_DIALOG (dialog),
_("You were trying to print to a printer using the \"%s\" driver. This program requires a PostScript printer driver."),
gnome_print_config_get (
- config, "Settings.Engine.Backend.Driver"));
+ config, (guchar *)"Settings.Engine.Backend.Driver"));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
} else {
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, TRUE);
- egg_find_bar_grab_focus (EGG_FIND_BAR (ev_window->priv->find_bar));
+ gtk_widget_grab_focus (ev_window->priv->find_bar);
}
}
+static void
+ev_window_cmd_edit_find_next (GtkAction *action, EvWindow *ev_window)
+{
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ ev_view_find_next (EV_VIEW (ev_window->priv->view));
+}
+
static void
ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
{
ev_window_update_fullscreen_popup (window);
}
+static void
+ev_window_sidebar_position_change_cb (GObject *object, GParamSpec *pspec,
+ EvWindow *ev_window)
+{
+ GConfClient *client;
+ int sidebar_size;
+
+ sidebar_size = gtk_paned_get_position (GTK_PANED (object));
+
+ client = gconf_client_get_default ();
+ gconf_client_set_int (client, GCONF_SIDEBAR_SIZE, sidebar_size, NULL);
+ g_object_unref (client);
+}
+
static void
destroy_fullscreen_popup (EvWindow *window)
{
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view),
- ev_view_get_page (EV_VIEW (ev_window->priv->view)) - 1);
+ ev_page_cache_prev_page (ev_window->priv->page_cache);
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view),
- ev_view_get_page (EV_VIEW (ev_window->priv->view)) + 1);
+ ev_page_cache_next_page (ev_window->priv->page_cache);
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view), 1);
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, 0);
}
static void
ev_window_cmd_go_last_page (GtkAction *action, EvWindow *ev_window)
{
+ int n_pages;
+
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view), G_MAXINT);
+ n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, n_pages - 1);
}
static void
g_return_if_fail (EV_IS_WINDOW (ev_window));
- page = ev_document_get_page (ev_window->priv->document);
+ page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
uri = g_strdup (ev_window->priv->uri);
ev_window_open (ev_window, uri);
static void
ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
{
+ GError *error = NULL;
+
g_return_if_fail (EV_IS_WINDOW (ev_window));
- /* FIXME */
+ gnome_help_display ("evince.xml", NULL, &error);
+
+ if(error != NULL) {
+ g_warning (error->message);
+ g_error_free (error);
+ }
}
static void
gtk_window_unfullscreen (GTK_WINDOW (window));
}
+static void
+ev_window_cmd_escape (GtkAction *action, EvWindow *window)
+{
+ GtkWidget *widget;
+
+ widget = gtk_window_get_focus (GTK_WINDOW (window));
+ 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));
+ }
+}
+
static void
update_view_size (EvWindow *window)
{
}
}
-static void
-update_current_page (EvWindow *ev_window,
- EvView *view)
-{
- int page;
- GtkAction *action;
- EvSidebarThumbnails *thumbs;
-
- thumbs = EV_SIDEBAR_THUMBNAILS (ev_window->priv->thumbs_sidebar);
- ev_sidebar_thumbnails_select_page (thumbs, ev_view_get_page (view));
-
- action = gtk_action_group_get_action
- (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
-
- page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
- ev_page_action_set_current_page (EV_PAGE_ACTION (action), page);
-}
-
-static void
-view_page_changed_cb (EvView *view,
- EvWindow *ev_window)
-{
- update_current_page (ev_window, view);
- update_action_sensitivity (ev_window);
-}
-
static void
view_status_changed_cb (EvView *view,
GParamSpec *pspec,
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- if (visible && search_string) {
- ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document), search_string, case_sensitive);
+ if (visible && search_string && search_string[0]) {
+ g_mutex_lock (EV_DOC_MUTEX);
+ ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
+ ev_view_get_page (EV_VIEW (ev_window->priv->view)),
+ search_string,
+ case_sensitive);
+ g_mutex_unlock (EV_DOC_MUTEX);
} else {
+ g_mutex_lock (EV_DOC_MUTEX);
ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
+ g_mutex_unlock (EV_DOC_MUTEX);
+
egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
NULL);
gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
priv->password_uri = NULL;
}
+ if (priv->find_bar) {
+ g_signal_handlers_disconnect_by_func
+ (window->priv->find_bar,
+ G_CALLBACK (find_bar_close_cb),
+ window);
+ priv->find_bar = NULL;
+ }
+
destroy_fullscreen_popup (window);
G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
{ "EditFind", GTK_STOCK_FIND, NULL, "<control>F",
N_("Find a word or phrase in the document"),
G_CALLBACK (ev_window_cmd_edit_find) },
+ { "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) },
/* View menu */
{ "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
G_CALLBACK (ev_window_cmd_go_last_page) },
/* Help menu */
- { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), NULL,
+ { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
N_("Display help for the viewer application"),
G_CALLBACK (ev_window_cmd_help_contents) },
G_CALLBACK (ev_window_cmd_help_about) },
/* Toolbar-only */
- { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), "Escape",
+ { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), NULL,
N_("Leave fullscreen mode"),
- G_CALLBACK (ev_window_cmd_leave_fullscreen) }
+ G_CALLBACK (ev_window_cmd_leave_fullscreen) },
+
+ { "Escape", NULL, N_("Selection Caret"), "Escape", "",
+ G_CALLBACK (ev_window_cmd_escape) }
};
/* Toggle items */
PAGE_MODE_CONTINUOUS_PAGE }
};
-static void
-goto_page_cb (GtkAction *action, int page_number, EvWindow *ev_window)
-{
- EvView *view = EV_VIEW (ev_window->priv->view);
-
- if (ev_view_get_page (view) != page_number) {
- ev_view_set_page (view, page_number);
- }
-}
-
static void
drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
gint x, gint y, GtkSelectionData *selection_data,
"label", _("Page"),
"tooltip", _("Select Page"),
NULL);
- g_signal_connect (action, "goto_page",
- G_CALLBACK (goto_page_cb), window);
gtk_action_group_add_action (group, action);
g_object_unref (action);
}
/*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Previous"), NULL);
g_object_set (action, "is-important", TRUE, NULL);
+
action = gtk_action_group_get_action (action_group, "GoNextPage");
- /*translators: this is the label for toolbar button*/
g_object_set (action, "is-important", TRUE, NULL);
+ /*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Next"), NULL);
+
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+ /*translators: this is the label for toolbar button*/
+ g_object_set (action, "short_label", _("Zoom In"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
+ action = gtk_action_group_get_action (action_group, "ViewZoomOut");
+ /*translators: this is the label for toolbar button*/
+ g_object_set (action, "short_label", _("Zoom Out"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
+ action = gtk_action_group_get_action (action_group, "ViewBestFit");
+ /*translators: this is the label for toolbar button*/
+ g_object_set (action, "short_label", _("Best Fit"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
action = gtk_action_group_get_action (action_group, "ViewPageWidth");
/*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Fit Width"), NULL);
return chrome;
}
+static void
+sidebar_widget_model_set (EvSidebarLinks *ev_sidebar_links,
+ GParamSpec *pspec,
+ EvWindow *ev_window)
+{
+ GtkTreeModel *model;
+ GtkAction *action;
+
+ g_object_get (G_OBJECT (ev_sidebar_links),
+ "model", &model,
+ NULL);
+
+ action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
+ ev_page_action_set_model (EV_PAGE_ACTION (action), model);
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
GtkAccelGroup *accel_group;
GError *error = NULL;
GtkWidget *sidebar_widget, *toolbar_dock;
+ GConfValue *value;
+ GConfClient *client;
+ int sidebar_size;
ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
/* Add the main area */
ev_window->priv->hpaned = gtk_hpaned_new ();
+ g_signal_connect (ev_window->priv->hpaned,
+ "notify::position",
+ G_CALLBACK (ev_window_sidebar_position_change_cb),
+ ev_window);
+
+ sidebar_size = SIDEBAR_DEFAULT_SIZE;
+ client = gconf_client_get_default ();
+ value = gconf_client_get (client, GCONF_SIDEBAR_SIZE, NULL);
+ if (value != NULL) {
+ if (value->type == GCONF_VALUE_INT) {
+ sidebar_size = gconf_value_get_int (value);
+ }
+ gconf_value_free (value);
+ }
+ g_object_unref (client);
+ gtk_paned_set_position (GTK_PANED (ev_window->priv->hpaned), sidebar_size);
gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
- TRUE, TRUE, 0);
+ TRUE, TRUE, 0);
+ gtk_widget_show (ev_window->priv->hpaned);
+
ev_window->priv->sidebar = ev_sidebar_new ();
- g_signal_connect (ev_window->priv->sidebar,
- "notify::visible",
- G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
- ev_window);
gtk_paned_pack1 (GTK_PANED (ev_window->priv->hpaned),
ev_window->priv->sidebar, FALSE, FALSE);
- gtk_widget_show (ev_window->priv->hpaned);
+ gtk_widget_show (ev_window->priv->sidebar);
/* Stub sidebar, for now */
sidebar_widget = ev_sidebar_links_new ();
+ g_signal_connect (sidebar_widget,
+ "notify::model",
+ G_CALLBACK (sidebar_widget_model_set),
+ ev_window);
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
"index",
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
ev_window->priv->view);
- g_signal_connect (ev_window->priv->view,
- "page-changed",
- G_CALLBACK (view_page_changed_cb),
- ev_window);
g_signal_connect (ev_window->priv->view,
"notify::find-status",
G_CALLBACK (view_find_status_changed_cb),
ev_window->priv->find_bar,
FALSE, TRUE, 0);
+ ev_window_setup_recent (ev_window);
ev_window->priv->chrome = load_chrome ();
set_chrome_actions (ev_window);
update_chrome_visibility (ev_window);
+ /* Connect sidebar signals */
+ g_signal_connect (ev_window->priv->sidebar,
+ "notify::visible",
+ G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
+ ev_window);
+
/* Connect to find bar signals */
g_signal_connect (ev_window->priv->find_bar,
"previous",
/* 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_BEST_FIT);
+ ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH);
update_action_sensitivity (ev_window);
}