• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009, Martin Robinson
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2 of the License, or (at your option) any later version.
8  *
9  *  This library is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public
15  *  License along with this library; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 #ifndef DataObjectGtk_h
20 #define DataObjectGtk_h
21 
22 #include "CString.h"
23 #include "FileList.h"
24 #include "KURL.h"
25 #include "Range.h"
26 #include "StringHash.h"
27 #include <wtf/RefCounted.h>
28 #include <wtf/gtk/GRefPtr.h>
29 
30 typedef struct _GdkPixbuf GdkPixbuf;
31 typedef struct _GdkDragContext GdkDragContext;
32 typedef struct _GtkClipboard GtkClipboard;
33 
34 namespace WebCore {
35 
36 class DataObjectGtk : public RefCounted<DataObjectGtk> {
37 public:
create()38     static PassRefPtr<DataObjectGtk> create()
39     {
40         return adoptRef(new DataObjectGtk());
41     }
42 
uriList()43     Vector<KURL> uriList() { return m_uriList; }
image()44     GdkPixbuf* image() { return m_image.get(); }
setRange(PassRefPtr<Range> newRange)45     void setRange(PassRefPtr<Range> newRange) { m_range = newRange; }
setURIList(const Vector<KURL> & newURIList)46     void setURIList(const Vector<KURL>& newURIList) {  m_uriList = newURIList; }
setImage(GdkPixbuf * newImage)47     void setImage(GdkPixbuf* newImage) { m_image = newImage; }
setDragContext(GdkDragContext * newDragContext)48     void setDragContext(GdkDragContext* newDragContext) { m_dragContext = newDragContext; }
hasText()49     bool hasText() { return m_range || !m_text.isEmpty(); }
hasMarkup()50     bool hasMarkup() { return m_range || !m_markup.isEmpty(); }
hasURIList()51     bool hasURIList() { return !m_uriList.isEmpty(); }
hasImage()52     bool hasImage() { return m_image; }
dragContext()53     GdkDragContext* dragContext() { return m_dragContext.get(); }
54 
55     String text();
56     String markup();
57     Vector<String> files();
58     void setText(const String& newText);
59     void setMarkup(const String& newMarkup);
60     bool hasURL();
61     String url();
62     String urlLabel();
63     void clear();
64 
65     static DataObjectGtk* forClipboard(GtkClipboard*);
66 
67 private:
68     String m_text;
69     String m_markup;
70     Vector<KURL> m_uriList;
71     GRefPtr<GdkPixbuf> m_image;
72     GRefPtr<GdkDragContext> m_dragContext;
73     RefPtr<Range> m_range;
74 };
75 
76 }
77 
78 #endif // DataObjectGtk_h
79