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