Index: chrome/browser/gtk/download_item_gtk.cc |
=================================================================== |
--- chrome/browser/gtk/download_item_gtk.cc (revision 26399) |
+++ chrome/browser/gtk/download_item_gtk.cc (working copy) |
@@ -8,6 +8,7 @@ |
#include "app/gfx/canvas_paint.h" |
#include "app/gfx/font.h" |
#include "app/gfx/text_elider.h" |
+#include "app/gtk_dnd_util.h" |
#include "app/resource_bundle.h" |
#include "app/slide_animation.h" |
#include "base/basictypes.h" |
@@ -26,6 +27,7 @@ |
#include "chrome/browser/gtk/standard_menus.h" |
#include "chrome/common/gtk_util.h" |
#include "chrome/common/notification_service.h" |
+#include "net/base/net_util.h" |
#include "grit/generated_resources.h" |
#include "grit/theme_resources.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
@@ -219,6 +221,7 @@ |
gtk_widget_modify_style(body_.get(), no_padding_style); |
g_object_unref(no_padding_style); |
Nico
2009/09/18 01:05:42
is this newline intentional? i don't care either w
Evan Stade
2009/09/18 02:43:42
nope, fixed
|
+ |
name_label_ = gtk_label_new(NULL); |
// TODO(estade): This is at best an educated guess, since we don't actually |
@@ -389,6 +392,16 @@ |
break; |
case DownloadItem::COMPLETE: |
StopDownloadProgress(); |
+ |
+ // Set up the widget as a drag source. |
+ gtk_drag_source_set(body_.get(), GDK_BUTTON1_MASK, NULL, 0, |
+ GDK_ACTION_COPY); |
+ GtkDndUtil::SetSourceTargetListFromCodeMask(body_.get(), |
+ GtkDndUtil::TEXT_URI_LIST | |
+ GtkDndUtil::CHROME_NAMED_URL); |
+ g_signal_connect(body_.get(), "drag-data-get", |
+ G_CALLBACK(OnDragDataGet), this); |
+ |
complete_animation_.reset(new SlideAnimation(this)); |
complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); |
complete_animation_->SetTweenType(SlideAnimation::NONE); |
@@ -852,6 +865,18 @@ |
} |
// static |
+void DownloadItemGtk::OnDragDataGet(GtkWidget* widget, GdkDragContext* context, |
+ GtkSelectionData* selection_data, |
+ guint target_type, guint time, |
+ DownloadItemGtk* item) { |
+ GURL url = net::FilePathToFileURL( |
+ item->get_download()->full_path()); |
Nico
2009/09/18 01:05:42
This looks like it might fit into one line.
Evan Stade
2009/09/18 02:43:42
so it does
|
+ |
+ GtkDndUtil::WriteURLWithName(selection_data, url, |
+ UTF8ToUTF16(item->get_download()->GetFileName().value()), target_type); |
+} |
+ |
+// static |
gboolean DownloadItemGtk::OnDangerousPromptExpose(GtkWidget* widget, |
GdkEventExpose* event, DownloadItemGtk* item) { |
if (!item->theme_provider_->UseGtkTheme()) { |