Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 10316013: linux: Move linux_util.h from gfx/ to ui/base/gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: LinuxUtilTest -> MenuLabelAcceleratorTest Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/menu_gtk.cc ('k') | chrome/browser/ui/gtk/task_manager_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/omnibox/omnibox_view_gtk.h" 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.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 <algorithm> 10 #include <algorithm>
(...skipping 25 matching lines...) Expand all
36 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
37 #include "googleurl/src/gurl.h" 37 #include "googleurl/src/gurl.h"
38 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
39 #include "net/base/escape.h" 39 #include "net/base/escape.h"
40 #include "third_party/undoview/undo_view.h" 40 #include "third_party/undoview/undo_view.h"
41 #include "ui/base/animation/multi_animation.h" 41 #include "ui/base/animation/multi_animation.h"
42 #include "ui/base/dragdrop/drag_drop_types.h" 42 #include "ui/base/dragdrop/drag_drop_types.h"
43 #include "ui/base/dragdrop/gtk_dnd_util.h" 43 #include "ui/base/dragdrop/gtk_dnd_util.h"
44 #include "ui/base/gtk/gtk_compat.h" 44 #include "ui/base/gtk/gtk_compat.h"
45 #include "ui/base/gtk/gtk_hig_constants.h" 45 #include "ui/base/gtk/gtk_hig_constants.h"
46 #include "ui/base/gtk/menu_label_accelerator_util.h"
46 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
47 #include "ui/base/resource/resource_bundle.h" 48 #include "ui/base/resource/resource_bundle.h"
48 #include "ui/gfx/color_utils.h" 49 #include "ui/gfx/color_utils.h"
49 #include "ui/gfx/font.h" 50 #include "ui/gfx/font.h"
50 #include "ui/gfx/linux_util.h"
51 #include "ui/gfx/skia_utils_gtk.h" 51 #include "ui/gfx/skia_utils_gtk.h"
52 52
53 using content::WebContents; 53 using content::WebContents;
54 54
55 namespace { 55 namespace {
56 56
57 const gchar* kOmniboxViewGtkKey = "__OMNIBOX_VIEW_GTK__"; 57 const gchar* kOmniboxViewGtkKey = "__OMNIBOX_VIEW_GTK__";
58 58
59 const char kTextBaseColor[] = "#808080"; 59 const char kTextBaseColor[] = "#808080";
60 const char kSecureSchemeColor[] = "#079500"; 60 const char kSecureSchemeColor[] = "#079500";
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 update_popup_without_focus_ = true; 1302 update_popup_without_focus_ = true;
1303 } 1303 }
1304 1304
1305 void OmniboxViewGtk::HandlePopulatePopup(GtkWidget* sender, GtkMenu* menu) { 1305 void OmniboxViewGtk::HandlePopulatePopup(GtkWidget* sender, GtkMenu* menu) {
1306 GtkWidget* separator = gtk_separator_menu_item_new(); 1306 GtkWidget* separator = gtk_separator_menu_item_new();
1307 gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator); 1307 gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator);
1308 gtk_widget_show(separator); 1308 gtk_widget_show(separator);
1309 1309
1310 // Search Engine menu item. 1310 // Search Engine menu item.
1311 GtkWidget* search_engine_menuitem = gtk_menu_item_new_with_mnemonic( 1311 GtkWidget* search_engine_menuitem = gtk_menu_item_new_with_mnemonic(
1312 gfx::ConvertAcceleratorsFromWindowsStyle( 1312 ui::ConvertAcceleratorsFromWindowsStyle(
1313 l10n_util::GetStringUTF8(IDS_EDIT_SEARCH_ENGINES)).c_str()); 1313 l10n_util::GetStringUTF8(IDS_EDIT_SEARCH_ENGINES)).c_str());
1314 gtk_menu_shell_append(GTK_MENU_SHELL(menu), search_engine_menuitem); 1314 gtk_menu_shell_append(GTK_MENU_SHELL(menu), search_engine_menuitem);
1315 g_signal_connect(search_engine_menuitem, "activate", 1315 g_signal_connect(search_engine_menuitem, "activate",
1316 G_CALLBACK(HandleEditSearchEnginesThunk), this); 1316 G_CALLBACK(HandleEditSearchEnginesThunk), this);
1317 gtk_widget_set_sensitive(search_engine_menuitem, 1317 gtk_widget_set_sensitive(search_engine_menuitem,
1318 command_updater_->IsCommandEnabled(IDC_EDIT_SEARCH_ENGINES)); 1318 command_updater_->IsCommandEnabled(IDC_EDIT_SEARCH_ENGINES));
1319 gtk_widget_show(search_engine_menuitem); 1319 gtk_widget_show(search_engine_menuitem);
1320 1320
1321 // We need to update the paste and go controller before we know what text 1321 // We need to update the paste and go controller before we know what text
1322 // to show. We could do this all asynchronously, but it would be elaborate 1322 // to show. We could do this all asynchronously, but it would be elaborate
1323 // because we'd have to account for multiple menus showing, getting called 1323 // because we'd have to account for multiple menus showing, getting called
1324 // back after shutdown, and similar issues. 1324 // back after shutdown, and similar issues.
1325 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); 1325 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
1326 gchar* text = gtk_clipboard_wait_for_text(x_clipboard); 1326 gchar* text = gtk_clipboard_wait_for_text(x_clipboard);
1327 string16 sanitized_text(text ? 1327 string16 sanitized_text(text ?
1328 StripJavascriptSchemas(CollapseWhitespace(UTF8ToUTF16(text), true)) : 1328 StripJavascriptSchemas(CollapseWhitespace(UTF8ToUTF16(text), true)) :
1329 string16()); 1329 string16());
1330 g_free(text); 1330 g_free(text);
1331 1331
1332 // Paste and Go menu item. Note that CanPasteAndGo() needs to be called 1332 // Paste and Go menu item. Note that CanPasteAndGo() needs to be called
1333 // before is_paste_and_search() in order to set up the paste-and-go state. 1333 // before is_paste_and_search() in order to set up the paste-and-go state.
1334 bool can_paste_and_go = model_->CanPasteAndGo(sanitized_text); 1334 bool can_paste_and_go = model_->CanPasteAndGo(sanitized_text);
1335 GtkWidget* paste_go_menuitem = gtk_menu_item_new_with_mnemonic( 1335 GtkWidget* paste_go_menuitem = gtk_menu_item_new_with_mnemonic(
1336 gfx::ConvertAcceleratorsFromWindowsStyle( 1336 ui::ConvertAcceleratorsFromWindowsStyle(
1337 l10n_util::GetStringUTF8(model_->is_paste_and_search() ? 1337 l10n_util::GetStringUTF8(model_->is_paste_and_search() ?
1338 IDS_PASTE_AND_SEARCH : IDS_PASTE_AND_GO)).c_str()); 1338 IDS_PASTE_AND_SEARCH : IDS_PASTE_AND_GO)).c_str());
1339 1339
1340 // Detect the Paste menu item by searching for the one that 1340 // Detect the Paste menu item by searching for the one that
1341 // uses the stock Paste label (i.e. gtk-paste). 1341 // uses the stock Paste label (i.e. gtk-paste).
1342 string16 stock_paste_label(UTF8ToUTF16(GTK_STOCK_PASTE)); 1342 string16 stock_paste_label(UTF8ToUTF16(GTK_STOCK_PASTE));
1343 GList* list = gtk_container_get_children(GTK_CONTAINER(menu)); 1343 GList* list = gtk_container_get_children(GTK_CONTAINER(menu));
1344 guint index = 1; 1344 guint index = 1;
1345 for (GList* item = list; item != NULL; item = item->next, ++index) { 1345 for (GList* item = list; item != NULL; item = item->next, ++index) {
1346 if (GTK_IS_IMAGE_MENU_ITEM(item->data)) { 1346 if (GTK_IS_IMAGE_MENU_ITEM(item->data)) {
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 // baseline, so we need to move the |instant_view_| down to make sure it 2250 // baseline, so we need to move the |instant_view_| down to make sure it
2251 // has the same baseline as the |text_view_|. 2251 // has the same baseline as the |text_view_|.
2252 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2252 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2253 int height; 2253 int height;
2254 pango_layout_get_size(layout, NULL, &height); 2254 pango_layout_get_size(layout, NULL, &height);
2255 PangoLayoutIter* iter = pango_layout_get_iter(layout); 2255 PangoLayoutIter* iter = pango_layout_get_iter(layout);
2256 int baseline = pango_layout_iter_get_baseline(iter); 2256 int baseline = pango_layout_iter_get_baseline(iter);
2257 pango_layout_iter_free(iter); 2257 pango_layout_iter_free(iter);
2258 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2258 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2259 } 2259 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/menu_gtk.cc ('k') | chrome/browser/ui/gtk/task_manager_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698