]> www.fi.muni.cz Git - evince.git/commitdiff
Automatically hide the fullscreen button. Patch by Kristian Høgsberg
authorMarco Pesenti Gritti <marco@gnome.org>
Wed, 16 Feb 2005 18:50:26 +0000 (18:50 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Wed, 16 Feb 2005 18:50:26 +0000 (18:50 +0000)
2005-02-16  Marco Pesenti Gritti  <marco@gnome.org>

        * shell/ev-view.c: (ev_view_realize), (highlight_find_results),
        (ev_view_create_invisible_cursor), (ev_view_set_cursor),
        (set_document_page), (document_changed_callback),
        (ev_view_set_document), (ev_view_find_previous),
        (ev_view_hide_cursor), (ev_view_show_cursor):
        * shell/ev-view.h:
        * shell/ev-window.c: (update_chrome_visibility),
        (fullscreen_timeout_cb), (fullscreen_set_timeout),
        (fullscreen_clear_timeout), (fullscreen_motion_notify_cb),
        (fullscreen_leave_notify_cb), (ev_window_fullscreen),
        (ev_window_unfullscreen):
        * shell/main.c: (main):

        Automatically hide the fullscreen button.
        Patch by Kristian Høgsberg <krh@redhat.com>

ChangeLog
shell/ev-view.c
shell/ev-view.h
shell/ev-window.c

index 73f6e5d5f98fdb8b5307188f6b57406285d96874..c0d5a399424ff8eab419a4dbf7acc752151810df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2005-02-16  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * shell/ev-view.c: (ev_view_realize), (highlight_find_results),
+       (ev_view_create_invisible_cursor), (ev_view_set_cursor),
+       (set_document_page), (document_changed_callback),
+       (ev_view_set_document), (ev_view_find_previous),
+       (ev_view_hide_cursor), (ev_view_show_cursor):
+       * shell/ev-view.h:
+       * shell/ev-window.c: (update_chrome_visibility),
+       (fullscreen_timeout_cb), (fullscreen_set_timeout),
+       (fullscreen_clear_timeout), (fullscreen_motion_notify_cb),
+       (fullscreen_leave_notify_cb), (ev_window_fullscreen),
+       (ev_window_unfullscreen):
+       * shell/main.c: (main):
+
+       Automatically hide the fullscreen button.
+       Patch by Kristian Høgsberg <krh@redhat.com>
+
 2005-02-16  Vincent Noel  <vnoel@cox.net>
 
        * shell/main.c (main): Specify an icon for the window. Patch by
index 095bd24dbed72cab6974a20a433c3fd4d2249530..4550292ede072180af296883f67594d917be36b4 100644 (file)
@@ -60,7 +60,8 @@ static const GtkTargetEntry targets[] = {
 typedef enum {
        EV_VIEW_CURSOR_NORMAL,
        EV_VIEW_CURSOR_LINK,
-       EV_VIEW_CURSOR_WAIT
+       EV_VIEW_CURSOR_WAIT,
+       EV_VIEW_CURSOR_HIDDEN
 } EvViewCursor;
 
 #define ZOOM_IN_FACTOR  1.2
@@ -310,7 +311,8 @@ ev_view_realize (GtkWidget *widget)
                                GDK_BUTTON_RELEASE_MASK |
                                GDK_SCROLL_MASK |
                                GDK_KEY_PRESS_MASK |
-                               GDK_POINTER_MOTION_MASK;
+                               GDK_POINTER_MOTION_MASK |
+                               GDK_LEAVE_NOTIFY_MASK;
   
        view->bin_window = gdk_window_new (widget->window,
                                           &attributes,
@@ -399,9 +401,13 @@ draw_rubberband (GtkWidget *widget, GdkWindow *window,
 static void
 highlight_find_results (EvView *view)
 {
-       EvDocumentFind *find = EV_DOCUMENT_FIND (view->document);
+       EvDocumentFind *find;
        int i, results;
 
+       g_return_if_fail (EV_IS_DOCUMENT_FIND (view->document));
+
+       find = EV_DOCUMENT_FIND (view->document);
+
        results = ev_document_find_get_n_results (find);
 
        for (i = 0; i < results; i++) {
@@ -633,6 +639,17 @@ ev_view_set_find_status (EvView *view, const char *message)
        g_object_notify (G_OBJECT (view), "find-status");
 }
 
+static GdkCursor *
+ev_view_create_invisible_cursor(void)
+{
+       GdkBitmap *empty;
+       GdkColor black = { 0, 0, 0, 0 };
+       static unsigned char bits[] = { 0x00 };
+
+       empty = gdk_bitmap_create_from_data (NULL, bits, 1, 1);
+
+       return gdk_cursor_new_from_pixmap (empty, empty, &black, &black, 0, 0);
+}
 
 static void
 ev_view_set_cursor (EvView *view, EvViewCursor new_cursor)
@@ -659,6 +676,10 @@ ev_view_set_cursor (EvView *view, EvViewCursor new_cursor)
                case EV_VIEW_CURSOR_WAIT:
                        cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
                        break;
+                case EV_VIEW_CURSOR_HIDDEN:
+                        cursor = ev_view_create_invisible_cursor ();
+                        break;
+
        }
 
        if (cursor) {
@@ -1012,7 +1033,9 @@ set_document_page (EvView *view, int new_page)
                                           &old_width, &old_height);
 
                if (old_page != page) {
-                       ev_view_set_cursor (view, EV_VIEW_CURSOR_WAIT);
+                       if (view->cursor != EV_VIEW_CURSOR_HIDDEN) {
+                               ev_view_set_cursor (view, EV_VIEW_CURSOR_WAIT);
+                       }
                        ev_document_set_page (view->document, page);
                }
 
@@ -1032,10 +1055,9 @@ set_document_page (EvView *view, int new_page)
                                                  view->vadjustment->lower);
                }
 
-               view->find_page = page;
-               view->find_result = 0;
-
                if (EV_IS_DOCUMENT_FIND (view->document)) {
+                       view->find_page = page;
+                       view->find_result = 0;
                        update_find_status_message (view);
                }
        }
@@ -1137,7 +1159,10 @@ document_changed_callback (EvDocument *document,
                           EvView     *view)
 {
        gtk_widget_queue_draw (GTK_WIDGET (view));
-       ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL);
+
+       if (view->cursor != EV_VIEW_CURSOR_HIDDEN) {
+               ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL);
+       }
 }
 
 /*** Public API ***/       
