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

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

Issue 8646002: GTK: Port ui/base/gtk to use avoid deprecated API and accessors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased version to fix AUTHORS file merge problem Created 9 years 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 | « ui/base/gtk/gtk_expanded_container_unittest.cc ('k') | ui/base/gtk/tooltip_window_gtk.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) 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 "ui/base/gtk/gtk_floating_container.h" 5 #include "ui/base/gtk/gtk_floating_container.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 0, 113 0,
114 kStaticReadWriteProp)); 114 kStaticReadWriteProp));
115 115
116 floating_container_signals[SET_FLOATING_POSITION] = 116 floating_container_signals[SET_FLOATING_POSITION] =
117 g_signal_new("set-floating-position", 117 g_signal_new("set-floating-position",
118 G_OBJECT_CLASS_TYPE(object_class), 118 G_OBJECT_CLASS_TYPE(object_class),
119 static_cast<GSignalFlags>(G_SIGNAL_RUN_FIRST | 119 static_cast<GSignalFlags>(G_SIGNAL_RUN_FIRST |
120 G_SIGNAL_ACTION), 120 G_SIGNAL_ACTION),
121 0, 121 0,
122 NULL, NULL, 122 NULL, NULL,
123 gtk_marshal_VOID__BOXED, 123 g_cclosure_marshal_VOID__BOXED,
124 G_TYPE_NONE, 1, 124 G_TYPE_NONE, 1,
125 GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE); 125 GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
126 } 126 }
127 127
128 static void gtk_floating_container_init(GtkFloatingContainer* container) { 128 static void gtk_floating_container_init(GtkFloatingContainer* container) {
129 GTK_WIDGET_SET_FLAGS(container, GTK_NO_WINDOW); 129 gtk_widget_set_has_window(GTK_WIDGET(container), FALSE);
130
131 container->floating_children = NULL; 130 container->floating_children = NULL;
132 } 131 }
133 132
134 static void gtk_floating_container_remove(GtkContainer* container, 133 static void gtk_floating_container_remove(GtkContainer* container,
135 GtkWidget* widget) { 134 GtkWidget* widget) {
136 g_return_if_fail(GTK_IS_WIDGET(widget)); 135 g_return_if_fail(GTK_IS_WIDGET(widget));
137 136
138 GtkBin* bin = GTK_BIN(container); 137 GtkBin* bin = GTK_BIN(container);
139 if (bin->child == widget) { 138 if (gtk_bin_get_child(bin) == widget) {
140 ((GTK_CONTAINER_CLASS(gtk_floating_container_parent_class))->remove) 139 ((GTK_CONTAINER_CLASS(gtk_floating_container_parent_class))->remove)
141 (container, widget); 140 (container, widget);
142 } else { 141 } else {
143 // Handle the other case where it's in our |floating_children| list. 142 // Handle the other case where it's in our |floating_children| list.
144 GtkFloatingContainer* floating = GTK_FLOATING_CONTAINER(container); 143 GtkFloatingContainer* floating = GTK_FLOATING_CONTAINER(container);
145 GList* children = floating->floating_children; 144 GList* children = floating->floating_children;
146 gboolean removed_child = false; 145 gboolean removed_child = false;
147 while (children) { 146 while (children) {
148 GtkFloatingContainerChild* child = 147 GtkFloatingContainerChild* child =
149 reinterpret_cast<GtkFloatingContainerChild*>(children->data); 148 reinterpret_cast<GtkFloatingContainerChild*>(children->data);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 reinterpret_cast<GtkFloatingContainerChild*>(children->data); 188 reinterpret_cast<GtkFloatingContainerChild*>(children->data);
190 children = children->next; 189 children = children->next;
191 190
192 (*callback)(child->widget, callback_data); 191 (*callback)(child->widget, callback_data);
193 } 192 }
194 } 193 }
195 194
196 static void gtk_floating_container_size_request(GtkWidget* widget, 195 static void gtk_floating_container_size_request(GtkWidget* widget,
197 GtkRequisition* requisition) { 196 GtkRequisition* requisition) {
198 GtkBin* bin = GTK_BIN(widget); 197 GtkBin* bin = GTK_BIN(widget);
199 if (bin && bin->child) { 198 if (bin && gtk_bin_get_child(bin)) {
200 gtk_widget_size_request(bin->child, requisition); 199 gtk_widget_size_request(gtk_bin_get_child(bin), requisition);
201 } else { 200 } else {
202 requisition->width = 0; 201 requisition->width = 0;
203 requisition->height = 0; 202 requisition->height = 0;
204 } 203 }
205 } 204 }
206 205
207 static void gtk_floating_container_size_allocate(GtkWidget* widget, 206 static void gtk_floating_container_size_allocate(GtkWidget* widget,
208 GtkAllocation* allocation) { 207 GtkAllocation* allocation) {
209 widget->allocation = *allocation; 208 gtk_widget_set_allocation(widget, allocation);
210 209
211 if (gtk_widget_get_has_window(widget) && gtk_widget_get_realized(widget)) { 210 if (gtk_widget_get_has_window(widget) && gtk_widget_get_realized(widget)) {
212 gdk_window_move_resize(widget->window, 211 gdk_window_move_resize(gtk_widget_get_window(widget),
213 allocation->x, 212 allocation->x,
214 allocation->y, 213 allocation->y,
215 allocation->width, 214 allocation->width,
216 allocation->height); 215 allocation->height);
217 } 216 }
218 217
219 // Give the same allocation to our GtkBin component. 218 // Give the same allocation to our GtkBin component.
220 GtkBin* bin = GTK_BIN(widget); 219 GtkBin* bin = GTK_BIN(widget);
221 if (bin->child) { 220 if (gtk_bin_get_child(bin)) {
222 gtk_widget_size_allocate(bin->child, allocation); 221 gtk_widget_size_allocate(gtk_bin_get_child(bin), allocation);
223 } 222 }
224 223
225 // We need to give whoever is pulling our strings a chance to set the "x" and 224 // We need to give whoever is pulling our strings a chance to set the "x" and
226 // "y" properties on all of our children. 225 // "y" properties on all of our children.
227 g_signal_emit(widget, floating_container_signals[SET_FLOATING_POSITION], 0, 226 g_signal_emit(widget, floating_container_signals[SET_FLOATING_POSITION], 0,
228 allocation); 227 allocation);
229 228
230 // Our allocation has been set. We've asked our controller to place the other 229 // Our allocation has been set. We've asked our controller to place the other
231 // widgets. Pass out allocations to all our children based on where they want 230 // widgets. Pass out allocations to all our children based on where they want
232 // to be. 231 // to be.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 child_info->x = 0; 313 child_info->x = 0;
315 child_info->y = 0; 314 child_info->y = 0;
316 315
317 gtk_widget_set_parent(widget, GTK_WIDGET(container)); 316 gtk_widget_set_parent(widget, GTK_WIDGET(container));
318 317
319 container->floating_children = 318 container->floating_children =
320 g_list_append(container->floating_children, child_info); 319 g_list_append(container->floating_children, child_info);
321 } 320 }
322 321
323 G_END_DECLS 322 G_END_DECLS
OLDNEW
« no previous file with comments | « ui/base/gtk/gtk_expanded_container_unittest.cc ('k') | ui/base/gtk/tooltip_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698