summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 21:31:39 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 21:31:39 +0000
commit395f9295b3e370746846dbe6073a0d43ab7e4af5 (patch)
tree2b505a988e91b4700268aaba2cdb9601c9122998 /chrome/browser/gtk
parent91ed49a3f98ff91be98d786f44da18d4bf182a32 (diff)
downloadchromium_src-395f9295b3e370746846dbe6073a0d43ab7e4af5.zip
chromium_src-395f9295b3e370746846dbe6073a0d43ab7e4af5.tar.gz
chromium_src-395f9295b3e370746846dbe6073a0d43ab7e4af5.tar.bz2
GTK Themes: Theme the popup notification.
TEST=Open popuptest.com in one tab and anything else in another. Switch between GTK theme and normal. Theme of blocked popup container should change, even when not the active tab. http://crbug.com/13967 Review URL: http://codereview.chromium.org/149277 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/blocked_popup_container_view_gtk.cc56
-rw-r--r--chrome/browser/gtk/blocked_popup_container_view_gtk.h11
2 files changed, 48 insertions, 19 deletions
diff --git a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc
index cc62286..785da3f 100644
--- a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc
+++ b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc
@@ -9,6 +9,7 @@
#include "base/string_util.h"
#include "chrome/browser/gtk/custom_button.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
+#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
@@ -60,6 +61,14 @@ void BlockedPopupContainerViewGtk::GetURLAndTitleForPopup(
*title = tab_contents->GetTitle();
}
+void BlockedPopupContainerViewGtk::UserChangedTheme(
+ GtkThemeProperties* properties) {
+ use_gtk_rendering_ = properties->use_gtk_rendering;
+
+ gtk_chrome_button_set_use_gtk_rendering(
+ GTK_CHROME_BUTTON(menu_button_), use_gtk_rendering_);
+}
+
// Overridden from BlockedPopupContainerView:
void BlockedPopupContainerViewGtk::SetPosition() {
// No-op. Not required with the GTK version.
@@ -122,8 +131,12 @@ void BlockedPopupContainerViewGtk::ExecuteCommand(int id) {
BlockedPopupContainerViewGtk::BlockedPopupContainerViewGtk(
BlockedPopupContainer* container)
: model_(container),
+ use_gtk_rendering_(false),
close_button_(CustomDrawButton::CloseButton()) {
Init();
+
+ GtkThemeProperties properties(container->profile());
+ UserChangedTheme(&properties);
}
void BlockedPopupContainerViewGtk::Init() {
@@ -185,13 +198,10 @@ void BlockedPopupContainerViewGtk::OnCloseButtonClicked(
}
gboolean BlockedPopupContainerViewGtk::OnContainerExpose(
- GtkWidget* widget, GdkEventExpose* event) {
- // TODO(erg): When evanm comes through the code, adding gtk theme support,
- // what's here needs to go in a if block and the else should just paint the
- // normal theme background with a border around the outsides.
+ GtkWidget* widget, GdkEventExpose* event,
+ BlockedPopupContainerViewGtk* container) {
int width = widget->allocation.width;
int height = widget->allocation.height;
- int half_width = width / 2;
// Clip to our damage rect
cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
@@ -199,19 +209,29 @@ gboolean BlockedPopupContainerViewGtk::OnContainerExpose(
event->area.width, event->area.height);
cairo_clip(cr);
- // Draws our background gradient.
- cairo_pattern_t* pattern = cairo_pattern_create_linear(
- half_width, 0, half_width, height);
- cairo_pattern_add_color_stop_rgb(
- pattern, 0.0,
- kBackgroundColorTop[0], kBackgroundColorTop[1], kBackgroundColorTop[2]);
- cairo_pattern_add_color_stop_rgb(
- pattern, 1.0,
- kBackgroundColorBottom[0], kBackgroundColorBottom[1],
- kBackgroundColorBottom[2]);
- cairo_set_source(cr, pattern);
- cairo_paint(cr);
- cairo_pattern_destroy(pattern);
+ if (!container->use_gtk_rendering_) {
+ // TODO(erg): We draw the gradient background only when GTK themes are
+ // off. This isn't a perfect solution as this isn't themed! The views
+ // version doesn't appear to be themed either, so at least for now,
+ // constants are OK.
+ int half_width = width / 2;
+ cairo_pattern_t* pattern = cairo_pattern_create_linear(
+ half_width, 0, half_width, height);
+ cairo_pattern_add_color_stop_rgb(
+ pattern, 0.0,
+ kBackgroundColorTop[0], kBackgroundColorTop[1], kBackgroundColorTop[2]);
+ cairo_pattern_add_color_stop_rgb(
+ pattern, 1.0,
+ kBackgroundColorBottom[0], kBackgroundColorBottom[1],
+ kBackgroundColorBottom[2]);
+ cairo_set_source(cr, pattern);
+ cairo_paint(cr);
+ cairo_pattern_destroy(pattern);
+ }
+
+ // TODO(erg): We need to figure out the border situation, too. We aren't
+ // provided a color from the theme system and the Windows implementation
+ // still uses constants for color. See the status bubble, too.
// Sets up our stroke pen.
cairo_set_source_rgb(cr, kBorderColor[0], kBorderColor[1], kBorderColor[2]);
diff --git a/chrome/browser/gtk/blocked_popup_container_view_gtk.h b/chrome/browser/gtk/blocked_popup_container_view_gtk.h
index c5fdc1a..dab57f4 100644
--- a/chrome/browser/gtk/blocked_popup_container_view_gtk.h
+++ b/chrome/browser/gtk/blocked_popup_container_view_gtk.h
@@ -15,6 +15,7 @@
class BlockedPopupContainerInternalView;
class CustomDrawButton;
+class GtkThemeProperties;
class MenuGtk;
class PrefService;
class Profile;
@@ -41,6 +42,10 @@ class BlockedPopupContainerViewGtk : public BlockedPopupContainerView,
string16* url,
string16* title) const;
+ // Notification that the theme has changed at that we should detect new
+ // values.
+ void UserChangedTheme(GtkThemeProperties* properties);
+
GtkWidget* widget() { return container_.get(); }
// Overridden from BlockedPopupContainerView:
@@ -72,7 +77,8 @@ class BlockedPopupContainerViewGtk : public BlockedPopupContainerView,
BlockedPopupContainerViewGtk* container);
// Draws |container_| with a custom background.
- static gboolean OnContainerExpose(GtkWidget* widget, GdkEventExpose* event);
+ static gboolean OnContainerExpose(GtkWidget* widget, GdkEventExpose* event,
+ BlockedPopupContainerViewGtk* container);
// Our model; calling the shots.
BlockedPopupContainer* model_;
@@ -83,6 +89,9 @@ class BlockedPopupContainerViewGtk : public BlockedPopupContainerView,
// The "Blocked Popups: XXX" button.
GtkWidget* menu_button_;
+ // Whether we should let GTK paint the background and the button decorations.
+ bool use_gtk_rendering_;
+
// Closes the container.
scoped_ptr<CustomDrawButton> close_button_;