]> www.fi.muni.cz Git - evince.git/commitdiff
Fix bugs in the links implementation and change cursor when hovering a
authorMarco Pesenti Gritti <marco@gnome.org>
Tue, 18 Jan 2005 12:45:49 +0000 (12:45 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Tue, 18 Jan 2005 12:45:49 +0000 (12:45 +0000)
2005-01-18  Marco Pesenti Gritti  <marco@gnome.org>

        * pdf/xpdf/pdf-document.cc:
        * shell/ev-view.c: (status_message_from_link),
        (ev_view_set_status), (ev_view_set_cursor),
        (ev_view_motion_notify_event), (ev_view_init):
        * shell/ev-window.c: (view_status_changed_cb), (ev_window_init):

        Fix bugs in the links implementation and change cursor
        when hovering a link.

ChangeLog
pdf/xpdf/pdf-document.cc
shell/ev-view.c
shell/ev-window.c

index e884400d9a33b5c47f8c90269125ab0f1b2e1a5b..7e3ed84d0ce34dbd7f18f6b36a431b8d6067bf9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-01-18  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * pdf/xpdf/pdf-document.cc:
+       * shell/ev-view.c: (status_message_from_link),
+       (ev_view_set_status), (ev_view_set_cursor),
+       (ev_view_motion_notify_event), (ev_view_init):
+       * shell/ev-window.c: (view_status_changed_cb), (ev_window_init):
+
+       Fix bugs in the links implementation and change cursor
+       when hovering a link.
+
 2005-01-17  Bryan Clark  <clarkbw@cvs.gnome.org>
 
        * viewer/.cvsignore: added cvsignore file for viewer directory
index a8824e8845036310d9cf57424155ec1a96a777fe..36ad37436a2e40626510fdf0792bc5b689829a29 100644 (file)
@@ -1005,7 +1005,11 @@ pdf_document_get_link (EvDocument *document, int x, int y)
        PdfDocument *pdf_document = PDF_DOCUMENT (document);
        LinkAction *action;
 
-       action = pdf_document->links->find (x, y);
+       y = pdf_document->out->getBitmapHeight() - y;
+
+       action = pdf_document->links->find ((double)x / pdf_document->scale,
+                                           (double)y / pdf_document->scale);
+       
        if (action) {
                return build_link_from_action (pdf_document, action, "");
        } else {
index 8e18ec48bbbcd4a1dc85466124d9971bbcf3ab43..7ca3630bc8903191a8102564a0efe49dc0d58fba 100644 (file)
@@ -55,6 +55,11 @@ static const GtkTargetEntry targets[] = {
        { "UTF8_STRING", 0, TARGET_UTF8_STRING },
 };
 
+typedef enum {
+       EV_VIEW_CURSOR_NORMAL,
+       EV_VIEW_CURSOR_HAND
+} EvViewCursor;
+
 struct _EvView {
        GtkWidget parent_instance;
 
@@ -72,6 +77,7 @@ struct _EvView {
        gboolean pressed_button;
        gboolean has_selection;
        GdkRectangle selection;
+       EvViewCursor cursor;
 
        GtkAdjustment *hadjustment;
        GtkAdjustment *vadjustment;
@@ -552,7 +558,7 @@ status_message_from_link (EvLink *link)
                        break;
                case EV_LINK_TYPE_PAGE:
                        page = ev_link_get_page (link);
-                       msg = g_strdup_printf (_("Page %d"), page);
+                       msg = g_strdup_printf (_("Go to page %d"), page);
                        break;
                case EV_LINK_TYPE_EXTERNAL_URI:
                        msg = g_strdup (ev_link_get_uri (link));
@@ -569,9 +575,11 @@ ev_view_set_status (EvView *view, const char *message)
 {
        g_return_if_fail (EV_IS_VIEW (view));
 
-       g_free (view->status);
-       view->status = g_strdup (message);
-       g_object_notify (G_OBJECT (view), "status");
+       if (message != view->status) {
+               g_free (view->status);
+               view->status = g_strdup (message);
+               g_object_notify (G_OBJECT (view), "status");
+       }
 }
 
 static void
@@ -584,6 +592,31 @@ ev_view_set_find_status (EvView *view, const char *message)
        g_object_notify (G_OBJECT (view), "find-status");
 }
 
+static void
+ev_view_set_cursor (EvView *view, EvViewCursor new_cursor)
+{
+       GdkCursor *cursor;
+       GtkWidget *widget = GTK_WIDGET (view);
+
+       if (view->cursor == new_cursor) {
+               return;
+       }
+
+       switch (new_cursor) {
+               case EV_VIEW_CURSOR_NORMAL:
+                       gdk_window_set_cursor (widget->window, NULL);
+                       break;
+               case EV_VIEW_CURSOR_HAND:
+                       cursor = gdk_cursor_new_for_display
+                               (gdk_display_get_default(), GDK_HAND2);
+                       gdk_window_set_cursor (widget->window, cursor);
+                       gdk_cursor_unref (cursor);
+                       break;
+       }
+
+       view->cursor = new_cursor;
+}
+
 static gboolean
 ev_view_motion_notify_event (GtkWidget      *widget,
                             GdkEventMotion *event)
@@ -605,10 +638,14 @@ ev_view_motion_notify_event (GtkWidget      *widget,
 
                        msg = status_message_from_link (link);
                        ev_view_set_status (view, msg);
+                       ev_view_set_cursor (view, EV_VIEW_CURSOR_HAND);
                        g_free (msg);
 
                         g_object_unref (link);
-                }
+               } else {
+                       ev_view_set_status (view, NULL);
+                       ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL);
+               }
        }
 
        gtk_widget_queue_draw (widget);
@@ -871,6 +908,7 @@ ev_view_init (EvView *view)
 
        view->scale = 1.0;
        view->pressed_button = -1;
+       view->cursor = EV_VIEW_CURSOR_NORMAL;
        
        gtk_widget_modify_bg (GTK_WIDGET (view), GTK_STATE_NORMAL, &white);
 
index 0b8679cb3d63bb605cd4d5ab20fdeb099d1aefb2..54effcd24e9b124180088b89ddbe5e4adb625783 100644 (file)
@@ -73,6 +73,7 @@ struct _EvWindowPrivate {
        GtkUIManager *ui_manager;
        GtkWidget *statusbar;
        guint help_message_cid;
+       guint view_message_cid;
        GtkWidget *exit_fullscreen_popup;
        char *uri;
 
@@ -1166,9 +1167,14 @@ view_status_changed_cb (EvView     *view,
 {
        const char *message;
 
+       gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
+                          ev_window->priv->view_message_cid);
+
        message = ev_view_get_status (view);
-       gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
-                           ev_window->priv->help_message_cid, message);
+       if (message) {
+               gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
+                                   ev_window->priv->view_message_cid, message);
+       }
 }
 
 static void
@@ -1582,6 +1588,8 @@ ev_window_init (EvWindow *ev_window)
                          FALSE, TRUE, 0);
        ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
                (GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
+       ev_window->priv->view_message_cid = gtk_statusbar_get_context_id
+               (GTK_STATUSBAR (ev_window->priv->statusbar), "view_message");
 
        ev_window->priv->find_bar = egg_find_bar_new ();
        gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),