[evince] ev-view: Create an EvAnnotationWindow for EvAnnotationMarkups allowing this



commit 74161bcb383d6d20e0b621bde8f12a1372f5b7d9
Author: Philipp Reinkemeier <philipp reinkemeier offis de>
Date:   Wed Mar 18 19:27:11 2015 +0100

    ev-view: Create an EvAnnotationWindow for EvAnnotationMarkups allowing this
    
    Depending on the property can-have-popup of EvAnnotationMarkup,
    EvView will dynamically create an EvAnnotationWindow with some
    default dimension and location, if no EvAnnotationWindow existed
    when creating the EvAnnotationMarkup from the backend.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733603

 libview/ev-view.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 3fc4584..6b6ed52 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -108,6 +108,9 @@ typedef struct {
 #define EV_STYLE_CLASS_DOCUMENT_PAGE "document-page"
 #define EV_STYLE_CLASS_INVERTED      "inverted"
 
+#define ANNOT_POPUP_WINDOW_DEFAULT_WIDTH  200
+#define ANNOT_POPUP_WINDOW_DEFAULT_HEIGHT 150
+
 /*** Scrolling ***/
 static void       view_update_range_and_current_page         (EvView             *view);
 static void       ensure_rectangle_is_visible                (EvView             *view,
@@ -3137,6 +3140,29 @@ ev_view_handle_annotation (EvView       *view,
                GtkWidget *window;
 
                window = g_object_get_data (G_OBJECT (annot), "popup");
+               if (!window && ev_annotation_markup_can_have_popup (EV_ANNOTATION_MARKUP (annot))) {
+                       EvRectangle    popup_rect;
+                       GtkWindow     *parent;
+                       EvMappingList *annots;
+                       EvMapping     *mapping;
+
+                       annots = ev_page_cache_get_annot_mapping (view->page_cache,
+                                                                 ev_annotation_get_page_index (annot));
+                       mapping = ev_mapping_list_find (annots, annot);
+
+                       popup_rect.x1 = mapping->area.x2;
+                       popup_rect.y1 = mapping->area.y2;
+                       popup_rect.x2 = popup_rect.x1 + ANNOT_POPUP_WINDOW_DEFAULT_WIDTH;
+                       popup_rect.y2 = popup_rect.y1 + ANNOT_POPUP_WINDOW_DEFAULT_HEIGHT;
+                       g_object_set (annot,
+                                     "rectangle", &popup_rect,
+                                     "has_popup", TRUE,
+                                     "popup_is_open", TRUE,
+                                     NULL);
+
+                       parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)));
+                       window = ev_view_create_annotation_window (view, annot, parent);
+               }
                ev_view_annotation_show_popup_window (view, window);
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]