Sat, 16 Apr 2005 18:44:40 +0000
[gaim-migrate @ 12503]
Fix bug #1016434 - "MSN phone numbers don't appear changed until next logon"
| 3391 | 1 | /* GTK - The GIMP Toolkit |
| 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald | |
| 3 | * | |
| 4 | * This library is free software; you can redistribute it and/or | |
| 5 | * modify it under the terms of the GNU Library General Public | |
| 6 | * License as published by the Free Software Foundation; either | |
| 7 | * version 2 of the License, or (at your option) any later version. | |
| 8 | * | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Library General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Library General Public | |
| 15 | * License along with this library; if not, write to the | |
| 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 17 | * Boston, MA 02111-1307, USA. | |
| 18 | */ | |
| 19 | ||
| 20 | /* | |
| 21 | * GtkTicker Copyright 2000 Syd Logan | |
| 22 | */ | |
| 23 | ||
| 24 | #include "gtkticker.h" | |
| 25 | #include <gtk/gtk.h> | |
| 26 | ||
| 27 | static void gtk_ticker_compute_offsets (GtkTicker *ticker); | |
| 28 | static void gtk_ticker_class_init (GtkTickerClass *klass); | |
| 29 | static void gtk_ticker_init (GtkTicker *ticker); | |
| 30 | static void gtk_ticker_map (GtkWidget *widget); | |
| 31 | static void gtk_ticker_realize (GtkWidget *widget); | |
| 32 | static void gtk_ticker_size_request (GtkWidget *widget, | |
| 5170 | 33 | GtkRequisition *requisition); |
| 3391 | 34 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 5170 | 35 | GtkAllocation *allocation); |
| 3391 | 36 | static void gtk_ticker_add_real (GtkContainer *container, |
| 5170 | 37 | GtkWidget *widget); |
| 3391 | 38 | static void gtk_ticker_remove_real (GtkContainer *container, |
| 5170 | 39 | GtkWidget *widget); |
| 3391 | 40 | static void gtk_ticker_forall (GtkContainer *container, |
| 5170 | 41 | gboolean include_internals, |
| 42 | GtkCallback callback, | |
| 43 | gpointer callback_data); | |
| 3391 | 44 | static GtkType gtk_ticker_child_type (GtkContainer *container); |
| 45 | ||
| 46 | ||
| 47 | static GtkContainerClass *parent_class = NULL; | |
| 48 | ||
| 49 | ||
| 5170 | 50 | GType gtk_ticker_get_type (void) |
| 3391 | 51 | { |
| 5170 | 52 | static GType ticker_type = 0; |
| 3391 | 53 | |
|
6560
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
54 | ticker_type = g_type_from_name("GtkTicker"); |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
55 | |
| 5170 | 56 | if (!ticker_type) |
| 57 | { | |
| 58 | static const GTypeInfo ticker_info = | |
| 59 | { | |
| 60 | sizeof(GtkTickerClass), | |
| 61 | NULL, | |
| 62 | NULL, | |
| 63 | (GClassInitFunc) gtk_ticker_class_init, | |
| 64 | NULL, | |
| 65 | NULL, | |
| 66 | sizeof(GtkTicker), | |
| 67 | 0, | |
| 68 | (GInstanceInitFunc) gtk_ticker_init | |
| 69 | }; | |
| 3391 | 70 | |
| 5170 | 71 | ticker_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkTicker", |
| 72 | &ticker_info, 0); | |
| 73 | } | |
| 3391 | 74 | |
|
6560
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
75 | /* kludge to re-initialise the class if it's already registered */ |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
76 | else if (parent_class == NULL) { |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
77 | gtk_ticker_class_init((GtkTickerClass *)g_type_class_peek(ticker_type)); |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
78 | } |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
79 | |
| 5170 | 80 | return ticker_type; |
| 81 | } | |
| 82 | ||
| 83 | static void gtk_ticker_finalize(GObject *object) { | |
| 84 | gtk_ticker_stop_scroll(GTK_TICKER(object)); | |
| 85 | ||
| 86 | G_OBJECT_CLASS(parent_class)->finalize(object); | |
| 3391 | 87 | } |
| 88 | ||
| 5170 | 89 | static void gtk_ticker_class_init (GtkTickerClass *class) |
| 3391 | 90 | { |
| 5170 | 91 | GObjectClass *gobject_class; |
| 92 | GtkWidgetClass *widget_class; | |
| 93 | GtkContainerClass *container_class; | |
| 3391 | 94 | |
| 5170 | 95 | gobject_class = (GObjectClass*) class; |
| 96 | widget_class = (GtkWidgetClass*) class; | |
| 97 | container_class = (GtkContainerClass*) class; | |
| 98 | ||
| 99 | parent_class = gtk_type_class (GTK_TYPE_CONTAINER); | |
| 3391 | 100 | |
| 5170 | 101 | gobject_class->finalize = gtk_ticker_finalize; |
| 3391 | 102 | |
| 5170 | 103 | widget_class->map = gtk_ticker_map; |
| 104 | widget_class->realize = gtk_ticker_realize; | |
| 105 | widget_class->size_request = gtk_ticker_size_request; | |
| 106 | widget_class->size_allocate = gtk_ticker_size_allocate; | |
| 3391 | 107 | |
| 5170 | 108 | container_class->add = gtk_ticker_add_real; |
| 109 | container_class->remove = gtk_ticker_remove_real; | |
| 110 | container_class->forall = gtk_ticker_forall; | |
| 111 | container_class->child_type = gtk_ticker_child_type; | |
| 3391 | 112 | } |
| 113 | ||
| 5170 | 114 | static GtkType gtk_ticker_child_type (GtkContainer *container) |
| 3391 | 115 | { |
| 5170 | 116 | return GTK_TYPE_WIDGET; |
| 3391 | 117 | } |
| 118 | ||
| 5170 | 119 | static void gtk_ticker_init (GtkTicker *ticker) |
| 3391 | 120 | { |
| 5170 | 121 | GTK_WIDGET_UNSET_FLAGS (ticker, GTK_NO_WINDOW); |
| 3391 | 122 | |
| 5170 | 123 | ticker->interval = (guint) 200; |
| 124 | ticker->scootch = (guint) 2; | |
| 125 | ticker->children = NULL; | |
| 126 | ticker->timer = 0; | |
| 127 | ticker->dirty = TRUE; | |
| 3391 | 128 | } |
| 129 | ||
| 5170 | 130 | GtkWidget* gtk_ticker_new (void) |
| 3391 | 131 | { |
| 4635 | 132 | return GTK_WIDGET(g_object_new(GTK_TYPE_TICKER, NULL)); |
| 3391 | 133 | } |
| 134 | ||
| 5170 | 135 | static void gtk_ticker_put (GtkTicker *ticker, GtkWidget *widget) |
| 3391 | 136 | { |
| 5170 | 137 | GtkTickerChild *child_info; |
| 3391 | 138 | |
| 5170 | 139 | g_return_if_fail (ticker != NULL); |
| 140 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 141 | g_return_if_fail (widget != NULL); | |
| 3391 | 142 | |
| 5170 | 143 | child_info = g_new(GtkTickerChild, 1); |
| 144 | child_info->widget = widget; | |
| 145 | child_info->x = 0; | |
| 3391 | 146 | |
| 5170 | 147 | gtk_widget_set_parent(widget, GTK_WIDGET (ticker)); |
| 3391 | 148 | |
| 5170 | 149 | ticker->children = g_list_append (ticker->children, child_info); |
| 3391 | 150 | |
| 5170 | 151 | if (GTK_WIDGET_REALIZED (ticker)) |
| 152 | gtk_widget_realize (widget); | |
| 3391 | 153 | |
| 5170 | 154 | if (GTK_WIDGET_VISIBLE (ticker) && GTK_WIDGET_VISIBLE (widget)) |
| 155 | { | |
| 156 | if (GTK_WIDGET_MAPPED (ticker)) | |
| 157 | gtk_widget_map (widget); | |
| 158 | ||
| 159 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); | |
| 160 | } | |
| 3391 | 161 | } |
| 162 | ||
| 5170 | 163 | void gtk_ticker_set_interval (GtkTicker *ticker, gint interval) |
| 3391 | 164 | { |
| 5170 | 165 | g_return_if_fail (ticker != NULL); |
| 166 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 167 | |
| 5170 | 168 | if ( interval < 0 ) |
| 169 | interval = 200; | |
| 170 | ticker->interval = interval; | |
| 3391 | 171 | } |
| 172 | ||
| 5170 | 173 | guint gtk_ticker_get_interval (GtkTicker *ticker) |
| 3391 | 174 | { |
| 5170 | 175 | g_return_val_if_fail (ticker != NULL, -1); |
| 176 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 177 | |
| 5170 | 178 | return ticker->interval; |
| 3391 | 179 | } |
| 180 | ||
| 5170 | 181 | void gtk_ticker_set_scootch (GtkTicker *ticker, gint scootch) |
| 3391 | 182 | { |
| 5170 | 183 | g_return_if_fail (ticker != NULL); |
| 184 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 185 | |
| 5170 | 186 | if (scootch <= 0) |
| 187 | scootch = 2; | |
| 188 | ticker->scootch = scootch; | |
| 189 | ticker->dirty = TRUE; | |
| 3391 | 190 | } |
| 191 | ||
| 5170 | 192 | guint gtk_ticker_get_scootch (GtkTicker *ticker ) |
| 3391 | 193 | { |
| 5170 | 194 | g_return_val_if_fail (ticker != NULL, -1); |
| 195 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 196 | |
| 5170 | 197 | return ticker->scootch; |
| 3391 | 198 | } |
| 199 | ||
| 5170 | 200 | void gtk_ticker_set_spacing (GtkTicker *ticker, gint spacing ) |
| 3391 | 201 | { |
| 5170 | 202 | g_return_if_fail (ticker != NULL); |
| 203 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 204 | |
| 5170 | 205 | if ( spacing < 0 ) |
| 206 | spacing = 0; | |
| 207 | ticker->spacing = spacing; | |
| 208 | ticker->dirty = TRUE; | |
| 3391 | 209 | } |
| 210 | ||
| 5170 | 211 | static int ticker_timeout(gpointer data) |
| 3391 | 212 | { |
| 213 | GtkTicker *ticker = (GtkTicker *) data; | |
| 214 | ||
| 5170 | 215 | if (GTK_WIDGET_VISIBLE (ticker)) |
| 216 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); | |
| 3391 | 217 | |
| 218 | return( TRUE ); | |
| 219 | } | |
| 220 | ||
| 5170 | 221 | void gtk_ticker_start_scroll(GtkTicker *ticker) |
| 3391 | 222 | { |
| 5170 | 223 | g_return_if_fail (ticker != NULL); |
| 224 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 225 | if ( ticker->timer != 0 ) |
| 226 | return; | |
| 4168 | 227 | ticker->timer = g_timeout_add(ticker->interval, ticker_timeout, ticker); |
| 3391 | 228 | } |
| 229 | ||
| 5170 | 230 | void gtk_ticker_stop_scroll(GtkTicker *ticker) |
| 3391 | 231 | { |
| 5170 | 232 | g_return_if_fail (ticker != NULL); |
| 233 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 234 | if ( ticker->timer == 0 ) |
| 235 | return; | |
| 4168 | 236 | g_source_remove(ticker->timer); |
| 3391 | 237 | ticker->timer = 0; |
| 238 | } | |
| 239 | ||
| 5170 | 240 | guint gtk_ticker_get_spacing (GtkTicker *ticker ) |
| 3391 | 241 | { |
| 5170 | 242 | g_return_val_if_fail (ticker != NULL, -1); |
| 243 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 244 | |
| 5170 | 245 | return ticker->spacing; |
| 3391 | 246 | } |
| 247 | ||
| 5170 | 248 | static void gtk_ticker_map (GtkWidget *widget) |
| 3391 | 249 | { |
| 5170 | 250 | GtkTicker *ticker; |
| 251 | GtkTickerChild *child; | |
| 252 | GList *children; | |
| 3391 | 253 | |
| 5170 | 254 | g_return_if_fail (widget != NULL); |
| 255 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 256 | |
| 5170 | 257 | GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); |
| 258 | ticker = GTK_TICKER (widget); | |
| 3391 | 259 | |
| 5170 | 260 | children = ticker->children; |
| 261 | while (children) | |
| 262 | { | |
| 263 | child = children->data; | |
| 264 | children = children->next; | |
| 3391 | 265 | |
| 5170 | 266 | if (GTK_WIDGET_VISIBLE (child->widget) && |
| 267 | !GTK_WIDGET_MAPPED (child->widget)) | |
| 268 | gtk_widget_map (child->widget); | |
| 269 | } | |
| 3391 | 270 | |
| 5170 | 271 | gdk_window_show (widget->window); |
| 3391 | 272 | } |
| 273 | ||
| 5170 | 274 | static void gtk_ticker_realize (GtkWidget *widget) |
| 3391 | 275 | { |
| 5170 | 276 | GdkWindowAttr attributes; |
| 277 | gint attributes_mask; | |
| 3391 | 278 | |
| 5170 | 279 | g_return_if_fail (widget != NULL); |
| 280 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 281 | |
| 5170 | 282 | GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); |
| 3391 | 283 | |
| 5170 | 284 | attributes.window_type = GDK_WINDOW_CHILD; |
| 285 | attributes.x = widget->allocation.x; | |
| 286 | attributes.y = widget->allocation.y; | |
| 287 | attributes.width = widget->allocation.width; | |
| 288 | attributes.height = widget->allocation.height; | |
| 289 | attributes.wclass = GDK_INPUT_OUTPUT; | |
| 290 | attributes.visual = gtk_widget_get_visual (widget); | |
| 291 | attributes.colormap = gtk_widget_get_colormap (widget); | |
| 292 | attributes.event_mask = gtk_widget_get_events (widget); | |
| 293 | attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; | |
| 3391 | 294 | |
| 5170 | 295 | attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
| 3391 | 296 | |
| 5170 | 297 | widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), |
| 298 | &attributes, attributes_mask); | |
| 299 | gdk_window_set_user_data (widget->window, widget); | |
| 3391 | 300 | |
| 5170 | 301 | widget->style = gtk_style_attach (widget->style, widget->window); |
| 302 | gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); | |
| 3391 | 303 | } |
| 304 | ||
| 5170 | 305 | static void gtk_ticker_size_request (GtkWidget *widget, GtkRequisition *requisition) |
| 3391 | 306 | { |
| 5170 | 307 | GtkTicker *ticker; |
| 308 | GtkTickerChild *child; | |
| 309 | GList *children; | |
| 310 | GtkRequisition child_requisition; | |
| 3391 | 311 | |
| 5170 | 312 | g_return_if_fail (widget != NULL); |
| 313 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 314 | g_return_if_fail (requisition != NULL); | |
| 3391 | 315 | |
| 5170 | 316 | ticker = GTK_TICKER (widget); |
| 317 | requisition->width = 0; | |
| 318 | requisition->height = 0; | |
| 3391 | 319 | |
| 5170 | 320 | children = ticker->children; |
| 321 | while (children) | |
| 322 | { | |
| 323 | child = children->data; | |
| 324 | children = children->next; | |
| 3391 | 325 | |
| 5170 | 326 | if (GTK_WIDGET_VISIBLE (child->widget)) |
| 327 | { | |
| 328 | gtk_widget_size_request (child->widget, &child_requisition); | |
| 3391 | 329 | |
| 5170 | 330 | requisition->height = MAX (requisition->height, |
| 331 | child_requisition.height); | |
| 332 | requisition->width += child_requisition.width + ticker->spacing; | |
| 333 | } | |
| 3391 | 334 | } |
| 5170 | 335 | if ( requisition->width > ticker->spacing ) |
| 336 | requisition->width -= ticker->spacing; | |
| 3391 | 337 | |
| 5170 | 338 | requisition->height += GTK_CONTAINER (ticker)->border_width * 2; |
| 339 | requisition->width += GTK_CONTAINER (ticker)->border_width * 2; | |
| 3391 | 340 | } |
| 341 | ||
| 5170 | 342 | static void gtk_ticker_compute_offsets (GtkTicker *ticker) |
| 3391 | 343 | { |
| 5170 | 344 | GtkTickerChild *child; |
| 345 | GtkRequisition child_requisition; | |
| 346 | GList *children; | |
| 347 | guint16 border_width; | |
| 3391 | 348 | |
| 5170 | 349 | g_return_if_fail (ticker != NULL); |
| 350 | g_return_if_fail (GTK_IS_TICKER(ticker)); | |
| 3391 | 351 | |
| 5170 | 352 | border_width = GTK_CONTAINER (ticker)->border_width; |
| 3391 | 353 | |
| 5170 | 354 | ticker->width = GTK_WIDGET(ticker)->allocation.width; |
| 355 | ticker->total = 0; | |
| 356 | children = ticker->children; | |
| 357 | while (children) { | |
| 358 | child = children->data; | |
| 359 | ||
| 360 | child->x = 0; | |
| 361 | if (GTK_WIDGET_VISIBLE (child->widget)) { | |
| 362 | gtk_widget_get_child_requisition (child->widget, &child_requisition); | |
| 363 | child->offset = ticker->total; | |
| 364 | ticker->total += | |
| 365 | child_requisition.width + border_width + ticker->spacing; | |
| 366 | } | |
| 367 | children = children->next; | |
| 368 | } | |
| 369 | ticker->dirty = FALSE; | |
| 3391 | 370 | } |
| 371 | ||
| 5170 | 372 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 373 | GtkAllocation *allocation) | |
| 3391 | 374 | { |
| 5170 | 375 | GtkTicker *ticker; |
| 376 | GtkTickerChild *child; | |
| 377 | GtkAllocation child_allocation; | |
| 378 | GtkRequisition child_requisition; | |
| 379 | GList *children; | |
| 380 | guint16 border_width; | |
| 381 | ||
| 382 | g_return_if_fail (widget != NULL); | |
| 383 | g_return_if_fail (GTK_IS_TICKER(widget)); | |
| 384 | g_return_if_fail (allocation != NULL); | |
| 385 | ||
| 386 | ticker = GTK_TICKER (widget); | |
| 3391 | 387 | |
| 5170 | 388 | if ( GTK_WIDGET(ticker)->allocation.width != ticker->width ) |
| 389 | ticker->dirty = TRUE; | |
| 3391 | 390 | |
| 5170 | 391 | if ( ticker->dirty == TRUE ) { |
| 392 | gtk_ticker_compute_offsets( ticker ); | |
| 393 | } | |
| 3391 | 394 | |
| 5170 | 395 | widget->allocation = *allocation; |
| 396 | if (GTK_WIDGET_REALIZED (widget)) | |
| 397 | gdk_window_move_resize (widget->window, | |
| 398 | allocation->x, | |
| 399 | allocation->y, | |
| 400 | allocation->width, | |
| 401 | allocation->height); | |
| 3391 | 402 | |
| 5170 | 403 | border_width = GTK_CONTAINER (ticker)->border_width; |
| 3391 | 404 | |
| 5170 | 405 | children = ticker->children; |
| 406 | while (children) | |
| 407 | { | |
| 408 | child = children->data; | |
| 409 | child->x -= ticker->scootch; | |
| 3391 | 410 | |
| 5170 | 411 | if (GTK_WIDGET_VISIBLE (child->widget)) { |
| 412 | gtk_widget_get_child_requisition (child->widget, &child_requisition); | |
| 413 | child_allocation.width = child_requisition.width; | |
| 414 | child_allocation.x = child->offset + border_width + child->x; | |
| 415 | if ( ( child_allocation.x + child_allocation.width ) < GTK_WIDGET(ticker)->allocation.x ) { | |
| 416 | if ( ticker->total >= GTK_WIDGET(ticker)->allocation.width ) { | |
| 417 | child->x += GTK_WIDGET(ticker)->allocation.x + GTK_WIDGET(ticker)->allocation.width + ( ticker->total - ( GTK_WIDGET(ticker)->allocation.x + GTK_WIDGET(ticker)->allocation.width ) ); | |
| 418 | } | |
| 419 | else { | |
| 420 | child->x += GTK_WIDGET(ticker)->allocation.x + GTK_WIDGET(ticker)->allocation.width; | |
| 421 | } | |
| 422 | } | |
| 423 | child_allocation.y = border_width; | |
| 424 | child_allocation.height = child_requisition.height; | |
| 425 | gtk_widget_size_allocate (child->widget, &child_allocation); | |
| 3391 | 426 | } |
| 5170 | 427 | children = children->next; |
| 428 | } | |
| 429 | } | |
| 430 | ||
| 431 | void gtk_ticker_add(GtkTicker *ticker, GtkWidget *widget) | |
| 432 | { | |
| 433 | gtk_ticker_add_real( GTK_CONTAINER( ticker ), widget ); | |
| 434 | ticker->dirty = TRUE; | |
| 435 | } | |
| 436 | ||
| 437 | void gtk_ticker_remove(GtkTicker *ticker, GtkWidget *widget) | |
| 438 | { | |
| 439 | gtk_ticker_remove_real( GTK_CONTAINER( ticker ), widget ); | |
| 440 | ticker->dirty = TRUE; | |
| 3391 | 441 | } |
| 442 | ||
| 5170 | 443 | static void gtk_ticker_add_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 444 | { |
| 5170 | 445 | g_return_if_fail (container != NULL); |
| 446 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 447 | g_return_if_fail (widget != NULL); | |
| 3391 | 448 | |
| 5170 | 449 | gtk_ticker_put(GTK_TICKER (container), widget); |
| 3391 | 450 | } |
| 451 | ||
| 5170 | 452 | static void gtk_ticker_remove_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 453 | { |
| 5170 | 454 | GtkTicker *ticker; |
| 455 | GtkTickerChild *child; | |
| 456 | GList *children; | |
| 3391 | 457 | |
| 5170 | 458 | g_return_if_fail (container != NULL); |
| 459 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 460 | g_return_if_fail (widget != NULL); | |
| 3391 | 461 | |
| 5170 | 462 | ticker = GTK_TICKER (container); |
| 3391 | 463 | |
| 5170 | 464 | children = ticker->children; |
| 465 | while (children) | |
| 466 | { | |
| 467 | child = children->data; | |
| 3391 | 468 | |
| 5170 | 469 | if (child->widget == widget) |
| 470 | { | |
| 471 | gboolean was_visible = GTK_WIDGET_VISIBLE (widget); | |
| 472 | ||
| 473 | gtk_widget_unparent (widget); | |
| 3391 | 474 | |
| 5170 | 475 | ticker->children = g_list_remove_link (ticker->children, children); |
| 476 | g_list_free (children); | |
| 477 | g_free (child); | |
| 3391 | 478 | |
| 5170 | 479 | if (was_visible && GTK_WIDGET_VISIBLE (container)) |
| 480 | gtk_widget_queue_resize (GTK_WIDGET (container)); | |
| 3391 | 481 | |
| 5170 | 482 | break; |
| 483 | } | |
| 3391 | 484 | |
| 5170 | 485 | children = children->next; |
| 486 | } | |
| 3391 | 487 | } |
| 488 | ||
| 5170 | 489 | static void gtk_ticker_forall (GtkContainer *container, |
| 490 | gboolean include_internals, | |
| 491 | GtkCallback callback, | |
| 492 | gpointer callback_data) | |
| 3391 | 493 | { |
| 5170 | 494 | GtkTicker *ticker; |
| 495 | GtkTickerChild *child; | |
| 496 | GList *children; | |
| 497 | ||
| 498 | g_return_if_fail (container != NULL); | |
| 499 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 500 | g_return_if_fail (callback != NULL); | |
| 3391 | 501 | |
| 5170 | 502 | ticker = GTK_TICKER (container); |
| 3391 | 503 | |
| 5170 | 504 | children = ticker->children; |
| 505 | while (children) | |
| 506 | { | |
| 507 | child = children->data; | |
| 508 | children = children->next; | |
| 3391 | 509 | |
| 5170 | 510 | (* callback) (child->widget, callback_data); |
| 511 | } | |
| 3391 | 512 | } |
| 5170 | 513 |