Sat, 17 Apr 2010 22:21:17 +0000
gtk_widget_set_window was added in GTK+ 2.18. Thanks to Josh Mueller.
| 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15435
diff
changeset
|
16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15435
diff
changeset
|
17 | * Boston, MA 02111-1301, USA. |
| 3391 | 18 | */ |
| 19 | ||
| 20 | /* | |
| 21 | * GtkTicker Copyright 2000 Syd Logan | |
| 22 | */ | |
| 23 | ||
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
24 | /* FIXME: GTK+ deprecated GTK_WIDGET_MAPPED/REALIZED, but don't provide |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
25 | accessor functions yet. */ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
26 | #undef GSEAL_ENABLE |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
27 | |
| 3391 | 28 | #include "gtkticker.h" |
| 29 | #include <gtk/gtk.h> | |
| 30 | ||
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
31 | /* These don't seem to be in a release yet. See BZ #69872 */ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
32 | #define gtk_widget_is_mapped(x) GTK_WIDGET_MAPPED(x) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
33 | #define gtk_widget_is_realized(x) GTK_WIDGET_REALIZED(x) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
34 | #define gtk_widget_set_realized(x,y) do {\ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
35 | if (y) \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
36 | GTK_WIDGET_SET_FLAGS(x, GTK_REALIZED); \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
37 | else \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
38 | GTK_WIDGET_UNSET_FLAGS(x, GTK_REALIZED); \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
39 | } while(0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
40 | #define gtk_widget_set_mapped(x,y) do {\ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
41 | if (y) \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
42 | GTK_WIDGET_SET_FLAGS(x, GTK_MAPPED); \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
43 | else \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
44 | GTK_WIDGET_UNSET_FLAGS(x, GTK_MAPPED); \ |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
45 | } while(0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
46 | |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
47 | #if !GTK_CHECK_VERSION(2,18,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
48 | #define gtk_widget_get_visible(x) GTK_WIDGET_VISIBLE(x) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
49 | |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
50 | #if !GTK_CHECK_VERSION(2,14,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
51 | #define gtk_widget_get_window(x) x->window |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
52 | #endif |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
53 | #endif |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
54 | |
| 3391 | 55 | static void gtk_ticker_compute_offsets (GtkTicker *ticker); |
| 56 | static void gtk_ticker_class_init (GtkTickerClass *klass); | |
| 57 | static void gtk_ticker_init (GtkTicker *ticker); | |
| 58 | static void gtk_ticker_map (GtkWidget *widget); | |
| 59 | static void gtk_ticker_realize (GtkWidget *widget); | |
| 60 | static void gtk_ticker_size_request (GtkWidget *widget, | |
| 5170 | 61 | GtkRequisition *requisition); |
| 3391 | 62 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 5170 | 63 | GtkAllocation *allocation); |
| 3391 | 64 | static void gtk_ticker_add_real (GtkContainer *container, |
| 5170 | 65 | GtkWidget *widget); |
| 3391 | 66 | static void gtk_ticker_remove_real (GtkContainer *container, |
| 5170 | 67 | GtkWidget *widget); |
| 3391 | 68 | static void gtk_ticker_forall (GtkContainer *container, |
| 5170 | 69 | gboolean include_internals, |
| 70 | GtkCallback callback, | |
| 71 | gpointer callback_data); | |
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
72 | static GType gtk_ticker_child_type (GtkContainer *container); |
| 3391 | 73 | |
| 74 | ||
| 75 | static GtkContainerClass *parent_class = NULL; | |
| 76 | ||
| 77 | ||
| 5170 | 78 | GType gtk_ticker_get_type (void) |
| 3391 | 79 | { |
| 5170 | 80 | static GType ticker_type = 0; |
| 3391 | 81 | |
|
6560
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
82 | ticker_type = g_type_from_name("GtkTicker"); |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
83 | |
| 5170 | 84 | if (!ticker_type) |
| 85 | { | |
| 86 | static const GTypeInfo ticker_info = | |
| 87 | { | |
| 88 | sizeof(GtkTickerClass), | |
| 89 | NULL, | |
| 90 | NULL, | |
| 91 | (GClassInitFunc) gtk_ticker_class_init, | |
| 92 | NULL, | |
| 93 | NULL, | |
| 94 | sizeof(GtkTicker), | |
| 95 | 0, | |
| 12600 | 96 | (GInstanceInitFunc) gtk_ticker_init, |
| 97 | NULL | |
| 5170 | 98 | }; |
| 3391 | 99 | |
| 5170 | 100 | ticker_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkTicker", |
| 101 | &ticker_info, 0); | |
| 102 | } | |
| 3391 | 103 | |
|
6560
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
104 | /* kludge to re-initialise the class if it's already registered */ |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
105 | else if (parent_class == NULL) { |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
106 | gtk_ticker_class_init((GtkTickerClass *)g_type_class_peek(ticker_type)); |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
107 | } |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
108 | |
| 5170 | 109 | return ticker_type; |
| 110 | } | |
| 111 | ||
| 112 | static void gtk_ticker_finalize(GObject *object) { | |
| 113 | gtk_ticker_stop_scroll(GTK_TICKER(object)); | |
| 114 | ||
| 115 | G_OBJECT_CLASS(parent_class)->finalize(object); | |
| 3391 | 116 | } |
| 117 | ||
| 5170 | 118 | static void gtk_ticker_class_init (GtkTickerClass *class) |
| 3391 | 119 | { |
| 5170 | 120 | GObjectClass *gobject_class; |
| 121 | GtkWidgetClass *widget_class; | |
| 122 | GtkContainerClass *container_class; | |
| 3391 | 123 | |
| 5170 | 124 | gobject_class = (GObjectClass*) class; |
| 125 | widget_class = (GtkWidgetClass*) class; | |
| 126 | container_class = (GtkContainerClass*) class; | |
| 127 | ||
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
128 | parent_class = g_type_class_ref (GTK_TYPE_CONTAINER); |
| 3391 | 129 | |
| 5170 | 130 | gobject_class->finalize = gtk_ticker_finalize; |
| 3391 | 131 | |
| 5170 | 132 | widget_class->map = gtk_ticker_map; |
| 133 | widget_class->realize = gtk_ticker_realize; | |
| 134 | widget_class->size_request = gtk_ticker_size_request; | |
| 135 | widget_class->size_allocate = gtk_ticker_size_allocate; | |
| 3391 | 136 | |
| 5170 | 137 | container_class->add = gtk_ticker_add_real; |
| 138 | container_class->remove = gtk_ticker_remove_real; | |
| 139 | container_class->forall = gtk_ticker_forall; | |
| 140 | container_class->child_type = gtk_ticker_child_type; | |
| 3391 | 141 | } |
| 142 | ||
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
143 | static GType gtk_ticker_child_type (GtkContainer *container) |
| 3391 | 144 | { |
| 5170 | 145 | return GTK_TYPE_WIDGET; |
| 3391 | 146 | } |
| 147 | ||
| 5170 | 148 | static void gtk_ticker_init (GtkTicker *ticker) |
| 3391 | 149 | { |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
150 | #if GTK_CHECK_VERSION(2,18,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
151 | gtk_widget_set_has_window (GTK_WIDGET (ticker), TRUE); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
152 | #else |
| 5170 | 153 | GTK_WIDGET_UNSET_FLAGS (ticker, GTK_NO_WINDOW); |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
154 | #endif |
| 3391 | 155 | |
| 5170 | 156 | ticker->interval = (guint) 200; |
| 157 | ticker->scootch = (guint) 2; | |
| 158 | ticker->children = NULL; | |
| 159 | ticker->timer = 0; | |
| 160 | ticker->dirty = TRUE; | |
| 3391 | 161 | } |
| 162 | ||
| 5170 | 163 | GtkWidget* gtk_ticker_new (void) |
| 3391 | 164 | { |
| 4635 | 165 | return GTK_WIDGET(g_object_new(GTK_TYPE_TICKER, NULL)); |
| 3391 | 166 | } |
| 167 | ||
| 5170 | 168 | static void gtk_ticker_put (GtkTicker *ticker, GtkWidget *widget) |
| 3391 | 169 | { |
| 5170 | 170 | GtkTickerChild *child_info; |
| 3391 | 171 | |
| 5170 | 172 | g_return_if_fail (ticker != NULL); |
| 173 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 174 | g_return_if_fail (widget != NULL); | |
| 3391 | 175 | |
| 5170 | 176 | child_info = g_new(GtkTickerChild, 1); |
| 177 | child_info->widget = widget; | |
| 178 | child_info->x = 0; | |
| 3391 | 179 | |
| 5170 | 180 | gtk_widget_set_parent(widget, GTK_WIDGET (ticker)); |
| 3391 | 181 | |
| 5170 | 182 | ticker->children = g_list_append (ticker->children, child_info); |
| 3391 | 183 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
184 | if (gtk_widget_is_realized (ticker)) |
| 5170 | 185 | gtk_widget_realize (widget); |
| 3391 | 186 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
187 | if (gtk_widget_get_visible (GTK_WIDGET (ticker)) && |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
188 | gtk_widget_get_visible (widget)) |
| 5170 | 189 | { |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
190 | if (gtk_widget_is_mapped (GTK_WIDGET (ticker))) |
| 5170 | 191 | gtk_widget_map (widget); |
| 192 | ||
| 193 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); | |
| 194 | } | |
| 3391 | 195 | } |
| 196 | ||
| 5170 | 197 | void gtk_ticker_set_interval (GtkTicker *ticker, gint interval) |
| 3391 | 198 | { |
| 5170 | 199 | g_return_if_fail (ticker != NULL); |
| 200 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 201 | |
| 5170 | 202 | if ( interval < 0 ) |
| 203 | interval = 200; | |
| 204 | ticker->interval = interval; | |
| 3391 | 205 | } |
| 206 | ||
| 5170 | 207 | guint gtk_ticker_get_interval (GtkTicker *ticker) |
| 3391 | 208 | { |
| 5170 | 209 | g_return_val_if_fail (ticker != NULL, -1); |
| 210 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 211 | |
| 5170 | 212 | return ticker->interval; |
| 3391 | 213 | } |
| 214 | ||
| 5170 | 215 | void gtk_ticker_set_scootch (GtkTicker *ticker, gint scootch) |
| 3391 | 216 | { |
| 5170 | 217 | g_return_if_fail (ticker != NULL); |
| 218 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 219 | |
| 5170 | 220 | if (scootch <= 0) |
| 221 | scootch = 2; | |
| 222 | ticker->scootch = scootch; | |
| 223 | ticker->dirty = TRUE; | |
| 3391 | 224 | } |
| 225 | ||
| 5170 | 226 | guint gtk_ticker_get_scootch (GtkTicker *ticker ) |
| 3391 | 227 | { |
| 5170 | 228 | g_return_val_if_fail (ticker != NULL, -1); |
| 229 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 230 | |
| 5170 | 231 | return ticker->scootch; |
| 3391 | 232 | } |
| 233 | ||
| 5170 | 234 | void gtk_ticker_set_spacing (GtkTicker *ticker, gint spacing ) |
| 3391 | 235 | { |
| 5170 | 236 | g_return_if_fail (ticker != NULL); |
| 237 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 238 | |
| 5170 | 239 | if ( spacing < 0 ) |
| 240 | spacing = 0; | |
| 241 | ticker->spacing = spacing; | |
| 242 | ticker->dirty = TRUE; | |
| 3391 | 243 | } |
| 244 | ||
| 5170 | 245 | static int ticker_timeout(gpointer data) |
| 3391 | 246 | { |
| 247 | GtkTicker *ticker = (GtkTicker *) data; | |
| 248 | ||
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
249 | if (gtk_widget_get_visible (GTK_WIDGET (ticker))) |
| 5170 | 250 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); |
| 3391 | 251 | |
| 252 | return( TRUE ); | |
| 253 | } | |
| 254 | ||
| 5170 | 255 | void gtk_ticker_start_scroll(GtkTicker *ticker) |
| 3391 | 256 | { |
| 5170 | 257 | g_return_if_fail (ticker != NULL); |
| 258 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 259 | if ( ticker->timer != 0 ) |
| 260 | return; | |
| 4168 | 261 | ticker->timer = g_timeout_add(ticker->interval, ticker_timeout, ticker); |
| 3391 | 262 | } |
| 263 | ||
| 5170 | 264 | void gtk_ticker_stop_scroll(GtkTicker *ticker) |
| 3391 | 265 | { |
| 5170 | 266 | g_return_if_fail (ticker != NULL); |
| 267 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 268 | if ( ticker->timer == 0 ) |
| 269 | return; | |
| 4168 | 270 | g_source_remove(ticker->timer); |
| 3391 | 271 | ticker->timer = 0; |
| 272 | } | |
| 273 | ||
| 5170 | 274 | guint gtk_ticker_get_spacing (GtkTicker *ticker ) |
| 3391 | 275 | { |
| 5170 | 276 | g_return_val_if_fail (ticker != NULL, -1); |
| 277 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 278 | |
| 5170 | 279 | return ticker->spacing; |
| 3391 | 280 | } |
| 281 | ||
| 5170 | 282 | static void gtk_ticker_map (GtkWidget *widget) |
| 3391 | 283 | { |
| 5170 | 284 | GtkTicker *ticker; |
| 285 | GtkTickerChild *child; | |
| 286 | GList *children; | |
| 3391 | 287 | |
| 5170 | 288 | g_return_if_fail (widget != NULL); |
| 289 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 290 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
291 | gtk_widget_set_mapped (widget, TRUE); |
| 5170 | 292 | ticker = GTK_TICKER (widget); |
| 3391 | 293 | |
| 5170 | 294 | children = ticker->children; |
| 295 | while (children) | |
| 296 | { | |
| 297 | child = children->data; | |
| 298 | children = children->next; | |
| 3391 | 299 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
300 | if (gtk_widget_get_visible (child->widget) && |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
301 | !gtk_widget_is_mapped (child->widget)) |
| 5170 | 302 | gtk_widget_map (child->widget); |
| 303 | } | |
| 3391 | 304 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
305 | gdk_window_show (gtk_widget_get_window (widget)); |
| 3391 | 306 | } |
| 307 | ||
| 5170 | 308 | static void gtk_ticker_realize (GtkWidget *widget) |
| 3391 | 309 | { |
| 5170 | 310 | GdkWindowAttr attributes; |
| 311 | gint attributes_mask; | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
312 | GdkWindow *window; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
313 | GtkStyle *style; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
314 | #if GTK_CHECK_VERSION(2,18,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
315 | GtkAllocation allocation; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
316 | #endif |
| 3391 | 317 | |
| 5170 | 318 | g_return_if_fail (widget != NULL); |
| 319 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 320 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
321 | gtk_widget_set_realized (widget, TRUE); |
| 3391 | 322 | |
| 5170 | 323 | attributes.window_type = GDK_WINDOW_CHILD; |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
324 | #if GTK_CHECK_VERSION(2,18,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
325 | gtk_widget_get_allocation (widget, &allocation); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
326 | attributes.x = allocation.x; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
327 | attributes.y = allocation.y; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
328 | attributes.width = allocation.width; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
329 | attributes.height = allocation.height; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
330 | #else |
| 5170 | 331 | attributes.x = widget->allocation.x; |
| 332 | attributes.y = widget->allocation.y; | |
| 333 | attributes.width = widget->allocation.width; | |
| 334 | attributes.height = widget->allocation.height; | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
335 | #endif |
| 5170 | 336 | attributes.wclass = GDK_INPUT_OUTPUT; |
| 337 | attributes.visual = gtk_widget_get_visual (widget); | |
| 338 | attributes.colormap = gtk_widget_get_colormap (widget); | |
| 339 | attributes.event_mask = gtk_widget_get_events (widget); | |
| 340 | attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; | |
| 3391 | 341 | |
| 5170 | 342 | attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
| 3391 | 343 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
344 | window = gdk_window_new (gtk_widget_get_parent_window (widget), |
| 5170 | 345 | &attributes, attributes_mask); |
|
30024
f15d76be2ef8
gtk_widget_set_window was added in GTK+ 2.18. Thanks to Josh Mueller.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30010
diff
changeset
|
346 | #if GTK_CHECK_VERSION(2,18,0) |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
347 | gtk_widget_set_window (widget, window); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
348 | #else |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
349 | widget->window = window; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
350 | #endif |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
351 | gdk_window_set_user_data (window, widget); |
| 3391 | 352 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
353 | #if GTK_CHECK_VERSION(2,14,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
354 | style = gtk_widget_get_style (widget); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
355 | style = gtk_style_attach (style, window); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
356 | gtk_widget_set_style (widget, style); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
357 | #else |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
358 | style = widget->style = gtk_style_attach (widget->style, window); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
359 | #endif |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
360 | gtk_style_set_background (style, window, GTK_STATE_NORMAL); |
| 3391 | 361 | } |
| 362 | ||
| 5170 | 363 | static void gtk_ticker_size_request (GtkWidget *widget, GtkRequisition *requisition) |
| 3391 | 364 | { |
| 5170 | 365 | GtkTicker *ticker; |
| 366 | GtkTickerChild *child; | |
| 367 | GList *children; | |
| 368 | GtkRequisition child_requisition; | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
369 | guint border_width; |
| 3391 | 370 | |
| 5170 | 371 | g_return_if_fail (widget != NULL); |
| 372 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 373 | g_return_if_fail (requisition != NULL); | |
| 3391 | 374 | |
| 5170 | 375 | ticker = GTK_TICKER (widget); |
| 376 | requisition->width = 0; | |
| 377 | requisition->height = 0; | |
| 3391 | 378 | |
| 5170 | 379 | children = ticker->children; |
| 380 | while (children) | |
| 381 | { | |
| 382 | child = children->data; | |
| 383 | children = children->next; | |
| 3391 | 384 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
385 | if (gtk_widget_get_visible (child->widget)) |
| 5170 | 386 | { |
| 387 | gtk_widget_size_request (child->widget, &child_requisition); | |
| 3391 | 388 | |
| 5170 | 389 | requisition->height = MAX (requisition->height, |
| 390 | child_requisition.height); | |
| 391 | requisition->width += child_requisition.width + ticker->spacing; | |
| 392 | } | |
| 3391 | 393 | } |
| 5170 | 394 | if ( requisition->width > ticker->spacing ) |
| 395 | requisition->width -= ticker->spacing; | |
| 3391 | 396 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
397 | border_width = gtk_container_get_border_width (GTK_CONTAINER (ticker)); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
398 | requisition->height += border_width * 2; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
399 | requisition->width += border_width * 2; |
| 3391 | 400 | } |
| 401 | ||
| 5170 | 402 | static void gtk_ticker_compute_offsets (GtkTicker *ticker) |
| 3391 | 403 | { |
| 5170 | 404 | GtkTickerChild *child; |
| 405 | GtkRequisition child_requisition; | |
| 406 | GList *children; | |
| 407 | guint16 border_width; | |
| 3391 | 408 | |
| 5170 | 409 | g_return_if_fail (ticker != NULL); |
| 410 | g_return_if_fail (GTK_IS_TICKER(ticker)); | |
| 3391 | 411 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
412 | border_width = gtk_container_get_border_width (GTK_CONTAINER (ticker)); |
| 3391 | 413 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
414 | #if GTK_CHECK_VERSION(2,18,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
415 | { |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
416 | GtkAllocation allocation; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
417 | gtk_widget_get_allocation (GTK_WIDGET (ticker), &allocation); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
418 | ticker->width = allocation.width; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
419 | } |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
420 | #else |
| 5170 | 421 | ticker->width = GTK_WIDGET(ticker)->allocation.width; |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
422 | #endif |
| 5170 | 423 | ticker->total = 0; |
| 424 | children = ticker->children; | |
| 425 | while (children) { | |
| 426 | child = children->data; | |
| 427 | ||
| 428 | child->x = 0; | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
429 | if (gtk_widget_get_visible (child->widget)) { |
| 5170 | 430 | gtk_widget_get_child_requisition (child->widget, &child_requisition); |
| 431 | child->offset = ticker->total; | |
| 432 | ticker->total += | |
| 433 | child_requisition.width + border_width + ticker->spacing; | |
| 434 | } | |
| 435 | children = children->next; | |
| 436 | } | |
| 437 | ticker->dirty = FALSE; | |
| 3391 | 438 | } |
| 439 | ||
| 5170 | 440 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 441 | GtkAllocation *allocation) | |
| 3391 | 442 | { |
| 5170 | 443 | GtkTicker *ticker; |
| 444 | GtkTickerChild *child; | |
| 445 | GtkAllocation child_allocation; | |
| 446 | GtkRequisition child_requisition; | |
| 447 | GList *children; | |
| 448 | guint16 border_width; | |
| 449 | ||
| 450 | g_return_if_fail (widget != NULL); | |
| 451 | g_return_if_fail (GTK_IS_TICKER(widget)); | |
| 452 | g_return_if_fail (allocation != NULL); | |
| 453 | ||
| 454 | ticker = GTK_TICKER (widget); | |
| 3391 | 455 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
456 | #if GTK_CHECK_VERSION(2,18,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
457 | { |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
458 | GtkAllocation a; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
459 | gtk_widget_get_allocation (GTK_WIDGET (ticker), &a); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
460 | if ( a.width != ticker->width ) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
461 | ticker->dirty = TRUE; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
462 | } |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
463 | #else |
| 5170 | 464 | if ( GTK_WIDGET(ticker)->allocation.width != ticker->width ) |
| 465 | ticker->dirty = TRUE; | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
466 | #endif |
| 3391 | 467 | |
| 5170 | 468 | if ( ticker->dirty == TRUE ) { |
| 469 | gtk_ticker_compute_offsets( ticker ); | |
| 470 | } | |
| 3391 | 471 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
472 | #if GTK_CHECK_VERSION(2,18,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
473 | gtk_widget_set_allocation (widget, allocation); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
474 | #else |
| 5170 | 475 | widget->allocation = *allocation; |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
476 | #endif |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
477 | if (gtk_widget_is_realized (widget)) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
478 | gdk_window_move_resize (gtk_widget_get_window (widget), |
| 5170 | 479 | allocation->x, |
| 480 | allocation->y, | |
| 481 | allocation->width, | |
| 482 | allocation->height); | |
| 3391 | 483 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
484 | border_width = gtk_container_get_border_width (GTK_CONTAINER (ticker)); |
| 3391 | 485 | |
| 5170 | 486 | children = ticker->children; |
| 487 | while (children) | |
| 488 | { | |
| 489 | child = children->data; | |
| 490 | child->x -= ticker->scootch; | |
| 3391 | 491 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
492 | if (gtk_widget_get_visible (child->widget)) { |
| 5170 | 493 | gtk_widget_get_child_requisition (child->widget, &child_requisition); |
| 494 | child_allocation.width = child_requisition.width; | |
| 495 | child_allocation.x = child->offset + border_width + child->x; | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
496 | if ( ( child_allocation.x + child_allocation.width ) < allocation->x ) { |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
497 | if ( ticker->total >= allocation->width ) { |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
498 | child->x += allocation->x + allocation->width + ( ticker->total - ( allocation->x + allocation->width ) ); |
| 5170 | 499 | } |
| 500 | else { | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
501 | child->x += allocation->x + allocation->width; |
| 5170 | 502 | } |
| 503 | } | |
| 504 | child_allocation.y = border_width; | |
| 505 | child_allocation.height = child_requisition.height; | |
| 506 | gtk_widget_size_allocate (child->widget, &child_allocation); | |
| 3391 | 507 | } |
| 5170 | 508 | children = children->next; |
| 509 | } | |
| 510 | } | |
| 511 | ||
| 512 | void gtk_ticker_add(GtkTicker *ticker, GtkWidget *widget) | |
| 513 | { | |
| 514 | gtk_ticker_add_real( GTK_CONTAINER( ticker ), widget ); | |
| 515 | ticker->dirty = TRUE; | |
| 516 | } | |
| 517 | ||
| 518 | void gtk_ticker_remove(GtkTicker *ticker, GtkWidget *widget) | |
| 519 | { | |
| 520 | gtk_ticker_remove_real( GTK_CONTAINER( ticker ), widget ); | |
| 521 | ticker->dirty = TRUE; | |
| 3391 | 522 | } |
| 523 | ||
| 5170 | 524 | static void gtk_ticker_add_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 525 | { |
| 5170 | 526 | g_return_if_fail (container != NULL); |
| 527 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 528 | g_return_if_fail (widget != NULL); | |
| 3391 | 529 | |
| 5170 | 530 | gtk_ticker_put(GTK_TICKER (container), widget); |
| 3391 | 531 | } |
| 532 | ||
| 5170 | 533 | static void gtk_ticker_remove_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 534 | { |
| 5170 | 535 | GtkTicker *ticker; |
| 536 | GtkTickerChild *child; | |
| 537 | GList *children; | |
| 3391 | 538 | |
| 5170 | 539 | g_return_if_fail (container != NULL); |
| 540 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 541 | g_return_if_fail (widget != NULL); | |
| 3391 | 542 | |
| 5170 | 543 | ticker = GTK_TICKER (container); |
| 3391 | 544 | |
| 5170 | 545 | children = ticker->children; |
| 546 | while (children) | |
| 547 | { | |
| 548 | child = children->data; | |
| 3391 | 549 | |
| 5170 | 550 | if (child->widget == widget) |
| 551 | { | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
552 | gboolean was_visible = gtk_widget_get_visible (widget); |
| 5170 | 553 | |
| 554 | gtk_widget_unparent (widget); | |
| 3391 | 555 | |
| 5170 | 556 | ticker->children = g_list_remove_link (ticker->children, children); |
| 557 | g_list_free (children); | |
| 558 | g_free (child); | |
| 3391 | 559 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
560 | if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) |
| 5170 | 561 | gtk_widget_queue_resize (GTK_WIDGET (container)); |
| 3391 | 562 | |
| 5170 | 563 | break; |
| 564 | } | |
| 3391 | 565 | |
| 5170 | 566 | children = children->next; |
| 567 | } | |
| 3391 | 568 | } |
| 569 | ||
| 5170 | 570 | static void gtk_ticker_forall (GtkContainer *container, |
| 571 | gboolean include_internals, | |
| 572 | GtkCallback callback, | |
| 573 | gpointer callback_data) | |
| 3391 | 574 | { |
| 5170 | 575 | GtkTicker *ticker; |
| 576 | GtkTickerChild *child; | |
| 577 | GList *children; | |
| 578 | ||
| 579 | g_return_if_fail (container != NULL); | |
| 580 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 581 | g_return_if_fail (callback != NULL); | |
| 3391 | 582 | |
| 5170 | 583 | ticker = GTK_TICKER (container); |
| 3391 | 584 | |
| 5170 | 585 | children = ticker->children; |
| 586 | while (children) | |
| 587 | { | |
| 588 | child = children->data; | |
| 589 | children = children->next; | |
| 3391 | 590 | |
| 5170 | 591 | (* callback) (child->widget, callback_data); |
| 592 | } | |
| 3391 | 593 | } |
| 5170 | 594 |