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 "FileList.h"
23#include <GRefPtr.h>
24#include "KURL.h"
25#include "Range.h"
26#include <wtf/RefCounted.h>
27#include <wtf/text/CString.h>
28#include <wtf/text/StringHash.h>
29
30namespace WebCore {
31
32class DataObjectGtk : public RefCounted<DataObjectGtk> {
33public:
34    static PassRefPtr<DataObjectGtk> create()
35    {
36        return adoptRef(new DataObjectGtk());
37    }
38
39    const KURL& url() { return m_url; }
40    const String& uriList() { return m_uriList; }
41    const Vector<String>& filenames() { return m_filenames; }
42    GdkPixbuf* image() { return m_image.get(); }
43    void setRange(PassRefPtr<Range> newRange) { m_range = newRange; }
44    void setImage(GdkPixbuf* newImage) { m_image = newImage; }
45    void setDragContext(GdkDragContext* newDragContext) { m_dragContext = newDragContext; }
46    void setURL(const KURL&, const String&);
47    bool hasText() { return m_range || !m_text.isEmpty(); }
48    bool hasMarkup() { return m_range || !m_markup.isEmpty(); }
49    bool hasURIList() { return !m_uriList.isEmpty(); }
50    bool hasURL() { return !m_url.isEmpty() && m_url.isValid(); }
51    bool hasFilenames() { return !m_filenames.isEmpty(); }
52    bool hasImage() { return m_image; }
53    void clearURIList() { m_uriList = ""; }
54    void clearURL() { m_url = KURL(); }
55    void clearImage() { m_image = 0; }
56    GdkDragContext* dragContext() { return m_dragContext.get(); }
57
58    String text();
59    String markup();
60    void setText(const String&);
61    void setMarkup(const String&);
62    void setURIList(const String&);
63    String urlLabel();
64    void clear();
65    void clearText();
66    void clearMarkup();
67
68    static DataObjectGtk* forClipboard(GtkClipboard*);
69
70private:
71    String m_text;
72    String m_markup;
73    KURL m_url;
74    String m_uriList;
75    Vector<String> m_filenames;
76    GRefPtr<GdkPixbuf> m_image;
77    GRefPtr<GdkDragContext> m_dragContext;
78    RefPtr<Range> m_range;
79};
80
81}
82
83#endif // DataObjectGtk_h
84