@@ -1156,8 +1181,9 @@ ev_view_set_document (EvView     *view,
 
        if (document != view->document) {
                if (view->document) {
-                        g_signal_handlers_disconnect_by_func
-                               (view->document, find_changed_cb, view);
+                        g_signal_handlers_disconnect_by_func (view->document,
+                                                              find_changed_cb,
+                                                              view);
                        g_object_unref (view->document);
                 }
 
@@ -1424,3 +1450,14 @@ ev_view_find_previous (EvView *view)
                gtk_widget_queue_draw (GTK_WIDGET (view));
        }
 }
+void
+ev_view_hide_cursor (EvView *view)
+{
+       ev_view_set_cursor (view, EV_VIEW_CURSOR_HIDDEN);
+}
+
+void
+ev_view_show_cursor (EvView *view)
+{
+       ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK);
+}
index 5feb0f718f31b485c6f3fbe18e307ed31aea8ca2..2fdb38a48e4a3e57cbb0becb5c5ebd6145a9d537 100644 (file)
@@ -78,6 +78,10 @@ void            ev_view_find_previous   (EvView     *view);
 const char     *ev_view_get_status      (EvView     *view);
 const char     *ev_view_get_find_status (EvView     *view);
 
+/* Cursor */
+void           ev_view_hide_cursor     (EvView     *view);
+void           ev_view_show_cursor     (EvView     *view);
+
 G_END_DECLS
 
 #endif /* __EV_VIEW_H__ */
