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