Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 149277: GTK Themes: Theme the popup notification. (Closed)
Patch Set: lint + comments Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/tab_contents/tab_contents_view_gtk.h" 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/mime_util.h" 10 #include "base/mime_util.h"
11 #include "base/gfx/point.h" 11 #include "base/gfx/point.h"
12 #include "base/gfx/rect.h" 12 #include "base/gfx/rect.h"
13 #include "base/gfx/size.h" 13 #include "base/gfx/size.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/download/download_shelf.h" 16 #include "chrome/browser/download/download_shelf.h"
17 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h" 17 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h"
18 #include "chrome/browser/gtk/browser_window_gtk.h" 18 #include "chrome/browser/gtk/browser_window_gtk.h"
19 #include "chrome/browser/gtk/constrained_window_gtk.h" 19 #include "chrome/browser/gtk/constrained_window_gtk.h"
20 #include "chrome/browser/gtk/gtk_dnd_util.h" 20 #include "chrome/browser/gtk/gtk_dnd_util.h"
21 #include "chrome/browser/gtk/gtk_floating_container.h" 21 #include "chrome/browser/gtk/gtk_floating_container.h"
22 #include "chrome/browser/gtk/gtk_theme_provider.h"
22 #include "chrome/browser/gtk/sad_tab_gtk.h" 23 #include "chrome/browser/gtk/sad_tab_gtk.h"
23 #include "chrome/browser/renderer_host/render_view_host.h" 24 #include "chrome/browser/renderer_host/render_view_host.h"
24 #include "chrome/browser/renderer_host/render_view_host_factory.h" 25 #include "chrome/browser/renderer_host/render_view_host_factory.h"
25 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" 26 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
26 #include "chrome/browser/tab_contents/interstitial_page.h" 27 #include "chrome/browser/tab_contents/interstitial_page.h"
27 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" 28 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h"
28 #include "chrome/browser/tab_contents/tab_contents.h" 29 #include "chrome/browser/tab_contents/tab_contents.h"
29 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 30 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
30 #include "chrome/common/gtk_util.h" 31 #include "chrome/common/gtk_util.h"
32 #include "chrome/common/notification_service.h"
31 #include "chrome/common/notification_source.h" 33 #include "chrome/common/notification_source.h"
32 #include "chrome/common/notification_type.h" 34 #include "chrome/common/notification_type.h"
33 #include "webkit/glue/webdropdata.h" 35 #include "webkit/glue/webdropdata.h"
34 36
35 namespace { 37 namespace {
36 38
37 // TODO(erg): I have no idea how to progromatically figure out how wide the 39 // TODO(erg): I have no idea how to progromatically figure out how wide the
38 // vertical scrollbar is. Hack it with a hardcoded value for now. 40 // vertical scrollbar is. Hack it with a hardcoded value for now.
39 const int kScrollbarWidthHack = 25; 41 const int kScrollbarWidthHack = 25;
40 42
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 method_factory_(this) { 115 method_factory_(this) {
114 gtk_drag_dest_set(widget, static_cast<GtkDestDefaults>(0), 116 gtk_drag_dest_set(widget, static_cast<GtkDestDefaults>(0),
115 NULL, 0, GDK_ACTION_COPY); 117 NULL, 0, GDK_ACTION_COPY);
116 g_signal_connect(widget, "drag-motion", 118 g_signal_connect(widget, "drag-motion",
117 G_CALLBACK(OnDragMotionThunk), this); 119 G_CALLBACK(OnDragMotionThunk), this);
118 g_signal_connect(widget, "drag-leave", 120 g_signal_connect(widget, "drag-leave",
119 G_CALLBACK(OnDragLeaveThunk), this); 121 G_CALLBACK(OnDragLeaveThunk), this);
120 g_signal_connect(widget, "drag-drop", 122 g_signal_connect(widget, "drag-drop",
121 G_CALLBACK(OnDragDropThunk), this); 123 G_CALLBACK(OnDragDropThunk), this);
122 g_signal_connect(widget, "drag-data-received", 124 g_signal_connect(widget, "drag-data-received",
123 G_CALLBACK(OnDragDataReceivedThunk),this); 125 G_CALLBACK(OnDragDataReceivedThunk), this);
124 126
125 destroy_handler_ = g_signal_connect(widget, "destroy", 127 destroy_handler_ = g_signal_connect(widget, "destroy",
126 G_CALLBACK(gtk_widget_destroyed), &widget_); 128 G_CALLBACK(gtk_widget_destroyed), &widget_);
127 } 129 }
128 130
129 ~WebDragDest() { 131 ~WebDragDest() {
130 if (widget_) { 132 if (widget_) {
131 gtk_drag_dest_unset(widget_); 133 gtk_drag_dest_unset(widget_);
132 g_signal_handler_disconnect(widget_, destroy_handler_); 134 g_signal_handler_disconnect(widget_, destroy_handler_);
133 } 135 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 g_signal_connect(fixed_, "size-allocate", 315 g_signal_connect(fixed_, "size-allocate",
314 G_CALLBACK(OnSizeAllocate), this); 316 G_CALLBACK(OnSizeAllocate), this);
315 g_signal_connect(floating_.get(), "set-floating-position", 317 g_signal_connect(floating_.get(), "set-floating-position",
316 G_CALLBACK(OnSetFloatingPosition), this); 318 G_CALLBACK(OnSetFloatingPosition), this);
317 319
318 gtk_container_add(GTK_CONTAINER(floating_.get()), fixed_); 320 gtk_container_add(GTK_CONTAINER(floating_.get()), fixed_);
319 gtk_widget_show(fixed_); 321 gtk_widget_show(fixed_);
320 gtk_widget_show(floating_.get()); 322 gtk_widget_show(floating_.get());
321 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED, 323 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED,
322 Source<TabContents>(tab_contents)); 324 Source<TabContents>(tab_contents));
325 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
326 NotificationService::AllSources());
323 } 327 }
324 328
325 TabContentsViewGtk::~TabContentsViewGtk() { 329 TabContentsViewGtk::~TabContentsViewGtk() {
326 floating_.Destroy(); 330 floating_.Destroy();
327 } 331 }
328 332
329 void TabContentsViewGtk::AttachBlockedPopupView( 333 void TabContentsViewGtk::AttachBlockedPopupView(
330 BlockedPopupContainerViewGtk* popup_view) { 334 BlockedPopupContainerViewGtk* popup_view) {
331 DCHECK(popup_view_ == NULL); 335 DCHECK(popup_view_ == NULL);
332 popup_view_ = popup_view; 336 popup_view_ = popup_view;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 const NotificationSource& source, 538 const NotificationSource& source,
535 const NotificationDetails& details) { 539 const NotificationDetails& details) {
536 switch (type.value) { 540 switch (type.value) {
537 case NotificationType::TAB_CONTENTS_CONNECTED: { 541 case NotificationType::TAB_CONTENTS_CONNECTED: {
538 // No need to remove the SadTabGtk's widget from the container since 542 // No need to remove the SadTabGtk's widget from the container since
539 // the new RenderWidgetHostViewGtk instance already removed all the 543 // the new RenderWidgetHostViewGtk instance already removed all the
540 // vbox's children. 544 // vbox's children.
541 sad_tab_.reset(); 545 sad_tab_.reset();
542 break; 546 break;
543 } 547 }
548 case NotificationType::BROWSER_THEME_CHANGED: {
549 GtkThemeProperties properties(tab_contents()->profile());
550 UserChangedTheme(&properties);
551 break;
552 }
544 default: 553 default:
545 NOTREACHED() << "Got a notification we didn't register for."; 554 NOTREACHED() << "Got a notification we didn't register for.";
546 break; 555 break;
547 } 556 }
548 } 557 }
549 558
550 void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { 559 void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) {
551 context_menu_.reset(new RenderViewContextMenuGtk(tab_contents(), params, 560 context_menu_.reset(new RenderViewContextMenuGtk(tab_contents(), params,
552 last_mouse_down_.time)); 561 last_mouse_down_.time));
553 context_menu_->Init(); 562 context_menu_->Init();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 660
652 // static 661 // static
653 void TabContentsViewGtk::OnDragEnd(GtkWidget* widget, 662 void TabContentsViewGtk::OnDragEnd(GtkWidget* widget,
654 GdkDragContext* drag_context, TabContentsViewGtk* view) { 663 GdkDragContext* drag_context, TabContentsViewGtk* view) {
655 view->DragEnded(); 664 view->DragEnded();
656 view->drop_data_.reset(); 665 view->drop_data_.reset();
657 } 666 }
658 667
659 // ----------------------------------------------------------------------------- 668 // -----------------------------------------------------------------------------
660 669
670 void TabContentsViewGtk::UserChangedTheme(GtkThemeProperties* properties) {
671 if (popup_view_)
672 popup_view_->UserChangedTheme(properties);
673
674 // TODO(erg): Plumb the selected text color, etc from here all the way to
675 // RenderThemeChromiumLinux.cpp in WebKit through our associated
676 // RenderViewHost.
677 }
678
661 void TabContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { 679 void TabContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) {
662 gtk_fixed_put(GTK_FIXED(fixed_), widget, 0, 0); 680 gtk_fixed_put(GTK_FIXED(fixed_), widget, 0, 0);
663 } 681 }
664 682
665 gboolean TabContentsViewGtk::OnMouseDown(GtkWidget* widget, 683 gboolean TabContentsViewGtk::OnMouseDown(GtkWidget* widget,
666 GdkEventButton* event, TabContentsViewGtk* view) { 684 GdkEventButton* event, TabContentsViewGtk* view) {
667 view->last_mouse_down_ = *event; 685 view->last_mouse_down_ = *event;
668 return FALSE; 686 return FALSE;
669 } 687 }
670 688
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 752 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
735 widget, "x", &value); 753 widget, "x", &value);
736 754
737 int child_y = std::max(half_view_height - (requisition.height / 2), 0); 755 int child_y = std::max(half_view_height - (requisition.height / 2), 0);
738 g_value_set_int(&value, child_y); 756 g_value_set_int(&value, child_y);
739 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 757 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
740 widget, "y", &value); 758 widget, "y", &value);
741 g_value_unset(&value); 759 g_value_unset(&value);
742 } 760 }
743 } 761 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698