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

Side by Side Diff: chrome/browser/ui/gtk/gtk_chrome_link_button.cc

Issue 7227027: GTK: More 2.18 goodness. Move from macros to real accessor functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove views/ Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/gtk_chrome_link_button.h" 5 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "chrome/browser/ui/gtk/gtk_util.h" 9 #include "chrome/browser/ui/gtk/gtk_util.h"
10 #include "ui/gfx/gtk_util.h" 10 #include "ui/gfx/gtk_util.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 gtk_label_set_markup(GTK_LABEL(button->label), 104 gtk_label_set_markup(GTK_LABEL(button->label),
105 button->using_native_theme ? button->native_markup : 105 button->using_native_theme ? button->native_markup :
106 button->normal_markup); 106 button->normal_markup);
107 } 107 }
108 108
109 static void gtk_chrome_link_button_style_changed(GtkChromeLinkButton* button) { 109 static void gtk_chrome_link_button_style_changed(GtkChromeLinkButton* button) {
110 // Regenerate the link with the possibly new colors after the user has 110 // Regenerate the link with the possibly new colors after the user has
111 // changed his GTK style. 111 // changed his GTK style.
112 gtk_chrome_link_button_set_text(button); 112 gtk_chrome_link_button_set_text(button);
113 113
114 if (GTK_WIDGET_VISIBLE(button)) 114 if (gtk_widget_get_visible(GTK_WIDGET(button)))
115 gtk_widget_queue_draw(GTK_WIDGET(button)); 115 gtk_widget_queue_draw(GTK_WIDGET(button));
116 } 116 }
117 117
118 static gboolean gtk_chrome_link_button_expose(GtkWidget* widget, 118 static gboolean gtk_chrome_link_button_expose(GtkWidget* widget,
119 GdkEventExpose* event) { 119 GdkEventExpose* event) {
120 GtkChromeLinkButton* button = GTK_CHROME_LINK_BUTTON(widget); 120 GtkChromeLinkButton* button = GTK_CHROME_LINK_BUTTON(widget);
121 GtkWidget* label = button->label; 121 GtkWidget* label = button->label;
122 122
123 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE && button->is_normal) { 123 if (gtk_widget_get_state(widget) == GTK_STATE_ACTIVE && button->is_normal) {
124 gtk_label_set_markup(GTK_LABEL(label), button->pressed_markup); 124 gtk_label_set_markup(GTK_LABEL(label), button->pressed_markup);
125 button->is_normal = FALSE; 125 button->is_normal = FALSE;
126 } else if (GTK_WIDGET_STATE(widget) != GTK_STATE_ACTIVE && 126 } else if (gtk_widget_get_state(widget) != GTK_STATE_ACTIVE &&
127 !button->is_normal) { 127 !button->is_normal) {
128 gtk_label_set_markup(GTK_LABEL(label), 128 gtk_label_set_markup(GTK_LABEL(label),
129 button->using_native_theme ? button->native_markup : 129 button->using_native_theme ? button->native_markup :
130 button->normal_markup); 130 button->normal_markup);
131 button->is_normal = TRUE; 131 button->is_normal = TRUE;
132 } 132 }
133 133
134 // Draw the link inside the button. 134 // Draw the link inside the button.
135 gtk_container_propagate_expose(GTK_CONTAINER(widget), label, event); 135 gtk_container_propagate_expose(GTK_CONTAINER(widget), label, event);
136 136
137 // Draw the focus rectangle. 137 // Draw the focus rectangle.
138 if (GTK_WIDGET_HAS_FOCUS(widget)) { 138 if (gtk_widget_has_focus(widget)) {
139 gtk_paint_focus(widget->style, widget->window, 139 gtk_paint_focus(widget->style, widget->window,
140 static_cast<GtkStateType>(GTK_WIDGET_STATE(widget)), 140 gtk_widget_get_state(widget),
141 &event->area, widget, NULL, 141 &event->area, widget, NULL,
142 widget->allocation.x, widget->allocation.y, 142 widget->allocation.x, widget->allocation.y,
143 widget->allocation.width, widget->allocation.height); 143 widget->allocation.width, widget->allocation.height);
144 } 144 }
145 145
146 return TRUE; 146 return TRUE;
147 } 147 }
148 148
149 static void gtk_chrome_link_button_enter(GtkButton* button) { 149 static void gtk_chrome_link_button_enter(GtkButton* button) {
150 GtkWidget* widget = GTK_WIDGET(button); 150 GtkWidget* widget = GTK_WIDGET(button);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return lb; 221 return lb;
222 } 222 }
223 223
224 void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, 224 void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button,
225 gboolean use_gtk) { 225 gboolean use_gtk) {
226 if (use_gtk != button->using_native_theme) { 226 if (use_gtk != button->using_native_theme) {
227 button->using_native_theme = use_gtk; 227 button->using_native_theme = use_gtk;
228 228
229 gtk_chrome_link_button_set_text(button); 229 gtk_chrome_link_button_set_text(button);
230 230
231 if (GTK_WIDGET_VISIBLE(button)) 231 if (gtk_widget_get_visible(GTK_WIDGET(button)))
232 gtk_widget_queue_draw(GTK_WIDGET(button)); 232 gtk_widget_queue_draw(GTK_WIDGET(button));
233 } 233 }
234 } 234 }
235 235
236 void gtk_chrome_link_button_set_label(GtkChromeLinkButton* button, 236 void gtk_chrome_link_button_set_label(GtkChromeLinkButton* button,
237 const char* text) { 237 const char* text) {
238 g_free(button->text); 238 g_free(button->text);
239 button->text = g_strdup(text); 239 button->text = g_strdup(text);
240 240
241 gtk_chrome_link_button_set_text(button); 241 gtk_chrome_link_button_set_text(button);
242 242
243 if (GTK_WIDGET_VISIBLE(button)) 243 if (gtk_widget_get_visible(GTK_WIDGET(button)))
244 gtk_widget_queue_draw(GTK_WIDGET(button)); 244 gtk_widget_queue_draw(GTK_WIDGET(button));
245 } 245 }
246 246
247 void gtk_chrome_link_button_set_normal_color(GtkChromeLinkButton* button, 247 void gtk_chrome_link_button_set_normal_color(GtkChromeLinkButton* button,
248 const GdkColor* color) { 248 const GdkColor* color) {
249 if (color) { 249 if (color) {
250 snprintf(button->normal_color, 9, "#%02X%02X%02X", color->red / 257, 250 snprintf(button->normal_color, 9, "#%02X%02X%02X", color->red / 257,
251 color->green / 257, color->blue / 257); 251 color->green / 257, color->blue / 257);
252 } else { 252 } else {
253 strncpy(button->normal_color, "blue", 9); 253 strncpy(button->normal_color, "blue", 9);
254 } 254 }
255 255
256 gtk_chrome_link_button_set_text(button); 256 gtk_chrome_link_button_set_text(button);
257 257
258 if (GTK_WIDGET_VISIBLE(button)) 258 if (gtk_widget_get_visible(GTK_WIDGET(button)))
259 gtk_widget_queue_draw(GTK_WIDGET(button)); 259 gtk_widget_queue_draw(GTK_WIDGET(button));
260 } 260 }
261 261
262 G_END_DECLS 262 G_END_DECLS
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_chrome_button.cc ('k') | chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698