| 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/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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 // Cache the layout so we don't have to create it for every expose. If we | 242 // Cache the layout so we don't have to create it for every expose. If we |
| 243 // were a real widget we should handle changing directions, but we're not | 243 // were a real widget we should handle changing directions, but we're not |
| 244 // doing RTL or anything yet, so it shouldn't be important now. | 244 // doing RTL or anything yet, so it shouldn't be important now. |
| 245 layout_ = gtk_widget_create_pango_layout(window_, NULL); | 245 layout_ = gtk_widget_create_pango_layout(window_, NULL); |
| 246 // We always ellipsize when drawing our text runs. | 246 // We always ellipsize when drawing our text runs. |
| 247 pango_layout_set_ellipsize(layout_, PANGO_ELLIPSIZE_END); | 247 pango_layout_set_ellipsize(layout_, PANGO_ELLIPSIZE_END); |
| 248 // TODO(deanm): We might want to eventually follow what Windows does and | 248 // TODO(deanm): We might want to eventually follow what Windows does and |
| 249 // plumb a gfx::Font through. This is because popup windows have a | 249 // plumb a gfx::Font through. This is because popup windows have a |
| 250 // different font size, although we could just derive that font here. | 250 // different font size, although we could just derive that font here. |
| 251 PangoFontDescription* pfd = PangoFontFromGfxFont(gfx::Font()); | 251 // For now, force the font size to 10pt. |
| 252 gfx::Font font = gfx::Font::CreateFont(gfx::Font().FontName(), 10); |
| 253 PangoFontDescription* pfd = PangoFontFromGfxFont(font); |
| 252 pango_layout_set_font_description(layout_, pfd); | 254 pango_layout_set_font_description(layout_, pfd); |
| 253 pango_font_description_free(pfd); | 255 pango_font_description_free(pfd); |
| 254 | 256 |
| 255 gtk_widget_add_events(window_, GDK_BUTTON_MOTION_MASK | | 257 gtk_widget_add_events(window_, GDK_BUTTON_MOTION_MASK | |
| 256 GDK_POINTER_MOTION_MASK | | 258 GDK_POINTER_MOTION_MASK | |
| 257 GDK_BUTTON_PRESS_MASK | | 259 GDK_BUTTON_PRESS_MASK | |
| 258 GDK_BUTTON_RELEASE_MASK); | 260 GDK_BUTTON_RELEASE_MASK); |
| 259 g_signal_connect(window_, "motion-notify-event", | 261 g_signal_connect(window_, "motion-notify-event", |
| 260 G_CALLBACK(&HandleMotionThunk), this); | 262 G_CALLBACK(&HandleMotionThunk), this); |
| 261 g_signal_connect(window_, "button-press-event", | 263 g_signal_connect(window_, "button-press-event", |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 gdk_draw_layout(drawable, gc, | 475 gdk_draw_layout(drawable, gc, |
| 474 kIconAreaWidth + actual_content_width, content_y, | 476 kIconAreaWidth + actual_content_width, content_y, |
| 475 layout_); | 477 layout_); |
| 476 } | 478 } |
| 477 } | 479 } |
| 478 | 480 |
| 479 g_object_unref(gc); | 481 g_object_unref(gc); |
| 480 | 482 |
| 481 return TRUE; | 483 return TRUE; |
| 482 } | 484 } |
| OLD | NEW |