diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-17 16:34:50 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-17 16:34:50 +0000 |
commit | f4a2435ea81199ac48dbaf07c8514aa38b7cb106 (patch) | |
tree | 3a0034978477f8cbdb3e80eb7b2c00aecd2fdc16 /chrome/browser/gtk/gtk_chrome_button.cc | |
parent | 8adbe223e105bbfd17dba1115ed0044466fd49fe (diff) | |
download | chromium_src-f4a2435ea81199ac48dbaf07c8514aa38b7cb106.zip chromium_src-f4a2435ea81199ac48dbaf07c8514aa38b7cb106.tar.gz chromium_src-f4a2435ea81199ac48dbaf07c8514aa38b7cb106.tar.bz2 |
Refactor NineBox to take 9 image ids instead of having to create
the GdkPixbuf array and passing it into the constructor. This allows
us to remove some resource_bundle.h includes.
Clean up the style in gtk_chrome_button.cc. There was some C style
and moved the globals to just static pointers. I verified with
a debugger that we call gtk_chrome_button_class_init only once.
Review URL: http://codereview.chromium.org/69025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/gtk_chrome_button.cc')
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_button.cc | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/chrome/browser/gtk/gtk_chrome_button.cc b/chrome/browser/gtk/gtk_chrome_button.cc index 193a295..3206e9f 100644 --- a/chrome/browser/gtk/gtk_chrome_button.cc +++ b/chrome/browser/gtk/gtk_chrome_button.cc @@ -5,7 +5,6 @@ #include "chrome/browser/gtk/gtk_chrome_button.h" #include "base/basictypes.h" -#include "chrome/common/resource_bundle.h" #include "chrome/browser/gtk/nine_box.h" #include "grit/theme_resources.h" @@ -13,61 +12,56 @@ namespace { // The theme graphics for when the mouse is over the button. -scoped_ptr<NineBox> nine_box_prelight; +static NineBox* g_nine_box_prelight; // The theme graphics for when the button is clicked. -scoped_ptr<NineBox> nine_box_active; +static NineBox* g_nine_box_active; } G_BEGIN_DECLS G_DEFINE_TYPE (GtkChromeButton, gtk_chrome_button, GTK_TYPE_BUTTON) -static gboolean gtk_chrome_button_expose (GtkWidget *widget, - GdkEventExpose *event); +static gboolean gtk_chrome_button_expose(GtkWidget* widget, + GdkEventExpose* event); static void gtk_chrome_button_class_init(GtkChromeButtonClass *button_class) { GtkWidgetClass* widget_class = (GtkWidgetClass*)button_class; widget_class->expose_event = gtk_chrome_button_expose; - GdkPixbuf* images[9]; - int i = 0; - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_TOP_LEFT_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_TOP_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_TOP_RIGHT_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_LEFT_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_CENTER_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_RIGHT_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_BOTTOM_LEFT_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_BOTTOM_H); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_BOTTOM_RIGHT_H); - nine_box_prelight.reset(new NineBox(images)); - - i = 0; - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_TOP_LEFT_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_TOP_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_TOP_RIGHT_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_LEFT_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_CENTER_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_RIGHT_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_BOTTOM_LEFT_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_BOTTOM_P); - images[i++] = rb.GetPixbufNamed(IDR_TEXTBUTTON_BOTTOM_RIGHT_P); - nine_box_active.reset(new NineBox(images)); + g_nine_box_prelight = new NineBox( + IDR_TEXTBUTTON_TOP_LEFT_H, + IDR_TEXTBUTTON_TOP_H, + IDR_TEXTBUTTON_TOP_RIGHT_H, + IDR_TEXTBUTTON_LEFT_H, + IDR_TEXTBUTTON_CENTER_H, + IDR_TEXTBUTTON_RIGHT_H, + IDR_TEXTBUTTON_BOTTOM_LEFT_H, + IDR_TEXTBUTTON_BOTTOM_H, + IDR_TEXTBUTTON_BOTTOM_RIGHT_H); + + g_nine_box_active = new NineBox( + IDR_TEXTBUTTON_TOP_LEFT_P, + IDR_TEXTBUTTON_TOP_P, + IDR_TEXTBUTTON_TOP_RIGHT_P, + IDR_TEXTBUTTON_LEFT_P, + IDR_TEXTBUTTON_CENTER_P, + IDR_TEXTBUTTON_RIGHT_P, + IDR_TEXTBUTTON_BOTTOM_LEFT_P, + IDR_TEXTBUTTON_BOTTOM_P, + IDR_TEXTBUTTON_BOTTOM_RIGHT_P); } static void gtk_chrome_button_init(GtkChromeButton* button) { gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); } -static gboolean gtk_chrome_button_expose (GtkWidget *widget, - GdkEventExpose *event) { +static gboolean gtk_chrome_button_expose(GtkWidget* widget, + GdkEventExpose* event) { NineBox* nine_box = NULL; if (GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT) - nine_box = nine_box_prelight.get(); + nine_box = g_nine_box_prelight; else if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) - nine_box = nine_box_active.get(); + nine_box = g_nine_box_active; // Only draw theme graphics if we have some. if (nine_box) |