summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/tabs
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 17:02:17 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 17:02:17 +0000
commit640df92a452a54e7ee28d245e07a143b90961ea8 (patch)
treee01a5ae2f951a5cc0e312172af82096ea9c5ea99 /chrome/browser/gtk/tabs
parentd4852bd8928321b4857d480e06c28893ec6b1afb (diff)
downloadchromium_src-640df92a452a54e7ee28d245e07a143b90961ea8.zip
chromium_src-640df92a452a54e7ee28d245e07a143b90961ea8.tar.gz
chromium_src-640df92a452a54e7ee28d245e07a143b90961ea8.tar.bz2
GTK: More signal macro usage.
BUG=none TEST=none Review URL: http://codereview.chromium.org/2345002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/tabs')
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.cc72
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.h18
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc61
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h23
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.cc106
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.h37
6 files changed, 135 insertions, 182 deletions
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc
index 3ca4688..bda8d62 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_gtk.cc
@@ -146,13 +146,13 @@ TabGtk::TabGtk(TabDelegate* delegate)
event_box_ = gtk_event_box_new();
gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), FALSE);
g_signal_connect(event_box_, "button-press-event",
- G_CALLBACK(OnButtonPressEvent), this);
+ G_CALLBACK(OnButtonPressEventThunk), this);
g_signal_connect(event_box_, "button-release-event",
- G_CALLBACK(OnButtonReleaseEvent), this);
+ G_CALLBACK(OnButtonReleaseEventThunk), this);
g_signal_connect(event_box_, "enter-notify-event",
- G_CALLBACK(OnEnterNotifyEvent), this);
+ G_CALLBACK(OnEnterNotifyEventThunk), this);
g_signal_connect(event_box_, "leave-notify-event",
- G_CALLBACK(OnLeaveNotifyEvent), this);
+ G_CALLBACK(OnLeaveNotifyEventThunk), this);
gtk_widget_add_events(event_box_,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
@@ -178,44 +178,41 @@ TabGtk::~TabGtk() {
}
}
-// static
-gboolean TabGtk::OnButtonPressEvent(GtkWidget* widget, GdkEventButton* event,
- TabGtk* tab) {
+gboolean TabGtk::OnButtonPressEvent(GtkWidget* widget, GdkEventButton* event) {
// Every button press ensures either a button-release-event or a drag-fail
// signal for |widget|.
if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
// Store whether or not we were selected just now... we only want to be
// able to drag foreground tabs, so we don't start dragging the tab if
// it was in the background.
- bool just_selected = !tab->IsSelected();
+ bool just_selected = !IsSelected();
if (just_selected) {
- tab->delegate_->SelectTab(tab);
+ delegate_->SelectTab(this);
}
// Hook into the message loop to handle dragging.
- tab->observer_.reset(new TabGtkObserverHelper(tab));
+ observer_.reset(new TabGtkObserverHelper(this));
// Store the button press event, used to initiate a drag.
- tab->last_mouse_down_ = gdk_event_copy(reinterpret_cast<GdkEvent*>(event));
+ last_mouse_down_ = gdk_event_copy(reinterpret_cast<GdkEvent*>(event));
} else if (event->button == 3) {
// Only show the context menu if the left mouse button isn't down (i.e.,
// the user might want to drag instead).
- if (!tab->last_mouse_down_)
- tab->ShowContextMenu();
+ if (!last_mouse_down_)
+ ShowContextMenu();
}
return TRUE;
}
-// static
-gboolean TabGtk::OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event,
- TabGtk* tab) {
+gboolean TabGtk::OnButtonReleaseEvent(GtkWidget* widget,
+ GdkEventButton* event) {
if (event->button == 1) {
- tab->observer_.reset();
+ observer_.reset();
- if (tab->last_mouse_down_) {
- gdk_event_free(tab->last_mouse_down_);
- tab->last_mouse_down_ = NULL;
+ if (last_mouse_down_) {
+ gdk_event_free(last_mouse_down_);
+ last_mouse_down_ = NULL;
}
}
@@ -229,43 +226,38 @@ gboolean TabGtk::OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event,
// moved the mouse yet, a drag hasn't started yet. In that case, clean up
// some state before closing the tab to avoid a crash. Once the drag has
// started, we don't get the middle mouse click here.
- if (tab->last_mouse_down_) {
- DCHECK(!tab->drag_widget_);
- tab->observer_.reset();
- gdk_event_free(tab->last_mouse_down_);
- tab->last_mouse_down_ = NULL;
+ if (last_mouse_down_) {
+ DCHECK(!drag_widget_);
+ observer_.reset();
+ gdk_event_free(last_mouse_down_);
+ last_mouse_down_ = NULL;
}
- tab->delegate_->CloseTab(tab);
+ delegate_->CloseTab(this);
}
return TRUE;
}
-// static
gboolean TabGtk::OnDragFailed(GtkWidget* widget, GdkDragContext* context,
- GtkDragResult result,
- TabGtk* tab) {
+ GtkDragResult result) {
bool canceled = (result == GTK_DRAG_RESULT_USER_CANCELLED);
- tab->EndDrag(canceled);
+ EndDrag(canceled);
return TRUE;
}
-// static
-gboolean TabGtk::OnDragButtonReleased(GtkWidget* widget, GdkEventButton* button,
- TabGtk* tab) {
+gboolean TabGtk::OnDragButtonReleased(GtkWidget* widget,
+ GdkEventButton* button) {
// We always get this event when gtk is releasing the grab and ending the
// drag. However, if the user ended the drag with space or enter, we don't
// get a follow up event to tell us the drag has finished (either a
// drag-failed or a drag-end). So we post a task to manually end the drag.
// If GTK+ does send the drag-failed or drag-end event, we cancel the task.
MessageLoop::current()->PostTask(FROM_HERE,
- tab->drag_end_factory_.NewRunnableMethod(&TabGtk::EndDrag, false));
+ drag_end_factory_.NewRunnableMethod(&TabGtk::EndDrag, false));
return TRUE;
}
-// static
-void TabGtk::OnDragBegin(GtkWidget* widget, GdkDragContext* context,
- TabGtk* tab) {
+void TabGtk::OnDragBegin(GtkWidget* widget, GdkDragContext* context) {
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0);
g_object_unref(pixbuf);
@@ -368,11 +360,11 @@ void TabGtk::CreateDragWidget() {
DCHECK(!drag_widget_);
drag_widget_ = gtk_invisible_new();
g_signal_connect(drag_widget_, "drag-failed",
- G_CALLBACK(OnDragFailed), this);
+ G_CALLBACK(OnDragFailedThunk), this);
g_signal_connect(drag_widget_, "button-release-event",
- G_CALLBACK(OnDragButtonReleased), this);
+ G_CALLBACK(OnDragButtonReleasedThunk), this);
g_signal_connect_after(drag_widget_, "drag-begin",
- G_CALLBACK(OnDragBegin), this);
+ G_CALLBACK(OnDragBeginThunk), this);
}
void TabGtk::DestroyDragWidget() {
diff --git a/chrome/browser/gtk/tabs/tab_gtk.h b/chrome/browser/gtk/tabs/tab_gtk.h
index a2614e1..8bd5f5a 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_gtk.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_GTK_TABS_TAB_GTK_H_
#define CHROME_BROWSER_GTK_TABS_TAB_GTK_H_
+#include "app/gtk_signal.h"
#include "app/theme_provider.h"
#include "base/basictypes.h"
#include "base/message_loop.h"
@@ -113,31 +114,26 @@ class TabGtk : public TabRendererGtk,
virtual void DidProcessEvent(GdkEvent* event);
// button-press-event handler that handles mouse clicks.
- static gboolean OnButtonPressEvent(GtkWidget* widget, GdkEventButton* event,
- TabGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabGtk, gboolean, OnButtonPressEvent, GdkEventButton*);
// button-release-event handler that handles mouse click releases.
- static gboolean OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event,
- TabGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabGtk, gboolean, OnButtonReleaseEvent, GdkEventButton*);
// drag-begin is emitted when the drag is started. We connect so that we can
// set the drag icon to a transparent pixbuf.
- static void OnDragBegin(GtkWidget* widget, GdkDragContext* context,
- TabGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabGtk, void, OnDragBegin, GdkDragContext*);
// drag-failed is emitted when the drag is finished. In our case the signal
// does not imply failure as we don't use the drag-n-drop API to transfer drop
// data.
- static gboolean OnDragFailed(GtkWidget* widget, GdkDragContext* context,
- GtkDragResult result, TabGtk* tab);
+ CHROMEGTK_CALLBACK_2(TabGtk, gboolean, OnDragFailed, GdkDragContext*,
+ GtkDragResult);
// When a drag is ending, a fake button release event is passed to the drag
// widget to fake letting go of the mouse button. We need a callback for
// this event because it is the only way to catch drag end events when the
// user presses space or return.
- static gboolean OnDragButtonReleased(GtkWidget* widget,
- GdkEventButton* event,
- TabGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabGtk, gboolean, OnDragButtonReleased, GdkEventButton*);
// Shows the context menu.
void ShowContextMenu();
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index aeca6ae..df16d83 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -252,9 +252,9 @@ TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider)
tab_.Own(gtk_fixed_new());
gtk_widget_set_app_paintable(tab_.get(), TRUE);
g_signal_connect(tab_.get(), "expose-event",
- G_CALLBACK(OnExposeEvent), this);
+ G_CALLBACK(OnExposeEventThunk), this);
g_signal_connect(tab_.get(), "size-allocate",
- G_CALLBACK(OnSizeAllocate), this);
+ G_CALLBACK(OnSizeAllocateThunk), this);
close_button_.reset(MakeCloseButton());
gtk_widget_show(tab_.get());
@@ -972,13 +972,13 @@ CustomDrawButton* TabRendererGtk::MakeCloseButton() {
l10n_util::GetStringUTF8(IDS_TOOLTIP_CLOSE_TAB).c_str());
g_signal_connect(button->widget(), "clicked",
- G_CALLBACK(OnCloseButtonClicked), this);
+ G_CALLBACK(OnCloseButtonClickedThunk), this);
g_signal_connect(button->widget(), "button-release-event",
- G_CALLBACK(OnCloseButtonMouseRelease), this);
+ G_CALLBACK(OnCloseButtonMouseReleaseThunk), this);
g_signal_connect(button->widget(), "enter-notify-event",
- G_CALLBACK(OnEnterNotifyEvent), this);
+ G_CALLBACK(OnEnterNotifyEventThunk), this);
g_signal_connect(button->widget(), "leave-notify-event",
- G_CALLBACK(OnLeaveNotifyEvent), this);
+ G_CALLBACK(OnLeaveNotifyEventThunk), this);
GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS);
gtk_fixed_put(GTK_FIXED(tab_.get()), button->widget(), 0, 0);
@@ -998,64 +998,53 @@ void TabRendererGtk::CloseButtonClicked() {
// Nothing to do.
}
-// static
-void TabRendererGtk::OnCloseButtonClicked(GtkWidget* widget,
- TabRendererGtk* tab) {
- tab->CloseButtonClicked();
+void TabRendererGtk::OnCloseButtonClicked(GtkWidget* widget) {
+ CloseButtonClicked();
}
-// static
gboolean TabRendererGtk::OnCloseButtonMouseRelease(GtkWidget* widget,
- GdkEventButton* event,
- TabRendererGtk* tab) {
+ GdkEventButton* event) {
if (event->button == 2) {
- tab->CloseButtonClicked();
+ CloseButtonClicked();
return TRUE;
}
return FALSE;
}
-// static
-gboolean TabRendererGtk::OnExposeEvent(GtkWidget* widget, GdkEventExpose* event,
- TabRendererGtk* tab) {
- tab->PaintTab(event);
- gtk_container_propagate_expose(GTK_CONTAINER(tab->tab_.get()),
- tab->close_button_->widget(), event);
+gboolean TabRendererGtk::OnExposeEvent(GtkWidget* widget,
+ GdkEventExpose* event) {
+ PaintTab(event);
+ gtk_container_propagate_expose(GTK_CONTAINER(tab_.get()),
+ close_button_->widget(), event);
return TRUE;
}
-// static
void TabRendererGtk::OnSizeAllocate(GtkWidget* widget,
- GtkAllocation* allocation,
- TabRendererGtk* tab) {
+ GtkAllocation* allocation) {
gfx::Rect bounds = gfx::Rect(allocation->x, allocation->y,
allocation->width, allocation->height);
// Nothing to do if the bounds are the same. If we don't catch this, we'll
// get an infinite loop of size-allocate signals.
- if (tab->bounds_ == bounds)
+ if (bounds_ == bounds)
return;
- tab->bounds_ = bounds;
- tab->Layout();
+ bounds_ = bounds;
+ Layout();
}
-// static
gboolean TabRendererGtk::OnEnterNotifyEvent(GtkWidget* widget,
- GdkEventCrossing* event,
- TabRendererGtk* tab) {
- tab->hover_animation_->SetTweenType(Tween::EASE_OUT);
- tab->hover_animation_->Show();
+ GdkEventCrossing* event) {
+ hover_animation_->SetTweenType(Tween::EASE_OUT);
+ hover_animation_->Show();
return FALSE;
}
-// static
gboolean TabRendererGtk::OnLeaveNotifyEvent(GtkWidget* widget,
- GdkEventCrossing* event,
- TabRendererGtk* tab) {
- tab->hover_animation_->SetTweenType(Tween::EASE_IN);
- tab->hover_animation_->Hide();
+ GdkEventCrossing* event) {
+ hover_animation_->SetTweenType(Tween::EASE_IN);
+ hover_animation_->Hide();
return FALSE;
}
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index 912b329..e666506 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -9,6 +9,7 @@
#include <map>
#include "app/animation.h"
+#include "app/gtk_signal.h"
#include "app/slide_animation.h"
#include "base/basictypes.h"
#include "base/string16.h"
@@ -222,12 +223,12 @@ class TabRendererGtk : public AnimationDelegate,
std::wstring GetTitle() const;
// enter-notify-event handler that signals when the mouse enters the tab.
- static gboolean OnEnterNotifyEvent(GtkWidget* widget, GdkEventCrossing* event,
- TabRendererGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnEnterNotifyEvent,
+ GdkEventCrossing*);
// leave-notify-event handler that signals when the mouse enters the tab.
- static gboolean OnLeaveNotifyEvent(GtkWidget* widget, GdkEventCrossing* event,
- TabRendererGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnLeaveNotifyEvent,
+ GdkEventCrossing*);
private:
class FavIconCrashAnimation;
@@ -350,20 +351,18 @@ class TabRendererGtk : public AnimationDelegate,
double GetThrobValue();
// Handles the clicked signal for the close button.
- static void OnCloseButtonClicked(GtkWidget* widget, TabRendererGtk* tab);
+ CHROMEGTK_CALLBACK_0(TabRendererGtk, void, OnCloseButtonClicked);
// Handles middle clicking the close button.
- static gboolean OnCloseButtonMouseRelease(GtkWidget* widget,
- GdkEventButton* event,
- TabRendererGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnCloseButtonMouseRelease,
+ GdkEventButton*);
// expose-event handler that redraws the tab.
- static gboolean OnExposeEvent(GtkWidget* widget, GdkEventExpose* event,
- TabRendererGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnExposeEvent,
+ GdkEventExpose*);
// size-allocate handler used to update the current bounds of the tab.
- static void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation,
- TabRendererGtk* tab);
+ CHROMEGTK_CALLBACK_1(TabRendererGtk, void, OnSizeAllocate, GtkAllocation*);
// TODO(jhawkins): Move to TabResources.
static void InitResources();
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index 996ebd1..9c4019e 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -737,17 +737,17 @@ void TabStripGtk::Init() {
gtk_dnd_util::SetDestTargetList(tabstrip_.get(), targets);
g_signal_connect(tabstrip_.get(), "expose-event",
- G_CALLBACK(OnExpose), this);
+ G_CALLBACK(OnExposeThunk), this);
g_signal_connect(tabstrip_.get(), "size-allocate",
- G_CALLBACK(OnSizeAllocate), this);
+ G_CALLBACK(OnSizeAllocateThunk), this);
g_signal_connect(tabstrip_.get(), "drag-motion",
- G_CALLBACK(OnDragMotion), this);
+ G_CALLBACK(OnDragMotionThunk), this);
g_signal_connect(tabstrip_.get(), "drag-drop",
- G_CALLBACK(OnDragDrop), this);
+ G_CALLBACK(OnDragDropThunk), this);
g_signal_connect(tabstrip_.get(), "drag-leave",
- G_CALLBACK(OnDragLeave), this);
+ G_CALLBACK(OnDragLeaveThunk), this);
g_signal_connect(tabstrip_.get(), "drag-data-received",
- G_CALLBACK(OnDragDataReceived), this);
+ G_CALLBACK(OnDragDataReceivedThunk), this);
newtab_button_.reset(MakeNewTabButton());
@@ -1644,18 +1644,16 @@ TabStripGtk::DropInfo::~DropInfo() {
DestroyContainer();
}
-// static
gboolean TabStripGtk::DropInfo::OnExposeEvent(GtkWidget* widget,
- GdkEventExpose* event,
- DropInfo* drop_info) {
+ GdkEventExpose* event) {
if (gtk_util::IsScreenComposited()) {
- drop_info->SetContainerTransparency();
+ SetContainerTransparency();
} else {
- drop_info->SetContainerShapeMask();
+ SetContainerShapeMask();
}
- gdk_pixbuf_render_to_drawable(drop_info->drop_arrow,
- drop_info->container->window,
+ gdk_pixbuf_render_to_drawable(drop_arrow,
+ container->window,
0, 0, 0,
0, 0,
drop_indicator_width,
@@ -1726,7 +1724,7 @@ void TabStripGtk::DropInfo::CreateContainer() {
SetContainerColorMap();
gtk_widget_set_app_paintable(container, TRUE);
g_signal_connect(container, "expose-event",
- G_CALLBACK(OnExposeEvent), this);
+ G_CALLBACK(OnExposeEventThunk), this);
gtk_widget_add_events(container, GDK_STRUCTURE_MASK);
gtk_window_move(GTK_WINDOW(container), 0, 0);
gtk_window_resize(GTK_WINDOW(container),
@@ -1827,9 +1825,7 @@ void TabStripGtk::FinishAnimation(TabStripGtk::TabAnimation* animation,
Layout();
}
-// static
-gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
- TabStripGtk* tabstrip) {
+gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) {
if (gdk_region_empty(event->region))
return TRUE;
@@ -1840,9 +1836,9 @@ gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
gdk_region_get_rectangles(event->region, &rects, &num_rects);
qsort(rects, num_rects, sizeof(GdkRectangle), CompareGdkRectangles);
std::vector<int> tabs_to_repaint;
- if (!tabstrip->IsDragSessionActive() &&
- tabstrip->CanPaintOnlyFavIcons(rects, num_rects, &tabs_to_repaint)) {
- tabstrip->PaintOnlyFavIcons(event, tabs_to_repaint);
+ if (!IsDragSessionActive() &&
+ CanPaintOnlyFavIcons(rects, num_rects, &tabs_to_repaint)) {
+ PaintOnlyFavIcons(event, tabs_to_repaint);
g_free(rects);
return TRUE;
}
@@ -1856,24 +1852,24 @@ gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
// could change the damage rect to just contain the tabs + the new tab button.
event->area.x = 0;
event->area.y = 0;
- event->area.width = tabstrip->bounds_.width();
- event->area.height = tabstrip->bounds_.height();
+ event->area.width = bounds_.width();
+ event->area.height = bounds_.height();
gdk_region_union_with_rect(event->region, &event->area);
// Paint the New Tab button.
- gtk_container_propagate_expose(GTK_CONTAINER(tabstrip->tabstrip_.get()),
- tabstrip->newtab_button_->widget(), event);
+ gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()),
+ newtab_button_->widget(), event);
// Paint the tabs in reverse order, so they stack to the left.
TabGtk* selected_tab = NULL;
- int tab_count = tabstrip->GetTabCount();
+ int tab_count = GetTabCount();
for (int i = tab_count - 1; i >= 0; --i) {
- TabGtk* tab = tabstrip->GetTabAt(i);
+ TabGtk* tab = GetTabAt(i);
// We must ask the _Tab's_ model, not ourselves, because in some situations
// the model will be different to this object, e.g. when a Tab is being
// removed after its TabContents has been destroyed.
if (!tab->IsSelected()) {
- gtk_container_propagate_expose(GTK_CONTAINER(tabstrip->tabstrip_.get()),
+ gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()),
tab->widget(), event);
} else {
selected_tab = tab;
@@ -1882,29 +1878,27 @@ gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
// Paint the selected tab last, so it overlaps all the others.
if (selected_tab) {
- gtk_container_propagate_expose(GTK_CONTAINER(tabstrip->tabstrip_.get()),
+ gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()),
selected_tab->widget(), event);
}
return TRUE;
}
-// static
-void TabStripGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation,
- TabStripGtk* tabstrip) {
+void TabStripGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) {
gfx::Rect bounds = gfx::Rect(allocation->x, allocation->y,
allocation->width, allocation->height);
// Nothing to do if the bounds are the same. If we don't catch this, we'll
// get an infinite loop of size-allocate signals.
- if (tabstrip->bounds_ == bounds)
+ if (bounds_ == bounds)
return;
- tabstrip->SetBounds(bounds);
+ SetBounds(bounds);
// No tabs, nothing to layout. This happens when a browser window is created
// and shown before tabs are added (as in a popup window).
- if (tabstrip->GetTabCount() == 0)
+ if (GetTabCount() == 0)
return;
// Do a regular layout on the first configure-event so we don't animate
@@ -1912,25 +1906,21 @@ void TabStripGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation,
// TODO(jhawkins): Windows resizes the layout tabs continuously during
// a resize. I need to investigate which signal to watch in order to
// reproduce this behavior.
- if (tabstrip->GetTabCount() == 1)
- tabstrip->Layout();
+ if (GetTabCount() == 1)
+ Layout();
else
- tabstrip->ResizeLayoutTabs();
+ ResizeLayoutTabs();
}
-// static
gboolean TabStripGtk::OnDragMotion(GtkWidget* widget, GdkDragContext* context,
- gint x, gint y, guint time,
- TabStripGtk* tabstrip) {
- tabstrip->UpdateDropIndex(context, x, y);
+ gint x, gint y, guint time) {
+ UpdateDropIndex(context, x, y);
return TRUE;
}
-// static
gboolean TabStripGtk::OnDragDrop(GtkWidget* widget, GdkDragContext* context,
- gint x, gint y, guint time,
- TabStripGtk* tabstrip) {
- if (!tabstrip->drop_info_.get())
+ gint x, gint y, guint time) {
+ if (!drop_info_.get())
return FALSE;
GdkAtom target = gtk_drag_dest_find_target(widget, context, NULL);
@@ -1942,34 +1932,30 @@ gboolean TabStripGtk::OnDragDrop(GtkWidget* widget, GdkDragContext* context,
return TRUE;
}
-// static
gboolean TabStripGtk::OnDragLeave(GtkWidget* widget, GdkDragContext* context,
- guint time, TabStripGtk* tabstrip) {
+ guint time) {
// Destroy the drop indicator.
- tabstrip->drop_info_->DestroyContainer();
+ drop_info_->DestroyContainer();
return FALSE;
}
-// static
gboolean TabStripGtk::OnDragDataReceived(GtkWidget* widget,
GdkDragContext* context,
gint x, gint y,
GtkSelectionData* data,
- guint info, guint time,
- TabStripGtk* tabstrip) {
+ guint info, guint time) {
bool success = false;
if (info == gtk_dnd_util::TEXT_URI_LIST ||
info == gtk_dnd_util::NETSCAPE_URL) {
- success = tabstrip->CompleteDrop(data->data);
+ success = CompleteDrop(data->data);
}
gtk_drag_finish(context, success, success, time);
return TRUE;
}
-// static
-void TabStripGtk::OnNewTabClicked(GtkWidget* widget, TabStripGtk* tabstrip) {
+void TabStripGtk::OnNewTabClicked(GtkWidget* widget) {
GdkEvent* event = gtk_get_current_event();
DCHECK_EQ(event->type, GDK_BUTTON_RELEASE);
int mouse_button = event->button.button;
@@ -1977,24 +1963,24 @@ void TabStripGtk::OnNewTabClicked(GtkWidget* widget, TabStripGtk* tabstrip) {
switch (mouse_button) {
case 1:
- tabstrip->model_->delegate()->AddBlankTab(true);
+ model_->delegate()->AddBlankTab(true);
break;
case 2: {
// On middle-click, try to parse the PRIMARY selection as a URL and load
// it instead of creating a blank page.
GURL url;
- if (!gtk_util::URLFromPrimarySelection(tabstrip->model_->profile(), &url))
+ if (!gtk_util::URLFromPrimarySelection(model_->profile(), &url))
return;
TabContents* contents =
- tabstrip->model_->delegate()->CreateTabContentsForURL(
+ model_->delegate()->CreateTabContentsForURL(
url,
GURL(), // referrer
- tabstrip->model_->profile(),
+ model_->profile(),
PageTransition::TYPED,
false, // defer_load
NULL); // instance
- tabstrip->model_->AddTabContents(
+ model_->AddTabContents(
contents,
-1, // index
false, // force_index
@@ -2048,7 +2034,7 @@ CustomDrawButton* TabStripGtk::MakeNewTabButton() {
// Let the middle mouse button initiate clicks as well.
gtk_util::SetButtonTriggersNavigation(button->widget());
g_signal_connect(button->widget(), "clicked",
- G_CALLBACK(OnNewTabClicked), this);
+ G_CALLBACK(OnNewTabClickedThunk), this);
GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS);
gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0);
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h
index 6a22a8b..7fe8c60 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h
@@ -8,6 +8,7 @@
#include <gtk/gtk.h>
#include <vector>
+#include "app/gtk_signal.h"
#include "base/basictypes.h"
#include "base/task.h"
#include "base/message_loop.h"
@@ -176,8 +177,7 @@ class TabStripGtk : public TabStripModelObserver,
// TODO(jhawkins): Factor out this code into a TransparentContainer class.
// expose-event handler that redraws the drop indicator.
- static gboolean OnExposeEvent(GtkWidget* widget, GdkEventExpose* event,
- DropInfo* drop_info);
+ CHROMEGTK_CALLBACK_1(DropInfo, gboolean, OnExposeEvent, GdkEventExpose*);
// Sets the color map of the container window to allow the window to be
// transparent.
@@ -222,41 +222,32 @@ class TabStripGtk : public TabStripModelObserver,
};
// expose-event handler that redraws the tabstrip
- static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e,
- TabStripGtk* tabstrip);
+ CHROMEGTK_CALLBACK_1(TabStripGtk, gboolean, OnExpose, GdkEventExpose*);
// size-allocate handler that gets the new bounds of the tabstrip.
- static void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation,
- TabStripGtk* tabstrip);
+ CHROMEGTK_CALLBACK_1(TabStripGtk, void, OnSizeAllocate, GtkAllocation*);
// drag-motion handler that is signaled when the user performs a drag in the
// tabstrip bounds.
- static gboolean OnDragMotion(GtkWidget* widget, GdkDragContext* context,
- gint x, gint y, guint time,
- TabStripGtk* tabstrip);
+ CHROMEGTK_CALLBACK_4(TabStripGtk, gboolean, OnDragMotion, GdkDragContext*,
+ gint, gint, guint);
// drag-drop handler that is notified when the user finishes a drag.
- static gboolean OnDragDrop(GtkWidget* widget, GdkDragContext* context,
- gint x, gint y, guint time,
- TabStripGtk* tabstrip);
+ CHROMEGTK_CALLBACK_4(TabStripGtk, gboolean, OnDragDrop, GdkDragContext*,
+ gint, gint, guint);
// drag-leave handler that is signaled when the mouse leaves the tabstrip
// during a drag.
- static gboolean OnDragLeave(GtkWidget* widget, GdkDragContext* context,
- guint time, TabStripGtk* tabstrip);
-
- // drag-failed handler that is signaled when the drag fails or is canceled.
- static gboolean OnDragFailed(GtkWidget* widget, GdkDragContext* context,
- GtkDragResult result, TabStripGtk* tabstrip);
+ CHROMEGTK_CALLBACK_2(TabStripGtk, gboolean, OnDragLeave, GdkDragContext*,
+ guint);
// drag-data-received handler that receives the data associated with the drag.
- static gboolean OnDragDataReceived(GtkWidget* widget, GdkDragContext* context,
- gint x, gint y, GtkSelectionData* data,
- guint info, guint time,
- TabStripGtk* tabstrip);
+ CHROMEGTK_CALLBACK_6(TabStripGtk, gboolean, OnDragDataReceived,
+ GdkDragContext*, gint, gint, GtkSelectionData*,
+ guint, guint);
// Handles the clicked signal from the new tab button.
- static void OnNewTabClicked(GtkWidget* widget, TabStripGtk* tabstrip);
+ CHROMEGTK_CALLBACK_0(TabStripGtk, void, OnNewTabClicked);
// Sets the bounds of the tab and moves the tab widget to those bounds.
void SetTabBounds(TabGtk* tab, const gfx::Rect& bounds);