]> www.fi.muni.cz Git - evince.git/commitdiff
Add support for Named Action links
authorCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 4 May 2006 08:24:19 +0000 (08:24 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Thu, 4 May 2006 08:24:19 +0000 (08:24 +0000)
2006-05-03  Carlos Garcia Campos  <carlosgc@gnome.org>
* backend/ev-link-action.[ch]:
* pdf/ev-poppler.cc: (ev_link_from_action):
* shell/ev-view-private.h:
* shell/ev-view.c: (ev_view_handle_link), (tip_from_action_named):
* shell/ev-window.c: (do_action_named), (view_external_link_cb):
Add support for Named Action links

ChangeLog
backend/ev-link-action.c
backend/ev-link-action.h
pdf/ev-poppler.cc
shell/ev-view-private.h
shell/ev-view.c
shell/ev-window.c

index b583775a9654ce31240963c1eee0ba0e71a94eba..0c60baae61fc613e9872493fe77a50934c947e75 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-05-03  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * backend/ev-link-action.[ch]:
+       * pdf/ev-poppler.cc: (ev_link_from_action):
+       * shell/ev-view-private.h:
+       * shell/ev-view.c: (ev_view_handle_link), (tip_from_action_named):
+       * shell/ev-window.c: (do_action_named), (view_external_link_cb):
+
+       Add support for Named Action links
+
 2006-05-02  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * backend/Makefile.am:
index 23f41943f87fa7fdf1a7325f79126fba2961a41a..bc0a8fc14ddbf53a7b0b4d8df0434b6a05034204 100644 (file)
@@ -26,7 +26,8 @@ enum {
        PROP_DEST,
        PROP_URI,
        PROP_FILENAME,
-       PROP_PARAMS
+       PROP_PARAMS,
+       PROP_NAME
 };
 
 struct _EvLinkAction {
@@ -45,6 +46,7 @@ struct _EvLinkActionPrivate {
        gchar            *uri;
        gchar            *filename;
        gchar            *params;
+       gchar            *name;
 };
 
 G_DEFINE_TYPE (EvLinkAction, ev_link_action, G_TYPE_OBJECT)
@@ -63,6 +65,7 @@ ev_link_action_type_get_type (void)
                        { EV_LINK_ACTION_TYPE_GOTO_REMOTE, "EV_LINK_ACTION_TYPE_GOTO_REMOTE", "goto-remote" },
                        { EV_LINK_ACTION_TYPE_LAUNCH, "EV_LINK_ACTION_TYPE_LAUNCH", "launch" },
                        { EV_LINK_ACTION_TYPE_EXTERNAL_URI, "EV_LINK_ACTION_TYPE_EXTERNAL_URI", "external-uri"},
+                       { EV_LINK_ACTION_TYPE_NAMED, "EV_LINK_ACTION_TYPE_NAMED", "named"},
                        { 0, NULL, NULL }
                };
 
@@ -112,6 +115,14 @@ ev_link_action_get_params (EvLinkAction *self)
        return self->priv->params;
 }
 
+const gchar *
+ev_link_action_get_name (EvLinkAction *self)
+{
+       g_return_val_if_fail (EV_IS_LINK_ACTION (self), NULL);
+
+       return self->priv->name;
+}
+
 static void
 ev_link_action_get_property (GObject    *object,
                             guint       prop_id,
@@ -138,6 +149,9 @@ ev_link_action_get_property (GObject    *object,
                case PROP_PARAMS:
                        g_value_set_string (value, self->priv->params);
                        break;
+               case PROP_NAME:
+                       g_value_set_string (value, self->priv->name);
+                       break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
                                                           prop_id,
@@ -173,6 +187,10 @@ ev_link_action_set_property (GObject      *object,
                        g_free (self->priv->params);
                        self->priv->params = g_value_dup_string (value);
                        break;
+               case PROP_NAME:
+                       g_free (self->priv->name);
+                       self->priv->name = g_value_dup_string (value);
+                       break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
                                                           prop_id,
@@ -208,6 +226,11 @@ ev_link_action_finalize (GObject *object)
                priv->params = NULL;
        }
 
+       if (priv->name) {
+               g_free (priv->name);
+               priv->name = NULL;
+       }
+
        G_OBJECT_CLASS (ev_link_action_parent_class)->finalize (object);
 }
 
@@ -220,6 +243,7 @@ ev_link_action_init (EvLinkAction *ev_link_action)
        ev_link_action->priv->uri = NULL;
        ev_link_action->priv->filename = NULL;
        ev_link_action->priv->params = NULL;
+       ev_link_action->priv->name = NULL;
 }
 
 static void
