*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
GtkWidget *sidebar_attachments;
GtkWidget *sidebar_layers;
+ /* Settings */
+ GSettings *settings;
+ GSettings *last_settings;
+
/* Menubar accels */
guint menubar_accel_keyval;
GdkModifierType menubar_accel_modifier;
#define NAVIGATION_ACTION "Navigation"
#define GCONF_LOCKDOWN_DIR "/desktop/gnome/lockdown"
-#define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions"
#define GCONF_LOCKDOWN_SAVE "/desktop/gnome/lockdown/disable_save_to_disk"
#define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
#define GCONF_LOCKDOWN_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
+#define GS_SCHEMA_NAME "org.gnome.Evince"
+#define GS_OVERRIDE_RESTRICTIONS "override-restrictions"
+
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
#define MIN_SCALE 0.05409
#define MAX_SCALE 4.0
+#define MAX_RECENT_ITEM_LEN (40)
+
static const gchar *document_print_settings[] = {
GTK_PRINT_SETTINGS_N_COPIES,
GTK_PRINT_SETTINGS_COLLATE,
can_find = TRUE;
}
-#ifdef WITH_GCONF
- if (has_document)
- override_restrictions = gconf_client_get_bool (ev_window->priv->gconf_client,
- GCONF_OVERRIDE_RESTRICTIONS,
- NULL);
-#endif
+ if (has_document && ev_window->priv->settings) {
+ override_restrictions =
+ g_settings_get_boolean (ev_window->priv->settings,
+ GS_OVERRIDE_RESTRICTIONS);
+ }
+
if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY);
ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, FALSE);
- /* Help menu */
-#ifdef G_OS_WIN32
- ev_window_set_action_sensitive (ev_window, "HelpContents", FALSE);
-#endif
-
ev_window_update_actions (ev_window);
}
fullscreen_toolbar = ((priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
- sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !presentation;
+ sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && priv->document && !presentation;
set_widget_visibility (priv->menubar, menubar);
set_widget_visibility (priv->toolbar, toolbar);
EvChrome chrome = EV_CHROME_NORMAL;
gboolean show_toolbar;
- if (window->priv->metadata &&
- ev_metadata_get_boolean (window->priv->metadata, "show_toolbar", &show_toolbar)) {
+ if (window->priv->document) {
+ if (!window->priv->metadata ||
+ !ev_metadata_get_boolean (window->priv->metadata, "show_toolbar", &show_toolbar)) {
+ show_toolbar = g_settings_get_boolean (window->priv->last_settings, "show-toolbar");
+ }
+
if (!show_toolbar)
chrome &= ~EV_CHROME_TOOLBAR;
}
+
window->priv->chrome = chrome;
}
gint sidebar_size;
gboolean sidebar_visibility;
+ if (document) {
+ if (!window->priv->metadata ||
+ !ev_metadata_get_boolean (window->priv->metadata, "sidebar_visibility", &sidebar_visibility)) {
+ sidebar_visibility = g_settings_get_boolean (window->priv->last_settings, "show-sidebar");
+ }
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, sidebar_visibility);
+ update_chrome_visibility (window);
+ }
+
if (!window->priv->metadata)
return;
ev_sidebar_set_page (EV_SIDEBAR (sidebar), layers);
}
}
-
- if (ev_metadata_get_boolean (window->priv->metadata, "sidebar_visibility", &sidebar_visibility)) {
- update_chrome_flag (window, EV_CHROME_SIDEBAR, sidebar_visibility);
- update_chrome_visibility (window);
- }
}
static void
gdouble width_ratio;
gdouble height_ratio;
- if (!window->priv->metadata)
- return;
-
- /* Make sure to not open a document on the last page,
- * since closing it on the last page most likely means the
- * user was finished reading the document. In that case, reopening should
- * show the first page. */
- page = ev_document_model_get_page (window->priv->model);
- n_pages = ev_document_get_n_pages (window->priv->document);
- if (page == n_pages - 1)
- ev_document_model_set_page (window->priv->model, 0);
+ if (window->priv->metadata) {
+ /* Make sure to not open a document on the last page,
+ * since closing it on the last page most likely means the
+ * user was finished reading the document. In that case, reopening should
+ * show the first page. */
+ page = ev_document_model_get_page (window->priv->model);
+ n_pages = ev_document_get_n_pages (window->priv->document);
+ if (page == n_pages - 1)
+ ev_document_model_set_page (window->priv->model, 0);
- setup_sidebar_from_metadata (window);
+ setup_sidebar_from_metadata (window);
- if (ev_metadata_get_int (window->priv->metadata, "window_width", &width) &&
- ev_metadata_get_int (window->priv->metadata, "window_height", &height))
- return; /* size was already set in setup_size_from_metadata */
+ if (ev_metadata_get_int (window->priv->metadata, "window_width", &width) &&
+ ev_metadata_get_int (window->priv->metadata, "window_height", &height))
+ return; /* size was already set in setup_size_from_metadata */
+ }
- if (ev_metadata_get_double (window->priv->metadata, "window_width_ratio", &width_ratio) &&
- ev_metadata_get_double (window->priv->metadata, "window_height_ratio", &height_ratio)) {
+ g_settings_get (window->priv->last_settings, "window-ratio", "(dd)", &width_ratio, &height_ratio);
+ if (width_ratio > 0. && height_ratio > 0.) {
gdouble document_width;
gdouble document_height;
GdkScreen *screen;
screen = gtk_window_get_screen (GTK_WINDOW (window));
if (screen) {
request_width = MIN (request_width, gdk_screen_get_width (screen));
- request_height = MIN (request_width, gdk_screen_get_height (screen));
+ request_height = MIN (request_height, gdk_screen_get_height (screen));
}
if (request_width > 0 && request_height > 0) {
ev_job_scheduler_push_job (ev_window->priv->thumbnail_job, EV_JOB_PRIORITY_NONE);
}
+static void
+override_restrictions_changed (GSettings *settings,
+ gchar *key,
+ EvWindow *ev_window)
+{
+ ev_window_setup_action_sensitivity (ev_window);
+}
+
#ifdef WITH_GCONF
static void
lockdown_changed (GConfClient *client,
ev_window_title_set_document (ev_window->priv->title, document);
ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
+ ev_window->priv->settings = g_settings_new (GS_SCHEMA_NAME);
+ g_signal_connect (ev_window->priv->settings,
+ "changed::"GS_OVERRIDE_RESTRICTIONS,
+ G_CALLBACK (override_restrictions_changed),
+ ev_window);
+
#ifdef WITH_GCONF
if (!ev_window->priv->gconf_client)
ev_window->priv->gconf_client = gconf_client_get_default ();
GCONF_LOCKDOWN_DIR,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
- gconf_client_add_dir (ev_window->priv->gconf_client,
- GCONF_OVERRIDE_RESTRICTIONS,
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
gconf_client_notify_add (ev_window->priv->gconf_client,
GCONF_LOCKDOWN_DIR,
(GConfClientNotifyFunc)lockdown_changed,
ev_window, NULL, NULL);
- gconf_client_notify_add (ev_window->priv->gconf_client,
- GCONF_OVERRIDE_RESTRICTIONS,
- (GConfClientNotifyFunc)lockdown_changed,
- ev_window, NULL, NULL);
#endif /* WITH_GCONF */
ev_window_setup_action_sensitivity (ev_window);
g_object_unref (ev_window->priv->metadata);
source_file = g_file_new_for_uri (uri);
- if (ev_is_metadata_supported_for_file (source_file))
+ if (!ev_file_is_temp (source_file) &&
+ ev_is_metadata_supported_for_file (source_file))
ev_window->priv->metadata = ev_metadata_new (source_file);
else
ev_window->priv->metadata = NULL;
return g_string_free (str, FALSE);
}
+static void
+ev_window_recent_action_connect_proxy_cb (GtkActionGroup *action_group,
+ GtkAction *action,
+ GtkWidget *proxy,
+ gpointer data)
+{
+ GtkLabel *label;
+
+ if (!GTK_IS_MENU_ITEM (proxy))
+ return;
+
+ label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));
+
+ gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_MIDDLE);
+ gtk_label_set_max_width_chars (label, MAX_RECENT_ITEM_LEN);
+}
+
static void
ev_window_setup_recent (EvWindow *ev_window)
{
g_object_unref (ev_window->priv->recent_action_group);
}
ev_window->priv->recent_action_group = gtk_action_group_new ("RecentFilesActions");
+ g_signal_connect (ev_window->priv->recent_action_group, "connect-proxy",
+ G_CALLBACK (ev_window_recent_action_connect_proxy_cb), NULL);
+
gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
- ev_window->priv->recent_action_group, 0);
+ ev_window->priv->recent_action_group, -1);
items = gtk_recent_manager_get_items (ev_window->priv->recent_manager);
items = g_list_sort (items, (GCompareFunc) compare_recent_items);
GtkAction *action;
gchar *action_name;
gchar *label;
+ const gchar *mime_type;
+ gchar *content_type;
+ GIcon *icon = NULL;
info = (GtkRecentInfo *) l->data;
action_name = g_strdup_printf ("RecentFile%u", i++);
label = ev_window_get_recent_file_label (
n_items + 1, gtk_recent_info_get_display_name (info));
-
+
+ mime_type = gtk_recent_info_get_mime_type (info);
+ content_type = g_content_type_from_mime_type (mime_type);
+ if (content_type != NULL) {
+ icon = g_content_type_get_icon (content_type);
+ g_free (content_type);
+ }
+
action = g_object_new (GTK_TYPE_ACTION,
"name", action_name,
"label", label,
+ "gicon", icon,
+ "always-show-image", TRUE,
NULL);
g_object_set_data_full (G_OBJECT (action),
FALSE);
g_free (action_name);
g_free (label);
+ if (icon != NULL)
+ g_object_unref (icon);
if (++n_items == 5)
break;
ev_window_error_message (window, job->error,
_("The file could not be saved as ā%sā."),
EV_JOB_SAVE (job)->uri);
+ } else {
+ ev_window_add_recent (window, EV_JOB_SAVE (job)->uri);
}
ev_window_clear_save_job (window);
gboolean fullscreen_window = TRUE;
guint current_page;
guint rotation;
+ gboolean inverted_colors;
if (EV_WINDOW_IS_PRESENTATION (window))
return;
current_page = ev_document_model_get_page (window->priv->model);
rotation = ev_document_model_get_rotation (window->priv->model);
- window->priv->presentation_view =
- ev_view_presentation_new (window->priv->document, current_page, rotation);
+ inverted_colors = ev_document_model_get_inverted_colors (window->priv->model);
+ window->priv->presentation_view = ev_view_presentation_new (window->priv->document,
+ current_page,
+ rotation,
+ inverted_colors);
g_signal_connect_swapped (window->priv->presentation_view, "finished",
G_CALLBACK (ev_window_view_presentation_finished),
window);
{
GtkWidget *dialog;
GtkWidget *editor;
+ GtkWidget *content_area;
EggEditableToolbar *toolbar;
dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor"),
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
+ gtk_box_set_spacing (GTK_BOX (content_area), 2);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
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);
+ gtk_container_add (GTK_CONTAINER (content_area), editor);
egg_editable_toolbar_set_edit_mode (toolbar, TRUE);
ev_view_autoscroll_start (EV_VIEW (ev_window->priv->view));
}
+#if OFFLINE_HELP_ENABLED
+#define EV_HELP "ghelp:evince"
+#else
+#define EV_HELP "http://library.gnome.org/users/evince/stable/"
+#endif
+
static void
ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
{
GError *error = NULL;
gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
- "ghelp:evince",
+ EV_HELP,
gtk_get_current_event_time (),
&error);
if (error) {
"GNU General Public License for more details.\n"),
N_("You should have received a copy of the GNU General Public License "
"along with Evince; if not, write to the Free Software Foundation, Inc., "
- "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n")
+ "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n")
};
char *license_trans;
update_chrome_visibility (ev_window);
if (ev_window->priv->metadata)
ev_metadata_set_boolean (ev_window->priv->metadata, "show_toolbar", active);
+ if (ev_window->priv->document)
+ g_settings_set_boolean (ev_window->priv->last_settings, "show-toolbar", active);
}
static void
action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
if (!EV_WINDOW_IS_PRESENTATION (ev_window)) {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- GTK_WIDGET_VISIBLE (ev_sidebar));
+ gboolean visible = gtk_widget_get_visible (GTK_WIDGET (ev_sidebar));
+
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
if (ev_window->priv->metadata)
ev_metadata_set_boolean (ev_window->priv->metadata, "sidebar_visibility",
- GTK_WIDGET_VISIBLE (ev_sidebar));
+ visible);
+ if (ev_window->priv->document)
+ g_settings_set_boolean (ev_window->priv->last_settings, "show-sidebar", visible);
}
}
{
gboolean visible;
- visible = GTK_WIDGET_VISIBLE (find_bar);
+ visible = gtk_widget_get_visible (GTK_WIDGET (find_bar));
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
priv->recent_manager = NULL;
}
+ if (priv->settings) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
+
+ if (priv->last_settings) {
+ g_settings_apply (priv->last_settings);
+ g_object_unref (priv->last_settings);
+ priv->last_settings = NULL;
+ }
+
priv->recent_ui_id = 0;
if (priv->model) {
if (priv->menubar_accel_keyval != 0 &&
event->keyval == priv->menubar_accel_keyval &&
modifier == priv->menubar_accel_modifier) {
- if (!GTK_WIDGET_VISIBLE (priv->menubar)) {
+ if (!gtk_widget_get_visible (priv->menubar)) {
g_signal_connect (priv->menubar, "deactivate",
G_CALLBACK (menubar_deactivate_cb),
ev_window);
if (!window->priv->metadata)
return FALSE;
- state = gdk_window_get_state (GTK_WIDGET (window)->window);
+ state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (window)));
if (!(state & GDK_WINDOW_STATE_FULLSCREEN)) {
- if (!ev_window_is_empty (window) && window->priv->document) {
+ if (window->priv->document) {
ev_document_get_max_page_size (window->priv->document,
&document_width, &document_height);
- ev_metadata_set_double (window->priv->metadata, "window_width_ratio",
- (double)event->width / document_width);
- ev_metadata_set_double (window->priv->metadata, "window_height_ratio",
- (double)event->height / document_height);
+ g_settings_set (window->priv->last_settings, "window-ratio", "(dd)",
+ (double)event->width / document_width,
+ (double)event->height / document_height);
+
ev_metadata_set_int (window->priv->metadata, "window_x", event->x);
ev_metadata_set_int (window->priv->metadata, "window_y", event->y);
ev_metadata_set_int (window->priv->metadata, "window_width", event->width);
/* Give focus to the document view */
gtk_widget_grab_focus (ev_window->priv->view);
+ ev_window->priv->last_settings = g_settings_new (GS_SCHEMA_NAME".Default");
+ g_settings_delay (ev_window->priv->last_settings);
+
/* Set it user interface params */
ev_window_setup_recent (ev_window);