Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/gtk/custom_drag.h

Issue 1029004: GTK: implement extension bookmark manager drag api.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/bookmark_utils_gtk.cc ('k') | chrome/browser/gtk/custom_drag.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_GTK_DOWNLOAD_ITEM_DRAG_H_ 5 #ifndef CHROME_BROWSER_GTK_CUSTOM_DRAG_H_
6 #define CHROME_BROWSER_GTK_DOWNLOAD_ITEM_DRAG_H_ 6 #define CHROME_BROWSER_GTK_CUSTOM_DRAG_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <vector>
9 10
11 #include "app/gtk_signal.h"
10 #include "base/basictypes.h" 12 #include "base/basictypes.h"
11 13
14 class BookmarkNode;
12 class DownloadItem; 15 class DownloadItem;
16 class Profile;
13 class SkBitmap; 17 class SkBitmap;
14 18
15 class DownloadItemDrag { 19 // Base class for programatically generated drags.
20 class CustomDrag {
21 protected:
22 explicit CustomDrag(SkBitmap* icon, int code_mask, GdkDragAction action);
23 virtual ~CustomDrag();
24
25 virtual void OnDragDataGet(GtkWidget* widget, GdkDragContext* context,
26 GtkSelectionData* selection_data,
27 guint target_type, guint time) = 0;
28
29 private:
30 CHROMEGTK_CALLBACK_1(CustomDrag, void, OnDragBegin, GdkDragContext*);
31 CHROMEGTK_CALLBACK_1(CustomDrag, void, OnDragEnd, GdkDragContext*);
32
33 // Since this uses a virtual function, we can't use a macro.
34 static void OnDragDataGetThunk(GtkWidget* widget, GdkDragContext* context,
35 GtkSelectionData* selection_data,
36 guint target_type, guint time,
37 CustomDrag* custom_drag) {
38 return custom_drag->OnDragDataGet(widget, context, selection_data,
39 target_type, time);
40 }
41
42 GtkWidget* drag_widget_;
43 GdkPixbuf* pixbuf_;
44
45 DISALLOW_COPY_AND_ASSIGN(CustomDrag);
46 };
47
48 // Encapsulates functionality for drags of download items.
49 class DownloadItemDrag : public CustomDrag {
16 public: 50 public:
17 // Sets |widget| as a source for drags pertaining to |item|. No 51 // Sets |widget| as a source for drags pertaining to |item|. No
18 // DownloadItemDrag object is created. 52 // DownloadItemDrag object is created.
19 static void SetSource(GtkWidget* widget, DownloadItem* item); 53 static void SetSource(GtkWidget* widget, DownloadItem* item);
20 54
21 // Creates a new DownloadItemDrag, the lifetime of which is tied to the 55 // Creates a new DownloadItemDrag, the lifetime of which is tied to the
22 // system drag. 56 // system drag.
23 static void BeginDrag(const DownloadItem* item, SkBitmap* icon); 57 static void BeginDrag(const DownloadItem* item, SkBitmap* icon);
24 58
25 private: 59 private:
26 explicit DownloadItemDrag(const DownloadItem* item, SkBitmap* icon); 60 DownloadItemDrag(const DownloadItem* item, SkBitmap* icon);
27 ~DownloadItemDrag(); 61 virtual ~DownloadItemDrag();
28 62
29 static void OnDragBegin(GtkWidget* widget, 63 virtual void OnDragDataGet(GtkWidget* widget, GdkDragContext* context,
30 GdkDragContext* drag_context, 64 GtkSelectionData* selection_data,
31 DownloadItemDrag* drag); 65 guint target_type, guint time);
32 66
33 static void OnDragEnd(GtkWidget* widget, 67 const DownloadItem* download_item_;
34 GdkDragContext* drag_context,
35 DownloadItemDrag* drag);
36
37 GtkWidget* drag_widget_;
38 GdkPixbuf* pixbuf_;
39 68
40 DISALLOW_COPY_AND_ASSIGN(DownloadItemDrag); 69 DISALLOW_COPY_AND_ASSIGN(DownloadItemDrag);
41 }; 70 };
42 71
43 #endif // CHROME_BROWSER_GTK_DOWNLOAD_ITEM_DRAG_H_ 72 // Encapsulates functionality for drags of one or more bookmarks.
73 class BookmarkDrag : public CustomDrag {
74 public:
75 // Creates a new BookmarkDrag, the lifetime of which is tied to the
76 // system drag.
77 static void BeginDrag(Profile* profile,
78 const std::vector<const BookmarkNode*>& nodes);
79
80 private:
81 BookmarkDrag(Profile* profile,
82 const std::vector<const BookmarkNode*>& nodes);
83 virtual ~BookmarkDrag();
84
85 virtual void OnDragDataGet(GtkWidget* widget, GdkDragContext* context,
86 GtkSelectionData* selection_data,
87 guint target_type, guint time);
88
89 Profile* profile_;
90 std::vector<const BookmarkNode*> nodes_;
91
92 DISALLOW_COPY_AND_ASSIGN(BookmarkDrag);
93 };
94
95 #endif // CHROME_BROWSER_GTK_CUSTOM_DRAG_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/bookmark_utils_gtk.cc ('k') | chrome/browser/gtk/custom_drag.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698