/src/mozilla-central/widget/gtk/nsClipboard.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* vim:expandtab:shiftwidth=4:tabstop=4: |
3 | | */ |
4 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
5 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | | |
8 | | #ifndef __nsClipboard_h_ |
9 | | #define __nsClipboard_h_ |
10 | | |
11 | | #include "nsIClipboard.h" |
12 | | #include "nsIObserver.h" |
13 | | #include "nsIBinaryOutputStream.h" |
14 | | #include <gtk/gtk.h> |
15 | | |
16 | | class nsRetrievalContext { |
17 | | public: |
18 | | // Get actual clipboard content (GetClipboardData/GetClipboardText) |
19 | | // which has to be released by ReleaseClipboardData(). |
20 | | virtual const char* GetClipboardData(const char* aMimeType, |
21 | | int32_t aWhichClipboard, |
22 | | uint32_t* aContentLength) = 0; |
23 | | virtual const char* GetClipboardText(int32_t aWhichClipboard) = 0; |
24 | | virtual void ReleaseClipboardData(const char* aClipboardData) = 0; |
25 | | |
26 | | // Get data mime types which can be obtained from clipboard. |
27 | | // The returned array has to be released by g_free(). |
28 | | virtual GdkAtom* GetTargets(int32_t aWhichClipboard, |
29 | | int* aTargetNum) = 0; |
30 | | |
31 | | virtual bool HasSelectionSupport(void) = 0; |
32 | | |
33 | 0 | virtual ~nsRetrievalContext() {}; |
34 | | }; |
35 | | |
36 | | class nsClipboard : public nsIClipboard, |
37 | | public nsIObserver |
38 | | { |
39 | | public: |
40 | | nsClipboard(); |
41 | | |
42 | | NS_DECL_ISUPPORTS |
43 | | NS_DECL_NSIOBSERVER |
44 | | NS_DECL_NSICLIPBOARD |
45 | | |
46 | | // Make sure we are initialized, called from the factory |
47 | | // constructor |
48 | | nsresult Init (void); |
49 | | |
50 | | // Someone requested the selection |
51 | | void SelectionGetEvent (GtkClipboard *aGtkClipboard, |
52 | | GtkSelectionData *aSelectionData); |
53 | | void SelectionClearEvent (GtkClipboard *aGtkClipboard); |
54 | | |
55 | | private: |
56 | | virtual ~nsClipboard(); |
57 | | |
58 | | // Save global clipboard content to gtk |
59 | | nsresult Store (void); |
60 | | |
61 | | // Get our hands on the correct transferable, given a specific |
62 | | // clipboard |
63 | | nsITransferable *GetTransferable (int32_t aWhichClipboard); |
64 | | |
65 | | // Send clipboard data by nsITransferable |
66 | | void SetTransferableData(nsITransferable* aTransferable, |
67 | | nsCString& aFlavor, |
68 | | const char* aClipboardData, |
69 | | uint32_t aClipboardDataLength); |
70 | | |
71 | | // Hang on to our owners and transferables so we can transfer data |
72 | | // when asked. |
73 | | nsCOMPtr<nsIClipboardOwner> mSelectionOwner; |
74 | | nsCOMPtr<nsIClipboardOwner> mGlobalOwner; |
75 | | nsCOMPtr<nsITransferable> mSelectionTransferable; |
76 | | nsCOMPtr<nsITransferable> mGlobalTransferable; |
77 | | nsAutoPtr<nsRetrievalContext> mContext; |
78 | | }; |
79 | | |
80 | | extern const int kClipboardTimeout; |
81 | | |
82 | | GdkAtom GetSelectionAtom(int32_t aWhichClipboard); |
83 | | |
84 | | #endif /* __nsClipboard_h_ */ |