Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/menu_gtk.h" | 5 #include "chrome/browser/gtk/menu_gtk.h" |
| 6 | 6 |
| 7 #include "app/gfx/gtk_util.h" | 7 #include "app/gfx/gtk_util.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 void MenuGtk::PointMenuPositionFunc(GtkMenu* menu, | 315 void MenuGtk::PointMenuPositionFunc(GtkMenu* menu, |
| 316 int* x, | 316 int* x, |
| 317 int* y, | 317 int* y, |
| 318 gboolean* push_in, | 318 gboolean* push_in, |
| 319 gpointer userdata) { | 319 gpointer userdata) { |
| 320 *push_in = TRUE; | 320 *push_in = TRUE; |
| 321 | 321 |
| 322 gfx::Point* point = reinterpret_cast<gfx::Point*>(userdata); | 322 gfx::Point* point = reinterpret_cast<gfx::Point*>(userdata); |
| 323 *x = point->x(); | 323 *x = point->x(); |
| 324 *y = point->y(); | 324 *y = point->y(); |
| 325 | |
| 326 GtkRequisition menu_req; | |
| 327 gtk_widget_size_request(GTK_WIDGET(menu), &menu_req); | |
| 328 GdkScreen* screen = gdk_screen_get_default(); | |
|
Evan Martin
2009/11/19 00:40:32
Isn't this wrong if the menu's on a different scre
Evan Stade
2009/11/19 00:46:18
oh, like a dual monitor setup? didn't think about
| |
| 329 gint screen_height = gdk_screen_get_height(screen); | |
| 330 | |
| 331 if (*y + menu_req.height > screen_height) | |
| 332 *y -= menu_req.height; | |
| 325 } | 333 } |
| 326 | 334 |
| 327 void MenuGtk::UpdateMenu() { | 335 void MenuGtk::UpdateMenu() { |
| 328 gtk_container_foreach(GTK_CONTAINER(menu_.get()), SetMenuItemInfo, this); | 336 gtk_container_foreach(GTK_CONTAINER(menu_.get()), SetMenuItemInfo, this); |
| 329 } | 337 } |
| 330 | 338 |
| 331 // static | 339 // static |
| 332 void MenuGtk::OnMenuShow(GtkWidget* widget, MenuGtk* menu) { | 340 void MenuGtk::OnMenuShow(GtkWidget* widget, MenuGtk* menu) { |
| 333 MessageLoop::current()->PostTask(FROM_HERE, | 341 MessageLoop::current()->PostTask(FROM_HERE, |
| 334 menu->factory_.NewRunnableMethod(&MenuGtk::UpdateMenu)); | 342 menu->factory_.NewRunnableMethod(&MenuGtk::UpdateMenu)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 gtk_widget_set_sensitive( | 389 gtk_widget_set_sensitive( |
| 382 widget, menu->delegate_->IsCommandEnabled(id)); | 390 widget, menu->delegate_->IsCommandEnabled(id)); |
| 383 | 391 |
| 384 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); | 392 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); |
| 385 if (submenu) { | 393 if (submenu) { |
| 386 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, | 394 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, |
| 387 userdata); | 395 userdata); |
| 388 } | 396 } |
| 389 } | 397 } |
| 390 } | 398 } |
| OLD | NEW |