| 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/browser_titlebar.h" | 5 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 FALSE, 0); | 376 FALSE, 0); |
| 377 // We use the app logo as a placeholder image so the title doesn't jump | 377 // We use the app logo as a placeholder image so the title doesn't jump |
| 378 // around. | 378 // around. |
| 379 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 379 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 380 app_mode_favicon_ = gtk_image_new_from_pixbuf(rb.GetNativeImageNamed( | 380 app_mode_favicon_ = gtk_image_new_from_pixbuf(rb.GetNativeImageNamed( |
| 381 IDR_PRODUCT_LOGO_16, ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf()); | 381 IDR_PRODUCT_LOGO_16, ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf()); |
| 382 g_object_set_data(G_OBJECT(app_mode_favicon_), "left-align-popup", | 382 g_object_set_data(G_OBJECT(app_mode_favicon_), "left-align-popup", |
| 383 reinterpret_cast<void*>(true)); | 383 reinterpret_cast<void*>(true)); |
| 384 gtk_container_add(GTK_CONTAINER(favicon_event_box), app_mode_favicon_); | 384 gtk_container_add(GTK_CONTAINER(favicon_event_box), app_mode_favicon_); |
| 385 | 385 |
| 386 if (IsTypePanel()) { | |
| 387 panel_wrench_button_.reset( | |
| 388 BuildTitlebarButton(IDR_BALLOON_WRENCH, IDR_BALLOON_WRENCH_P, | |
| 389 IDR_BALLOON_WRENCH_H, app_mode_hbox, FALSE, | |
| 390 IDS_PANEL_WINDOW_SETTINGS_BUTTON_TOOLTIP)); | |
| 391 g_signal_connect(panel_wrench_button_->widget(), "button-press-event", | |
| 392 G_CALLBACK(OnPanelSettingsMenuButtonPressedThunk), this); | |
| 393 gtk_widget_set_no_show_all(panel_wrench_button_->widget(), TRUE); | |
| 394 } | |
| 395 | |
| 396 app_mode_title_ = gtk_label_new(NULL); | 386 app_mode_title_ = gtk_label_new(NULL); |
| 397 gtk_label_set_ellipsize(GTK_LABEL(app_mode_title_), PANGO_ELLIPSIZE_END); | 387 gtk_label_set_ellipsize(GTK_LABEL(app_mode_title_), PANGO_ELLIPSIZE_END); |
| 398 gtk_misc_set_alignment(GTK_MISC(app_mode_title_), 0.0, 0.5); | 388 gtk_misc_set_alignment(GTK_MISC(app_mode_title_), 0.0, 0.5); |
| 399 gtk_box_pack_start(GTK_BOX(app_mode_hbox), app_mode_title_, TRUE, TRUE, | 389 gtk_box_pack_start(GTK_BOX(app_mode_hbox), app_mode_title_, TRUE, TRUE, |
| 400 0); | 390 0); |
| 401 | 391 |
| 402 UpdateTitleAndIcon(); | 392 UpdateTitleAndIcon(); |
| 403 } | 393 } |
| 404 | 394 |
| 405 theme_service_ = ThemeServiceGtk::GetFrom( | 395 theme_service_ = ThemeServiceGtk::GetFrom( |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 | 908 |
| 919 gboolean BrowserTitlebar::OnFaviconMenuButtonPressed(GtkWidget* widget, | 909 gboolean BrowserTitlebar::OnFaviconMenuButtonPressed(GtkWidget* widget, |
| 920 GdkEventButton* event) { | 910 GdkEventButton* event) { |
| 921 if (event->button != 1 || IsTypePanel()) | 911 if (event->button != 1 || IsTypePanel()) |
| 922 return FALSE; | 912 return FALSE; |
| 923 | 913 |
| 924 ShowFaviconMenu(event); | 914 ShowFaviconMenu(event); |
| 925 return TRUE; | 915 return TRUE; |
| 926 } | 916 } |
| 927 | 917 |
| 928 gboolean BrowserTitlebar::OnPanelSettingsMenuButtonPressed( | |
| 929 GtkWidget* widget, GdkEventButton* event) { | |
| 930 if (event->button != 1) | |
| 931 return FALSE; | |
| 932 | |
| 933 browser_window_->ShowSettingsMenu(widget, event); | |
| 934 return TRUE; | |
| 935 } | |
| 936 | |
| 937 void BrowserTitlebar::ShowContextMenu(GdkEventButton* event) { | 918 void BrowserTitlebar::ShowContextMenu(GdkEventButton* event) { |
| 938 if (!context_menu_.get()) { | 919 if (!context_menu_.get()) { |
| 939 context_menu_model_.reset(new ContextMenuModel(this)); | 920 context_menu_model_.reset(new ContextMenuModel(this)); |
| 940 context_menu_.reset(new MenuGtk(NULL, context_menu_model_.get())); | 921 context_menu_.reset(new MenuGtk(NULL, context_menu_model_.get())); |
| 941 } | 922 } |
| 942 | 923 |
| 943 context_menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 924 context_menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 944 event->time); | 925 event->time); |
| 945 } | 926 } |
| 946 | 927 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 "enter-notify-event", event, | 962 "enter-notify-event", event, |
| 982 &return_value); | 963 &return_value); |
| 983 } | 964 } |
| 984 | 965 |
| 985 int BrowserTitlebar::IconOnlyWidth() { | 966 int BrowserTitlebar::IconOnlyWidth() { |
| 986 GtkAllocation allocation; | 967 GtkAllocation allocation; |
| 987 gtk_widget_get_allocation(app_mode_favicon_, &allocation); | 968 gtk_widget_get_allocation(app_mode_favicon_, &allocation); |
| 988 return 2 * kFrameBorderThickness + allocation.width; | 969 return 2 * kFrameBorderThickness + allocation.width; |
| 989 } | 970 } |
| 990 | 971 |
| 991 void BrowserTitlebar::ShowPanelWrenchButton() { | |
| 992 if (panel_wrench_button_.get()) | |
| 993 gtk_widget_show(panel_wrench_button_->widget()); | |
| 994 } | |
| 995 | |
| 996 void BrowserTitlebar::HidePanelWrenchButton() { | |
| 997 if (panel_wrench_button_.get()) | |
| 998 gtk_widget_hide(panel_wrench_button_->widget()); | |
| 999 } | |
| 1000 | |
| 1001 bool BrowserTitlebar::IsCommandIdEnabled(int command_id) const { | 972 bool BrowserTitlebar::IsCommandIdEnabled(int command_id) const { |
| 1002 if (command_id == kShowWindowDecorationsCommand) | 973 if (command_id == kShowWindowDecorationsCommand) |
| 1003 return true; | 974 return true; |
| 1004 | 975 |
| 1005 return browser_window_->browser()->command_updater()-> | 976 return browser_window_->browser()->command_updater()-> |
| 1006 IsCommandEnabled(command_id); | 977 IsCommandEnabled(command_id); |
| 1007 } | 978 } |
| 1008 | 979 |
| 1009 bool BrowserTitlebar::IsCommandIdChecked(int command_id) const { | 980 bool BrowserTitlebar::IsCommandIdChecked(int command_id) const { |
| 1010 if (command_id == kShowWindowDecorationsCommand) { | 981 if (command_id == kShowWindowDecorationsCommand) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 ui::SimpleMenuModel::Delegate* delegate) | 1132 ui::SimpleMenuModel::Delegate* delegate) |
| 1162 : SimpleMenuModel(delegate) { | 1133 : SimpleMenuModel(delegate) { |
| 1163 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); | 1134 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); |
| 1164 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); | 1135 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); |
| 1165 AddSeparator(); | 1136 AddSeparator(); |
| 1166 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | 1137 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); |
| 1167 AddSeparator(); | 1138 AddSeparator(); |
| 1168 AddCheckItemWithStringId(kShowWindowDecorationsCommand, | 1139 AddCheckItemWithStringId(kShowWindowDecorationsCommand, |
| 1169 IDS_SHOW_WINDOW_DECORATIONS_MENU); | 1140 IDS_SHOW_WINDOW_DECORATIONS_MENU); |
| 1170 } | 1141 } |
| OLD | NEW |