Tue, 07 May 2013 05:04:46 -0400
Rewrite debug window filter in JS.
Note, this does cause a couple regressions, but they are probably not
that big a deal. First, the JS regular expression syntax is slightly
different. Second, the JS regex API lacks a way to reliably determine
the location of matched groups, so we can't highlight just the groups
and must highlight the entire expression.
I suspect that none of our users ever had to use any fancy regex in the
debug window, and that most of our developers didn't even know it could
be done. So I doubt these regressions will cause much pain.
| 3391 | 1 | /* GTK - The GIMP Toolkit |
| 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald | |
| 3 | * | |
| 4 | * This library is free software; you can redistribute it and/or | |
| 5 | * modify it under the terms of the GNU Library General Public | |
| 6 | * License as published by the Free Software Foundation; either | |
| 7 | * version 2 of the License, or (at your option) any later version. | |
| 8 | * | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Library General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Library General Public | |
| 15 | * License along with this library; if not, write to the | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15435
diff
changeset
|
16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15435
diff
changeset
|
17 | * Boston, MA 02111-1301, USA. |
| 3391 | 18 | */ |
| 19 | ||
| 20 | /* | |
| 21 | * GtkTicker Copyright 2000 Syd Logan | |
| 22 | */ | |
| 23 | ||
| 24 | #include "gtkticker.h" | |
| 25 | #include <gtk/gtk.h> | |
| 26 | ||
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
27 | #include "gtk3compat.h" |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
28 | |
| 3391 | 29 | static void gtk_ticker_compute_offsets (GtkTicker *ticker); |
| 30 | static void gtk_ticker_class_init (GtkTickerClass *klass); | |
| 31 | static void gtk_ticker_init (GtkTicker *ticker); | |
| 32 | static void gtk_ticker_map (GtkWidget *widget); | |
| 33 | static void gtk_ticker_realize (GtkWidget *widget); | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
34 | #if GTK_CHECK_VERSION(3,0,0) |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
35 | static void gtk_ticker_get_preferred_width (GtkWidget *widget, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
36 | gint *minimal_width, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
37 | gint *natural_width); |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
38 | static void gtk_ticker_get_preferred_height (GtkWidget *widget, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
39 | gint *minimal_height, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
40 | gint *natural_height); |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
41 | #else |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
42 | static void gtk_ticker_size_request (GtkWidget *widget, |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
43 | GtkRequisition *requisition); |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
44 | #endif |
| 3391 | 45 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 5170 | 46 | GtkAllocation *allocation); |
| 3391 | 47 | static void gtk_ticker_add_real (GtkContainer *container, |
| 5170 | 48 | GtkWidget *widget); |
| 3391 | 49 | static void gtk_ticker_remove_real (GtkContainer *container, |
| 5170 | 50 | GtkWidget *widget); |
| 3391 | 51 | static void gtk_ticker_forall (GtkContainer *container, |
| 5170 | 52 | gboolean include_internals, |
| 53 | GtkCallback callback, | |
| 54 | gpointer callback_data); | |
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
55 | static GType gtk_ticker_child_type (GtkContainer *container); |
| 3391 | 56 | |
| 57 | ||
| 58 | static GtkContainerClass *parent_class = NULL; | |
| 59 | ||
| 60 | ||
| 5170 | 61 | GType gtk_ticker_get_type (void) |
| 3391 | 62 | { |
| 5170 | 63 | static GType ticker_type = 0; |
| 3391 | 64 | |
|
6560
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
65 | ticker_type = g_type_from_name("GtkTicker"); |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
66 | |
| 5170 | 67 | if (!ticker_type) |
| 68 | { | |
| 69 | static const GTypeInfo ticker_info = | |
| 70 | { | |
| 71 | sizeof(GtkTickerClass), | |
| 72 | NULL, | |
| 73 | NULL, | |
| 74 | (GClassInitFunc) gtk_ticker_class_init, | |
| 75 | NULL, | |
| 76 | NULL, | |
| 77 | sizeof(GtkTicker), | |
| 78 | 0, | |
| 12600 | 79 | (GInstanceInitFunc) gtk_ticker_init, |
| 80 | NULL | |
| 5170 | 81 | }; |
| 3391 | 82 | |
| 5170 | 83 | ticker_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkTicker", |
| 84 | &ticker_info, 0); | |
| 85 | } | |
| 3391 | 86 | |
|
6560
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
87 | /* kludge to re-initialise the class if it's already registered */ |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
88 | else if (parent_class == NULL) { |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
89 | gtk_ticker_class_init((GtkTickerClass *)g_type_class_peek(ticker_type)); |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
90 | } |
|
fe90c8a024d5
[gaim-migrate @ 7082]
Robert McQueen <robot101@debian.org>
parents:
5170
diff
changeset
|
91 | |
| 5170 | 92 | return ticker_type; |
| 93 | } | |
| 94 | ||
| 95 | static void gtk_ticker_finalize(GObject *object) { | |
| 96 | gtk_ticker_stop_scroll(GTK_TICKER(object)); | |
| 97 | ||
| 98 | G_OBJECT_CLASS(parent_class)->finalize(object); | |
| 3391 | 99 | } |
| 100 | ||
| 5170 | 101 | static void gtk_ticker_class_init (GtkTickerClass *class) |
| 3391 | 102 | { |
| 5170 | 103 | GObjectClass *gobject_class; |
| 104 | GtkWidgetClass *widget_class; | |
| 105 | GtkContainerClass *container_class; | |
| 3391 | 106 | |
| 5170 | 107 | gobject_class = (GObjectClass*) class; |
| 108 | widget_class = (GtkWidgetClass*) class; | |
| 109 | container_class = (GtkContainerClass*) class; | |
| 110 | ||
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
111 | parent_class = g_type_class_ref (GTK_TYPE_CONTAINER); |
| 3391 | 112 | |
| 5170 | 113 | gobject_class->finalize = gtk_ticker_finalize; |
| 3391 | 114 | |
| 5170 | 115 | widget_class->map = gtk_ticker_map; |
| 116 | widget_class->realize = gtk_ticker_realize; | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
117 | #if GTK_CHECK_VERSION(3,0,0) |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
118 | widget_class->get_preferred_width = gtk_ticker_get_preferred_width; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
119 | widget_class->get_preferred_height = gtk_ticker_get_preferred_height; |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
120 | #else |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
121 | widget_class->size_request = gtk_ticker_size_request; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
122 | #endif |
| 5170 | 123 | widget_class->size_allocate = gtk_ticker_size_allocate; |
| 3391 | 124 | |
| 5170 | 125 | container_class->add = gtk_ticker_add_real; |
| 126 | container_class->remove = gtk_ticker_remove_real; | |
| 127 | container_class->forall = gtk_ticker_forall; | |
| 128 | container_class->child_type = gtk_ticker_child_type; | |
| 3391 | 129 | } |
| 130 | ||
|
26819
9aa978699dbc
Fix some more GTK_CHECK_* macros and a GtkType.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
131 | static GType gtk_ticker_child_type (GtkContainer *container) |
| 3391 | 132 | { |
| 5170 | 133 | return GTK_TYPE_WIDGET; |
| 3391 | 134 | } |
| 135 | ||
| 5170 | 136 | static void gtk_ticker_init (GtkTicker *ticker) |
| 3391 | 137 | { |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
138 | gtk_widget_set_has_window (GTK_WIDGET (ticker), TRUE); |
| 3391 | 139 | |
| 5170 | 140 | ticker->interval = (guint) 200; |
| 141 | ticker->scootch = (guint) 2; | |
| 142 | ticker->children = NULL; | |
| 143 | ticker->timer = 0; | |
| 144 | ticker->dirty = TRUE; | |
| 3391 | 145 | } |
| 146 | ||
| 5170 | 147 | GtkWidget* gtk_ticker_new (void) |
| 3391 | 148 | { |
| 4635 | 149 | return GTK_WIDGET(g_object_new(GTK_TYPE_TICKER, NULL)); |
| 3391 | 150 | } |
| 151 | ||
| 5170 | 152 | static void gtk_ticker_put (GtkTicker *ticker, GtkWidget *widget) |
| 3391 | 153 | { |
| 5170 | 154 | GtkTickerChild *child_info; |
| 3391 | 155 | |
| 5170 | 156 | g_return_if_fail (ticker != NULL); |
| 157 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 158 | g_return_if_fail (widget != NULL); | |
| 3391 | 159 | |
| 5170 | 160 | child_info = g_new(GtkTickerChild, 1); |
| 161 | child_info->widget = widget; | |
| 162 | child_info->x = 0; | |
| 3391 | 163 | |
| 5170 | 164 | gtk_widget_set_parent(widget, GTK_WIDGET (ticker)); |
| 3391 | 165 | |
| 5170 | 166 | ticker->children = g_list_append (ticker->children, child_info); |
| 3391 | 167 | |
|
32903
ac8c85044e35
Fix a type warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32382
diff
changeset
|
168 | if (gtk_widget_get_realized (GTK_WIDGET (ticker))) |
| 5170 | 169 | gtk_widget_realize (widget); |
| 3391 | 170 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
171 | if (gtk_widget_get_visible (GTK_WIDGET (ticker)) && |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
172 | gtk_widget_get_visible (widget)) |
| 5170 | 173 | { |
|
32382
ff09c7d01b39
gtk_widget_[gs]et_{mapped,realized} were added in GTK+ 2.20.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30024
diff
changeset
|
174 | if (gtk_widget_get_mapped (GTK_WIDGET (ticker))) |
| 5170 | 175 | gtk_widget_map (widget); |
| 176 | ||
| 177 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); | |
| 178 | } | |
| 3391 | 179 | } |
| 180 | ||
| 5170 | 181 | void gtk_ticker_set_interval (GtkTicker *ticker, gint interval) |
| 3391 | 182 | { |
| 5170 | 183 | g_return_if_fail (ticker != NULL); |
| 184 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 185 | |
| 5170 | 186 | if ( interval < 0 ) |
| 187 | interval = 200; | |
| 188 | ticker->interval = interval; | |
| 3391 | 189 | } |
| 190 | ||
| 5170 | 191 | guint gtk_ticker_get_interval (GtkTicker *ticker) |
| 3391 | 192 | { |
| 5170 | 193 | g_return_val_if_fail (ticker != NULL, -1); |
| 194 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 195 | |
| 5170 | 196 | return ticker->interval; |
| 3391 | 197 | } |
| 198 | ||
| 5170 | 199 | void gtk_ticker_set_scootch (GtkTicker *ticker, gint scootch) |
| 3391 | 200 | { |
| 5170 | 201 | g_return_if_fail (ticker != NULL); |
| 202 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 203 | |
| 5170 | 204 | if (scootch <= 0) |
| 205 | scootch = 2; | |
| 206 | ticker->scootch = scootch; | |
| 207 | ticker->dirty = TRUE; | |
| 3391 | 208 | } |
| 209 | ||
| 5170 | 210 | guint gtk_ticker_get_scootch (GtkTicker *ticker ) |
| 3391 | 211 | { |
| 5170 | 212 | g_return_val_if_fail (ticker != NULL, -1); |
| 213 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 214 | |
| 5170 | 215 | return ticker->scootch; |
| 3391 | 216 | } |
| 217 | ||
| 5170 | 218 | void gtk_ticker_set_spacing (GtkTicker *ticker, gint spacing ) |
| 3391 | 219 | { |
| 5170 | 220 | g_return_if_fail (ticker != NULL); |
| 221 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 222 | |
| 5170 | 223 | if ( spacing < 0 ) |
| 224 | spacing = 0; | |
| 225 | ticker->spacing = spacing; | |
| 226 | ticker->dirty = TRUE; | |
| 3391 | 227 | } |
| 228 | ||
| 5170 | 229 | static int ticker_timeout(gpointer data) |
| 3391 | 230 | { |
| 231 | GtkTicker *ticker = (GtkTicker *) data; | |
| 232 | ||
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
233 | if (gtk_widget_get_visible (GTK_WIDGET (ticker))) |
| 5170 | 234 | gtk_widget_queue_resize (GTK_WIDGET (ticker)); |
| 3391 | 235 | |
| 236 | return( TRUE ); | |
| 237 | } | |
| 238 | ||
| 5170 | 239 | void gtk_ticker_start_scroll(GtkTicker *ticker) |
| 3391 | 240 | { |
| 5170 | 241 | g_return_if_fail (ticker != NULL); |
| 242 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 243 | if ( ticker->timer != 0 ) |
| 244 | return; | |
| 4168 | 245 | ticker->timer = g_timeout_add(ticker->interval, ticker_timeout, ticker); |
| 3391 | 246 | } |
| 247 | ||
| 5170 | 248 | void gtk_ticker_stop_scroll(GtkTicker *ticker) |
| 3391 | 249 | { |
| 5170 | 250 | g_return_if_fail (ticker != NULL); |
| 251 | g_return_if_fail (GTK_IS_TICKER (ticker)); | |
| 3391 | 252 | if ( ticker->timer == 0 ) |
| 253 | return; | |
| 4168 | 254 | g_source_remove(ticker->timer); |
| 3391 | 255 | ticker->timer = 0; |
| 256 | } | |
| 257 | ||
| 5170 | 258 | guint gtk_ticker_get_spacing (GtkTicker *ticker ) |
| 3391 | 259 | { |
| 5170 | 260 | g_return_val_if_fail (ticker != NULL, -1); |
| 261 | g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); | |
| 3391 | 262 | |
| 5170 | 263 | return ticker->spacing; |
| 3391 | 264 | } |
| 265 | ||
| 5170 | 266 | static void gtk_ticker_map (GtkWidget *widget) |
| 3391 | 267 | { |
| 5170 | 268 | GtkTicker *ticker; |
| 269 | GtkTickerChild *child; | |
| 270 | GList *children; | |
| 3391 | 271 | |
| 5170 | 272 | g_return_if_fail (widget != NULL); |
| 273 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 274 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
275 | gtk_widget_set_mapped (widget, TRUE); |
| 5170 | 276 | ticker = GTK_TICKER (widget); |
| 3391 | 277 | |
| 5170 | 278 | children = ticker->children; |
| 279 | while (children) | |
| 280 | { | |
| 281 | child = children->data; | |
| 282 | children = children->next; | |
| 3391 | 283 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
284 | if (gtk_widget_get_visible (child->widget) && |
|
32382
ff09c7d01b39
gtk_widget_[gs]et_{mapped,realized} were added in GTK+ 2.20.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30024
diff
changeset
|
285 | !gtk_widget_get_mapped (child->widget)) |
| 5170 | 286 | gtk_widget_map (child->widget); |
| 287 | } | |
| 3391 | 288 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
289 | gdk_window_show (gtk_widget_get_window (widget)); |
| 3391 | 290 | } |
| 291 | ||
| 5170 | 292 | static void gtk_ticker_realize (GtkWidget *widget) |
| 3391 | 293 | { |
| 5170 | 294 | GdkWindowAttr attributes; |
| 295 | gint attributes_mask; | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
296 | GdkWindow *window; |
|
33271
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
297 | #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
|
298 | GtkStyleContext *context; |
|
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
299 | #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
|
300 | GtkStyle *style; |
|
33271
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
301 | #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
|
302 | GtkAllocation allocation; |
| 3391 | 303 | |
| 5170 | 304 | g_return_if_fail (widget != NULL); |
| 305 | g_return_if_fail (GTK_IS_TICKER (widget)); | |
| 3391 | 306 | |
|
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
|
307 | gtk_widget_set_realized (widget, TRUE); |
| 3391 | 308 | |
| 5170 | 309 | 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
|
310 | 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
|
311 | 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
|
312 | 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
|
313 | 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
|
314 | attributes.height = allocation.height; |
| 5170 | 315 | attributes.wclass = GDK_INPUT_OUTPUT; |
| 316 | 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
|
317 | #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
|
318 | 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
|
319 | #endif |
| 5170 | 320 | attributes.event_mask = gtk_widget_get_events (widget); |
| 321 | attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; | |
| 3391 | 322 | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
323 | #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
|
324 | 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
|
325 | #else |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
326 | 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
|
327 | #endif |
| 3391 | 328 | |
|
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
|
329 | window = gdk_window_new (gtk_widget_get_parent_window (widget), |
| 5170 | 330 | &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
|
331 | 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
|
332 | gdk_window_set_user_data (window, widget); |
| 3391 | 333 | |
|
33271
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
334 | #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
|
335 | 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
|
336 | gtk_style_context_add_class(context, GTK_STYLE_CLASS_BACKGROUND); |
|
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
337 | gtk_style_context_set_state(context, GTK_STATE_NORMAL); |
|
53bf180b9eb1
Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
338 | 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
|
339 | #else |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
340 | 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
|
341 | 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
|
342 | 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
|
343 | #endif |
| 3391 | 344 | } |
| 345 | ||
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
346 | #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
|
347 | static void |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
348 | 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
|
349 | gint *minimal_width, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
350 | gint *natural_width) |
| 3391 | 351 | { |
| 5170 | 352 | GtkTicker *ticker; |
| 353 | GtkTickerChild *child; | |
| 354 | GList *children; | |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
355 | 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
|
356 | 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
|
357 | guint border_width; |
| 3391 | 358 | |
| 5170 | 359 | 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
|
360 | *minimal_width = width = 0; |
| 3391 | 361 | |
| 5170 | 362 | children = ticker->children; |
| 363 | while (children) | |
| 364 | { | |
| 365 | child = children->data; | |
| 366 | children = children->next; | |
| 3391 | 367 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26819
diff
changeset
|
368 | if (gtk_widget_get_visible (child->widget)) |
| 5170 | 369 | { |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
370 | gtk_widget_get_preferred_width (child->widget, &child_min_width, &child_nat_width); |
| 3391 | 371 | |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
372 | 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
|
373 | *minimal_width = MAX(*minimal_width, child_min_width); |
| 5170 | 374 | } |
| 3391 | 375 | } |
|
33151
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
376 | if ( width > ticker->spacing ) |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
377 | width -= ticker->spacing; |
| 3391 | 378 | |
|
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
|
379 | 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
|
380 | width += border_width * 2; |
|
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 | *natural_width = width; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
383 | } |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
384 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
385 | static void |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
386 | 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
|
387 | gint *minimal_height, |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
388 | gint *natural_height) |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
389 | { |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
390 | GtkTicker *ticker; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
391 | GtkTickerChild *child; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
392 | GList *children; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
393 | 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
|
394 | gint height; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
395 | guint border_width; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
396 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
397 | ticker = GTK_TICKER (widget); |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
398 | height = 0; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
399 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
400 | children = ticker->children; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
401 | while (children) |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
402 | { |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
403 | child = children->data; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
404 | children = children->next; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
405 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
406 | 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
|
407 | { |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
408 | 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
|
409 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
410 | 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
|
411 | } |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
412 | } |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
413 | |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
414 | 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
|
415 | height += border_width * 2; |
|
bf6111db26df
Implement new sizing algorithm for the Buddy Ticker.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33150
diff
changeset
|
416 | *minimal_height = *natural_height = height; |
| 3391 | 417 | } |
| 418 | ||
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
419 | #else |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
420 | |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
421 | 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
|
422 | { |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
423 | GtkTicker *ticker; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
424 | GtkTickerChild *child; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
425 | GList *children; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
426 | GtkRequisition child_requisition; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
427 | guint border_width; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
428 | |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
429 | 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
|
430 | 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
|
431 | 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
|
432 | |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
433 | ticker = GTK_TICKER (widget); |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
434 | requisition->width = 0; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
435 | requisition->height = 0; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
436 | |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
437 | children = ticker->children; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
438 | while (children) |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
439 | { |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
440 | child = children->data; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
441 | children = children->next; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
442 | |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
443 | 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
|
444 | { |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
445 | 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
|
446 | |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
447 | requisition->height = MAX (requisition->height, |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
448 | child_requisition.height); |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
449 | 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
|
450 | } |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
451 | } |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
452 | if ( requisition->width > ticker->spacing ) |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
453 | requisition->width -= ticker->spacing; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
454 | |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
455 | 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
|
456 | requisition->height += border_width * 2; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
457 | requisition->width += border_width * 2; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
458 | } |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
459 | #endif |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33151
diff
changeset
|
460 | |
| 5170 | 461 | static void gtk_ticker_compute_offsets (GtkTicker *ticker) |
| 3391 | 462 | { |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
463 | GtkAllocation allocation; |
| 5170 | 464 | GtkTickerChild *child; |
| 465 | GtkRequisition child_requisition; | |
| 466 | GList *children; | |
| 467 | guint16 border_width; | |
| 3391 | 468 | |
| 5170 | 469 | g_return_if_fail (ticker != NULL); |
| 470 | g_return_if_fail (GTK_IS_TICKER(ticker)); | |
| 3391 | 471 | |
|
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
|
472 | border_width = gtk_container_get_border_width (GTK_CONTAINER (ticker)); |
| 3391 | 473 | |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
474 | 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
|
475 | ticker->width = allocation.width; |
| 5170 | 476 | ticker->total = 0; |
| 477 | children = ticker->children; | |
| 478 | while (children) { | |
| 479 | child = children->data; | |
| 480 | ||
| 481 | 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
|
482 | 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
|
483 | gtk_widget_get_preferred_size (child->widget, NULL, &child_requisition); |
| 5170 | 484 | child->offset = ticker->total; |
| 485 | ticker->total += | |
| 486 | child_requisition.width + border_width + ticker->spacing; | |
| 487 | } | |
| 488 | children = children->next; | |
| 489 | } | |
| 490 | ticker->dirty = FALSE; | |
| 3391 | 491 | } |
| 492 | ||
| 5170 | 493 | static void gtk_ticker_size_allocate (GtkWidget *widget, |
| 494 | GtkAllocation *allocation) | |
| 3391 | 495 | { |
| 5170 | 496 | GtkTicker *ticker; |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
497 | GtkAllocation a; |
| 5170 | 498 | GtkTickerChild *child; |
| 499 | GtkAllocation child_allocation; | |
| 500 | GtkRequisition child_requisition; | |
| 501 | GList *children; | |
| 502 | guint16 border_width; | |
| 503 | ||
| 504 | g_return_if_fail (widget != NULL); | |
| 505 | g_return_if_fail (GTK_IS_TICKER(widget)); | |
| 506 | g_return_if_fail (allocation != NULL); | |
| 507 | ||
| 508 | ticker = GTK_TICKER (widget); | |
| 3391 | 509 | |
|
33150
6fb8211beae6
Remove unnecessary GTK checks from Buddy Ticker plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
510 | 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
|
511 | if ( a.width != ticker->width ) |
| 5170 | 512 | ticker->dirty = TRUE; |
| 3391 | 513 | |
| 5170 | 514 | if ( ticker->dirty == TRUE ) { |
| 515 | gtk_ticker_compute_offsets( ticker ); | |
| 516 | } | |
| 3391 | 517 | |
|
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
|
518 | 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
|
519 | 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
|
520 | gdk_window_move_resize (gtk_widget_get_window (widget), |
| 5170 | 521 | allocation->x, |
| 522 | allocation->y, | |
| 523 | allocation->width, | |
| 524 | allocation->height); | |
| 3391 | 525 | |
|
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
|
526 | border_width = gtk_container_get_border_width (GTK_CONTAINER (ticker)); |
| 3391 | 527 | |
| 5170 | 528 | children = ticker->children; |
| 529 | while (children) | |
| 530 | { | |
| 531 | child = children->data; | |
| 532 | child->x -= ticker->scootch; | |
| 3391 | 533 | |
|
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
|
534 | 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
|
535 | gtk_widget_get_preferred_size (child->widget, NULL, &child_requisition); |
| 5170 | 536 | child_allocation.width = child_requisition.width; |
| 537 | 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
|
538 | 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
|
539 | 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
|
540 | child->x += allocation->x + allocation->width + ( ticker->total - ( allocation->x + allocation->width ) ); |
| 5170 | 541 | } |
| 542 | 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
|
543 | child->x += allocation->x + allocation->width; |
| 5170 | 544 | } |
| 545 | } | |
| 546 | child_allocation.y = border_width; | |
| 547 | child_allocation.height = child_requisition.height; | |
| 548 | gtk_widget_size_allocate (child->widget, &child_allocation); | |
| 3391 | 549 | } |
| 5170 | 550 | children = children->next; |
| 551 | } | |
| 552 | } | |
| 553 | ||
| 554 | void gtk_ticker_add(GtkTicker *ticker, GtkWidget *widget) | |
| 555 | { | |
| 556 | gtk_ticker_add_real( GTK_CONTAINER( ticker ), widget ); | |
| 557 | ticker->dirty = TRUE; | |
| 558 | } | |
| 559 | ||
| 560 | void gtk_ticker_remove(GtkTicker *ticker, GtkWidget *widget) | |
| 561 | { | |
| 562 | gtk_ticker_remove_real( GTK_CONTAINER( ticker ), widget ); | |
| 563 | ticker->dirty = TRUE; | |
| 3391 | 564 | } |
| 565 | ||
| 5170 | 566 | static void gtk_ticker_add_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 567 | { |
| 5170 | 568 | g_return_if_fail (container != NULL); |
| 569 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 570 | g_return_if_fail (widget != NULL); | |
| 3391 | 571 | |
| 5170 | 572 | gtk_ticker_put(GTK_TICKER (container), widget); |
| 3391 | 573 | } |
| 574 | ||
| 5170 | 575 | static void gtk_ticker_remove_real(GtkContainer *container, GtkWidget *widget) |
| 3391 | 576 | { |
| 5170 | 577 | GtkTicker *ticker; |
| 578 | GtkTickerChild *child; | |
| 579 | GList *children; | |
| 3391 | 580 | |
| 5170 | 581 | g_return_if_fail (container != NULL); |
| 582 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 583 | g_return_if_fail (widget != NULL); | |
| 3391 | 584 | |
| 5170 | 585 | ticker = GTK_TICKER (container); |
| 3391 | 586 | |
| 5170 | 587 | children = ticker->children; |
| 588 | while (children) | |
| 589 | { | |
| 590 | child = children->data; | |
| 3391 | 591 | |
| 5170 | 592 | if (child->widget == widget) |
| 593 | { | |
|
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
|
594 | gboolean was_visible = gtk_widget_get_visible (widget); |
| 5170 | 595 | |
| 596 | gtk_widget_unparent (widget); | |
| 3391 | 597 | |
| 5170 | 598 | ticker->children = g_list_remove_link (ticker->children, children); |
| 599 | g_list_free (children); | |
| 600 | g_free (child); | |
| 3391 | 601 | |
|
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
|
602 | if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) |
| 5170 | 603 | gtk_widget_queue_resize (GTK_WIDGET (container)); |
| 3391 | 604 | |
| 5170 | 605 | break; |
| 606 | } | |
| 3391 | 607 | |
| 5170 | 608 | children = children->next; |
| 609 | } | |
| 3391 | 610 | } |
| 611 | ||
| 5170 | 612 | static void gtk_ticker_forall (GtkContainer *container, |
| 613 | gboolean include_internals, | |
| 614 | GtkCallback callback, | |
| 615 | gpointer callback_data) | |
| 3391 | 616 | { |
| 5170 | 617 | GtkTicker *ticker; |
| 618 | GtkTickerChild *child; | |
| 619 | GList *children; | |
| 620 | ||
| 621 | g_return_if_fail (container != NULL); | |
| 622 | g_return_if_fail (GTK_IS_TICKER (container)); | |
| 623 | g_return_if_fail (callback != NULL); | |
| 3391 | 624 | |
| 5170 | 625 | ticker = GTK_TICKER (container); |
| 3391 | 626 | |
| 5170 | 627 | children = ticker->children; |
| 628 | while (children) | |
| 629 | { | |
| 630 | child = children->data; | |
| 631 | children = children->next; | |
| 3391 | 632 | |
| 5170 | 633 | (* callback) (child->widget, callback_data); |
| 634 | } | |
| 3391 | 635 | } |
| 5170 | 636 |