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