]> www.fi.muni.cz Git - evince.git/commitdiff
Fix a headers problem with ev-link
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 30 Jul 2007 16:35:31 +0000 (16:35 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Mon, 30 Jul 2007 16:35:31 +0000 (16:35 +0000)
2007-07-30  Carlos Garcia Campos  <carlosgc@gnome.org>
* libdocument/ev-document-info.h:
* libdocument/ev-document.h:
* shell/ev-page-action.h:
* shell/ev-sidebar-links.h:
Fix a headers problem with ev-link
* libdocument/ev-link.[ch]: (ev_link_mapping_get_area):
* shell/ev-view-private.h:
* shell/ev-view.c: (ev_view_handle_cursor_over_xy),
(get_link_area), (ev_view_query_tooltip),
(ev_view_leave_notify_event), (ev_view_destroy),
(ev_view_class_init):
Use new gtk tooltips when available instead of ev-tooltip.

svn path=/trunk/; revision=2599

ChangeLog
libdocument/ev-document-info.h
libdocument/ev-document.h
libdocument/ev-link.c
libdocument/ev-link.h
shell/ev-page-action.h
shell/ev-sidebar-links.h
shell/ev-view-private.h
shell/ev-view.c

index 5c2e7b1142318ba0e103917e40a3e1526139ee70..0a21ca81d493346a149e2ecfa225e5ff162fcde4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2007-07-30  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * libdocument/ev-document-info.h:
+       * libdocument/ev-document.h:
+       * shell/ev-page-action.h:
+       * shell/ev-sidebar-links.h:
+
+       Fix a headers problem with ev-link
+       
+       * libdocument/ev-link.[ch]: (ev_link_mapping_get_area):
+       * shell/ev-view-private.h:
+       * shell/ev-view.c: (ev_view_handle_cursor_over_xy),
+       (get_link_area), (ev_view_query_tooltip),
+       (ev_view_leave_notify_event), (ev_view_destroy),
+       (ev_view_class_init):
+
+       Use new gtk tooltips when available instead of ev-tooltip.
+       
 2007-07-30  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-window.c: (update_chrome_visibility),
index 0cd1ef850b244e767f32bb779d1d08c510a1375c..b5e865430fb6b9019fbd489aa13ebe52471a516d 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <glib-object.h>
 #include <glib.h>
-#include "ev-link.h"
 
 G_BEGIN_DECLS
 
index e83295f0c0d256f4ea67609d48c784103615e1fc..833491e25a0816279b908ada6f9075f6d86abe3c 100644 (file)
@@ -27,7 +27,6 @@
 #include <gdk/gdk.h>
 #include <cairo.h>
 
-#include "ev-link.h"
 #include "ev-document-info.h"
 #include "ev-render-context.h"
 
index 17e44213951323282b2f483d957113d92297eb8e..1e8251a87bc7a065a66b746f2394e5875a3f276e 100644 (file)
@@ -224,6 +224,27 @@ ev_link_mapping_find (GList   *link_mapping,
        return link;
 }
 
+void
+ev_link_mapping_get_area (GList       *link_mapping,
+                         EvLink      *link,
+                         EvRectangle *area)
+{
+       GList *list;
+
+       for (list = link_mapping; list; list = list->next) {
+               EvLinkMapping *mapping = list->data;
+
+               if (mapping->link == link) {
+                       area->x1 = mapping->x1;
+                       area->y1 = mapping->y1;
+                       area->x2 = mapping->x2;
+                       area->y2 = mapping->y2;
+
+                       break;
+               }
+       }
+}
+
 gint
 ev_link_get_page (EvLink *link)
 {
index 9bd7f6e0af18e6d170ce23302f84214777be06ba..136047c7a5ef333ab144e3082a192b99bdcc89c4 100644 (file)
@@ -21,6 +21,7 @@
 #define EV_LINK_H
 
 #include <glib-object.h>
+#include "ev-document.h"
 #include "ev-link-action.h"
 
 G_BEGIN_DECLS
@@ -43,7 +44,7 @@ EvLink             *ev_link_new        (const gchar  *title,
 
 const gchar  *ev_link_get_title  (EvLink       *self);
 EvLinkAction *ev_link_get_action (EvLink       *self);
-gint         ev_link_get_page   (EvLink *link);
+gint         ev_link_get_page   (EvLink       *link);
 
 /* Link Mapping stuff */
 typedef struct _EvLinkMapping    EvLinkMapping;
@@ -56,10 +57,13 @@ struct _EvLinkMapping
        gdouble y2;
 };
 
-void    ev_link_mapping_free (GList   *link_mapping);
-EvLink *ev_link_mapping_find (GList   *link_mapping,
-                             gdouble  x,
-                             gdouble  y);
+void    ev_link_mapping_free     (GList       *link_mapping);
+EvLink *ev_link_mapping_find     (GList       *link_mapping,
+                                 gdouble      x,
+                                 gdouble      y);
+void    ev_link_mapping_get_area (GList       *link_mapping,
+                                 EvLink      *link,
+                                 EvRectangle *area);
 G_END_DECLS
 
 #endif /* !EV_LINK_H */
index c9785c655b30e974a85ad58ca42ea556ea690500..82f3ac8079e30744e7b27b7187e7d5ad67019843 100644 (file)
@@ -24,6 +24,7 @@
 #include <gtk/gtkaction.h>
 #include <gtk/gtktreemodel.h>
 #include <ev-document.h>
+#include "ev-link.h"
 
 G_BEGIN_DECLS
 
index 36fb1da2250d0ec448a29a14677ea041390fd806..f1a6b870c19a19c3cb22a38dd89efc6a8470f618 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <gtk/gtkvbox.h>
 #include "ev-document.h"
+#include "ev-link.h"
 #include "ev-utils.h"
 
 G_BEGIN_DECLS
index 12d5c8a383b3c321d017b8f2c3510a252ff225f3..feed78a919b49d0010986b73deea9ad289d10fef 100644 (file)
@@ -142,9 +142,11 @@ struct _EvView {
        /* Image DND */
        ImageDNDInfo image_dnd_info;
 
+#if !GTK_CHECK_VERSION (2, 11, 7)
        /* Links */
        GtkWidget *link_tooltip;
        EvLink *hovered_link;
+#endif
 
        /* Goto Popup */
        GtkWidget *goto_window;
index 1f9e82443244757d49c79768872be25be0f3875a..577aefc4d1a155a8dd970a5c77e181b265743556 100644 (file)
@@ -42,7 +42,9 @@
 #include "ev-job-queue.h"
 #include "ev-page-cache.h"
 #include "ev-pixbuf-cache.h"
+#if !GTK_CHECK_VERSION (2, 11, 7)
 #include "ev-tooltip.h"
+#endif
 #include "ev-application.h"
 
 #define EV_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_VIEW, EvViewClass))
@@ -1497,7 +1499,8 @@ ev_view_handle_cursor_over_xy (EvView *view, gint x, gint y)
                return;
        
        link = ev_view_get_link_at_location (view, x, y);
-
+       
+#if !GTK_CHECK_VERSION (2, 11, 7)
        if (view->link_tooltip == NULL) {
                view->link_tooltip = ev_tooltip_new (GTK_WIDGET (view));
        }
@@ -1506,8 +1509,12 @@ ev_view_handle_cursor_over_xy (EvView *view, gint x, gint y)
                view->hovered_link = link;
                ev_tooltip_deactivate (EV_TOOLTIP (view->link_tooltip));
        }
+#endif
 
         if (link) {
+#if GTK_CHECK_VERSION (2, 11, 7)
+               g_object_set (view, "has-tooltip", TRUE, NULL);
+#else
                char *msg = tip_from_link (view, link);
 
                if (msg && g_utf8_validate (msg, -1, NULL)) {
@@ -1518,7 +1525,7 @@ ev_view_handle_cursor_over_xy (EvView *view, gint x, gint y)
                        ev_tooltip_activate (tooltip);
                }
                g_free (msg);
-
+#endif
                ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK);
        } else if ((field = ev_view_get_form_field_at_location (view, x, y))) {
                if (field->is_read_only) {
@@ -2527,6 +2534,60 @@ ev_view_popup_menu (GtkWidget *widget)
        return ev_view_do_popup_menu (EV_VIEW (widget), x, y);
 }
 
+#if GTK_CHECK_VERSION (2, 11, 7)
+static void
+get_link_area (EvView       *view,
+              gint          x,
+              gint          y,
+              EvLink       *link,
+              GdkRectangle *area)
+{
+       EvRectangle  ev_rect;
+       GList       *link_mapping;
+       gint         page;
+       gint         x_offset = 0, y_offset = 0;
+
+       x += view->scroll_x;
+       y += view->scroll_y;
+       
+       find_page_at_location (view, x, y, &page, &x_offset, &y_offset);
+       
+       link_mapping = ev_pixbuf_cache_get_link_mapping (view->pixbuf_cache, page);
+       ev_link_mapping_get_area (link_mapping, link, &ev_rect);
+
+       doc_rect_to_view_rect (view, page, &ev_rect, area);
+       area->y -= view->scroll_y ;
+}
+
+static gboolean
+ev_view_query_tooltip (GtkWidget         *widget,
+                      gint               x,
+                      gint               y,
+                      gboolean           keyboard_tip,
+                      GtkTooltip        *tooltip)
+{
+       EvView *view = EV_VIEW (widget);
+       EvLink *link;
+       gchar  *text;
+
+       link = ev_view_get_link_at_location (view, x, y);
+       if (!link)
+               return FALSE;
+
+       text = tip_from_link (view, link);
+       if (text && g_utf8_validate (text, -1, NULL)) {
+               GdkRectangle link_area;
+
+               get_link_area (view, x, y, link, &link_area);
+               gtk_tooltip_set_text (tooltip, text);
+               gtk_tooltip_set_tip_area (tooltip, &link_area);
+       }
+       g_free (text);
+
+       return TRUE;
+}
+#endif /* GTK_CHECK_VERSION (2, 11, 7) */
+
 static gboolean
 ev_view_button_press_event (GtkWidget      *widget,
                            GdkEventButton *event)
@@ -3260,11 +3321,13 @@ ev_view_leave_notify_event (GtkWidget *widget, GdkEventCrossing   *event)
            view->cursor == EV_VIEW_CURSOR_IBEAM)
                ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL);
 
+#if !GTK_CHECK_VERSION (2, 11, 7)
        if (view->link_tooltip) {
                view->hovered_link = NULL;
                ev_tooltip_deactivate (EV_TOOLTIP (view->link_tooltip));
        }
-
+#endif
+       
        return FALSE;
 }
 
@@ -3595,11 +3658,12 @@ ev_view_destroy (GtkObject *object)
                view->pixbuf_cache = NULL;
        }
 
+#if !GTK_CHECK_VERSION (2, 11, 7)
        if (view->link_tooltip) {
                gtk_widget_destroy (view->link_tooltip);
                view->link_tooltip = NULL;
        }
-
+#endif
        if (view->goto_window) {
                gtk_widget_destroy (view->goto_window);
                view->goto_window = NULL;
@@ -3768,6 +3832,9 @@ ev_view_class_init (EvViewClass *class)
        widget_class->drag_motion = ev_view_drag_motion;
        widget_class->drag_data_received = ev_view_drag_data_received;
        widget_class->popup_menu = ev_view_popup_menu;
+#if GTK_CHECK_VERSION (2, 11, 7)
+       widget_class->query_tooltip = ev_view_query_tooltip;
+#endif
 
        gtk_object_class->destroy = ev_view_destroy;