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

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

Issue 9147044: GTK: More GSEALing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: jhawkins refactor Created 8 years, 11 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 | « chrome/browser/ui/gtk/gtk_custom_menu.cc ('k') | chrome/browser/ui/gtk/gtk_util.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/base/gtk/gtk_compat.h" 9 #include "ui/base/gtk/gtk_compat.h"
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 } 86 }
87 87
88 // When GtkButtons set the label text, they rebuild the widget hierarchy each 88 // When GtkButtons set the label text, they rebuild the widget hierarchy each
89 // and every time. Therefore, we can't just fish out the label from the button 89 // and every time. Therefore, we can't just fish out the label from the button
90 // and set some properties; we have to create this callback function that 90 // and set some properties; we have to create this callback function that
91 // listens on the button's "notify" signal, which is emitted right after the 91 // listens on the button's "notify" signal, which is emitted right after the
92 // label has been (re)created. (Label values can change dynamically.) 92 // label has been (re)created. (Label values can change dynamically.)
93 static void on_button_label_set(GObject* object) { 93 static void on_button_label_set(GObject* object) {
94 GtkButton* button = GTK_BUTTON(object); 94 GtkButton* button = GTK_BUTTON(object);
95 gtk_widget_set_sensitive(GTK_BIN(button)->child, FALSE); 95 GtkWidget* child = gtk_bin_get_child(GTK_BIN(button));
96 gtk_misc_set_padding(GTK_MISC(GTK_BIN(button)->child), 2, 0); 96 gtk_widget_set_sensitive(child, FALSE);
97 gtk_misc_set_padding(GTK_MISC(child), 2, 0);
97 } 98 }
98 99
99 static void gtk_custom_menu_item_finalize(GObject *object); 100 static void gtk_custom_menu_item_finalize(GObject *object);
100 static gint gtk_custom_menu_item_expose(GtkWidget* widget, 101 static gint gtk_custom_menu_item_expose(GtkWidget* widget,
101 GdkEventExpose* event); 102 GdkEventExpose* event);
102 static gboolean gtk_custom_menu_item_hbox_expose(GtkWidget* widget, 103 static gboolean gtk_custom_menu_item_hbox_expose(GtkWidget* widget,
103 GdkEventExpose* event, 104 GdkEventExpose* event,
104 GtkCustomMenuItem* menu_item); 105 GtkCustomMenuItem* menu_item);
105 static void gtk_custom_menu_item_select(GtkItem *item); 106 static void gtk_custom_menu_item_select(GtkItem *item);
106 static void gtk_custom_menu_item_deselect(GtkItem *item); 107 static void gtk_custom_menu_item_deselect(GtkItem *item);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (GTK_IS_BUTTON(current_item->data)) { 255 if (GTK_IS_BUTTON(current_item->data)) {
255 // Check to see if this is the last button in a run. 256 // Check to see if this is the last button in a run.
256 GList* next_item = g_list_next(current_item); 257 GList* next_item = g_list_next(current_item);
257 if (next_item && GTK_IS_BUTTON(next_item->data)) { 258 if (next_item && GTK_IS_BUTTON(next_item->data)) {
258 GtkWidget* current_button = GTK_WIDGET(current_item->data); 259 GtkWidget* current_button = GTK_WIDGET(current_item->data);
259 GtkAllocation button_allocation; 260 GtkAllocation button_allocation;
260 gtk_widget_get_allocation(current_button, &button_allocation); 261 gtk_widget_get_allocation(current_button, &button_allocation);
261 GtkAllocation child_alloc; 262 GtkAllocation child_alloc;
262 gtk_widget_get_allocation(gtk_bin_get_child(GTK_BIN(current_button)), 263 gtk_widget_get_allocation(gtk_bin_get_child(GTK_BIN(current_button)),
263 &child_alloc); 264 &child_alloc);
264 int half_offset = widget->style->xthickness / 2; 265 GtkStyle* style = gtk_widget_get_style(widget);
265 gtk_paint_vline(gtk_widget_get_style(widget), 266 int half_offset = style->xthickness / 2;
267 gtk_paint_vline(style,
266 gtk_widget_get_window(widget), 268 gtk_widget_get_window(widget),
267 gtk_widget_get_state(current_button), 269 gtk_widget_get_state(current_button),
268 &event->area, widget, "button", 270 &event->area, widget, "button",
269 child_alloc.y, 271 child_alloc.y,
270 child_alloc.y + child_alloc.height, 272 child_alloc.y + child_alloc.height,
271 button_allocation.x + 273 button_allocation.x +
272 button_allocation.width - half_offset); 274 button_allocation.width - half_offset);
273 } 275 }
274 } 276 }
275 } 277 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 gpointer callback_data) { 484 gpointer callback_data) {
483 // Even though we're filtering |all_widgets| on GTK_IS_BUTTON(), this isn't 485 // Even though we're filtering |all_widgets| on GTK_IS_BUTTON(), this isn't
484 // equivalent to |button_widgets| because we also want the button-labels. 486 // equivalent to |button_widgets| because we also want the button-labels.
485 for (GList* i = menu_item->all_widgets; i && GTK_IS_BUTTON(i->data); 487 for (GList* i = menu_item->all_widgets; i && GTK_IS_BUTTON(i->data);
486 i = g_list_next(i)) { 488 i = g_list_next(i)) {
487 if (GTK_IS_BUTTON(i->data)) { 489 if (GTK_IS_BUTTON(i->data)) {
488 callback(GTK_WIDGET(i->data), callback_data); 490 callback(GTK_WIDGET(i->data), callback_data);
489 } 491 }
490 } 492 }
491 } 493 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_custom_menu.cc ('k') | chrome/browser/ui/gtk/gtk_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698