+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:
PROP_DEST,
PROP_URI,
PROP_FILENAME,
- PROP_PARAMS
+ PROP_PARAMS,
+ PROP_NAME
};
struct _EvLinkAction {
gchar *uri;
gchar *filename;
gchar *params;
+ gchar *name;
};
G_DEFINE_TYPE (EvLinkAction, ev_link_action, G_TYPE_OBJECT)
{ 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 }
};
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,
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,
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,
priv->params = NULL;
}
+ if (priv->name) {
+ g_free (priv->name);
+ priv->name = NULL;
+ }
+
G_OBJECT_CLASS (ev_link_action_parent_class)->finalize (object);
}
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
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 *
"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));
+}
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;
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,
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
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";
gboolean horizontal);
void (*zoom_invalid) (EvView *view);
void (*external_link) (EvView *view,
- EvLink *link);
+ EvLinkAction *action);
void (*popup_menu) (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;
}
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)
{
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);
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)
{
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 ();
}