diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 00:19:04 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 00:19:04 +0000 |
commit | 736d1898191dc530e603a996d8c4bf2415326aa7 (patch) | |
tree | 79c524d49f164c8c970b119279be072aaaaee91d /chrome/browser/ui/gtk/custom_drag.h | |
parent | 2dee6d5003f0d5a9fffd55856b9f54b404988cab (diff) | |
download | chromium_src-736d1898191dc530e603a996d8c4bf2415326aa7.zip chromium_src-736d1898191dc530e603a996d8c4bf2415326aa7.tar.gz chromium_src-736d1898191dc530e603a996d8c4bf2415326aa7.tar.bz2 |
Move chrome/browser/gtk/ to chrome/browser/ui/gtk/
(moved *.cc using 'svn mv' to preserve history)
(copied *.h using 'svn cp' to preserve history and stub out originals)
Stubbed out original headers in chrome/browser/gtk/
Update header guards & copyright dates in chrome/browser/ui/gtk/
Update .gypi files
Remove chrome/chrome_browser.gypi:4228 reference to nonexistant:
['include', '^browser/gtk/pk11_password_dialog.h'],
Remove stray header guard in:
chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc
Add #pragma once to the following files:
chrome/browser/ui/gtk/instant_confirm_dialog_gtk.h
chrome/browser/ui/gtk/infobar_arrow_model.h
Ran the following to appease presubmit: 'svn pset svn:eol-style LF \
chrome/browser/ui/gtk/info_bubble_accelerators_gtk.cc \
chrome/browser/ui/gtk/gtk_custom_menu.cc \
chrome/browser/ui/gtk/info_bubble_accelerators_gtk.h \
chrome/browser/ui/gtk/gtk_custom_menu.h \
chrome/browser/ui/gtk/options/managed_prefs_banner_gtk.h \
chrome/browser/ui/gtk/chrome_gtk_frame.h \
chrome/browser/ui/gtk/chrome_gtk_frame.cc \
chrome/browser/ui/gtk/gtk_custom_menu_item.h \
chrome/browser/gtk/info_bubble_accelerators_gtk.h \
chrome/browser/gtk/gtk_custom_menu.h \
chrome/browser/gtk/options/managed_prefs_banner_gtk.h \
chrome/browser/gtk/chrome_gtk_frame.h \
chrome/browser/gtk/gtk_custom_menu_item.h'
BUG=69289
TEST=Compile&Trybots
Review URL: http://codereview.chromium.org/6251001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/gtk/custom_drag.h')
-rw-r--r-- | chrome/browser/ui/gtk/custom_drag.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/chrome/browser/ui/gtk/custom_drag.h b/chrome/browser/ui/gtk/custom_drag.h new file mode 100644 index 0000000..40916e3 --- /dev/null +++ b/chrome/browser/ui/gtk/custom_drag.h @@ -0,0 +1,100 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_GTK_CUSTOM_DRAG_H_ +#define CHROME_BROWSER_UI_GTK_CUSTOM_DRAG_H_ +#pragma once + +#include <gtk/gtk.h> +#include <vector> + +#include "app/gtk_signal.h" +#include "base/basictypes.h" + +class BookmarkNode; +class DownloadItem; +class Profile; +class SkBitmap; + +// 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); + } + + // Can't use a OwnedWidgetGtk because the initialization of GtkInvisible + // sinks the reference. + 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. + // It is safe to call this multiple times with different values of |icon|. + static void SetSource(GtkWidget* widget, DownloadItem* item, SkBitmap* icon); + + // Creates a new DownloadItemDrag, the lifetime of which is tied to the + // system drag. + static void BeginDrag(const DownloadItem* item, SkBitmap* icon); + + private: + DownloadItemDrag(const DownloadItem* item, SkBitmap* icon); + virtual ~DownloadItemDrag(); + + virtual void OnDragDataGet(GtkWidget* widget, GdkDragContext* context, + GtkSelectionData* selection_data, + guint target_type, guint time); + + const DownloadItem* download_item_; + + DISALLOW_COPY_AND_ASSIGN(DownloadItemDrag); +}; + +// 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_UI_GTK_CUSTOM_DRAG_H_ |