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

Side by Side Diff: ui/base/gtk/tooltip_window_gtk.cc

Issue 10008058: Remove obsolete chromeos specific code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 8 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 | « ui/base/gtk/tooltip_window_gtk.h ('k') | ui/ui.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/base/gtk/tooltip_window_gtk.h"
6
7 #include <gtk/gtk.h>
8
9 #include "base/utf_string_conversions.h"
10
11 namespace ui {
12
13 TooltipWindowGtk::TooltipWindowGtk(GtkWidget* widget)
14 : host_(widget),
15 window_(NULL),
16 alignment_(NULL),
17 label_(NULL) {
18 Init();
19 }
20
21 TooltipWindowGtk::~TooltipWindowGtk() {
22 if (window_)
23 gtk_widget_destroy(window_);
24 }
25
26 void TooltipWindowGtk::SetTooltipText(const string16& text) {
27 gtk_label_set_text(label(), UTF16ToUTF8(text).c_str());
28 }
29
30 GtkLabel* TooltipWindowGtk::label() {
31 return GTK_LABEL(label_);
32 }
33
34 void TooltipWindowGtk::Init() {
35 // Creates and setup tooltip window.
36 window_ = gtk_window_new(GTK_WINDOW_POPUP);
37 gtk_window_set_type_hint(GTK_WINDOW(window_), GDK_WINDOW_TYPE_HINT_TOOLTIP);
38 gtk_widget_set_app_paintable(window_, TRUE);
39 gtk_window_set_resizable(GTK_WINDOW(window_), FALSE);
40 gtk_widget_set_name(window_, "gtk-tooltip");
41
42 GdkColormap* rgba_colormap =
43 gdk_screen_get_rgba_colormap(gdk_screen_get_default());
44 if (rgba_colormap)
45 gtk_widget_set_colormap(window_, rgba_colormap);
46
47 g_signal_connect(G_OBJECT(window_), "expose-event",
48 G_CALLBACK(&OnPaintThunk), this);
49 g_signal_connect(G_OBJECT(window_), "style-set",
50 G_CALLBACK(&OnStyleSetThunk), this);
51
52 alignment_ = gtk_alignment_new(0.5, 0.5, 1.0, 1.0);
53 gtk_container_add(GTK_CONTAINER(window_), alignment_);
54 gtk_widget_show(alignment_);
55
56 label_ = gtk_label_new("");
57 gtk_label_set_line_wrap(GTK_LABEL(label_), TRUE);
58 gtk_container_add(GTK_CONTAINER(alignment_), label_);
59 gtk_widget_show(label_);
60
61 // Associates the tooltip window with given widget
62 gtk_widget_set_tooltip_window(host_, GTK_WINDOW(window_));
63 }
64
65 // Paints our customized tooltip window.
66 gboolean TooltipWindowGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) {
67 GtkAllocation allocation;
68 gtk_widget_get_allocation(widget, &allocation);
69 gtk_paint_flat_box(gtk_widget_get_style(widget),
70 gtk_widget_get_window(widget),
71 GTK_STATE_NORMAL,
72 GTK_SHADOW_OUT,
73 NULL,
74 widget,
75 "tooltip",
76 0, 0,
77 allocation.width,
78 allocation.height);
79
80 return FALSE;
81 }
82
83 // Style change handler.
84 void TooltipWindowGtk::OnStyleSet(GtkWidget* widget,
85 GtkStyle* previous_style) {
86 GtkStyle* style = gtk_widget_get_style(widget);
87 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_),
88 style->ythickness,
89 style->ythickness,
90 style->xthickness,
91 style->xthickness);
92
93 gtk_widget_queue_draw(widget);
94 }
95
96 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/gtk/tooltip_window_gtk.h ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698