X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fev-window.c;h=bee7d341b506e1543e6da22523c5c655f7343ac8;hb=e732e45fbf5930d8c3ac2471ff8912f41152ec7a;hp=a07bea71a38276916682373e4ea3f78bc3e0a0bf;hpb=a919e61801f30689700e3179b99d32b3f445f39e;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index a07bea71..bee7d341 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ /* this file is part of evince, a gnome document viewer * + * Copyright (C) 2009 Juanjo Marín * Copyright (C) 2008 Carlos Garcia Campos * Copyright (C) 2004 Martin Kretzschmar * Copyright (C) 2004 Red Hat, Inc. @@ -423,12 +424,18 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages); ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages); ev_window_set_action_sensitive (ev_window, "ViewAutoscroll", has_pages); + ev_window_set_action_sensitive (ev_window, "ViewInvertedColors", has_pages); /* Toolbar-specific actions: */ ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages); 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); } @@ -947,9 +954,10 @@ setup_model_from_metadata (EvWindow *window) gchar *sizing_mode; gdouble zoom; gint rotation; - gboolean continuous = { 0, }; - gboolean dual_page = { 0, }; - gboolean fullscreen = { 0, }; + gboolean inverted_colors = FALSE; + gboolean continuous = FALSE; + gboolean dual_page = FALSE; + gboolean fullscreen = FALSE; if (!window->priv->metadata) return; @@ -995,6 +1003,10 @@ setup_model_from_metadata (EvWindow *window) ev_document_model_set_rotation (window->priv->model, rotation); } + /* Inverted Colors */ + if (ev_metadata_get_boolean (window->priv->metadata, "inverted-colors", &inverted_colors)) + ev_document_model_set_inverted_colors (window->priv->model, inverted_colors); + /* Continuous */ if (ev_metadata_get_boolean (window->priv->metadata, "continuous", &continuous)) { ev_document_model_set_continuous (window->priv->model, continuous); @@ -1146,10 +1158,11 @@ ev_window_set_icon_from_thumbnail (EvJobThumbnail *job, } static void -ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation) +ev_window_refresh_window_thumbnail (EvWindow *ev_window) { gdouble page_width; gdouble scale; + gint rotation; EvDocument *document = ev_window->priv->document; if (!EV_IS_DOCUMENT_THUMBNAILS (document) || @@ -1162,6 +1175,7 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation) ev_document_get_page_size (document, 0, &page_width, NULL); scale = 128. / page_width; + rotation = ev_document_model_get_rotation (ev_window->priv->model); ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale); g_signal_connect (ev_window->priv->thumbnail_job, "finished", @@ -1190,7 +1204,7 @@ ev_window_setup_document (EvWindow *ev_window) ev_window->priv->setup_document_idle = 0; - ev_window_refresh_window_thumbnail (ev_window, 0); + ev_window_refresh_window_thumbnail (ev_window); ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT); ev_window_title_set_document (ev_window->priv->title, document); @@ -3845,6 +3859,14 @@ ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window) ev_document_model_set_rotation (ev_window->priv->model, rotation + 90); } +static void +ev_window_cmd_view_inverted_colors (GtkAction *action, EvWindow *ev_window) +{ + gboolean inverted_colors = ev_document_model_get_inverted_colors (ev_window->priv->model); + + ev_document_model_set_inverted_colors (ev_window->priv->model, !inverted_colors); +} + static void ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, @@ -4166,7 +4188,21 @@ ev_window_rotation_changed_cb (EvDocumentModel *model, ev_metadata_set_int (window->priv->metadata, "rotation", rotation); - ev_window_refresh_window_thumbnail (window, rotation); + ev_window_refresh_window_thumbnail (window); +} + +static void +ev_window_update_inverted_colors_action (EvWindow *window) +{ + GtkAction *action; + + action = gtk_action_group_get_action (window->priv->action_group, "ViewInvertedColors"); + g_signal_handlers_block_by_func + (action, G_CALLBACK (ev_window_cmd_view_inverted_colors), window); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + ev_document_model_get_inverted_colors (window->priv->model)); + g_signal_handlers_unblock_by_func + (action, G_CALLBACK (ev_window_cmd_view_inverted_colors), window); } static void @@ -4175,13 +4211,14 @@ ev_window_inverted_colors_changed_cb (EvDocumentModel *model, EvWindow *window) { gboolean inverted_colors = ev_document_model_get_inverted_colors (model); - gint rotation = ev_document_model_get_rotation (model); + + ev_window_update_inverted_colors_action (window); if (window->priv->metadata && !ev_window_is_empty (window)) ev_metadata_set_boolean (window->priv->metadata, "inverted-colors", inverted_colors); - ev_window_refresh_window_thumbnail (window, rotation); + ev_window_refresh_window_thumbnail (window); } static void @@ -5085,6 +5122,7 @@ static const GtkActionEntry entries[] = { { "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), "Right", NULL, G_CALLBACK (ev_window_cmd_edit_rotate_right) }, + /* View menu */ { "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "plus", N_("Enlarge the document"), @@ -5208,6 +5246,10 @@ static const GtkToggleActionEntry toggle_entries[] = { { "ViewPageWidth", EV_STOCK_ZOOM_WIDTH, N_("Fit Page _Width"), NULL, N_("Make the current document fill the window width"), G_CALLBACK (ev_window_cmd_view_page_width) }, + { "ViewInvertedColors", EV_STOCK_INVERTED_COLORS, N_("_Inverted Colors"), "I", + N_("Show page contents with the colors inverted"), + G_CALLBACK (ev_window_cmd_view_inverted_colors) }, + }; /* Popups specific items */ @@ -5557,18 +5599,35 @@ launch_external_uri (EvWindow *window, EvLinkAction *action) if (!g_strstr_len (uri, strlen (uri), "://") && !g_str_has_prefix (uri, "mailto:")) { - gchar *http; - - /* Not a valid uri, assuming it's http */ - http = g_strdup_printf ("http://%s", uri); - ret = g_app_info_launch_default_for_uri (http, context, &error); - g_free (http); + gchar *new_uri; + + /* Not a valid uri, assume http if it starts with www */ + if (g_str_has_prefix (uri, "www.")) { + new_uri = g_strdup_printf ("http://%s", uri); + } else { + GFile *file, *parent; + + file = g_file_new_for_uri (window->priv->uri); + parent = g_file_get_parent (file); + g_object_unref (file); + if (parent) { + gchar *parent_uri = g_file_get_uri (parent); + + new_uri = g_build_filename (parent_uri, uri, NULL); + g_free (parent_uri); + g_object_unref (parent); + } else { + new_uri = g_strdup_printf ("file:///%s", uri); + } + } + ret = g_app_info_launch_default_for_uri (new_uri, context, &error); + g_free (new_uri); } else { ret = g_app_info_launch_default_for_uri (uri, context, &error); } - + if (ret == FALSE) { - ev_window_error_message (window, error, + ev_window_error_message (window, error, "%s", _("Unable to open external link")); g_error_free (error); } @@ -6085,6 +6144,7 @@ ev_window_init (EvWindow *ev_window) GtkAccelGroup *accel_group; GError *error = NULL; GtkWidget *sidebar_widget; + GtkWidget *menuitem; EggToolbarsModel *toolbars_model; GObject *mpkeys; gchar *ui_path; @@ -6179,6 +6239,12 @@ ev_window_init (EvWindow *ev_window) gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->menubar, FALSE, FALSE, 0); + menuitem = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, + "/MainMenu/EditMenu/EditRotateLeftMenu"); + gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE); + menuitem = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, + "/MainMenu/EditMenu/EditRotateRightMenu"); + gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE); toolbars_model = get_toolbars_model (); ev_window->priv->toolbar = GTK_WIDGET