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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/custom_drag.h
===================================================================
--- chrome/browser/gtk/custom_drag.h (revision 41804)
+++ chrome/browser/gtk/custom_drag.h (working copy)
@@ -2,17 +2,51 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_GTK_DOWNLOAD_ITEM_DRAG_H_
-#define CHROME_BROWSER_GTK_DOWNLOAD_ITEM_DRAG_H_
+#ifndef CHROME_BROWSER_GTK_CUSTOM_DRAG_H_
+#define CHROME_BROWSER_GTK_CUSTOM_DRAG_H_
#include <gtk/gtk.h>
+#include <vector>
+#include "app/gtk_signal.h"
#include "base/basictypes.h"
+class BookmarkNode;
class DownloadItem;
+class Profile;
class SkBitmap;
-class DownloadItemDrag {
+// Base class for programatically generated drags.
+class CustomDrag {
+ protected:
+ explicit CustomDrag(SkBitmap* icon, int code_mask, GdkDragAction action);
+ virtual ~CustomDrag();
+
+ virtual void OnDragDataGet(GtkWidget* widget, GdkDragContext* context,
+ GtkSelectionData* selection_data,
+ guint target_type, guint time) = 0;
+
+ private:
+ CHROMEGTK_CALLBACK_1(CustomDrag, void, OnDragBegin, GdkDragContext*);
+ CHROMEGTK_CALLBACK_1(CustomDrag, void, OnDragEnd, GdkDragContext*);
+
+ // Since this uses a virtual function, we can't use a macro.
+ static void OnDragDataGetThunk(GtkWidget* widget, GdkDragContext* context,
+ GtkSelectionData* selection_data,
+ guint target_type, guint time,
+ CustomDrag* custom_drag) {
+ return custom_drag->OnDragDataGet(widget, context, selection_data,
+ target_type, time);
+ }
+
+ GtkWidget* drag_widget_;
+ GdkPixbuf* pixbuf_;
+
+ DISALLOW_COPY_AND_ASSIGN(CustomDrag);
+};
+
+// Encapsulates functionality for drags of download items.
+class DownloadItemDrag : public CustomDrag {
public:
// Sets |widget| as a source for drags pertaining to |item|. No
// DownloadItemDrag object is created.
@@ -23,21 +57,39 @@
static void BeginDrag(const DownloadItem* item, SkBitmap* icon);
private:
- explicit DownloadItemDrag(const DownloadItem* item, SkBitmap* icon);
- ~DownloadItemDrag();
+ DownloadItemDrag(const DownloadItem* item, SkBitmap* icon);
+ virtual ~DownloadItemDrag();
- static void OnDragBegin(GtkWidget* widget,
- GdkDragContext* drag_context,
- DownloadItemDrag* drag);
+ virtual void OnDragDataGet(GtkWidget* widget, GdkDragContext* context,
+ GtkSelectionData* selection_data,
+ guint target_type, guint time);
- static void OnDragEnd(GtkWidget* widget,
- GdkDragContext* drag_context,
- DownloadItemDrag* drag);
+ const DownloadItem* download_item_;
- GtkWidget* drag_widget_;
- GdkPixbuf* pixbuf_;
-
DISALLOW_COPY_AND_ASSIGN(DownloadItemDrag);
};
-#endif // CHROME_BROWSER_GTK_DOWNLOAD_ITEM_DRAG_H_
+// Encapsulates functionality for drags of one or more bookmarks.
+class BookmarkDrag : public CustomDrag {
+ public:
+ // Creates a new BookmarkDrag, the lifetime of which is tied to the
+ // system drag.
+ static void BeginDrag(Profile* profile,
+ const std::vector<const BookmarkNode*>& nodes);
+
+ private:
+ BookmarkDrag(Profile* profile,
+ const std::vector<const BookmarkNode*>& nodes);
+ virtual ~BookmarkDrag();
+
+ virtual void OnDragDataGet(GtkWidget* widget, GdkDragContext* context,
+ GtkSelectionData* selection_data,
+ guint target_type, guint time);
+
+ Profile* profile_;
+ std::vector<const BookmarkNode*> nodes_;
+
+ DISALLOW_COPY_AND_ASSIGN(BookmarkDrag);
+};
+
+#endif // CHROME_BROWSER_GTK_CUSTOM_DRAG_H_
Property changes on: chrome/browser/gtk/custom_drag.h
___________________________________________________________________
Added: svn:mergeinfo
« 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