| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/gtk/tabs/tab_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include "app/gfx/path.h" | 9 #include "app/gfx/path.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), FALSE); | 114 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), FALSE); |
| 115 gtk_drag_source_set(event_box_, GDK_BUTTON1_MASK, | 115 gtk_drag_source_set(event_box_, GDK_BUTTON1_MASK, |
| 116 NULL, 0, GDK_ACTION_MOVE); | 116 NULL, 0, GDK_ACTION_MOVE); |
| 117 GtkDndUtil::SetSourceTargetListFromCodeMask(event_box_, | 117 GtkDndUtil::SetSourceTargetListFromCodeMask(event_box_, |
| 118 GtkDndUtil::CHROME_TAB); | 118 GtkDndUtil::CHROME_TAB); |
| 119 g_signal_connect(G_OBJECT(event_box_), "button-press-event", | 119 g_signal_connect(G_OBJECT(event_box_), "button-press-event", |
| 120 G_CALLBACK(OnMousePress), this); | 120 G_CALLBACK(OnMousePress), this); |
| 121 g_signal_connect(G_OBJECT(event_box_), "button-release-event", | 121 g_signal_connect(G_OBJECT(event_box_), "button-release-event", |
| 122 G_CALLBACK(OnMouseRelease), this); | 122 G_CALLBACK(OnMouseRelease), this); |
| 123 g_signal_connect(G_OBJECT(event_box_), "enter-notify-event", | 123 g_signal_connect(G_OBJECT(event_box_), "enter-notify-event", |
| 124 G_CALLBACK(OnEnterNotify), this); | 124 G_CALLBACK(OnEnterNotifyEvent), this); |
| 125 g_signal_connect(G_OBJECT(event_box_), "leave-notify-event", | 125 g_signal_connect(G_OBJECT(event_box_), "leave-notify-event", |
| 126 G_CALLBACK(OnLeaveNotify), this); | 126 G_CALLBACK(OnLeaveNotifyEvent), this); |
| 127 g_signal_connect_after(G_OBJECT(event_box_), "drag-begin", | 127 g_signal_connect_after(G_OBJECT(event_box_), "drag-begin", |
| 128 G_CALLBACK(OnDragBegin), this); | 128 G_CALLBACK(OnDragBegin), this); |
| 129 g_signal_connect_after(G_OBJECT(event_box_), "drag-end", | 129 g_signal_connect_after(G_OBJECT(event_box_), "drag-end", |
| 130 G_CALLBACK(OnDragEnd), this); | 130 G_CALLBACK(OnDragEnd), this); |
| 131 g_signal_connect_after(G_OBJECT(event_box_), "drag-failed", | 131 g_signal_connect_after(G_OBJECT(event_box_), "drag-failed", |
| 132 G_CALLBACK(OnDragFailed), this); | 132 G_CALLBACK(OnDragFailed), this); |
| 133 gtk_widget_add_events(event_box_, | 133 gtk_widget_add_events(event_box_, |
| 134 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | 134 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
| 135 GDK_LEAVE_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); | 135 GDK_LEAVE_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); |
| 136 gtk_container_add(GTK_CONTAINER(event_box_), TabRendererGtk::widget()); | 136 gtk_container_add(GTK_CONTAINER(event_box_), TabRendererGtk::widget()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 event->x >= 0 && event->y >= 0 && | 176 event->x >= 0 && event->y >= 0 && |
| 177 event->x < widget->allocation.width && | 177 event->x < widget->allocation.width && |
| 178 event->y < widget->allocation.height) { | 178 event->y < widget->allocation.height) { |
| 179 tab->delegate_->CloseTab(tab); | 179 tab->delegate_->CloseTab(tab); |
| 180 } | 180 } |
| 181 | 181 |
| 182 return TRUE; | 182 return TRUE; |
| 183 } | 183 } |
| 184 | 184 |
| 185 // static | 185 // static |
| 186 gboolean TabGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event, | |
| 187 TabGtk* tab) { | |
| 188 tab->OnMouseEntered(); | |
| 189 return TRUE; | |
| 190 } | |
| 191 | |
| 192 // static | |
| 193 gboolean TabGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, | |
| 194 TabGtk* tab) { | |
| 195 tab->OnMouseExited(); | |
| 196 return TRUE; | |
| 197 } | |
| 198 | |
| 199 // static | |
| 200 void TabGtk::OnDragBegin(GtkWidget* widget, GdkDragContext* context, | 186 void TabGtk::OnDragBegin(GtkWidget* widget, GdkDragContext* context, |
| 201 TabGtk* tab) { | 187 TabGtk* tab) { |
| 202 MessageLoopForUI::current()->AddObserver(tab); | 188 MessageLoopForUI::current()->AddObserver(tab); |
| 203 | 189 |
| 204 int x, y; | 190 int x, y; |
| 205 gdk_window_get_pointer(tab->event_box_->window, &x, &y, NULL); | 191 gdk_window_get_pointer(tab->event_box_->window, &x, &y, NULL); |
| 206 | 192 |
| 207 // Make the mouse coordinate relative to the tab. | 193 // Make the mouse coordinate relative to the tab. |
| 208 x -= tab->bounds().x(); | 194 x -= tab->bounds().x(); |
| 209 y -= tab->bounds().y(); | 195 y -= tab->bounds().y(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 if (!menu_controller_.get()) | 297 if (!menu_controller_.get()) |
| 312 menu_controller_.reset(new ContextMenuController(this)); | 298 menu_controller_.reset(new ContextMenuController(this)); |
| 313 | 299 |
| 314 menu_controller_->RunMenu(); | 300 menu_controller_->RunMenu(); |
| 315 } | 301 } |
| 316 | 302 |
| 317 void TabGtk::ContextMenuClosed() { | 303 void TabGtk::ContextMenuClosed() { |
| 318 delegate()->StopAllHighlighting(); | 304 delegate()->StopAllHighlighting(); |
| 319 menu_controller_.reset(); | 305 menu_controller_.reset(); |
| 320 } | 306 } |
| OLD | NEW |