summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-03-05 19:47:42 +0100
committerraveit65 <[email protected]>2017-03-07 13:34:19 +0100
commit5db08321cfc0edfc2bf374c753a83707f2d7e129 (patch)
tree745961d2ef399cb65228cb44483f045726c2fcb1
parente38b3acf50a127bbe50e8a53e405f0f13740e230 (diff)
downloadatril-5db08321cfc0edfc2bf374c753a83707f2d7e129.tar.bz2
atril-5db08321cfc0edfc2bf374c753a83707f2d7e129.tar.xz
libview: Make EvLinkAccessible implement AtkAction
taken from: https://git.gnome.org/browse/evince/commit/?h=gnome-3-8&id=0291193
-rw-r--r--libview/ev-link-accessible.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/libview/ev-link-accessible.c b/libview/ev-link-accessible.c
index 9e2de642..029fb2df 100644
--- a/libview/ev-link-accessible.c
+++ b/libview/ev-link-accessible.c
@@ -192,9 +192,11 @@ ev_hyperlink_init (EvHyperlink *link)
}
static void ev_link_accessible_hyperlink_impl_iface_init (AtkHyperlinkImplIface *iface);
+static void ev_link_accessible_action_interface_init (AtkActionIface *iface);
G_DEFINE_TYPE_WITH_CODE (EvLinkAccessible, ev_link_accessible, ATK_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (ATK_TYPE_HYPERLINK_IMPL, ev_link_accessible_hyperlink_impl_iface_init))
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_HYPERLINK_IMPL, ev_link_accessible_hyperlink_impl_iface_init)
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, ev_link_accessible_action_interface_init))
static void
ev_link_accessible_finalize (GObject *object)
@@ -244,6 +246,56 @@ ev_link_accessible_hyperlink_impl_iface_init (AtkHyperlinkImplIface *iface)
iface->get_hyperlink = ev_link_accessible_get_hyperlink;
}
+static gboolean
+ev_link_accessible_action_do_action (AtkAction *atk_action,
+ gint i)
+{
+ EvLinkAccessiblePrivate *priv = EV_LINK_ACCESSIBLE (atk_action)->priv;
+ GtkWidget *widget;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (priv->view));
+ if (widget == NULL)
+ /* State is defunct */
+ return FALSE;
+
+ if (!ev_link_get_action (priv->link))
+ return FALSE;
+
+ ev_view_handle_link (EV_VIEW (widget), priv->link);
+
+ return TRUE;
+}
+
+static gint
+ev_link_accessible_action_get_n_actions (AtkAction *atk_action)
+{
+ return 1;
+}
+
+static const gchar *
+ev_link_accessible_action_get_description (AtkAction *atk_action,
+ gint i)
+{
+ /* TODO */
+ return NULL;
+}
+
+static const gchar *
+ev_link_accessible_action_get_name (AtkAction *atk_action,
+ gint i)
+{
+ return i == 0 ? "activate" : NULL;
+}
+
+static void
+ev_link_accessible_action_interface_init (AtkActionIface *iface)
+{
+ iface->do_action = ev_link_accessible_action_do_action;
+ iface->get_n_actions = ev_link_accessible_action_get_n_actions;
+ iface->get_description = ev_link_accessible_action_get_description;
+ iface->get_name = ev_link_accessible_action_get_name;
+}
+
EvLinkAccessible *
ev_link_accessible_new (EvViewAccessible *view,
EvLink *link,