| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/bookmark_bar_gtk.h" | 5 #include "chrome/browser/gtk/bookmark_bar_gtk.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/gfx/text_elider.h" | 9 #include "app/gfx/text_elider.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 gtk_drag_dest_set(bookmark_toolbar_.get(), GTK_DEST_DEFAULT_DROP, | 159 gtk_drag_dest_set(bookmark_toolbar_.get(), GTK_DEST_DEFAULT_DROP, |
| 160 NULL, 0, GDK_ACTION_MOVE); | 160 NULL, 0, GDK_ACTION_MOVE); |
| 161 GtkDndUtil::SetDestTargetListFromCodeMask(bookmark_toolbar_.get(), | 161 GtkDndUtil::SetDestTargetListFromCodeMask(bookmark_toolbar_.get(), |
| 162 GtkDndUtil::CHROME_BOOKMARK_ITEM | | 162 GtkDndUtil::CHROME_BOOKMARK_ITEM | |
| 163 GtkDndUtil::CHROME_NAMED_URL); | 163 GtkDndUtil::CHROME_NAMED_URL); |
| 164 g_signal_connect(bookmark_toolbar_.get(), "drag-motion", | 164 g_signal_connect(bookmark_toolbar_.get(), "drag-motion", |
| 165 G_CALLBACK(&OnToolbarDragMotion), this); | 165 G_CALLBACK(&OnToolbarDragMotion), this); |
| 166 g_signal_connect(bookmark_toolbar_.get(), "drag-leave", | 166 g_signal_connect(bookmark_toolbar_.get(), "drag-leave", |
| 167 G_CALLBACK(&OnToolbarDragLeave), this); | 167 G_CALLBACK(&OnToolbarDragLeave), this); |
| 168 g_signal_connect(bookmark_toolbar_.get(), "drag-drop", | |
| 169 G_CALLBACK(&OnToolbarDragDrop), this); | |
| 170 g_signal_connect(bookmark_toolbar_.get(), "drag-data-received", | 168 g_signal_connect(bookmark_toolbar_.get(), "drag-data-received", |
| 171 G_CALLBACK(&OnToolbarDragReceived), this); | 169 G_CALLBACK(&OnToolbarDragReceived), this); |
| 172 g_signal_connect(bookmark_toolbar_.get(), "button-press-event", | 170 g_signal_connect(bookmark_toolbar_.get(), "button-press-event", |
| 173 G_CALLBACK(&OnButtonPressed), this); | 171 G_CALLBACK(&OnButtonPressed), this); |
| 174 | 172 |
| 175 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), gtk_vseparator_new(), | 173 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), gtk_vseparator_new(), |
| 176 FALSE, FALSE, 0); | 174 FALSE, FALSE, 0); |
| 177 | 175 |
| 178 // We pack the button manually (rather than using gtk_button_set_*) so that | 176 // We pack the button manually (rather than using gtk_button_set_*) so that |
| 179 // we can have finer control over its label. | 177 // we can have finer control over its label. |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 BookmarkBarGtk* bar) { | 763 BookmarkBarGtk* bar) { |
| 766 if (bar->toolbar_drop_item_) { | 764 if (bar->toolbar_drop_item_) { |
| 767 g_object_unref(bar->toolbar_drop_item_); | 765 g_object_unref(bar->toolbar_drop_item_); |
| 768 bar->toolbar_drop_item_ = NULL; | 766 bar->toolbar_drop_item_ = NULL; |
| 769 } | 767 } |
| 770 | 768 |
| 771 gtk_toolbar_set_drop_highlight_item(toolbar, NULL, 0); | 769 gtk_toolbar_set_drop_highlight_item(toolbar, NULL, 0); |
| 772 } | 770 } |
| 773 | 771 |
| 774 // static | 772 // static |
| 775 gboolean BookmarkBarGtk::OnToolbarDragDrop( | |
| 776 GtkWidget* widget, GdkDragContext* context, | |
| 777 gint x, gint y, guint time, | |
| 778 BookmarkBarGtk* bar) { | |
| 779 gboolean is_valid_drop_site = FALSE; | |
| 780 | |
| 781 if (context->targets) { | |
| 782 GdkAtom target_type = | |
| 783 GDK_POINTER_TO_ATOM(g_list_nth_data( | |
| 784 context->targets, GtkDndUtil::CHROME_BOOKMARK_ITEM)); | |
| 785 gtk_drag_get_data(widget, context, target_type, time); | |
| 786 | |
| 787 is_valid_drop_site = TRUE; | |
| 788 } | |
| 789 | |
| 790 return is_valid_drop_site; | |
| 791 } | |
| 792 | |
| 793 // static | |
| 794 void BookmarkBarGtk::OnToolbarDragReceived(GtkWidget* widget, | 773 void BookmarkBarGtk::OnToolbarDragReceived(GtkWidget* widget, |
| 795 GdkDragContext* context, | 774 GdkDragContext* context, |
| 796 gint x, gint y, | 775 gint x, gint y, |
| 797 GtkSelectionData* selection_data, | 776 GtkSelectionData* selection_data, |
| 798 guint target_type, guint time, | 777 guint target_type, guint time, |
| 799 BookmarkBarGtk* bar) { | 778 BookmarkBarGtk* bar) { |
| 800 gboolean dnd_success = FALSE; | 779 gboolean dnd_success = FALSE; |
| 801 gboolean delete_selection_data = FALSE; | 780 gboolean delete_selection_data = FALSE; |
| 802 | 781 |
| 803 gint index = gtk_toolbar_get_drop_index( | 782 gint index = gtk_toolbar_get_drop_index( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 bar->InitBackground(); | 817 bar->InitBackground(); |
| 839 gfx::Point tabstrip_origin = | 818 gfx::Point tabstrip_origin = |
| 840 bar->window_->tabstrip()->GetTabStripOriginForWidget(widget); | 819 bar->window_->tabstrip()->GetTabStripOriginForWidget(widget); |
| 841 bar->background_ninebox_->RenderTopCenterStrip( | 820 bar->background_ninebox_->RenderTopCenterStrip( |
| 842 cr, tabstrip_origin.x(), tabstrip_origin.y(), | 821 cr, tabstrip_origin.x(), tabstrip_origin.y(), |
| 843 event->area.x + event->area.width - tabstrip_origin.x()); | 822 event->area.x + event->area.width - tabstrip_origin.x()); |
| 844 cairo_destroy(cr); | 823 cairo_destroy(cr); |
| 845 | 824 |
| 846 return FALSE; // Propagate expose to children. | 825 return FALSE; // Propagate expose to children. |
| 847 } | 826 } |
| OLD | NEW |