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