OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 312 |
313 GtkWidget* site_type_hbox = gtk_hbox_new(FALSE, 0); | 313 GtkWidget* site_type_hbox = gtk_hbox_new(FALSE, 0); |
314 gtk_box_pack_start(GTK_BOX(site_type_hbox), location_icon_image_, | 314 gtk_box_pack_start(GTK_BOX(site_type_hbox), location_icon_image_, |
315 FALSE, FALSE, 0); | 315 FALSE, FALSE, 0); |
316 gtk_box_pack_start(GTK_BOX(site_type_hbox), security_info_label_, | 316 gtk_box_pack_start(GTK_BOX(site_type_hbox), security_info_label_, |
317 FALSE, FALSE, kCornerSize); | 317 FALSE, FALSE, kCornerSize); |
318 | 318 |
319 site_type_event_box_ = gtk_event_box_new(); | 319 site_type_event_box_ = gtk_event_box_new(); |
320 gtk_widget_modify_bg(site_type_event_box_, GTK_STATE_NORMAL, | 320 gtk_widget_modify_bg(site_type_event_box_, GTK_STATE_NORMAL, |
321 &kEvSecureBackgroundColor); | 321 &kEvSecureBackgroundColor); |
| 322 g_signal_connect(site_type_event_box_, "drag-data-get", |
| 323 G_CALLBACK(&OnIconDragDataThunk), this); |
| 324 g_signal_connect(site_type_event_box_, "drag-begin", |
| 325 G_CALLBACK(&OnIconDragBeginThunk), this); |
| 326 g_signal_connect(site_type_event_box_, "drag-end", |
| 327 G_CALLBACK(&OnIconDragEndThunk), this); |
322 | 328 |
323 // Make the event box not visible so it does not paint a background. | 329 // Make the event box not visible so it does not paint a background. |
324 gtk_event_box_set_visible_window(GTK_EVENT_BOX(site_type_event_box_), | 330 gtk_event_box_set_visible_window(GTK_EVENT_BOX(site_type_event_box_), |
325 FALSE); | 331 FALSE); |
326 gtk_widget_set_name(site_type_event_box_, | 332 gtk_widget_set_name(site_type_event_box_, |
327 "chrome-location-icon-eventbox"); | 333 "chrome-location-icon-eventbox"); |
328 gtk_container_add(GTK_CONTAINER(site_type_event_box_), | 334 gtk_container_add(GTK_CONTAINER(site_type_event_box_), |
329 site_type_hbox); | 335 site_type_hbox); |
330 | 336 |
331 // Put the event box in an alignment to get the padding correct. | 337 // Put the event box in an alignment to get the padding correct. |
(...skipping 19 matching lines...) Expand all Loading... |
351 gtk_drag_source_unset(site_type_event_box_); | 357 gtk_drag_source_unset(site_type_event_box_); |
352 return; | 358 return; |
353 } | 359 } |
354 | 360 |
355 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, | 361 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, |
356 NULL, 0, GDK_ACTION_COPY); | 362 NULL, 0, GDK_ACTION_COPY); |
357 gtk_dnd_util::SetSourceTargetListFromCodeMask(site_type_event_box_, | 363 gtk_dnd_util::SetSourceTargetListFromCodeMask(site_type_event_box_, |
358 gtk_dnd_util::TEXT_PLAIN | | 364 gtk_dnd_util::TEXT_PLAIN | |
359 gtk_dnd_util::TEXT_URI_LIST | | 365 gtk_dnd_util::TEXT_URI_LIST | |
360 gtk_dnd_util::CHROME_NAMED_URL); | 366 gtk_dnd_util::CHROME_NAMED_URL); |
361 | |
362 g_signal_connect(site_type_event_box_, "drag-data-get", | |
363 G_CALLBACK(&OnIconDragDataThunk), this); | |
364 g_signal_connect(site_type_event_box_, "drag-begin", | |
365 G_CALLBACK(&OnIconDragBeginThunk), this); | |
366 g_signal_connect(site_type_event_box_, "drag-end", | |
367 G_CALLBACK(&OnIconDragEndThunk), this); | |
368 } | 367 } |
369 | 368 |
370 void LocationBarViewGtk::SetProfile(Profile* profile) { | 369 void LocationBarViewGtk::SetProfile(Profile* profile) { |
371 profile_ = profile; | 370 profile_ = profile; |
372 } | 371 } |
373 | 372 |
374 TabContents* LocationBarViewGtk::GetTabContents() const { | 373 TabContents* LocationBarViewGtk::GetTabContents() const { |
375 return browser_->GetSelectedTabContents(); | 374 return browser_->GetSelectedTabContents(); |
376 } | 375 } |
377 | 376 |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 if (!pixbuf) | 998 if (!pixbuf) |
1000 return; | 999 return; |
1001 drag_icon_ = bookmark_utils::GetDragRepresentation(pixbuf, GetTitle(), | 1000 drag_icon_ = bookmark_utils::GetDragRepresentation(pixbuf, GetTitle(), |
1002 theme_provider_); | 1001 theme_provider_); |
1003 g_object_unref(pixbuf); | 1002 g_object_unref(pixbuf); |
1004 gtk_drag_set_icon_widget(context, drag_icon_, 0, 0); | 1003 gtk_drag_set_icon_widget(context, drag_icon_, 0, 0); |
1005 } | 1004 } |
1006 | 1005 |
1007 void LocationBarViewGtk::OnIconDragEnd(GtkWidget* sender, | 1006 void LocationBarViewGtk::OnIconDragEnd(GtkWidget* sender, |
1008 GdkDragContext* context) { | 1007 GdkDragContext* context) { |
| 1008 DCHECK(drag_icon_); |
1009 gtk_widget_destroy(drag_icon_); | 1009 gtk_widget_destroy(drag_icon_); |
1010 drag_icon_ = NULL; | 1010 drag_icon_ = NULL; |
1011 } | 1011 } |
1012 | 1012 |
1013 void LocationBarViewGtk::OnHboxSizeAllocate(GtkWidget* sender, | 1013 void LocationBarViewGtk::OnHboxSizeAllocate(GtkWidget* sender, |
1014 GtkAllocation* allocation) { | 1014 GtkAllocation* allocation) { |
1015 if (hbox_width_ != allocation->width) { | 1015 if (hbox_width_ != allocation->width) { |
1016 hbox_width_ = allocation->width; | 1016 hbox_width_ = allocation->width; |
1017 UpdateEVCertificateLabelSize(); | 1017 UpdateEVCertificateLabelSize(); |
1018 } | 1018 } |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 | 1412 |
1413 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1413 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1414 if (badge_text.empty()) | 1414 if (badge_text.empty()) |
1415 return FALSE; | 1415 return FALSE; |
1416 | 1416 |
1417 gfx::CanvasPaint canvas(event, false); | 1417 gfx::CanvasPaint canvas(event, false); |
1418 gfx::Rect bounding_rect(widget->allocation); | 1418 gfx::Rect bounding_rect(widget->allocation); |
1419 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1419 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1420 return FALSE; | 1420 return FALSE; |
1421 } | 1421 } |
OLD | NEW |