@@ -276,6 +300,14 @@ ev_link_action_class_init (EvLinkActionClass *ev_link_action_class)
                                                              NULL,
                                                              G_PARAM_READWRITE |
                                                              G_PARAM_CONSTRUCT_ONLY));
+       g_object_class_install_property (g_object_class,
+                                        PROP_NAME,
+                                        g_param_spec_string ("name",
+                                                             "Name",
+                                                             "The link action name",
+                                                             NULL,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_CONSTRUCT_ONLY));
 }
 
 EvLinkAction *
@@ -317,3 +349,12 @@ ev_link_action_new_launch (const gchar *filename,
                                             "type", EV_LINK_ACTION_TYPE_LAUNCH,
                                             NULL));
 }
+
+EvLinkAction *
+ev_link_action_new_named (const gchar *name)
+{
+       return EV_LINK_ACTION (g_object_new (EV_TYPE_LINK_ACTION,
+                                            "name", name,
+                                            "type", EV_LINK_ACTION_TYPE_NAMED,
+                                            NULL));
+}
index 6ca8d572dd2935913906c828d282c9c8f67cc9e0..32211fe21bf494c1ea19cd8e2432e61f30ddd4dc 100644 (file)
@@ -44,6 +44,7 @@ typedef enum {
        EV_LINK_ACTION_TYPE_GOTO_REMOTE,
        EV_LINK_ACTION_TYPE_EXTERNAL_URI,
        EV_LINK_ACTION_TYPE_LAUNCH,
+       EV_LINK_ACTION_TYPE_NAMED
        /* We'll probably fill this in more as we support the other types of
         * actions */
 } EvLinkActionType;
@@ -56,6 +57,7 @@ EvLinkDest      *ev_link_action_get_dest         (EvLinkAction *self);
 const gchar     *ev_link_action_get_uri          (EvLinkAction *self);
 const gchar     *ev_link_action_get_filename     (EvLinkAction *self);
 const gchar     *ev_link_action_get_params       (EvLinkAction *self);
+const gchar     *ev_link_action_get_name         (EvLinkAction *self);
 
 EvLinkAction    *ev_link_action_new_dest         (EvLinkDest   *dest);
 EvLinkAction    *ev_link_action_new_remote       (EvLinkDest   *dest,
@@ -63,6 +65,7 @@ EvLinkAction    *ev_link_action_new_remote       (EvLinkDest   *dest,
 EvLinkAction    *ev_link_action_new_external_uri (const gchar  *uri);
 EvLinkAction    *ev_link_action_new_launch       (const gchar  *filename,
                                                  const gchar  *params);
+EvLinkAction    *ev_link_action_new_named        (const gchar  *name);
 
 G_END_DECLS
 
index efdd15f28aef4cb6762f429bfb2bd20b312304fc..5c2f54d6ed6e7937cdd7fd81e5f29c148641b5a8 100644 (file)
@@ -873,7 +873,7 @@ ev_link_from_action (PopplerAction *action)
                        ev_action = ev_link_action_new_external_uri (action->uri.uri);
                        break;
                case POPPLER_ACTION_NAMED:
-                       unimplemented_action = "POPPLER_ACTION_NAMED";
+                       ev_action = ev_link_action_new_named (action->named.named_dest);
                        break;
                case POPPLER_ACTION_MOVIE:
                        unimplemented_action = "POPPLER_ACTION_MOVIE";
index 1d09cb372f00d977509689363775c37082e12b84..a53fe5469e81f025a66f7d40e5a204a92f2c7adc 100644 (file)
@@ -129,7 +129,7 @@ struct _EvViewClass {
                                           gboolean        horizontal);
        void    (*zoom_invalid)           (EvView         *view);
        void    (*external_link)          (EvView         *view,
-                                          EvLink         *link);
+                                          EvLinkAction   *action);
        void    (*popup_menu)             (EvView         *view,
                                           EvLink         *link);
 };
