OLD | NEW |
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_custom_menu_item.h" | 5 #include "chrome/browser/ui/gtk/gtk_custom_menu_item.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "chrome/browser/ui/gtk/gtk_custom_menu.h" | 8 #include "chrome/browser/ui/gtk/gtk_custom_menu.h" |
9 | 9 |
10 // This method was autogenerated by the program glib-genmarshall, which | 10 // This method was autogenerated by the program glib-genmarshall, which |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 static void gtk_custom_menu_item_finalize(GObject *object) { | 164 static void gtk_custom_menu_item_finalize(GObject *object) { |
165 GtkCustomMenuItem* item = GTK_CUSTOM_MENU_ITEM(object); | 165 GtkCustomMenuItem* item = GTK_CUSTOM_MENU_ITEM(object); |
166 g_list_free(item->all_widgets); | 166 g_list_free(item->all_widgets); |
167 g_list_free(item->button_widgets); | 167 g_list_free(item->button_widgets); |
168 | 168 |
169 G_OBJECT_CLASS(gtk_custom_menu_item_parent_class)->finalize(object); | 169 G_OBJECT_CLASS(gtk_custom_menu_item_parent_class)->finalize(object); |
170 } | 170 } |
171 | 171 |
172 static gint gtk_custom_menu_item_expose(GtkWidget* widget, | 172 static gint gtk_custom_menu_item_expose(GtkWidget* widget, |
173 GdkEventExpose* event) { | 173 GdkEventExpose* event) { |
174 if (GTK_WIDGET_VISIBLE(widget) && | 174 if (gtk_widget_get_visible(widget) && |
175 GTK_WIDGET_MAPPED(widget) && | 175 GTK_WIDGET_MAPPED(widget) && |
176 gtk_bin_get_child(GTK_BIN(widget))) { | 176 gtk_bin_get_child(GTK_BIN(widget))) { |
177 // We skip the drawing in the GtkMenuItem class it draws the highlighted | 177 // We skip the drawing in the GtkMenuItem class it draws the highlighted |
178 // background and we don't want that. | 178 // background and we don't want that. |
179 gtk_container_propagate_expose(GTK_CONTAINER(widget), | 179 gtk_container_propagate_expose(GTK_CONTAINER(widget), |
180 gtk_bin_get_child(GTK_BIN(widget)), | 180 gtk_bin_get_child(GTK_BIN(widget)), |
181 event); | 181 event); |
182 } | 182 } |
183 | 183 |
184 return FALSE; | 184 return FALSE; |
(...skipping 20 matching lines...) Expand all Loading... |
205 if (base::i18n::IsRTL()) | 205 if (base::i18n::IsRTL()) |
206 std::swap(first_button, last_button); | 206 std::swap(first_button, last_button); |
207 | 207 |
208 int x = first_button->allocation.x; | 208 int x = first_button->allocation.x; |
209 int y = first_button->allocation.y; | 209 int y = first_button->allocation.y; |
210 int width = last_button->allocation.width + last_button->allocation.x - | 210 int width = last_button->allocation.width + last_button->allocation.x - |
211 first_button->allocation.x; | 211 first_button->allocation.x; |
212 int height = last_button->allocation.height; | 212 int height = last_button->allocation.height; |
213 | 213 |
214 gtk_paint_box(hbox->style, hbox->window, | 214 gtk_paint_box(hbox->style, hbox->window, |
215 static_cast<GtkStateType>( | 215 gtk_widget_get_state(current_button), |
216 GTK_WIDGET_STATE(current_button)), | |
217 GTK_SHADOW_OUT, | 216 GTK_SHADOW_OUT, |
218 ¤t_button->allocation, hbox, "button", | 217 ¤t_button->allocation, hbox, "button", |
219 x, y, width, height); | 218 x, y, width, height); |
220 | 219 |
221 // Propagate to the button's children. | 220 // Propagate to the button's children. |
222 gtk_container_propagate_expose( | 221 gtk_container_propagate_expose( |
223 GTK_CONTAINER(current_button), | 222 GTK_CONTAINER(current_button), |
224 gtk_bin_get_child(GTK_BIN(current_button)), | 223 gtk_bin_get_child(GTK_BIN(current_button)), |
225 event); | 224 event); |
226 } | 225 } |
(...skipping 19 matching lines...) Expand all Loading... |
246 current_item != NULL; current_item = g_list_next(current_item)) { | 245 current_item != NULL; current_item = g_list_next(current_item)) { |
247 if (GTK_IS_BUTTON(current_item->data)) { | 246 if (GTK_IS_BUTTON(current_item->data)) { |
248 // Check to see if this is the last button in a run. | 247 // Check to see if this is the last button in a run. |
249 GList* next_item = g_list_next(current_item); | 248 GList* next_item = g_list_next(current_item); |
250 if (next_item && GTK_IS_BUTTON(next_item->data)) { | 249 if (next_item && GTK_IS_BUTTON(next_item->data)) { |
251 GtkWidget* current_button = GTK_WIDGET(current_item->data); | 250 GtkWidget* current_button = GTK_WIDGET(current_item->data); |
252 GtkAllocation child_alloc = | 251 GtkAllocation child_alloc = |
253 gtk_bin_get_child(GTK_BIN(current_button))->allocation; | 252 gtk_bin_get_child(GTK_BIN(current_button))->allocation; |
254 int half_offset = widget->style->xthickness / 2; | 253 int half_offset = widget->style->xthickness / 2; |
255 gtk_paint_vline(widget->style, widget->window, | 254 gtk_paint_vline(widget->style, widget->window, |
256 static_cast<GtkStateType>( | 255 gtk_widget_get_state(current_button), |
257 GTK_WIDGET_STATE(current_button)), | |
258 &event->area, widget, "button", | 256 &event->area, widget, "button", |
259 child_alloc.y, | 257 child_alloc.y, |
260 child_alloc.y + child_alloc.height, | 258 child_alloc.y + child_alloc.height, |
261 current_button->allocation.x + | 259 current_button->allocation.x + |
262 current_button->allocation.width - half_offset); | 260 current_button->allocation.width - half_offset); |
263 } | 261 } |
264 } | 262 } |
265 } | 263 } |
266 | 264 |
267 // Finally, draw the selected item on top of the separators so there are no | 265 // Finally, draw the selected item on top of the separators so there are no |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 gpointer callback_data) { | 469 gpointer callback_data) { |
472 // Even though we're filtering |all_widgets| on GTK_IS_BUTTON(), this isn't | 470 // Even though we're filtering |all_widgets| on GTK_IS_BUTTON(), this isn't |
473 // equivalent to |button_widgets| because we also want the button-labels. | 471 // equivalent to |button_widgets| because we also want the button-labels. |
474 for (GList* i = menu_item->all_widgets; i && GTK_IS_BUTTON(i->data); | 472 for (GList* i = menu_item->all_widgets; i && GTK_IS_BUTTON(i->data); |
475 i = g_list_next(i)) { | 473 i = g_list_next(i)) { |
476 if (GTK_IS_BUTTON(i->data)) { | 474 if (GTK_IS_BUTTON(i->data)) { |
477 callback(GTK_WIDGET(i->data), callback_data); | 475 callback(GTK_WIDGET(i->data), callback_data); |
478 } | 476 } |
479 } | 477 } |
480 } | 478 } |
OLD | NEW |