index 27a6f60f21871f11215ad8d40d935410e889a4e4..387e998cafbf087eb704119ebb7b209d5b6521af 100644 (file)
@@ -108,6 +108,7 @@ struct _EvWindowPrivate {
        EvChrome chrome;
        gboolean fullscreen_mode;
        EvSizingMode sizing_mode;
+       GSource *fullscreen_timeout_source;
 };
 
 static GtkTargetEntry ev_drop_types[] = {
@@ -222,7 +223,7 @@ update_chrome_visibility (EvWindow *window)
 
        menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !priv->fullscreen_mode;
        toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
-       sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0;
+       sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !priv->fullscreen_mode;
        findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
        statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !priv->fullscreen_mode;
 
@@ -1038,6 +1039,71 @@ fullscreen_popup_size_request_cb (GtkWidget *popup, GtkRequisition *req, EvWindo
        ev_window_update_fullscreen_popup (window);
 }
 
+static gboolean
+fullscreen_timeout_cb (gpointer data)
+{
+       EvWindow *window = EV_WINDOW (data);
+
+       g_object_set (window->priv->toolbar_dock, "visible", FALSE, NULL);
+       ev_view_hide_cursor (EV_VIEW (window->priv->view));
+       window->priv->fullscreen_timeout_source = NULL;
+
+       return FALSE;
+}
+
+static void
+fullscreen_set_timeout (EvWindow *window)
+{
+       GSource *source;
+
+       if (window->priv->fullscreen_timeout_source != NULL)
+               g_source_destroy (window->priv->fullscreen_timeout_source);
+
+       source = g_timeout_source_new (1000);
+       g_source_set_callback (source, fullscreen_timeout_cb, window, NULL);
+       g_source_attach (source, NULL);
+       window->priv->fullscreen_timeout_source = source;
+}
+
+static void
+fullscreen_clear_timeout (EvWindow *window)
+{
+       if (window->priv->fullscreen_timeout_source != NULL)
+               g_source_destroy (window->priv->fullscreen_timeout_source);
+
+       window->priv->fullscreen_timeout_source = NULL;
+       ev_view_show_cursor (EV_VIEW (window->priv->view));
+}
+
+static gboolean
+fullscreen_motion_notify_cb (GtkWidget *widget,
+                            GdkEventMotion *event,
+                            gpointer user_data)
+{
+       EvWindow *window = EV_WINDOW (user_data);
+
+       if (!GTK_WIDGET_VISIBLE (window->priv->exit_fullscreen_popup)) {
+               g_object_set (window->priv->toolbar_dock, "visible", TRUE, NULL);
+               ev_view_show_cursor (EV_VIEW (window->priv->view));
+       }
+
+       fullscreen_set_timeout (window);
+
+       return FALSE;
+}
+
+static gboolean
+fullscreen_leave_notify_cb (GtkWidget *widget,
+                           GdkEventCrossing *event,
+                           gpointer user_data)
+{
+       EvWindow *window = EV_WINDOW (user_data);
+
+       fullscreen_clear_timeout (window);
+
+       return FALSE;
+}
+
 static void
 ev_window_fullscreen (EvWindow *window)
 {
@@ -1079,6 +1145,22 @@ ev_window_fullscreen (EvWindow *window)
 
        update_chrome_visibility (window);
 
+       g_object_set (G_OBJECT (window->priv->scrolled_window),
+                     "shadow-type", GTK_SHADOW_NONE,
+                     NULL);
+
+       g_signal_connect (window->priv->view,
+                         "motion-notify-event",
+                         G_CALLBACK (fullscreen_motion_notify_cb),
+                         window);
+       g_signal_connect (window->priv->view,
+                         "leave-notify-event",
+                         G_CALLBACK (fullscreen_leave_notify_cb),
+                         window);
+       fullscreen_set_timeout (window);
+
+       gtk_widget_grab_focus (window->priv->view);
+
        ev_window_update_fullscreen_popup (window);
 }
 
@@ -1087,6 +1169,16 @@ ev_window_unfullscreen (EvWindow *window)
 {
        window->priv->fullscreen_mode = FALSE;
 
+       g_object_set (G_OBJECT (window->priv->scrolled_window),
+                     "shadow-type", GTK_SHADOW_IN,
+                     NULL);
+
+       fullscreen_clear_timeout (window);
+
+       g_signal_handlers_disconnect_by_func (window->priv->view,
+                                             (gpointer) fullscreen_motion_notify_cb,
+                                             window);
+
        destroy_exit_fullscreen_popup (window);
 
        update_chrome_visibility (window);