index 0380e226f4aab36719cfc1d41730fd5bec2f6ef6..e3f07dc9e91fc1f67883d9ea01fca742a99f03b6 100644 (file)
@@ -1289,6 +1289,7 @@ ev_view_handle_link (EvView *view, EvLink *link)
                case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
                case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
                case EV_LINK_ACTION_TYPE_LAUNCH:
+               case EV_LINK_ACTION_TYPE_NAMED:
                        g_signal_emit (view, signals[SIGNAL_EXTERNAL_LINK], 0, action);
                        break;
        }
@@ -1326,6 +1327,28 @@ page_label_from_dest (EvView *view, EvLinkDest *dest)
        return msg;
 }
 
+static char *
+tip_from_action_named (EvLinkAction *action)
+{
+       const gchar *name = ev_link_action_get_name (action);
+       
+       if (g_ascii_strcasecmp (name, "FirstPage") == 0) {
+               return g_strdup (_("Got to fisrt page"));
+       } else if (g_ascii_strcasecmp (name, "PrevPage") == 0) {
+               return g_strdup (_("Got to previuos page"));
+       } else if (g_ascii_strcasecmp (name, "NextPage") == 0) {
+               return g_strdup (_("Got to next page"));
+       } else if (g_ascii_strcasecmp (name, "LastPage") == 0) {
+               return g_strdup (_("Got to last page"));
+       } else if (g_ascii_strcasecmp (name, "GoToPage") == 0) {
+               return g_strdup (_("Got to page"));
+       } else if (g_ascii_strcasecmp (name, "Find") == 0) {
+               return g_strdup (_("Find"));
+       }
+       
+       return NULL;
+}
+
 static char *
 tip_from_link (EvView *view, EvLink *link)
 {
@@ -1367,6 +1390,9 @@ tip_from_link (EvView *view, EvLink *link)
                        msg = g_strdup_printf (_("Launch %s"),
                                               ev_link_action_get_filename (action));
                        break;
+               case EV_LINK_ACTION_TYPE_NAMED:
+                       msg = tip_from_action_named (action);
+                       break;
                default:
                        if (title)
                                msg = g_strdup (title);
index 2fad47bfadc6ce092611f377ba5d7789924ece91..c04801a4f34c1027385c22fc7abe9e2204c3c15b 100644 (file)
@@ -3319,6 +3319,29 @@ open_remote_link (EvWindow *window, EvLinkAction *action)
        g_free (uri);
 }
 
+static void
+do_action_named (EvWindow *window, EvLinkAction *action)
+{
+       const gchar *name = ev_link_action_get_name (action);
+
+       if (g_ascii_strcasecmp (name, "FirstPage") == 0) {
+               ev_window_cmd_go_first_page (NULL, window);
+       } else if (g_ascii_strcasecmp (name, "PrevPage") == 0) {
+               ev_window_cmd_go_previous_page (NULL, window);
+       } else if (g_ascii_strcasecmp (name, "NextPage") == 0) {
+               ev_window_cmd_go_next_page (NULL, window);
+       } else if (g_ascii_strcasecmp (name, "LastPage") == 0) {
+               ev_window_cmd_go_last_page (NULL, window);
+       } else if (g_ascii_strcasecmp (name, "GoToPage") == 0) {
+               ev_window_cmd_focus_page_selector (NULL, window);
+       } else if (g_ascii_strcasecmp (name, "Find") == 0) {
+               ev_window_cmd_edit_find (NULL, window);
+       } else {
+               g_warning ("Unimplemented named action: %s, please post a bug report with a testcase.",
+                          name);
+       }
+}
+
 static void
 view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
 {
@@ -3332,6 +3355,9 @@ view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
                case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
                        open_remote_link (window, action);
                        break;
+               case EV_LINK_ACTION_TYPE_NAMED:
+                       do_action_named (window, action);
+                       break;
                default:
                        g_assert_not_reached ();
        }