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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc

Issue 100200: Use the new selected icons in Linux Omnibox. (Closed)
Patch Set: Shorted _selected to _s to avoid long lines. Created 11 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
« no previous file with comments | « no previous file | no next file » | 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) 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/autocomplete/autocomplete_popup_view_gtk.h" 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL; 166 PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
167 PangoAttribute* weight_attr = pango_attr_weight_new(weight); 167 PangoAttribute* weight_attr = pango_attr_weight_new(weight);
168 weight_attr->start_index = offset; 168 weight_attr->start_index = offset;
169 pango_attr_list_insert(attrs, weight_attr); // Ownership taken. 169 pango_attr_list_insert(attrs, weight_attr); // Ownership taken.
170 } 170 }
171 171
172 pango_layout_set_attributes(layout, attrs); // Ref taken. 172 pango_layout_set_attributes(layout, attrs); // Ref taken.
173 pango_attr_list_unref(attrs); 173 pango_attr_list_unref(attrs);
174 } 174 }
175 175
176 GdkPixbuf* IconForMatch(const AutocompleteMatch& match) { 176 GdkPixbuf* IconForMatch(const AutocompleteMatch& match, bool selected) {
177 // TODO(deanm): These would be better as pixmaps someday. 177 // TODO(deanm): These would be better as pixmaps someday.
178 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 178 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
179 static GdkPixbuf* o2_globe = rb.GetPixbufNamed(IDR_O2_GLOBE); 179 static GdkPixbuf* o2_globe = rb.GetPixbufNamed(IDR_O2_GLOBE);
180 static GdkPixbuf* o2_globe_s = rb.GetPixbufNamed(IDR_O2_GLOBE_SELECTED);
180 static GdkPixbuf* o2_history = rb.GetPixbufNamed(IDR_O2_HISTORY); 181 static GdkPixbuf* o2_history = rb.GetPixbufNamed(IDR_O2_HISTORY);
182 static GdkPixbuf* o2_history_s = rb.GetPixbufNamed(IDR_O2_HISTORY_SELECTED);
181 static GdkPixbuf* o2_more = rb.GetPixbufNamed(IDR_O2_MORE); 183 static GdkPixbuf* o2_more = rb.GetPixbufNamed(IDR_O2_MORE);
184 static GdkPixbuf* o2_more_s = rb.GetPixbufNamed(IDR_O2_MORE_SELECTED);
182 static GdkPixbuf* o2_search = rb.GetPixbufNamed(IDR_O2_SEARCH); 185 static GdkPixbuf* o2_search = rb.GetPixbufNamed(IDR_O2_SEARCH);
186 static GdkPixbuf* o2_search_s = rb.GetPixbufNamed(IDR_O2_SEARCH_SELECTED);
183 static GdkPixbuf* o2_star = rb.GetPixbufNamed(IDR_O2_STAR); 187 static GdkPixbuf* o2_star = rb.GetPixbufNamed(IDR_O2_STAR);
188 static GdkPixbuf* o2_star_s = rb.GetPixbufNamed(IDR_O2_STAR_SELECTED);
184 189
185 if (match.starred) 190 if (match.starred)
186 return o2_star; 191 return selected ? o2_star_s : o2_star;
187 192
188 switch (match.type) { 193 switch (match.type) {
189 case AutocompleteMatch::URL_WHAT_YOU_TYPED: 194 case AutocompleteMatch::URL_WHAT_YOU_TYPED:
190 case AutocompleteMatch::NAVSUGGEST: 195 case AutocompleteMatch::NAVSUGGEST:
191 return o2_globe; 196 return selected ? o2_globe_s : o2_globe;
192 case AutocompleteMatch::HISTORY_URL: 197 case AutocompleteMatch::HISTORY_URL:
193 case AutocompleteMatch::HISTORY_TITLE: 198 case AutocompleteMatch::HISTORY_TITLE:
194 case AutocompleteMatch::HISTORY_BODY: 199 case AutocompleteMatch::HISTORY_BODY:
195 case AutocompleteMatch::HISTORY_KEYWORD: 200 case AutocompleteMatch::HISTORY_KEYWORD:
196 return o2_history; 201 return selected ? o2_history_s : o2_history;
197 case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED: 202 case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED:
198 case AutocompleteMatch::SEARCH_HISTORY: 203 case AutocompleteMatch::SEARCH_HISTORY:
199 case AutocompleteMatch::SEARCH_SUGGEST: 204 case AutocompleteMatch::SEARCH_SUGGEST:
200 case AutocompleteMatch::SEARCH_OTHER_ENGINE: 205 case AutocompleteMatch::SEARCH_OTHER_ENGINE:
201 return o2_search; 206 return selected ? o2_search_s : o2_search;
202 case AutocompleteMatch::OPEN_HISTORY_PAGE: 207 case AutocompleteMatch::OPEN_HISTORY_PAGE:
203 return o2_more; 208 return selected ? o2_more_s : o2_more;
204 default: 209 default:
205 NOTREACHED(); 210 NOTREACHED();
206 break; 211 break;
207 } 212 }
208 213
209 return NULL; 214 return NULL;
210 } 215 }
211 216
212 } // namespace 217 } // namespace
213 218
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (is_selected || is_hovered) { 423 if (is_selected || is_hovered) {
419 gdk_gc_set_rgb_fg_color(gc, is_selected ? &kSelectedBackgroundColor : 424 gdk_gc_set_rgb_fg_color(gc, is_selected ? &kSelectedBackgroundColor :
420 &kHoveredBackgroundColor); 425 &kHoveredBackgroundColor);
421 // This entry is selected or hovered, fill a rect with the color. 426 // This entry is selected or hovered, fill a rect with the color.
422 gdk_draw_rectangle(drawable, gc, TRUE, 427 gdk_draw_rectangle(drawable, gc, TRUE,
423 line_rect.x(), line_rect.y(), 428 line_rect.x(), line_rect.y(),
424 line_rect.width(), line_rect.height()); 429 line_rect.width(), line_rect.height());
425 } 430 }
426 431
427 // Draw the icon for this result time. 432 // Draw the icon for this result time.
428 DrawFullPixbuf(drawable, gc, IconForMatch(match), 433 DrawFullPixbuf(drawable, gc, IconForMatch(match, is_selected),
429 kIconLeftPadding, line_rect.y() + kIconTopPadding); 434 kIconLeftPadding, line_rect.y() + kIconTopPadding);
430 435
431 // Draw the results text vertically centered in the results space. 436 // Draw the results text vertically centered in the results space.
432 // First draw the contents / url, but don't let it take up the whole width 437 // First draw the contents / url, but don't let it take up the whole width
433 // if there is also a description to be shown. 438 // if there is also a description to be shown.
434 bool has_description = !match.description.empty(); 439 bool has_description = !match.description.empty();
435 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding); 440 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding);
436 int content_width = has_description ? 441 int content_width = has_description ?
437 text_width * kContentWidthPercentage : text_width; 442 text_width * kContentWidthPercentage : text_width;
438 pango_layout_set_width(layout_, content_width * PANGO_SCALE); 443 pango_layout_set_width(layout_, content_width * PANGO_SCALE);
(...skipping 27 matching lines...) Expand all
466 gdk_draw_layout(drawable, gc, 471 gdk_draw_layout(drawable, gc,
467 kIconAreaWidth + actual_content_width, content_y, 472 kIconAreaWidth + actual_content_width, content_y,
468 layout_); 473 layout_);
469 } 474 }
470 } 475 }
471 476
472 g_object_unref(gc); 477 g_object_unref(gc);
473 478
474 return TRUE; 479 return TRUE;
475 } 480 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698