OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
6 | 6 |
7 #include <X11/XF86keysym.h> | 7 #include <X11/XF86keysym.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "app/gtk_dnd_util.h" | |
12 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
13 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
14 #include "base/command_line.h" | 13 #include "base/command_line.h" |
15 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
16 #include "base/logging.h" | 15 #include "base/logging.h" |
17 #include "base/path_service.h" | 16 #include "base/path_service.h" |
18 #include "base/singleton.h" | 17 #include "base/singleton.h" |
19 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
20 #include "chrome/browser/background_page_tracker.h" | 19 #include "chrome/browser/background_page_tracker.h" |
21 #include "chrome/browser/metrics/user_metrics.h" | 20 #include "chrome/browser/metrics/user_metrics.h" |
(...skipping 23 matching lines...) Expand all Loading... |
45 #include "chrome/common/notification_service.h" | 44 #include "chrome/common/notification_service.h" |
46 #include "chrome/common/notification_type.h" | 45 #include "chrome/common/notification_type.h" |
47 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
48 #include "chrome/common/url_constants.h" | 47 #include "chrome/common/url_constants.h" |
49 #include "gfx/canvas_skia_paint.h" | 48 #include "gfx/canvas_skia_paint.h" |
50 #include "gfx/gtk_util.h" | 49 #include "gfx/gtk_util.h" |
51 #include "gfx/skbitmap_operations.h" | 50 #include "gfx/skbitmap_operations.h" |
52 #include "grit/chromium_strings.h" | 51 #include "grit/chromium_strings.h" |
53 #include "grit/generated_resources.h" | 52 #include "grit/generated_resources.h" |
54 #include "grit/theme_resources.h" | 53 #include "grit/theme_resources.h" |
| 54 #include "ui/base/dragdrop/gtk_dnd_util.h" |
55 #include "ui/base/models/accelerator_gtk.h" | 55 #include "ui/base/models/accelerator_gtk.h" |
56 | 56 |
57 namespace { | 57 namespace { |
58 | 58 |
59 // Padding on left and right of the left toolbar buttons (back, forward, reload, | 59 // Padding on left and right of the left toolbar buttons (back, forward, reload, |
60 // etc.). | 60 // etc.). |
61 const int kToolbarLeftAreaPadding = 4; | 61 const int kToolbarLeftAreaPadding = 4; |
62 | 62 |
63 // Height of the toolbar in pixels (not counting padding). | 63 // Height of the toolbar in pixels (not counting padding). |
64 const int kToolbarHeight = 29; | 64 const int kToolbarHeight = 29; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 if (actions_toolbar_.get()) | 414 if (actions_toolbar_.get()) |
415 actions_toolbar_->Update(); | 415 actions_toolbar_->Update(); |
416 } | 416 } |
417 | 417 |
418 // BrowserToolbarGtk, private -------------------------------------------------- | 418 // BrowserToolbarGtk, private -------------------------------------------------- |
419 | 419 |
420 void BrowserToolbarGtk::SetUpDragForHomeButton(bool enable) { | 420 void BrowserToolbarGtk::SetUpDragForHomeButton(bool enable) { |
421 if (enable) { | 421 if (enable) { |
422 gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL, | 422 gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL, |
423 NULL, 0, GDK_ACTION_COPY); | 423 NULL, 0, GDK_ACTION_COPY); |
424 static const int targets[] = { gtk_dnd_util::TEXT_PLAIN, | 424 static const int targets[] = { ui::TEXT_PLAIN, ui::TEXT_URI_LIST, -1 }; |
425 gtk_dnd_util::TEXT_URI_LIST, -1 }; | 425 ui::SetDestTargetList(home_->widget(), targets); |
426 gtk_dnd_util::SetDestTargetList(home_->widget(), targets); | |
427 | 426 |
428 drop_handler_.reset(new GtkSignalRegistrar()); | 427 drop_handler_.reset(new GtkSignalRegistrar()); |
429 drop_handler_->Connect(home_->widget(), "drag-data-received", | 428 drop_handler_->Connect(home_->widget(), "drag-data-received", |
430 G_CALLBACK(OnDragDataReceivedThunk), this); | 429 G_CALLBACK(OnDragDataReceivedThunk), this); |
431 } else { | 430 } else { |
432 gtk_drag_dest_unset(home_->widget()); | 431 gtk_drag_dest_unset(home_->widget()); |
433 drop_handler_.reset(NULL); | 432 drop_handler_.reset(NULL); |
434 } | 433 } |
435 } | 434 } |
436 | 435 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 | 591 |
593 wrench_menu_button_->SetPaintOverride(GTK_STATE_ACTIVE); | 592 wrench_menu_button_->SetPaintOverride(GTK_STATE_ACTIVE); |
594 wrench_menu_->Popup(button, reinterpret_cast<GdkEvent*>(event)); | 593 wrench_menu_->Popup(button, reinterpret_cast<GdkEvent*>(event)); |
595 | 594 |
596 return TRUE; | 595 return TRUE; |
597 } | 596 } |
598 | 597 |
599 void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, | 598 void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, |
600 GdkDragContext* drag_context, gint x, gint y, | 599 GdkDragContext* drag_context, gint x, gint y, |
601 GtkSelectionData* data, guint info, guint time) { | 600 GtkSelectionData* data, guint info, guint time) { |
602 if (info != gtk_dnd_util::TEXT_PLAIN) { | 601 if (info != ui::TEXT_PLAIN) { |
603 NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!"; | 602 NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!"; |
604 return; | 603 return; |
605 } | 604 } |
606 | 605 |
607 GURL url(reinterpret_cast<char*>(data->data)); | 606 GURL url(reinterpret_cast<char*>(data->data)); |
608 if (!url.is_valid()) | 607 if (!url.is_valid()) |
609 return; | 608 return; |
610 | 609 |
611 bool url_is_newtab = url.spec() == chrome::kChromeUINewTabURL; | 610 bool url_is_newtab = url.spec() == chrome::kChromeUINewTabURL; |
612 home_page_is_new_tab_page_.SetValue(url_is_newtab); | 611 home_page_is_new_tab_page_.SetValue(url_is_newtab); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 int x_offset = base::i18n::IsRTL() ? 0 : | 651 int x_offset = base::i18n::IsRTL() ? 0 : |
653 sender->allocation.width - badge->width(); | 652 sender->allocation.width - badge->width(); |
654 int y_offset = 0; | 653 int y_offset = 0; |
655 canvas.DrawBitmapInt( | 654 canvas.DrawBitmapInt( |
656 *badge, | 655 *badge, |
657 sender->allocation.x + x_offset, | 656 sender->allocation.x + x_offset, |
658 sender->allocation.y + y_offset); | 657 sender->allocation.y + y_offset); |
659 | 658 |
660 return FALSE; | 659 return FALSE; |
661 } | 660 } |
OLD | NEW |