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