Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EvBrowserPlugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Igalia S.L.
3  *
4  * Evince is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Evince is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef EvBrowserPlugin_h
20 #define EvBrowserPlugin_h
21 
22 #include <evince-document.h>
23 #include <evince-view.h>
24 #include "EvMemoryUtils.h"
25 #include "npapi.h"
26 #include "npruntime.h"
27 
28 typedef union _XEvent XEvent;
30 
31 class EvBrowserPlugin: public NPObject {
32 public:
33  static EvBrowserPlugin* create(NPP);
34 
35  static const char *nameString();
36  static const char *descriptionString();
37 
38  // NPP API
39  NPError initialize(NPMIMEType, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *);
41  NPError newStream(NPMIMEType, NPStream *, NPBool seekable, uint16_t *stype);
43  void streamAsFile(NPStream *, const char *fname);
44  int32_t writeReady(NPStream *);
45  int32_t write(NPStream *, int32_t offset, int32_t len, void *buffer);
46  void print(NPPrint *);
47  int16_t handleEvent(XEvent *);
48  void urlNotify(const char *url, NPReason, void *notifyData);
49 
50  // Viewer API
51  EvDocumentModel *model() const { return m_model; }
52  unsigned currentPage() const;
53  unsigned pageCount() const;
54  double zoom() const;
55  void setZoom(double scale);
56  void goToPreviousPage();
57  void goToNextPage();
58  void goToPage(unsigned page);
59  void goToPage(const char *pageLabel);
60  void activateLink(EvLink *);
61  bool isContinuous() const;
62  void setContinuous(bool);
63  void toggleContinuous();
64  bool isDual() const;
65  void setDual(bool);
66  void toggleDual();
67  void zoomIn();
68  void zoomOut();
69  EvSizingMode sizingMode() const;
71  void download() const;
72  void print() const;
73  bool toolbarVisible() const;
74  void setToolbarVisible(bool);
75 
76  bool canDownload() const;
77 
78  void setSearchModeEnabled(bool);
79  void search(EvJobFind *);
81  void search(SearchDirection);
82  void clearSearch();
83  void restartSearch();
84 
85 private:
87  virtual ~EvBrowserPlugin();
88 
89  // Scripting interface
90  static NPObject *allocate(NPP, NPClass *);
91  static void deallocate(NPObject *);
92  static void invalidate(NPObject *);
93  static bool hasMethod(NPObject *, NPIdentifier name);
94  static bool invoke(NPObject *, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result);
95  static bool hasProperty(NPObject *, NPIdentifier name);
96  static bool getProperty(NPObject *, NPIdentifier name, NPVariant *);
97  static bool setProperty(NPObject *, NPIdentifier name, const NPVariant *);
98 
100  GtkWidget *m_window;
103  GtkWidget *m_toolbar;
105 
107 };
108 
109 #endif // EvBrowserPlugin_h