Sat, 12 Oct 2019 18:38:58 -0500
Fix a typo? Not sure what happened here...
| 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 | |
|
39554
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
29 | struct _GtkTicker |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
30 | { |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
31 | GtkContainer container; |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
32 | guint interval; /* how often to scootch */ |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
33 | gint spacing; /* inter-child horizontal spacing */ |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
34 | guint scootch; /* how many pixels to move each scootch */ |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
35 | gint timer; /* timer object */ |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
36 | gint total; /* total width of widgets */ |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
37 | gint width; /* width of containing window */ |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
38 | gboolean dirty; |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
39 | GList *children; |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
40 | }; |
|
5db4b5afd647
Use G_DECLARE_FINAL_TYPE for GtkTicker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
41 | |
| 3391 | 42 | static void gtk_ticker_compute_offsets (GtkTicker *ticker); |
| 43 | static void gtk_ticker_class_init (GtkTickerClass *klass); | |
| 44 | static void gtk_ticker_init (GtkTicker *ticker); | |
| 45 | static void gtk_ticker_map (GtkWidget *widget); | |
| 46 | static void gtk_ticker_realize (GtkWidget *widget); | |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
47 | 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
|
48 | gint *minimal_width, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
49 | gint *natural_width); |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
50 | 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
|
51 | gint *minimal_height, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
52 | gint *natural_height); |
| 3391 | 53 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 5170 | 54 | GtkAllocation *allocation); |
| 3391 | 55 | static void gtk_ticker_add_real (GtkContainer *container, |
| 5170 | 56 | GtkWidget *widget); |
| 3391 | 57 | static void gtk_ticker_remove_real (GtkContainer *container, |
| 5170 | 58 | GtkWidget *widget); |
| 3391 | 59 | static void gtk_ticker_forall (GtkContainer *container, |
| 5170 | 60 | gboolean include_internals, |
| 61 | GtkCallback callback, | |
| 62 | 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
|
63 | static GType gtk_ticker_child_type (GtkContainer *container); |
| 3391 | 64 | |
| 65 | ||
| 66 | static GtkContainerClass *parent_class = NULL; | |
| 67 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
68 | G_DEFINE_DYNAMIC_TYPE(GtkTicker, gtk_ticker, GTK_TYPE_CONTAINER); |
| 3391 | 69 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
70 | /* This exists solely because the above macro makes gtk_ticker_register_type |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
71 | * static. */ |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
72 | void |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
73 | gtk_ticker_register(PurplePlugin *plugin) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
74 | { |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
75 | gtk_ticker_register_type(G_TYPE_MODULE(plugin)); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
76 | } |
| 5170 | 77 | |
| 78 | static void gtk_ticker_finalize(GObject *object) { | |
| 79 | gtk_ticker_stop_scroll(GTK_TICKER(object)); | |
| 80 | ||
| 81 | G_OBJECT_CLASS(parent_class)->finalize(object); | |
| 3391 | 82 | } |
| 83 | ||
| 5170 | 84 | static void gtk_ticker_class_init (GtkTickerClass *class) |
| 3391 | 85 | { |
| 5170 | 86 | GObjectClass *gobject_class; |
| 87 | GtkWidgetClass *widget_class; | |
| 88 | GtkContainerClass *container_class; | |
| 3391 | 89 | |
| 5170 | 90 | gobject_class = (GObjectClass*) class; |
| 91 | widget_class = (GtkWidgetClass*) class; | |
| 92 | container_class = (GtkContainerClass*) class; | |
| 93 | ||
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
94 | parent_class = g_type_class_ref (GTK_TYPE_CONTAINER); |
| 3391 | 95 | |
| 5170 | 96 | gobject_class->finalize = gtk_ticker_finalize; |
| 3391 | 97 | |
| 5170 | 98 | widget_class->map = gtk_ticker_map; |
| 99 | widget_class->realize = gtk_ticker_realize; | |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
100 | 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
|
101 | widget_class->get_preferred_height = gtk_ticker_get_preferred_height; |
| 5170 | 102 | widget_class->size_allocate = gtk_ticker_size_allocate; |
| 3391 | 103 | |
| 5170 | 104 | container_class->add = gtk_ticker_add_real; |
| 105 | container_class->remove = gtk_ticker_remove_real; | |
| 106 | container_class->forall = gtk_ticker_forall; | |
| 107 | container_class->child_type = gtk_ticker_child_type; | |
| 3391 | 108 | } |
| 109 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
110 | static void |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
111 | gtk_ticker_class_finalize(G_GNUC_UNUSED GtkTickerClass *klass) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
112 | { |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
113 | } |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39554
diff
changeset
|
114 | |
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
115 | static GType gtk_ticker_child_type (GtkContainer *container) |
| 3391 | 116 | { |
| 5170 | 117 | return GTK_TYPE_WIDGET; |
| 3391 | 118 | } |
| 119 | ||
| 5170 | 120 | static void gtk_ticker_init (GtkTicker *ticker) |
| 3391 | 121 | { |
|
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
|
122 | gtk_widget_set_has_window (GTK_WIDGET (ticker), TRUE); |
| 3391 | 123 | |
| 5170 | 124 | ticker->interval = (guint) 200; |
| 125 | ticker->scootch = (guint) 2; | |
| 126 | ticker->children = NULL; | |
| 127 | ticker->timer = 0; | |
| 128 | ticker->dirty = TRUE; | |
| 3391 | 129 | } |
| 130 | ||
| 5170 | 131 | GtkWidget* gtk_ticker_new (void) |
| 3391 | 132 | { |
| 4635 | 133 | return GTK_WIDGET(g_object_new(GTK_TYPE_TICKER, NULL)); |
| 3391 | 134 | } |
| 135 | ||
| 5170 | 136 | static void gtk_ticker_put (GtkTicker *ticker, GtkWidget *widget) |
| 3391 | 137 | { |
| 5170 | 138 | GtkTickerChild *child_info; |
| 3391 | 139 | |
| 5170 | 140 | g_return_if_fail (ticker != NULL); |
| 141 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 142 | g_return_if_fail (widget != NULL); | |
| 3391 | 143 | |
| 5170 | 144 | child_info = g_new(GtkTickerChild, 1); |
| 145 | child_info->widget = widget; | |
| 146 | child_info->x = 0; | |
| 3391 | 147 | |
| 5170 | 148 | gtk_widget_set_parent(widget, GTK_WIDGET (ticker)); |
| 3391 | 149 | |
| 5170 | 150 | ticker->children = g_list_append (ticker->children, child_info); |
| 3391 | 151 | |
|
32903
ac8c85044e35
Fix a type warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32382
diff
changeset
|
152 | if (gtk_widget_get_realized (GTK_WIDGET (ticker))) |
| 5170 | 153 | gtk_widget_realize (widget); |
| 3391 | 154 | |
|
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
|
155 | 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
|
156 | gtk_widget_get_visible (widget)) |
| 5170 | 157 | { |
|
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
|
158 | if (gtk_widget_get_mapped (GTK_WIDGET (ticker))) |
| 5170 | 159 | gtk_widget_map (widget); |
| 160 | ||
| 161 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); | |
| 162 | } | |
| 3391 | 163 | } |
| 164 | ||
| 5170 | 165 | void gtk_ticker_set_interval (GtkTicker *ticker, gint interval) |
| 3391 | 166 | { |
| 5170 | 167 | g_return_if_fail (ticker != NULL); |
| 168 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 169 | |
| 5170 | 170 | if ( interval < 0 ) |
| 171 | interval = 200; | |
| 172 | ticker->interval = interval; | |
| 3391 | 173 | } |
| 174 | ||
| 5170 | 175 | guint gtk_ticker_get_interval (GtkTicker *ticker) |
| 3391 | 176 | { |
| 5170 | 177 | g_return_val_if_fail (ticker != NULL, -1); |
| 178 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 179 | |
| 5170 | 180 | return ticker->interval; |
| 3391 | 181 | } |
| 182 | ||
| 5170 | 183 | void gtk_ticker_set_scootch (GtkTicker *ticker, gint scootch) |
| 3391 | 184 | { |
| 5170 | 185 | g_return_if_fail (ticker != NULL); |
| 186 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 187 | |
| 5170 | 188 | if (scootch <= 0) |
| 189 | scootch = 2; | |
| 190 | ticker->scootch = scootch; | |
| 191 | ticker->dirty = TRUE; | |
| 3391 | 192 | } |
| 193 | ||
| 5170 | 194 | guint gtk_ticker_get_scootch (GtkTicker *ticker ) |
| 3391 | 195 | { |
| 5170 | 196 | g_return_val_if_fail (ticker != NULL, -1); |
| 197 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 198 | |
| 5170 | 199 | return ticker->scootch; |
| 3391 | 200 | } |
| 201 | ||
| 5170 | 202 | void gtk_ticker_set_spacing (GtkTicker *ticker, gint spacing ) |
| 3391 | 203 | { |
| 5170 | 204 | g_return_if_fail (ticker != NULL); |
| 205 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 206 | |
| 5170 | 207 | if ( spacing < 0 ) |
| 208 | spacing = 0; | |
| 209 | ticker->spacing = spacing; | |
| 210 | ticker->dirty = TRUE; | |
| 3391 | 211 | } |
| 212 | ||
| 5170 | 213 | static int ticker_timeout(gpointer data) |
| 3391 | 214 | { |
| 215 | GtkTicker *ticker = (GtkTicker *) data; | |
| 216 | ||
|
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
|
217 | if (gtk_widget_get_visible (GTK_WIDGET (ticker))) |
| 5170 | 218 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); |
| 3391 | 219 | |
| 220 | return( TRUE ); | |
| 221 | } | |
| 222 | ||
| 5170 | 223 | void gtk_ticker_start_scroll(GtkTicker *ticker) |
| 3391 | 224 | { |
| 5170 | 225 | g_return_if_fail (ticker != NULL); |
| 226 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 227 | if ( ticker->timer != 0 ) |
| 228 | return; | |
| 4168 | 229 | ticker->timer = g_timeout_add(ticker->interval, ticker_timeout, ticker); |
| 3391 | 230 | } |
| 231 | ||
| 5170 | 232 | void gtk_ticker_stop_scroll(GtkTicker *ticker) |
| 3391 | 233 | { |
| 5170 | 234 | g_return_if_fail (ticker != NULL); |
| 235 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 236 | if ( ticker->timer == 0 ) |
| 237 | return; | |
| 4168 | 238 | g_source_remove(ticker->timer); |
| 3391 | 239 | ticker->timer = 0; |
| 240 | } | |
| 241 | ||
| 5170 | 242 | guint gtk_ticker_get_spacing (GtkTicker *ticker ) |
| 3391 | 243 | { |
| 5170 | 244 | g_return_val_if_fail (ticker != NULL, -1); |
| 245 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 246 | |
| 5170 | 247 | return ticker->spacing; |
| 3391 | 248 | } |
| 249 | ||
| 5170 | 250 | static void gtk_ticker_map (GtkWidget *widget) |
| 3391 | 251 | { |
| 5170 | 252 | GtkTicker *ticker; |
| 253 | GtkTickerChild *child; | |
| 254 | GList *children; | |
| 3391 | 255 | |
| 5170 | 256 | g_return_if_fail (widget != NULL); |
| 257 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 258 | |
|
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
|
259 | gtk_widget_set_mapped (widget, TRUE); |
| 5170 | 260 | ticker = GTK_TICKER (widget); |
| 3391 | 261 | |
| 5170 | 262 | children = ticker->children; |
| 263 | while (children) | |
| 264 | { | |
| 265 | child = children->data; | |
| 266 | children = children->next; | |
| 3391 | 267 | |
|
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
|
268 | 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
|
269 | !gtk_widget_get_mapped (child->widget)) |
| 5170 | 270 | gtk_widget_map (child->widget); |
| 271 | } | |
| 3391 | 272 | |
|
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
|
273 | gdk_window_show (gtk_widget_get_window (widget)); |
| 3391 | 274 | } |
| 275 | ||
| 5170 | 276 | static void gtk_ticker_realize (GtkWidget *widget) |
| 3391 | 277 | { |
| 5170 | 278 | GdkWindowAttr attributes; |
| 279 | 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
|
280 | GdkWindow *window; |
|
33271
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
281 | GtkStyleContext *context; |
|
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
|
282 | GtkAllocation allocation; |
| 3391 | 283 | |
| 5170 | 284 | g_return_if_fail (widget != NULL); |
| 285 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 286 | |
|
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
|
287 | gtk_widget_set_realized (widget, TRUE); |
| 3391 | 288 | |
| 5170 | 289 | 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
|
290 | 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
|
291 | 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
|
292 | 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
|
293 | 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
|
294 | attributes.height = allocation.height; |
| 5170 | 295 | attributes.wclass = GDK_INPUT_OUTPUT; |
| 296 | attributes.visual = gtk_widget_get_visual (widget); | |
| 297 | attributes.event_mask = gtk_widget_get_events (widget); | |
| 298 | attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; | |
| 3391 | 299 | |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
300 | attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; |
| 3391 | 301 | |
|
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
|
302 | window = gdk_window_new (gtk_widget_get_parent_window (widget), |
| 5170 | 303 | &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
|
304 | 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
|
305 | gdk_window_set_user_data (window, widget); |
| 3391 | 306 | |
|
33271
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
307 | context = gtk_widget_get_style_context(widget); |
|
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
308 | gtk_style_context_add_class(context, GTK_STYLE_CLASS_BACKGROUND); |
| 35030 | 309 | gtk_style_context_set_state(context, GTK_STATE_FLAG_NORMAL); |
|
33271
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
310 | gtk_style_context_set_background(context, window); |
| 3391 | 311 | } |
| 312 | ||
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
313 | static void |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
314 | 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
|
315 | gint *minimal_width, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
316 | gint *natural_width) |
| 3391 | 317 | { |
| 5170 | 318 | GtkTicker *ticker; |
| 319 | GtkTickerChild *child; | |
| 320 | GList *children; | |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
321 | 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
|
322 | 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
|
323 | guint border_width; |
| 3391 | 324 | |
| 5170 | 325 | 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
|
326 | *minimal_width = width = 0; |
| 3391 | 327 | |
| 5170 | 328 | children = ticker->children; |
| 329 | while (children) | |
| 330 | { | |
| 331 | child = children->data; | |
| 332 | children = children->next; | |
| 3391 | 333 | |
|
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
|
334 | if (gtk_widget_get_visible (child->widget)) |
| 5170 | 335 | { |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
336 | gtk_widget_get_preferred_width (child->widget, &child_min_width, &child_nat_width); |
| 3391 | 337 | |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
338 | 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
|
339 | *minimal_width = MAX(*minimal_width, child_min_width); |
| 5170 | 340 | } |
| 3391 | 341 | } |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
342 | if ( width > ticker->spacing ) |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
343 | width -= ticker->spacing; |
| 3391 | 344 | |
|
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 | 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
|
346 | width += border_width * 2; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
347 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
348 | *natural_width = width; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
349 | } |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
350 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
351 | static void |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
352 | 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
|
353 | gint *minimal_height, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
354 | gint *natural_height) |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
355 | { |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
356 | GtkTicker *ticker; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
357 | GtkTickerChild *child; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
358 | GList *children; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
359 | 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
|
360 | gint height; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
361 | guint border_width; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
362 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
363 | ticker = GTK_TICKER (widget); |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
364 | height = 0; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
365 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
366 | children = ticker->children; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
367 | while (children) |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
368 | { |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
369 | child = children->data; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
370 | children = children->next; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
371 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
372 | 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
|
373 | { |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
374 | 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
|
375 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
376 | 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
|
377 | } |
|
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 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
380 | 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
|
381 | height += border_width * 2; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
382 | *minimal_height = *natural_height = height; |
| 3391 | 383 | } |
| 384 | ||
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
385 | |
| 5170 | 386 | static void gtk_ticker_compute_offsets (GtkTicker *ticker) |
| 3391 | 387 | { |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
388 | GtkAllocation allocation; |
| 5170 | 389 | GtkTickerChild *child; |
| 390 | GtkRequisition child_requisition; | |
| 391 | GList *children; | |
| 392 | guint16 border_width; | |
| 3391 | 393 | |
| 5170 | 394 | g_return_if_fail (ticker != NULL); |
| 395 | g_return_if_fail (GTK_IS_TICKER(ticker)); | |
| 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)); |
| 3391 | 398 | |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
399 | 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
|
400 | ticker->width = allocation.width; |
| 5170 | 401 | ticker->total = 0; |
| 402 | children = ticker->children; | |
| 403 | while (children) { | |
| 404 | child = children->data; | |
| 405 | ||
| 406 | 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
|
407 | if (gtk_widget_get_visible (child->widget)) { |
|
33278
137daf2c99b4
Remove deprecated gtk_widget_get_child_requisition calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33271
diff
changeset
|
408 | gtk_widget_get_preferred_size (child->widget, NULL, &child_requisition); |
| 5170 | 409 | child->offset = ticker->total; |
| 410 | ticker->total += | |
| 411 | child_requisition.width + border_width + ticker->spacing; | |
| 412 | } | |
| 413 | children = children->next; | |
| 414 | } | |
| 415 | ticker->dirty = FALSE; | |
| 3391 | 416 | } |
| 417 | ||
| 5170 | 418 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 419 | GtkAllocation *allocation) | |
| 3391 | 420 | { |
| 5170 | 421 | GtkTicker *ticker; |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
422 | GtkAllocation a; |
| 5170 | 423 | GtkTickerChild *child; |
| 424 | GtkAllocation child_allocation; | |
| 425 | GtkRequisition child_requisition; | |
| 426 | GList *children; | |
| 427 | guint16 border_width; | |
| 428 | ||
| 429 | g_return_if_fail (widget != NULL); | |
| 430 | g_return_if_fail (GTK_IS_TICKER(widget)); | |
| 431 | g_return_if_fail (allocation != NULL); | |
| 432 | ||
| 433 | ticker = GTK_TICKER (widget); | |
| 3391 | 434 | |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
435 | 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
|
436 | if ( a.width != ticker->width ) |
| 5170 | 437 | ticker->dirty = TRUE; |
| 3391 | 438 | |
| 5170 | 439 | if ( ticker->dirty == TRUE ) { |
| 440 | gtk_ticker_compute_offsets( ticker ); | |
| 441 | } | |
| 3391 | 442 | |
|
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
|
443 | 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
|
444 | 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
|
445 | gdk_window_move_resize (gtk_widget_get_window (widget), |
| 5170 | 446 | allocation->x, |
| 447 | allocation->y, | |
| 448 | allocation->width, | |
| 449 | allocation->height); | |
| 3391 | 450 | |
|
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
|
451 | border_width = gtk_container_get_border_width (GTK_CONTAINER (ticker)); |
| 3391 | 452 | |
| 5170 | 453 | children = ticker->children; |
| 454 | while (children) | |
| 455 | { | |
| 456 | child = children->data; | |
| 457 | child->x -= ticker->scootch; | |
| 3391 | 458 | |
|
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
|
459 | if (gtk_widget_get_visible (child->widget)) { |
|
33278
137daf2c99b4
Remove deprecated gtk_widget_get_child_requisition calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33271
diff
changeset
|
460 | gtk_widget_get_preferred_size (child->widget, NULL, &child_requisition); |
| 5170 | 461 | child_allocation.width = child_requisition.width; |
| 462 | 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
|
463 | 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
|
464 | 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
|
465 | child->x += allocation->x + allocation->width + ( ticker->total - ( allocation->x + allocation->width ) ); |
| 5170 | 466 | } |
| 467 | 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
|
468 | child->x += allocation->x + allocation->width; |
| 5170 | 469 | } |
| 470 | } | |
| 471 | child_allocation.y = border_width; | |
| 472 | child_allocation.height = child_requisition.height; | |
| 473 | gtk_widget_size_allocate (child->widget, &child_allocation); | |
| 3391 | 474 | } |
| 5170 | 475 | children = children->next; |
| 476 | } | |
| 477 | } | |
| 478 | ||
| 479 | void gtk_ticker_add(GtkTicker *ticker, GtkWidget *widget) | |
| 480 | { | |
| 481 | gtk_ticker_add_real( GTK_CONTAINER( ticker ), widget ); | |
| 482 | ticker->dirty = TRUE; | |
| 483 | } | |
| 484 | ||
| 485 | void gtk_ticker_remove(GtkTicker *ticker, GtkWidget *widget) | |
| 486 | { | |
| 487 | gtk_ticker_remove_real( GTK_CONTAINER( ticker ), widget ); | |
| 488 | ticker->dirty = TRUE; | |
| 3391 | 489 | } |
| 490 | ||
| 5170 | 491 | static void gtk_ticker_add_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 492 | { |
| 5170 | 493 | g_return_if_fail (container != NULL); |
| 494 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 495 | g_return_if_fail (widget != NULL); | |
| 3391 | 496 | |
| 5170 | 497 | gtk_ticker_put(GTK_TICKER (container), widget); |
| 3391 | 498 | } |
| 499 | ||
| 5170 | 500 | static void gtk_ticker_remove_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 501 | { |
| 5170 | 502 | GtkTicker *ticker; |
| 503 | GtkTickerChild *child; | |
| 504 | GList *children; | |
| 3391 | 505 | |
| 5170 | 506 | g_return_if_fail (container != NULL); |
| 507 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 508 | g_return_if_fail (widget != NULL); | |
| 3391 | 509 | |
| 5170 | 510 | ticker = GTK_TICKER (container); |
| 3391 | 511 | |
| 5170 | 512 | children = ticker->children; |
| 513 | while (children) | |
| 514 | { | |
| 515 | child = children->data; | |
| 3391 | 516 | |
| 5170 | 517 | if (child->widget == widget) |
| 518 | { | |
|
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
|
519 | gboolean was_visible = gtk_widget_get_visible (widget); |
| 5170 | 520 | |
| 521 | gtk_widget_unparent (widget); | |
| 3391 | 522 | |
| 5170 | 523 | ticker->children = g_list_remove_link (ticker->children, children); |
| 524 | g_list_free (children); | |
| 525 | g_free (child); | |
| 3391 | 526 | |
|
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 (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) |
| 5170 | 528 | gtk_widget_queue_resize (GTK_WIDGET (container)); |
| 3391 | 529 | |
| 5170 | 530 | break; |
| 531 | } | |
| 3391 | 532 | |
| 5170 | 533 | children = children->next; |
| 534 | } | |
| 3391 | 535 | } |
| 536 | ||
| 5170 | 537 | static void gtk_ticker_forall (GtkContainer *container, |
| 538 | gboolean include_internals, | |
| 539 | GtkCallback callback, | |
| 540 | gpointer callback_data) | |
| 3391 | 541 | { |
| 5170 | 542 | GtkTicker *ticker; |
| 543 | GtkTickerChild *child; | |
| 544 | GList *children; | |
| 545 | ||
| 546 | g_return_if_fail (container != NULL); | |
| 547 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 548 | g_return_if_fail (callback != NULL); | |
| 3391 | 549 | |
| 5170 | 550 | ticker = GTK_TICKER (container); |
| 3391 | 551 | |
| 5170 | 552 | children = ticker->children; |
| 553 | while (children) | |
| 554 | { | |
| 555 | child = children->data; | |
| 556 | children = children->next; | |
| 3391 | 557 | |
| 5170 | 558 | (* callback) (child->widget, callback_data); |
| 559 | } | |
| 3391 | 560 | } |
| 5170 | 561 |