]> www.fi.muni.cz Git - evince.git/commitdiff
Update NEWS and require poppler 0.5.0.
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>
Sun, 25 Dec 2005 20:08:35 +0000 (20:08 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sun, 25 Dec 2005 20:08:35 +0000 (20:08 +0000)
2005-12-25  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>

* NEWS:
* configure.ac:

Update NEWS and require poppler 0.5.0.

2005-12-25  Carlos Garcia Campos  <carlosgc@gnome.org>

* data/evince-ui.xml:
* shell/ev-view-private.h:
* shell/ev-view.c: (ev_view_get_link_at_location),
(handle_link_over_xy), (ev_view_button_press_event),
(ev_view_button_release_event), (ev_view_class_init):
* shell/ev-window.c: (view_menu_popup_cb), (ev_window_dispose),
(ev_popup_cmd_open_link), (ev_popup_cmd_copy_link_address),
(ev_window_init):

Implement right-click context menu.

ChangeLog
NEWS
configure.ac
data/evince-ui.xml
shell/ev-view-private.h
shell/ev-view.c
shell/ev-window.c

index 91448fb093da5a1d1868f8b5e99e46f695c1ef5a..e2a5dc5d1ce58a0ba2347dd9228b74c68dea563b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2005-12-25  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * NEWS:
+       * configure.ac:
+       
+       Update NEWS and require poppler 0.5.0.
+
+2005-12-25  Carlos Garcia Campos  <carlosgc@gnome.org>
+       
+       * data/evince-ui.xml:
+       * shell/ev-view-private.h:
+       * shell/ev-view.c: (ev_view_get_link_at_location),
+       (handle_link_over_xy), (ev_view_button_press_event),
+       (ev_view_button_release_event), (ev_view_class_init):
+       * shell/ev-window.c: (view_menu_popup_cb), (ev_window_dispose),
+       (ev_popup_cmd_open_link), (ev_popup_cmd_copy_link_address),
+       (ev_window_init):
+       
+       Implement right-click context menu.
+
 2005-12-25  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * djvu/djvu-document.c: (djvu_document_thumbnails_get_thumbnail):
diff --git a/NEWS b/NEWS
index 382b82b916ed14065a9e19ec14a3871b5f7ab5e2..6186419441721a5e64d7226b67493d09ba162252 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ Interface Improvements:
     * Improved intelligent window title that shouldn't confuse users
     * Show index by default if available
     * Tooltips for links
+    * Now we have right click context menu
 
 Bug Fixes:
 
index bb8ec0552b1bf7721c7e756cadeb73722f130e43..f241f9ab8c3cfb9400ee075e008a323f0a24b4e4 100644 (file)
@@ -43,7 +43,7 @@ dnl Check dependencies
 # SHELL_CFLAGS     for shell implementation.
 # SHELL_LIBS
 
-POPPLER_REQUIRED=0.4.1
+POPPLER_REQUIRED=0.5.0
 DBUS_GLIB_REQUIRED=0.33
 GTK_REQUIRED=2.6.0
 LIBGNOMEUI_REQUIRED=2.6.0
index 122bf262b7e805f4a2d7a8b42d7d599c6f0c7549..ae293678360f1fe778ce4f1354f8cf81e66daeaf 100644 (file)
     </menu>
   </menubar>
 
+  <popup name="DocumentPopup" action="PopupAction">
+    <menuitem name="GoPreviousPage" action="GoPreviousPage"/>
+    <menuitem name="GoNextPage" action="GoNextPage"/>
+    <menuitem name="ViewReload" action="ViewReload"/>
+    <separator/>
+    <menuitem name="EditCopy" action="EditCopy"/>
+    <menuitem name="EditSelectAllPopup" action="EditSelectAll"/>
+  </popup>
+
+  <popup name="ExternalLinkPopup" action="PopupAction">
+    <menuitem name="OpenLink" action="OpenLink"/>
+    <menuitem name="CopyLinkAddress" action="CopyLinkAddress"/>
+  </popup>
+
   <accelerator name="PageDownAccel" action="PageDown"/>
   <accelerator name="PageUpAccel" action="PageUp"/>
   <accelerator name="GoBackwardFastAccel" action="GoBackwardFast"/>
index 9a0c7731b64cbc6789342429754d49a54e0d7647..ef48e0be7f2ccc564e966a22dde34e213b015e84 100644 (file)
@@ -128,6 +128,8 @@ struct _EvViewClass {
        void    (*zoom_invalid)           (EvView         *view);
        void    (*external_link)          (EvView         *view,
                                           EvLink         *link);
+       void    (*popup_menu)             (EvView         *view,
+                                          EvLink         *link);
 };
 
 #endif  /* __EV_VIEW_PRIVATE_H__ */
index be6f29503b65f549ede8a0478ce11aae230c8d6c..c39a2657993a20c05f83a550e3ebba7ef6704aca 100644 (file)
@@ -64,6 +64,7 @@ enum {
        SIGNAL_BINDING_ACTIVATED,
        SIGNAL_ZOOM_INVALID,
        SIGNAL_EXTERNAL_LINK,
+       SIGNAL_POPUP_MENU,
        N_SIGNALS,
 };
 
@@ -149,9 +150,9 @@ static void       find_page_at_location                      (EvView
                                                              gint               *y_offset);
 
 /*** Hyperrefs ***/
-static EvLink*    get_link_at_location                       (EvView             *view,
-                                                             gdouble             x,
-                                                             gdouble             y);
+static EvLink *   ev_view_get_link_at_location                      (EvView  *view,
+                                                             gdouble  x,
+                                                             gdouble  y);
 static char*      tip_from_link                              (EvView             *view,
                                                              EvLink             *link);
 static void       handle_link_over_xy                        (EvView *view, 
@@ -1031,13 +1032,16 @@ location_in_selected_text (EvView  *view,
 
 /*** Hyperref ***/
 static EvLink *
-get_link_at_location (EvView  *view,
-                     gdouble  x,
-                     gdouble  y)
+ev_view_get_link_at_location (EvView  *view,
+                             gdouble  x,
+                             gdouble  y)
 {
        gint page = -1;
        gint x_offset = 0, y_offset = 0;
        GList *link_mapping;
+       
+       x += view->scroll_x;
+       y += view->scroll_y;
 
        find_page_at_location (view, x, y, &page, &x_offset, &y_offset);
 
@@ -1254,7 +1258,7 @@ handle_link_over_xy (EvView *view, gint x, gint y)
 {
        EvLink *link;
 
-       link = get_link_at_location (view, x + view->scroll_x, y + view->scroll_y);
+       link = ev_view_get_link_at_location (view, x, y);
 
        if (view->link_tooltip == NULL) {
                view->link_tooltip = ev_tooltip_new (GTK_WIDGET (view));
@@ -1617,6 +1621,7 @@ ev_view_button_press_event (GtkWidget      *widget,
                            GdkEventButton *event)
 {
        EvView *view = EV_VIEW (widget);
+       EvLink *link;
        
        if (!GTK_WIDGET_HAS_FOCUS (widget)) {
                gtk_widget_grab_focus (widget);
@@ -1653,6 +1658,10 @@ ev_view_button_press_event (GtkWidget      *widget,
 
                        ev_view_set_cursor (view, EV_VIEW_CURSOR_DRAG);
 
+                       return TRUE;
+               case 3:
+                       link = ev_view_get_link_at_location (view, event->x, event->y);
+                       g_signal_emit (view, signals[SIGNAL_POPUP_MENU], 0, link);
                        return TRUE;
        }
        
@@ -1835,8 +1844,7 @@ ev_view_button_release_event (GtkWidget      *widget,
        }
 
        if (view->document) {
-               link = get_link_at_location (view, event->x + view->scroll_x,
-                                            event->y + view->scroll_y);
+               link = ev_view_get_link_at_location (view, event->x, event->y);
        } else {
                link = NULL;
        }
@@ -2399,6 +2407,14 @@ ev_view_class_init (EvViewClass *class)
                         g_cclosure_marshal_VOID__OBJECT,
                         G_TYPE_NONE, 1,
                         G_TYPE_OBJECT);
+       signals[SIGNAL_POPUP_MENU] = g_signal_new ("popup",
+                        G_TYPE_FROM_CLASS (object_class),
+                        G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                        G_STRUCT_OFFSET (EvViewClass, popup_menu),
+                        NULL, NULL,
+                        g_cclosure_marshal_VOID__OBJECT,
+                        G_TYPE_NONE, 1,
+                        G_TYPE_OBJECT);
 
        g_object_class_install_property (object_class,
                                         PROP_STATUS,
index 77bb4c91f29c3f08ee528c1ea3ed71cc37c43ef3..fde1dae9c440d65607cbf500cc27711df794827d 100644 (file)
@@ -114,12 +114,18 @@ struct _EvWindowPrivate {
 
        /* UI Builders */
        GtkActionGroup *action_group;
+       GtkActionGroup *popups_action_group;
        GtkUIManager *ui_manager;
 
        /* Fullscreen mode */
        GtkWidget *fullscreen_toolbar;
        GtkWidget *fullscreen_popup;
        GSource   *fullscreen_timeout_source;
+       
+       /* Popup link */
+       GtkWidget *popup;
+       GtkWidget *link_popup;
+       EvLink    *link;
 
        /* Document */
        char *uri;
@@ -191,6 +197,10 @@ static void     ev_window_stop_presentation             (EvWindow         *windo
 static void     ev_window_cmd_view_presentation         (GtkAction        *action,
                                                         EvWindow         *window);
 static void     show_fullscreen_popup                   (EvWindow         *window);
+static void     ev_popup_cmd_open_link                  (GtkAction        *action,
+                                                        EvWindow         *window);
+static void     ev_popup_cmd_copy_link_address          (GtkAction        *action,
+                                                        EvWindow         *window);
 
 
 G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
@@ -2607,6 +2617,30 @@ ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspe
        }
 }
 
+static gboolean
+view_menu_popup_cb (EvView         *view,
+                   EvLink         *link,
+                   EvWindow       *ev_window)
+{
+       GtkWidget *popup;
+       
+       if (ev_window->priv->link)
+               g_object_unref (ev_window->priv->link);
+       ev_window->priv->link = link;
+
+       if (ev_window->priv->link &&
+                (ev_link_get_link_type (ev_window->priv->link) == EV_LINK_TYPE_EXTERNAL_URI)) {
+               popup = ev_window->priv->link_popup;
+       } else {
+               popup = ev_window->priv->popup;
+       }
+
+       gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
+                       NULL, NULL,
+                       3, gtk_get_current_event_time ());
+       return TRUE;
+}
+
 static void
 view_find_status_changed_cb (EvView     *view,
                             GParamSpec *pspec,
@@ -2751,6 +2785,11 @@ ev_window_dispose (GObject *object)
                priv->action_group = NULL;
        }
 
+       if (priv->popups_action_group) {
+               g_object_unref (priv->popups_action_group);
+               priv->popups_action_group = NULL;
+       }
+
        if (priv->page_cache) {
                g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
                priv->page_cache = NULL;
@@ -2793,6 +2832,11 @@ ev_window_dispose (GObject *object)
                gtk_widget_destroy (priv->password_dialog);
        }
 
+       if (priv->link) {
+               g_object_unref (priv->link);
+               priv->link = NULL;
+       }
+
        if (priv->find_bar) {
                g_signal_handlers_disconnect_by_func
                        (window->priv->find_bar,
@@ -2983,6 +3027,16 @@ static const GtkToggleActionEntry toggle_entries[] = {
           G_CALLBACK (ev_window_cmd_view_page_width) },
 };
 
+/* Popups specific items */
+static const GtkActionEntry popups_entries [] = {
+       /* Links */
+       { "OpenLink", GTK_STOCK_OPEN, N_("_Open Link"), NULL,
+         NULL, G_CALLBACK (ev_popup_cmd_open_link) },
+       { "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
+         NULL,
+         G_CALLBACK (ev_popup_cmd_copy_link_address) },
+};
+
 static void
 drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
                       gint x, gint y, GtkSelectionData *selection_data,
@@ -3300,6 +3354,25 @@ view_external_link_cb (EvView *view, EvLink *link, EvWindow *window)
        }
 }
 
+static void
+ev_popup_cmd_open_link (GtkAction *action, EvWindow *window)
+{
+       launch_external_uri (window, window->priv->link);
+}
+
+static void
+ev_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
+{
+       GtkClipboard *clipboard;
+       const gchar *uri;
+
+       uri = ev_link_get_uri (window->priv->link);
+
+       clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
+                                             GDK_SELECTION_CLIPBOARD);
+       gtk_clipboard_set_text (clipboard, uri, -1);
+}
+
 static void
 ev_window_init (EvWindow *ev_window)
 {
@@ -3343,6 +3416,14 @@ ev_window_init (EvWindow *ev_window)
 
        ev_window_set_view_accels_sensitivity (ev_window, FALSE);
 
+       action_group = gtk_action_group_new ("PopupsActions");
+       ev_window->priv->popups_action_group = action_group;
+       gtk_action_group_set_translation_domain (action_group, NULL);
+       gtk_action_group_add_actions (action_group, popups_entries,
+                                     G_N_ELEMENTS (popups_entries), ev_window);
+       gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
+                                           action_group, 0);
+
        if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
                                              DATADIR"/evince-ui.xml",
                                              &error)) {
@@ -3443,6 +3524,10 @@ ev_window_init (EvWindow *ev_window)
        g_signal_connect_object (ev_window->priv->view, "external-link",
                                 G_CALLBACK (view_external_link_cb),
                                 ev_window, 0);
+       g_signal_connect_object (ev_window->priv->view,
+                                "popup",
+                                G_CALLBACK (view_menu_popup_cb),
+                                ev_window, 0);
        gtk_widget_show (ev_window->priv->view);
        gtk_widget_show (ev_window->priv->password_view);
 
@@ -3524,6 +3609,13 @@ ev_window_init (EvWindow *ev_window)
                          G_CALLBACK (find_bar_search_changed_cb),
                          ev_window);
 
+       /* Popups */
+       ev_window->priv->link_popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+                                                               "/ExternalLinkPopup");
+       ev_window->priv->popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+                                                          "/DocumentPopup");
+       ev_window->priv->link = NULL;
+
        /* Give focus to the document view */
        gtk_widget_grab_focus (ev_window->priv->view);