Wed, 19 Sep 2007 15:06:26 +0000
Get rid of an unused PurpleDisconnectReason variable from switching to using
purple_connection_ssl_error.
| 10297 | 1 | /* |
| 2 | * @file gtkcellrendererprogress.c GTK+ Cell Renderer Progress | |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
15931
diff
changeset
|
3 | * @ingroup pidgin |
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 10297 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 3832 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16254
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 3832 | 25 | * |
| 26 | */ | |
| 27 | ||
| 28 | /* This is taken largely from GtkCellRenderer[Text|Pixbuf|Toggle] by | |
| 29 | * Jonathon Blandford <jrb@redhat.com> for RedHat, Inc. | |
| 30 | */ | |
| 31 | ||
| 32 | #include "gtkcellrendererprogress.h" | |
| 33 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
34 | static void pidgin_cell_renderer_progress_get_property (GObject *object, |
| 3832 | 35 | guint param_id, |
| 36 | GValue *value, | |
| 37 | GParamSpec *pspec); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
38 | static void pidgin_cell_renderer_progress_set_property (GObject *object, |
| 3832 | 39 | guint param_id, |
| 40 | const GValue *value, | |
| 41 | GParamSpec *pspec); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
42 | static void pidgin_cell_renderer_progress_init (PidginCellRendererProgress *cellprogress); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
43 | static void pidgin_cell_renderer_progress_class_init (PidginCellRendererProgressClass *class); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
44 | static void pidgin_cell_renderer_progress_get_size (GtkCellRenderer *cell, |
| 3832 | 45 | GtkWidget *widget, |
| 46 | GdkRectangle *cell_area, | |
| 47 | gint *x_offset, | |
| 48 | gint *y_offset, | |
| 49 | gint *width, | |
| 50 | gint *height); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
51 | static void pidgin_cell_renderer_progress_render (GtkCellRenderer *cell, |
| 3832 | 52 | GdkWindow *window, |
| 53 | GtkWidget *widget, | |
| 54 | GdkRectangle *background_area, | |
| 55 | GdkRectangle *cell_area, | |
| 56 | GdkRectangle *expose_area, | |
| 57 | guint flags); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
58 | #if 0 |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
59 | static gboolean pidgin_cell_renderer_progress_activate (GtkCellRenderer *cell, |
| 3832 | 60 | GdkEvent *event, |
| 61 | GtkWidget *widget, | |
| 62 | const gchar *path, | |
| 63 | GdkRectangle *background_area, | |
| 64 | GdkRectangle *cell_area, | |
| 65 | guint flags); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
66 | #endif |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
67 | static void pidgin_cell_renderer_progress_finalize (GObject *gobject); |
| 3832 | 68 | |
| 69 | enum { | |
| 70 | LAST_SIGNAL | |
| 71 | }; | |
| 72 | ||
| 73 | enum { | |
| 74 | PROP_0, | |
| 75 | PROP_PERCENTAGE, | |
| 76 | PROP_TEXT, | |
| 77 | PROP_SHOW_TEXT | |
| 78 | }; | |
| 79 | ||
| 80 | static gpointer parent_class; | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
81 | /* static guint progress_cell_renderer_signals [LAST_SIGNAL]; */ |
| 3832 | 82 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
83 | GType pidgin_cell_renderer_progress_get_type (void) |
| 3832 | 84 | { |
| 85 | static GType cell_progress_type = 0; | |
| 86 | ||
| 87 | if (!cell_progress_type) | |
| 88 | { | |
| 89 | static const GTypeInfo cell_progress_info = | |
| 90 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
91 | sizeof (PidginCellRendererProgressClass), |
| 3832 | 92 | NULL, /* base_init */ |
| 93 | NULL, /* base_finalize */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
94 | (GClassInitFunc) pidgin_cell_renderer_progress_class_init, |
| 3832 | 95 | NULL, /* class_finalize */ |
| 96 | NULL, /* class_data */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
97 | sizeof (PidginCellRendererProgress), |
| 3832 | 98 | 0, /* n_preallocs */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
99 | (GInstanceInitFunc) pidgin_cell_renderer_progress_init, |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
10297
diff
changeset
|
100 | NULL /* value_table */ |
| 3832 | 101 | }; |
| 102 | ||
| 103 | cell_progress_type = | |
|
9898
9d8d9e9ef1bc
[gaim-migrate @ 10788]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
104 | g_type_register_static (GTK_TYPE_CELL_RENDERER, |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
105 | "PidginCellRendererProgress", |
|
9898
9d8d9e9ef1bc
[gaim-migrate @ 10788]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
106 | &cell_progress_info, 0); |
| 3832 | 107 | } |
| 108 | ||
| 109 | return cell_progress_type; | |
| 110 | } | |
| 111 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
112 | static void pidgin_cell_renderer_progress_init (PidginCellRendererProgress *cellprogress) |
| 3832 | 113 | { |
| 114 | GTK_CELL_RENDERER(cellprogress)->mode = GTK_CELL_RENDERER_MODE_INERT; | |
| 115 | GTK_CELL_RENDERER(cellprogress)->xpad = 2; | |
| 116 | GTK_CELL_RENDERER(cellprogress)->ypad = 2; | |
| 117 | } | |
| 118 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
119 | static void pidgin_cell_renderer_progress_class_init (PidginCellRendererProgressClass *class) |
| 3832 | 120 | { |
| 121 | GObjectClass *object_class = G_OBJECT_CLASS(class); | |
| 122 | GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class); | |
| 123 | ||
| 124 | parent_class = g_type_class_peek_parent (class); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
125 | object_class->finalize = pidgin_cell_renderer_progress_finalize; |
| 3832 | 126 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
127 | object_class->get_property = pidgin_cell_renderer_progress_get_property; |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
128 | object_class->set_property = pidgin_cell_renderer_progress_set_property; |
| 3832 | 129 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
130 | cell_class->get_size = pidgin_cell_renderer_progress_get_size; |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
131 | cell_class->render = pidgin_cell_renderer_progress_render; |
| 3832 | 132 | |
| 133 | g_object_class_install_property (object_class, | |
| 134 | PROP_PERCENTAGE, | |
| 135 | g_param_spec_double ("percentage", | |
| 136 | "Percentage", | |
| 137 | "The fractional progress to display", | |
| 138 | 0, 1, 0, | |
| 139 | G_PARAM_READWRITE)); | |
| 140 | g_object_class_install_property (object_class, | |
| 141 | PROP_TEXT, | |
| 142 | g_param_spec_string ("text", | |
| 143 | "Text", | |
| 144 | "Text to overlay over progress bar", | |
| 145 | NULL, | |
| 146 | G_PARAM_READWRITE)); | |
| 147 | g_object_class_install_property(object_class, | |
| 148 | PROP_SHOW_TEXT, | |
| 149 | g_param_spec_string("text_set", | |
| 150 | "Text set", | |
| 151 | "Whether to overlay text on the progress bar", | |
| 152 | FALSE, | |
| 153 | G_PARAM_READABLE | G_PARAM_WRITABLE)); | |
| 154 | } | |
| 155 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
156 | static void pidgin_cell_renderer_progress_finalize (GObject *object) |
| 3832 | 157 | { |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
158 | /* |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
159 | PidginCellRendererProgress *cellprogress = PIDGIN_CELL_RENDERER_PROGRESS(object); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
160 | */ |
| 3832 | 161 | |
| 162 | (* G_OBJECT_CLASS (parent_class)->finalize) (object); | |
| 163 | } | |
| 164 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
165 | static void pidgin_cell_renderer_progress_get_property (GObject *object, |
| 3832 | 166 | guint param_id, |
| 167 | GValue *value, | |
| 168 | GParamSpec *psec) | |
| 169 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
170 | PidginCellRendererProgress *cellprogress = PIDGIN_CELL_RENDERER_PROGRESS(object); |
| 3832 | 171 | |
| 172 | switch (param_id) | |
| 173 | { | |
| 174 | case PROP_PERCENTAGE: | |
| 175 | g_value_set_double(value, cellprogress->progress); | |
| 176 | break; | |
| 177 | case PROP_TEXT: | |
| 178 | g_value_set_string(value, cellprogress->text); | |
| 179 | break; | |
| 180 | case PROP_SHOW_TEXT: | |
| 181 | g_value_set_boolean(value, cellprogress->text_set); | |
| 182 | break; | |
| 183 | default: | |
| 184 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, psec); | |
| 185 | break; | |
| 186 | } | |
| 187 | } | |
| 188 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
189 | static void pidgin_cell_renderer_progress_set_property (GObject *object, |
| 3832 | 190 | guint param_id, |
| 191 | const GValue *value, | |
| 192 | GParamSpec *pspec) | |
| 193 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
194 | PidginCellRendererProgress *cellprogress = PIDGIN_CELL_RENDERER_PROGRESS (object); |
| 3832 | 195 | |
| 196 | switch (param_id) | |
| 197 | { | |
| 198 | case PROP_PERCENTAGE: | |
| 199 | cellprogress->progress = g_value_get_double(value); | |
| 200 | break; | |
| 201 | case PROP_TEXT: | |
| 202 | if (cellprogress->text) | |
| 203 | g_free(cellprogress->text); | |
| 204 | cellprogress->text = g_strdup(g_value_get_string(value)); | |
| 205 | g_object_notify(object, "text"); | |
| 206 | break; | |
| 207 | case PROP_SHOW_TEXT: | |
| 208 | cellprogress->text_set = g_value_get_boolean(value); | |
| 209 | break; | |
| 210 | default: | |
| 211 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); | |
| 212 | break; | |
| 213 | } | |
| 214 | } | |
| 215 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
216 | GtkCellRenderer *pidgin_cell_renderer_progress_new(void) |
| 3832 | 217 | { |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15562
diff
changeset
|
218 | return g_object_new(PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, NULL); |
| 3832 | 219 | } |
| 220 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
221 | static void pidgin_cell_renderer_progress_get_size (GtkCellRenderer *cell, |
| 3832 | 222 | GtkWidget *widget, |
| 223 | GdkRectangle *cell_area, | |
| 224 | gint *x_offset, | |
| 225 | gint *y_offset, | |
| 226 | gint *width, | |
| 227 | gint *height) | |
| 228 | { | |
| 229 | gint calc_width; | |
| 230 | gint calc_height; | |
| 231 | ||
| 232 | calc_width = (gint) cell->xpad * 2 + 50; | |
| 7705 | 233 | calc_height = (gint) cell->ypad * 2 + 12; |
| 3832 | 234 | |
| 235 | if (width) | |
| 236 | *width = calc_width; | |
| 237 | ||
| 238 | if (height) | |
| 239 | *height = calc_height; | |
| 240 | ||
| 241 | if (cell_area) | |
| 242 | { | |
| 243 | if (x_offset) | |
| 244 | { | |
| 245 | *x_offset = cell->xalign * (cell_area->width - calc_width); | |
| 246 | *x_offset = MAX (*x_offset, 0); | |
| 247 | } | |
| 248 | if (y_offset) | |
| 249 | { | |
| 250 | *y_offset = cell->yalign * (cell_area->height - calc_height); | |
| 251 | *y_offset = MAX (*y_offset, 0); | |
| 252 | } | |
| 253 | } | |
| 254 | } | |
| 255 | ||
| 256 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
257 | static void pidgin_cell_renderer_progress_render (GtkCellRenderer *cell, |
| 3832 | 258 | GdkWindow *window, |
| 259 | GtkWidget *widget, | |
| 260 | GdkRectangle *background_area, | |
| 261 | GdkRectangle *cell_area, | |
| 262 | GdkRectangle *expose_area, | |
| 263 | guint flags) | |
| 264 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
265 | PidginCellRendererProgress *cellprogress = (PidginCellRendererProgress *) cell; |
| 3832 | 266 | |
| 267 | gint width, height; | |
| 268 | GtkStateType state; | |
| 269 | ||
| 7738 | 270 | width = cell_area->width; |
| 271 | height = cell_area->height; | |
| 3832 | 272 | |
| 273 | if (GTK_WIDGET_HAS_FOCUS (widget)) | |
| 274 | state = GTK_STATE_ACTIVE; | |
| 275 | else | |
| 276 | state = GTK_STATE_NORMAL; | |
|
9898
9d8d9e9ef1bc
[gaim-migrate @ 10788]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
277 | |
| 3832 | 278 | width -= cell->xpad*2; |
| 279 | height -= cell->ypad*2; | |
|
9898
9d8d9e9ef1bc
[gaim-migrate @ 10788]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
280 | |
| 3832 | 281 | gtk_paint_box (widget->style, |
| 282 | window, | |
| 283 | GTK_STATE_NORMAL, GTK_SHADOW_IN, | |
| 284 | NULL, widget, "trough", | |
| 7738 | 285 | cell_area->x + cell->xpad, |
| 286 | cell_area->y + cell->ypad, | |
| 3832 | 287 | width - 1, height - 1); |
| 288 | gtk_paint_box (widget->style, | |
| 289 | window, | |
| 290 | state, GTK_SHADOW_OUT, | |
| 291 | NULL, widget, "bar", | |
| 7738 | 292 | cell_area->x + cell->xpad + 1, |
| 293 | cell_area->y + cell->ypad + 1, | |
| 7705 | 294 | (width - 3) * cellprogress->progress, |
| 295 | height - 3); | |
| 3832 | 296 | } |