summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 23:03:14 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 23:03:14 +0000
commitb39b708246bd53c09e4fea01dac923d742c303e0 (patch)
treee127360cb5770501bca3e62a079853708ae52be4
parentbe930259c6ff84c0211298c0cdeecbf5d4863850 (diff)
downloadchromium_src-b39b708246bd53c09e4fea01dac923d742c303e0.zip
chromium_src-b39b708246bd53c09e4fea01dac923d742c303e0.tar.gz
chromium_src-b39b708246bd53c09e4fea01dac923d742c303e0.tar.bz2
Implement and use the -> operator for OwnedWidgetGtk.
Also change dragged_tabs_gtk's container_ to be a OwnedWidgetGtk just to be on the safe side. BUG=none TEST=none Review URL: http://codereview.chromium.org/119221 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17790 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc2
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc2
-rw-r--r--chrome/browser/gtk/custom_button.h10
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc5
-rw-r--r--chrome/browser/gtk/infobar_gtk.cc4
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc2
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc4
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc2
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_gtk.cc30
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_gtk.h4
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc8
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.cc12
-rw-r--r--chrome/common/owned_widget_gtk.h7
13 files changed, 47 insertions, 45 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index fc536eb..8fd2e4e 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -227,7 +227,7 @@ void BookmarkBarGtk::Hide() {
}
int BookmarkBarGtk::GetHeight() {
- return bookmark_hbox_.get()->allocation.height;
+ return bookmark_hbox_->allocation.height;
}
bool BookmarkBarGtk::IsClosing() {
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 8a9fb3d..ef34459 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -354,7 +354,7 @@ gboolean BrowserToolbarGtk::OnToolbarExpose(GtkWidget* widget,
// coordinates for the IDR_THEME_TOOLBAR bitmap relative to the top of the
// tab strip. Since the toolbar's GdkWindow has the same origin as the tab
// strip's GdkWindow, we can just pass 0.
- toolbar->background_ninebox_.get()->RenderTopCenterStrip(cr,
+ toolbar->background_ninebox_->RenderTopCenterStrip(cr,
e->area.x, 0, e->area.width);
cairo_destroy(cr);
diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h
index a3071df..fa6897b 100644
--- a/chrome/browser/gtk/custom_button.h
+++ b/chrome/browser/gtk/custom_button.h
@@ -62,13 +62,13 @@ class CustomDrawButton {
GtkWidget* widget() const { return widget_.get(); }
gfx::Rect bounds() const {
- return gfx::Rect(widget_.get()->allocation.x,
- widget_.get()->allocation.y,
- widget_.get()->allocation.width,
- widget_.get()->allocation.height);
+ return gfx::Rect(widget_->allocation.x,
+ widget_->allocation.y,
+ widget_->allocation.width,
+ widget_->allocation.height);
}
- int width() const { return widget_.get()->allocation.width; }
+ int width() const { return widget_->allocation.width; }
// Set the state to draw. We will paint the widget as if it were in this
// state.
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 22f2b3a..a411cb6 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -327,7 +327,8 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf,
gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_),
0, 0, kDangerousElementPadding, kDangerousElementPadding);
gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_);
- gtk_box_pack_start(GTK_BOX(hbox_.get()), dangerous_prompt_, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox_.get()), dangerous_prompt_, FALSE, FALSE,
+ 0);
gtk_widget_set_app_paintable(dangerous_prompt_, TRUE);
g_signal_connect(dangerous_prompt_, "expose-event",
G_CALLBACK(OnDangerousPromptExpose), this);
@@ -655,7 +656,7 @@ gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button,
void DownloadItemGtk::OnShelfResized(GtkWidget *widget,
GtkAllocation *allocation,
DownloadItemGtk* item) {
- if (item->hbox_.get()->allocation.x + item->hbox_.get()->allocation.width >
+ if (item->hbox_->allocation.x + item->hbox_->allocation.width >
item->bounding_widget_->allocation.x)
gtk_widget_hide(item->hbox_.get());
else
diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc
index fbf6b49..1a7b53f 100644
--- a/chrome/browser/gtk/infobar_gtk.cc
+++ b/chrome/browser/gtk/infobar_gtk.cc
@@ -89,8 +89,8 @@ void InfoBar::AnimateOpen() {
void InfoBar::Open() {
slide_widget_->OpenWithoutAnimation();
- if (border_bin_.get()->window)
- gdk_window_lower(border_bin_.get()->window);
+ if (border_bin_->window)
+ gdk_window_lower(border_bin_->window);
}
void InfoBar::AnimateClose() {
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index beccd08..2ba90f1 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -211,7 +211,7 @@ gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget,
GdkDrawable* drawable = GDK_DRAWABLE(event->window);
GdkGC* gc = gdk_gc_new(drawable);
- GdkRectangle* alloc_rect = &alignment_.get()->allocation;
+ GdkRectangle* alloc_rect = &alignment_->allocation;
// The area outside of our margin, which includes the border.
GdkRectangle inner_rect = {
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc
index 041d6b9..7b377b1 100644
--- a/chrome/browser/gtk/status_bubble_gtk.cc
+++ b/chrome/browser/gtk/status_bubble_gtk.cc
@@ -65,8 +65,8 @@ void StatusBubbleGtk::Show() {
gtk_widget_show_all(container_.get());
- if (container_.get()->window)
- gdk_window_raise(container_.get()->window);
+ if (container_->window)
+ gdk_window_raise(container_->window);
}
void StatusBubbleGtk::Hide() {
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index db61ce9..5092f79 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -410,7 +410,7 @@ void DraggedTabControllerGtk::Detach() {
gfx::Point DraggedTabControllerGtk::ConvertScreenPointToTabStripPoint(
TabStripGtk* tabstrip, const gfx::Point& screen_point) {
gint x, y;
- gdk_window_get_origin(tabstrip->tabstrip_.get()->window, &x, &y);
+ gdk_window_get_origin(tabstrip->tabstrip_->window, &x, &y);
return gfx::Point(screen_point.x() - x, screen_point.y() - y);
}
diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc
index 48413ef..733dcb8 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc
@@ -37,7 +37,8 @@ bool IsScreenComposited() {
DraggedTabGtk::DraggedTabGtk(TabContents* datasource,
const gfx::Point& mouse_tab_offset,
const gfx::Size& contents_size)
- : renderer_(new TabRendererGtk),
+ : container_(gtk_window_new(GTK_WINDOW_POPUP)),
+ renderer_(new TabRendererGtk),
attached_(false),
mouse_tab_offset_(mouse_tab_offset),
attached_tab_size_(TabRendererGtk::GetMinimumSelectedSize()),
@@ -45,18 +46,17 @@ DraggedTabGtk::DraggedTabGtk(TabContents* datasource,
close_animation_(this) {
renderer_->UpdateData(datasource, false);
- container_ = gtk_window_new(GTK_WINDOW_POPUP);
SetContainerColorMap();
- gtk_widget_set_app_paintable(container_, TRUE);
- g_signal_connect(G_OBJECT(container_), "expose-event",
+ gtk_widget_set_app_paintable(container_.get(), TRUE);
+ g_signal_connect(G_OBJECT(container_.get()), "expose-event",
G_CALLBACK(OnExposeEvent), this);
- gtk_widget_add_events(container_, GDK_STRUCTURE_MASK);
- gtk_container_add(GTK_CONTAINER(container_), renderer_->widget());
- gtk_widget_show_all(container_);
+ gtk_widget_add_events(container_.get(), GDK_STRUCTURE_MASK);
+ gtk_container_add(GTK_CONTAINER(container_.get()), renderer_->widget());
+ gtk_widget_show_all(container_.get());
}
DraggedTabGtk::~DraggedTabGtk() {
- gtk_widget_destroy(container_);
+ container_.Destroy();
}
void DraggedTabGtk::MoveTo(const gfx::Point& screen_point) {
@@ -65,7 +65,7 @@ void DraggedTabGtk::MoveTo(const gfx::Point& screen_point) {
int y = screen_point.y() + mouse_tab_offset_.y() -
ScaleValue(mouse_tab_offset_.y());
- gtk_window_move(GTK_WINDOW(container_), x, y);
+ gtk_window_move(GTK_WINDOW(container_.get()), x, y);
}
void DraggedTabGtk::Attach(int selected_width) {
@@ -80,7 +80,7 @@ void DraggedTabGtk::Detach() {
}
void DraggedTabGtk::Update() {
- gtk_widget_queue_draw(container_);
+ gtk_widget_queue_draw(container_.get());
}
void DraggedTabGtk::AnimateToBounds(const gfx::Rect& bounds,
@@ -138,7 +138,7 @@ gfx::Size DraggedTabGtk::GetPreferredSize() {
void DraggedTabGtk::ResizeContainer() {
gfx::Size size = GetPreferredSize();
- gtk_window_resize(GTK_WINDOW(container_),
+ gtk_window_resize(GTK_WINDOW(container_.get()),
ScaleValue(size.width()), ScaleValue(size.height()));
gfx::Rect bounds = renderer_->bounds();
bounds.set_width(ScaleValue(size.width()));
@@ -153,20 +153,20 @@ int DraggedTabGtk::ScaleValue(int value) {
gfx::Rect DraggedTabGtk::bounds() const {
gint x, y, width, height;
- gtk_window_get_position(GTK_WINDOW(container_), &x, &y);
- gtk_window_get_size(GTK_WINDOW(container_), &width, &height);
+ gtk_window_get_position(GTK_WINDOW(container_.get()), &x, &y);
+ gtk_window_get_size(GTK_WINDOW(container_.get()), &width, &height);
return gfx::Rect(x, y, width, height);
}
void DraggedTabGtk::SetContainerColorMap() {
- GdkScreen* screen = gtk_widget_get_screen(container_);
+ GdkScreen* screen = gtk_widget_get_screen(container_.get());
GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
// If rgba is not available, use rgb instead.
if (!colormap)
colormap = gdk_screen_get_rgb_colormap(screen);
- gtk_widget_set_colormap(container_, colormap);
+ gtk_widget_set_colormap(container_.get(), colormap);
}
void DraggedTabGtk::SetContainerTransparency() {
diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.h b/chrome/browser/gtk/tabs/dragged_tab_gtk.h
index fab68e1..039856c 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_gtk.h
+++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.h
@@ -49,7 +49,7 @@ class DraggedTabGtk : public AnimationDelegate {
// to determine where to place the tab in the attached tabstrip.
gfx::Size attached_tab_size() const { return attached_tab_size_; }
- GtkWidget* widget() const { return container_; }
+ GtkWidget* widget() const { return container_.get(); }
private:
// Overridden from AnimationDelegate:
@@ -87,7 +87,7 @@ class DraggedTabGtk : public AnimationDelegate {
DraggedTabGtk* dragged_tab);
// The window that contains the dragged tab or tab contents.
- GtkWidget* container_;
+ OwnedWidgetGtk container_;
// The renderer that paints the dragged tab.
scoped_ptr<TabRendererGtk> renderer_;
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index 87920c3..0e8e873 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -500,11 +500,11 @@ void TabRendererGtk::Layout() {
void TabRendererGtk::MoveCloseButtonWidget() {
if (!close_button_bounds_.IsEmpty()) {
- gtk_fixed_move(GTK_FIXED(tab_.get()), close_button_.get()->widget(),
+ gtk_fixed_move(GTK_FIXED(tab_.get()), close_button_->widget(),
close_button_bounds_.x(), close_button_bounds_.y());
- gtk_widget_show(close_button_.get()->widget());
+ gtk_widget_show(close_button_->widget());
} else {
- gtk_widget_hide(close_button_.get()->widget());
+ gtk_widget_hide(close_button_->widget());
}
}
@@ -700,7 +700,7 @@ gboolean TabRendererGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
TabRendererGtk* tab) {
tab->PaintTab(event);
gtk_container_propagate_expose(GTK_CONTAINER(tab->tab_.get()),
- tab->close_button_.get()->widget(), event);
+ tab->close_button_->widget(), event);
return TRUE;
}
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index 8db7a38..7cbdf67 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -881,10 +881,10 @@ void TabStripGtk::LayoutNewTabButton(double last_tab_right,
// We're shrinking tabs, so we need to anchor the New Tab button to the
// right edge of the TabStrip's bounds, rather than the right edge of the
// right-most Tab, otherwise it'll bounce when animating.
- gtk_fixed_move(GTK_FIXED(tabstrip_.get()), newtab_button_.get()->widget(),
- bounds_.width() - newtab_button_.get()->width(), kNewTabButtonVOffset);
+ gtk_fixed_move(GTK_FIXED(tabstrip_.get()), newtab_button_->widget(),
+ bounds_.width() - newtab_button_->width(), kNewTabButtonVOffset);
} else {
- gtk_fixed_move(GTK_FIXED(tabstrip_.get()), newtab_button_.get()->widget(),
+ gtk_fixed_move(GTK_FIXED(tabstrip_.get()), newtab_button_->widget(),
Round(last_tab_right - kTabHOffset) + kNewTabButtonHOffset,
kNewTabButtonVOffset);
}
@@ -906,11 +906,11 @@ void TabStripGtk::GetDesiredTabWidths(int tab_count,
}
// Determine how much space we can actually allocate to tabs.
- int available_width = tabstrip_.get()->allocation.width;
+ int available_width = tabstrip_->allocation.width;
if (available_width_for_tabs_ < 0) {
available_width = bounds_.width();
available_width -=
- (kNewTabButtonHOffset + newtab_button_.get()->width());
+ (kNewTabButtonHOffset + newtab_button_->width());
} else {
// Interesting corner case: if |available_width_for_tabs_| > the result
// of the calculation in the conditional arm above, the strip is in
@@ -1072,7 +1072,7 @@ gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
// Paint the New Tab button.
gtk_container_propagate_expose(GTK_CONTAINER(tabstrip->tabstrip_.get()),
- tabstrip->newtab_button_.get()->widget(), event);
+ tabstrip->newtab_button_->widget(), event);
// Paint the tabs in reverse order, so they stack to the left.
TabGtk* selected_tab = NULL;
diff --git a/chrome/common/owned_widget_gtk.h b/chrome/common/owned_widget_gtk.h
index 46d3996..72fadd5 100644
--- a/chrome/common/owned_widget_gtk.h
+++ b/chrome/common/owned_widget_gtk.h
@@ -46,8 +46,8 @@
// gtk_destroy_widget(widget); // Ask all code to destroy their references.
// g_object_unref(widget); // Destroy the initial reference we had claimed.
-#ifndef BASE_OWNED_WIDGET_GTK_H_
-#define BASE_OWNED_WIDGET_GTK_H_
+#ifndef CHROME_COMMON_OWNED_WIDGET_GTK_H_
+#define CHROME_COMMON_OWNED_WIDGET_GTK_H_
#include "base/basictypes.h"
@@ -64,6 +64,7 @@ class OwnedWidgetGtk {
// Return the currently owned widget, or NULL if no widget is owned.
GtkWidget* get() const { return widget_; }
+ GtkWidget* operator->() const { return widget_; }
// Takes ownership of a widget, by taking the initial floating reference of
// the GtkWidget. It is expected that Own() is called right after the widget
@@ -85,4 +86,4 @@ class OwnedWidgetGtk {
DISALLOW_COPY_AND_ASSIGN(OwnedWidgetGtk);
};
-#endif // BASE_OWNED_WIDGET_GTK_H_
+#endif // CHROME_COMMON_OWNED_WIDGET_GTK_H_