atkdocument: add get_current_page_number() and get_page_count() methods
authorAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 28 Nov 2013 16:03:53 +0000 (17:03 +0100)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 28 Nov 2013 18:02:49 +0000 (19:02 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=709214

atk/atkdocument.c
atk/atkdocument.h

index f1515bb..c975132 100755 (executable)
@@ -360,3 +360,59 @@ atk_document_set_attribute_value (AtkDocument *document,
       return FALSE;
     }
 }
+
+/**
+ * atk_document_get_current_page_number:
+ * @document: the #AtkDocument
+ *
+ * Since: 2.12
+ *
+ * Returns: current page number inside @document. -1 if not
+ * implemented, not know by the implementor or irrelevant.
+ */
+gint
+atk_document_get_current_page_number (AtkDocument *document)
+{
+  AtkDocumentIface *iface;
+
+  g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
+
+  iface = ATK_DOCUMENT_GET_IFACE (document);
+
+  if (iface->get_current_page_number)
+    {
+      return (iface->get_current_page_number) (document);
+    }
+  else
+    {
+      return -1;
+    }
+}
+
+/**
+ * atk_document_get_page_count:
+ * @document: the #AtkDocument
+ *
+ * Since: 2.12
+ *
+ * Returns: total page count of @document. -1 if not implemented, not
+ * know by the implementor or irrelevant.
+ */
+gint
+atk_document_get_page_count (AtkDocument *document)
+{
+  AtkDocumentIface *iface;
+
+  g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
+
+  iface = ATK_DOCUMENT_GET_IFACE (document);
+
+  if (iface->get_page_count)
+    {
+      return (iface->get_page_count) (document);
+    }
+  else
+    {
+      return -1;
+    }
+}
index 9ad537d..bc6d458 100755 (executable)
@@ -62,6 +62,8 @@ typedef struct _AtkDocumentIface AtkDocumentIface;
  *   with the named attribute for this document, or NULL
  * @set_document_attribute: sets the value of an attribute. Returns
  *   TRUE on success, FALSE otherwise
+ * @get_current_page_number: gets the current page number. Since 2.12
+ * @get_page_count: gets the page count of the document. Since 2.12
  */
 struct _AtkDocumentIface
 {
@@ -76,6 +78,8 @@ struct _AtkDocumentIface
   gboolean              ( *set_document_attribute) (AtkDocument         *document,
                                                     const gchar         *attribute_name,
                                                     const gchar         *attribute_value);
+  gint                  ( *get_current_page_number) (AtkDocument *document);
+  gint                  ( *get_page_count) (AtkDocument *document);
 };
 
 GType  atk_document_get_type             (void);
@@ -95,6 +99,8 @@ const gchar*          atk_document_get_attribute_value (AtkDocument *document,
 gboolean              atk_document_set_attribute_value (AtkDocument *document,
                                                         const gchar *attribute_name,
                                                         const gchar *attribute_value);
+gint                  atk_document_get_current_page_number (AtkDocument *document);
+gint                  atk_document_get_page_count      (AtkDocument *document);
 
 G_END_DECLS