Debian Codegraph @

src/af/xap/gtk/xap_UnixClipboard.h

raw
1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2
3 /* AbiSource Application Framework
4 * Copyright (C) 1998 AbiSource, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA.
20 */
21
22 #ifndef XAP_UNIXCLIPBOARD_H
23 #define XAP_UNIXCLIPBOARD_H
24
25 #include <glib.h>
26 #include <gdk/gdk.h>
27 #include <gtk/gtk.h>
28
29 #include "ut_types.h"
30 #include "ut_vector.h"
31 #include "ut_bytebuf.h"
32 #include "xap_FakeClipboard.h"
33 #include "xap_UnixApp.h"
34 #include "xap_EditMethods.h"
35 #include "ev_EditMethod.h"
36
37 //////////////////////////////////////////////////////////////////
38
39 class XAP_UnixClipboard
40 {
41 public:
42 typedef enum _T_AllowGet { TAG_ClipboardOnly, TAG_PrimaryOnly } T_AllowGet;
43
44 XAP_UnixClipboard(XAP_UnixApp * pUnixApp);
45 virtual ~XAP_UnixClipboard();
46
47 void initialize();
48 bool assertSelection();
49
50 bool addData(T_AllowGet tTo, const char* format, const void* pData,
51 UT_sint32 iNumBytes);
52
53 void clearData(bool bClipboard, bool bPrimary);
54 void finishedAddingData(void);
55 bool getData(T_AllowGet tFrom, const char** formatList,
56 void ** ppData, UT_uint32 * pLen,
57 const char **pszFormatFound);
58
59 bool getTextData(T_AllowGet tFrom, void ** ppData,
60 UT_uint32 * pLen);
61
62 bool canPaste(T_AllowGet tFrom);
63
64 GtkTargetEntry * getTargets () const { return m_Targets ; }
65 UT_uint32 getNumTargets () const { return m_nTargets; }
66
67 protected:
68
69 void AddFmt(const char * fmt);
70 void deleteFmt(const char * fmt);
71
72 private:
73
74 GtkClipboard * gtkClipboardForTarget(XAP_UnixClipboard::_T_AllowGet get);
75
76 bool _getDataFromServer(T_AllowGet tFrom, const char** formatList,
77 void ** ppData, UT_uint32 * pLen,
78 const char **pszFormatFound);
79 bool _getDataFromFakeClipboard(T_AllowGet tFrom, const char** formatList,
80 void ** ppData, UT_uint32 * pLen,
81 const char **pszFormatFound);
82
83 static inline void s_primary_get_func(GtkClipboard *clipboard,
84 GtkSelectionData *selection_data,
85 guint info,
86 gpointer ptr)
87 {
88 XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
89 pThis->primary_get_func(clipboard, selection_data, info);
90 }
91
92 static inline void s_primary_clear_func (GtkClipboard *clipboard,
93 gpointer ptr)
94 {
95 XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
96 pThis->primary_clear_func(clipboard);
97 }
98
99 void primary_get_func(GtkClipboard *clipboard,
100 GtkSelectionData *selection_data,
101 guint info);
102
103 void primary_clear_func (GtkClipboard *clipboard);
104
105 static inline void s_clipboard_get_func(GtkClipboard *clipboard,
106 GtkSelectionData *selection_data,
107 guint info,
108 gpointer ptr)
109 {
110 XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
111 pThis->clipboard_get_func(clipboard, selection_data, info);
112 }
113
114 static inline void s_clipboard_clear_func (GtkClipboard *clipboard,
115 gpointer ptr)
116 {
117 XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
118 pThis->clipboard_clear_func(clipboard);
119 }
120
121 void clipboard_get_func(GtkClipboard *clipboard,
122 GtkSelectionData *selection_data,
123 guint info);
124
125 void clipboard_clear_func (GtkClipboard *clipboard);
126
127 void common_get_func(GtkClipboard *clipboard,
128 GtkSelectionData *selection_data,
129 guint info, T_AllowGet which);
130
131 UT_GenericVector<const char*> m_vecFormat_AP_Name;
132 UT_GenericVector<GdkAtom> m_vecFormat_GdkAtom;
133
134 UT_ByteBuf m_databuf; // for gets only
135
136 XAP_UnixApp * m_pUnixApp;
137 XAP_FakeClipboard m_fakeClipboard; // internal clipboard to short-circut the XServer.
138
139 XAP_FakeClipboard m_fakePrimaryClipboard;
140 GtkTargetEntry * m_Targets ;
141 UT_uint32 m_nTargets;
142
143 GtkClipboard * m_clip;
144 GtkClipboard * m_primary;
145 };
146
147 #endif /* XAP_UNIXCLIPBOARD_H */