| 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/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/gfx/gtk_util.h" | 8 #include "base/gfx/gtk_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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 *y += widget->allocation.height; | 285 *y += widget->allocation.height; |
| 286 | 286 |
| 287 bool start_align = | 287 bool start_align = |
| 288 !!g_object_get_data(G_OBJECT(widget), "left-align-popup"); | 288 !!g_object_get_data(G_OBJECT(widget), "left-align-popup"); |
| 289 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 289 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) |
| 290 start_align = !start_align; | 290 start_align = !start_align; |
| 291 | 291 |
| 292 if (!start_align) | 292 if (!start_align) |
| 293 *x += widget->allocation.width - menu_req.width; | 293 *x += widget->allocation.width - menu_req.width; |
| 294 | 294 |
| 295 if (*y + menu_req.height >= screen_rect.height) | 295 // If the menu would run off the bottom of the screen, and there is more |
| 296 // screen space up than down, then pop upwards. |
| 297 if (*y + menu_req.height >= screen_rect.height && |
| 298 *y > screen_rect.height / 2) { |
| 296 *y -= menu_req.height; | 299 *y -= menu_req.height; |
| 300 } |
| 297 | 301 |
| 298 *push_in = FALSE; | 302 *push_in = FALSE; |
| 299 } | 303 } |
| 300 | 304 |
| 301 void MenuGtk::UpdateMenu() { | 305 void MenuGtk::UpdateMenu() { |
| 302 gtk_container_foreach(GTK_CONTAINER(menu_.get()), SetMenuItemInfo, this); | 306 gtk_container_foreach(GTK_CONTAINER(menu_.get()), SetMenuItemInfo, this); |
| 303 } | 307 } |
| 304 | 308 |
| 305 // static | 309 // static |
| 306 void MenuGtk::OnMenuShow(GtkWidget* widget, MenuGtk* menu) { | 310 void MenuGtk::OnMenuShow(GtkWidget* widget, MenuGtk* menu) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 gtk_widget_set_sensitive( | 359 gtk_widget_set_sensitive( |
| 356 widget, menu->delegate_->IsCommandEnabled(id)); | 360 widget, menu->delegate_->IsCommandEnabled(id)); |
| 357 | 361 |
| 358 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); | 362 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); |
| 359 if (submenu) { | 363 if (submenu) { |
| 360 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, | 364 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, |
| 361 userdata); | 365 userdata); |
| 362 } | 366 } |
| 363 } | 367 } |
| 364 } | 368 } |
| OLD | NEW |