|
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 "nsClipboardPrivacyHandler.h" |
|
13 #include "nsAutoPtr.h" |
|
14 #include <gtk/gtk.h> |
|
15 |
|
16 class nsClipboard : public nsIClipboard, |
|
17 public nsIObserver |
|
18 { |
|
19 public: |
|
20 nsClipboard(); |
|
21 virtual ~nsClipboard(); |
|
22 |
|
23 NS_DECL_ISUPPORTS |
|
24 |
|
25 NS_DECL_NSICLIPBOARD |
|
26 NS_DECL_NSIOBSERVER |
|
27 |
|
28 // Make sure we are initialized, called from the factory |
|
29 // constructor |
|
30 nsresult Init (void); |
|
31 |
|
32 // Someone requested the selection |
|
33 void SelectionGetEvent (GtkClipboard *aGtkClipboard, |
|
34 GtkSelectionData *aSelectionData); |
|
35 void SelectionClearEvent (GtkClipboard *aGtkClipboard); |
|
36 |
|
37 private: |
|
38 // Utility methods |
|
39 static GdkAtom GetSelectionAtom (int32_t aWhichClipboard); |
|
40 static GtkSelectionData *GetTargets (GdkAtom aWhichClipboard); |
|
41 |
|
42 // Save global clipboard content to gtk |
|
43 nsresult Store (void); |
|
44 |
|
45 // Get our hands on the correct transferable, given a specific |
|
46 // clipboard |
|
47 nsITransferable *GetTransferable (int32_t aWhichClipboard); |
|
48 |
|
49 // Hang on to our owners and transferables so we can transfer data |
|
50 // when asked. |
|
51 nsCOMPtr<nsIClipboardOwner> mSelectionOwner; |
|
52 nsCOMPtr<nsIClipboardOwner> mGlobalOwner; |
|
53 nsCOMPtr<nsITransferable> mSelectionTransferable; |
|
54 nsCOMPtr<nsITransferable> mGlobalTransferable; |
|
55 nsRefPtr<nsClipboardPrivacyHandler> mPrivacyHandler; |
|
56 |
|
57 }; |
|
58 |
|
59 #endif /* __nsClipboard_h_ */ |