X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-window.c;h=26708788d897f816e516b29631678545ad583042;hb=804d2382429a16dc10f2c0ec28443edf0b9bfac8;hp=ed21fffc0b85a069ee46665af43fe11532bee40e;hpb=f8e5af3518344dac7c885a7880bbd421ea56116d;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index ed21fffc..26708788 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -39,6 +39,7 @@ #include "ev-print-job.h" #include "ev-document-thumbnails.h" #include "ev-document-links.h" +#include "ev-document-types.h" #include "ev-document-find.h" #include "ev-document-security.h" #include "ev-job-queue.h" @@ -47,16 +48,6 @@ #include "egg-recent-view.h" #include "egg-recent-model.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 #include #include @@ -101,7 +92,6 @@ struct _EvWindowPrivate { GtkWidget *toolbar; GtkWidget *hpaned; GtkWidget *sidebar; - GtkWidget *thumbs_sidebar; GtkWidget *find_bar; GtkWidget *scrolled_window; GtkWidget *view; @@ -398,44 +388,6 @@ unable_to_load (EvWindow *ev_window, gtk_widget_destroy (dialog); } -/* Would be nice to have this in gdk-pixbuf */ -static gboolean -mime_type_supported_by_gdk_pixbuf (const gchar *mime_type) -{ - GSList *formats, *list; - gboolean retval = FALSE; - - formats = gdk_pixbuf_get_formats (); - - list = formats; - while (list) { - GdkPixbufFormat *format = list->data; - int i; - gchar **mime_types; - - if (gdk_pixbuf_format_is_disabled (format)) - continue; - - mime_types = gdk_pixbuf_format_get_mime_types (format); - - for (i = 0; mime_types[i] != NULL; i++) { - if (strcmp (mime_types[i], mime_type) == 0) { - retval = TRUE; - break; - } - } - - if (retval) - break; - - list = list->next; - } - - g_slist_free (formats); - - return retval; -} - static void update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_window) { @@ -495,21 +447,6 @@ update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_windo 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) { @@ -549,10 +486,7 @@ ev_window_setup_document (EvWindow *ev_window) 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); @@ -709,33 +643,6 @@ start_loading_document (EvWindow *ev_window, return FALSE; } -static gboolean -is_file_supported (const gchar *mime_type) -{ - static const char * const supported_types [] = { - "application/pdf", - "application/postscript", - "application/x-dvi", - "image/vnd.djvu", - "application/x-gzpostscript", - "image/x-eps", - NULL - }; - gint i; - - g_return_val_if_fail (mime_type != NULL, FALSE); - - if (mime_type_supported_by_gdk_pixbuf (mime_type)) - return TRUE; - - for (i = 0; supported_types[i] != NULL; i++) { - if (g_ascii_strcasecmp (mime_type, supported_types[i]) == 0) - return TRUE; - } - - return FALSE; -} - void ev_window_open (EvWindow *ev_window, const char *uri) { @@ -749,22 +656,13 @@ ev_window_open (EvWindow *ev_window, const char *uri) if (mime_type == NULL) document = NULL; - else if (!strcmp (mime_type, "application/pdf")) - document = g_object_new (PDF_TYPE_DOCUMENT, NULL); - else if (!strcmp (mime_type, "application/postscript") || - !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 + else { + GType document_type = ev_document_type_lookup (mime_type); + + if (document_type!=G_TYPE_INVALID) { + document = g_object_new (document_type, NULL); + } + } if (document) { start_loading_document (ev_window, document, uri); @@ -797,7 +695,7 @@ ev_window_open_uri_list (EvWindow *ev_window, GList *uri_list) uri = gnome_vfs_uri_to_string (list->data, GNOME_VFS_URI_HIDE_NONE); mime_type = gnome_vfs_get_mime_type (uri); - if (is_file_supported (mime_type)) { + if (ev_document_type_lookup (mime_type)!=G_TYPE_INVALID) { if (ev_window_is_empty (EV_WINDOW (ev_window))) { ev_window_open (ev_window, uri); @@ -1459,22 +1357,29 @@ ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window) } static gboolean -ev_window_state_event_cb (GtkWidget *widget, GdkEventWindowState *event, EvWindow *window) +ev_window_state_event (GtkWidget *widget, GdkEventWindowState *event) { - if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) - { + 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); + } + + if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { GtkActionGroup *action_group; GtkAction *action; gboolean fullscreen; fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN; - if (fullscreen) - { + if (fullscreen) { ev_window_fullscreen (window); - } - else - { + } else { ev_window_unfullscreen (window); } @@ -1486,7 +1391,6 @@ ev_window_state_event_cb (GtkWidget *widget, GdkEventWindowState *event, EvWindo 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); - } return FALSE; @@ -2087,6 +1991,7 @@ ev_window_class_init (EvWindowClass *ev_window_class) 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; @@ -2483,16 +2388,12 @@ ev_window_init (EvWindow *ev_window) 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, @@ -2581,10 +2482,6 @@ ev_window_init (EvWindow *ev_window) 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);