| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/bubble/bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" | 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 G_CALLBACK(OnButtonPressThunk), this); | 179 G_CALLBACK(OnButtonPressThunk), this); |
| 180 signals_.Connect(window_, "destroy", G_CALLBACK(OnDestroyThunk), this); | 180 signals_.Connect(window_, "destroy", G_CALLBACK(OnDestroyThunk), this); |
| 181 signals_.Connect(window_, "hide", G_CALLBACK(OnHideThunk), this); | 181 signals_.Connect(window_, "hide", G_CALLBACK(OnHideThunk), this); |
| 182 | 182 |
| 183 // If the toplevel window is being used as the anchor, then the signals below | 183 // If the toplevel window is being used as the anchor, then the signals below |
| 184 // are enough to keep us positioned correctly. | 184 // are enough to keep us positioned correctly. |
| 185 if (anchor_widget_ != toplevel_window_) { | 185 if (anchor_widget_ != toplevel_window_) { |
| 186 signals_.Connect(anchor_widget_, "size-allocate", | 186 signals_.Connect(anchor_widget_, "size-allocate", |
| 187 G_CALLBACK(OnAnchorAllocateThunk), this); | 187 G_CALLBACK(OnAnchorAllocateThunk), this); |
| 188 signals_.Connect(anchor_widget_, "destroy", | 188 signals_.Connect(anchor_widget_, "destroy", |
| 189 G_CALLBACK(gtk_widget_destroyed), &anchor_widget_); | 189 G_CALLBACK(OnAnchorDestroyThunk), this); |
| 190 } | 190 } |
| 191 | 191 |
| 192 signals_.Connect(toplevel_window_, "configure-event", | 192 signals_.Connect(toplevel_window_, "configure-event", |
| 193 G_CALLBACK(OnToplevelConfigureThunk), this); | 193 G_CALLBACK(OnToplevelConfigureThunk), this); |
| 194 signals_.Connect(toplevel_window_, "unmap-event", | 194 signals_.Connect(toplevel_window_, "unmap-event", |
| 195 G_CALLBACK(OnToplevelUnmapThunk), this); | 195 G_CALLBACK(OnToplevelUnmapThunk), this); |
| 196 // Set |toplevel_window_| to NULL if it gets destroyed. | 196 signals_.Connect(window_, "destroy", |
| 197 signals_.Connect(toplevel_window_, "destroy", | 197 G_CALLBACK(OnToplevelDestroyThunk), this); |
| 198 G_CALLBACK(gtk_widget_destroyed), &toplevel_window_); | |
| 199 | 198 |
| 200 gtk_widget_show_all(window_); | 199 gtk_widget_show_all(window_); |
| 201 | 200 |
| 202 if (grab_input_) | 201 if (grab_input_) |
| 203 gtk_grab_add(window_); | 202 gtk_grab_add(window_); |
| 204 GrabPointerAndKeyboard(); | 203 GrabPointerAndKeyboard(); |
| 205 | 204 |
| 206 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 205 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 207 content::Source<ThemeService>(theme_service_)); | 206 content::Source<ThemeService>(theme_service_)); |
| 208 theme_service_->InitThemesFor(this); | 207 theme_service_->InitThemesFor(this); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { | 660 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { |
| 662 Close(); | 661 Close(); |
| 663 return FALSE; | 662 return FALSE; |
| 664 } | 663 } |
| 665 | 664 |
| 666 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, | 665 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, |
| 667 GtkAllocation* allocation) { | 666 GtkAllocation* allocation) { |
| 668 if (!UpdateArrowLocation(false)) | 667 if (!UpdateArrowLocation(false)) |
| 669 MoveWindow(); | 668 MoveWindow(); |
| 670 } | 669 } |
| 670 |
| 671 void BubbleGtk::OnAnchorDestroy(GtkWidget* widget) { |
| 672 anchor_widget_ = NULL; |
| 673 Close(); |
| 674 // |this| is deleted. |
| 675 } |
| 676 |
| 677 void BubbleGtk::OnToplevelDestroy(GtkWidget* widget) { |
| 678 toplevel_window_ = NULL; |
| 679 Close(); |
| 680 // |this| is deleted. |
| 681 } |
| OLD | NEW |