Wed, 19 Sep 2007 15:06:26 +0000
Get rid of an unused PurpleDisconnectReason variable from switching to using
purple_connection_ssl_error.
| 14623 | 1 | /* |
| 2 | * @file gtkcellrendererexpander.c GTK+ Cell Renderer Expander | |
|
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:
20327
diff
changeset
|
4 | */ |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
20327
diff
changeset
|
5 | |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
20327
diff
changeset
|
6 | /* pidgin |
| 14623 | 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 |
| 14623 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 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 |
| 14623 | 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 | ||
|
14719
d2bad68670ed
[gaim-migrate @ 17403]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14654
diff
changeset
|
32 | #include <gtk/gtk.h> |
| 14623 | 33 | #include <gtk/gtktreeview.h> |
| 34 | #include "gtkcellrendererexpander.h" | |
| 35 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
36 | static void pidgin_cell_renderer_expander_get_property (GObject *object, |
| 14623 | 37 | guint param_id, |
| 38 | GValue *value, | |
| 39 | GParamSpec *pspec); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
40 | static void pidgin_cell_renderer_expander_set_property (GObject *object, |
| 14623 | 41 | guint param_id, |
| 42 | const GValue *value, | |
| 43 | GParamSpec *pspec); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
44 | static void pidgin_cell_renderer_expander_init (PidginCellRendererExpander *cellexpander); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
45 | static void pidgin_cell_renderer_expander_class_init (PidginCellRendererExpanderClass *class); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
46 | static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell, |
| 14623 | 47 | GtkWidget *widget, |
| 48 | GdkRectangle *cell_area, | |
| 49 | gint *x_offset, | |
| 50 | gint *y_offset, | |
| 51 | gint *width, | |
| 52 | gint *height); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
53 | static void pidgin_cell_renderer_expander_render (GtkCellRenderer *cell, |
| 14623 | 54 | GdkWindow *window, |
| 55 | GtkWidget *widget, | |
| 56 | GdkRectangle *background_area, | |
| 57 | GdkRectangle *cell_area, | |
| 58 | GdkRectangle *expose_area, | |
| 59 | guint flags); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
60 | static gboolean pidgin_cell_renderer_expander_activate (GtkCellRenderer *r, |
| 14623 | 61 | GdkEvent *event, |
| 62 | GtkWidget *widget, | |
| 14953 | 63 | const gchar *p, |
| 64 | GdkRectangle *bg, | |
| 65 | GdkRectangle *cell, | |
| 14860 | 66 | GtkCellRendererState flags); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
67 | static void pidgin_cell_renderer_expander_finalize (GObject *gobject); |
| 14623 | 68 | |
| 69 | enum { | |
| 70 | LAST_SIGNAL | |
| 71 | }; | |
| 72 | ||
| 73 | enum { | |
| 74 | PROP_0, | |
| 75 | PROP_IS_EXPANDER | |
| 76 | }; | |
| 77 | ||
| 78 | static gpointer parent_class; | |
| 79 | /* static guint expander_cell_renderer_signals [LAST_SIGNAL]; */ | |
| 80 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
81 | GType pidgin_cell_renderer_expander_get_type (void) |
| 14623 | 82 | { |
| 83 | static GType cell_expander_type = 0; | |
| 84 | ||
| 85 | if (!cell_expander_type) | |
| 86 | { | |
| 87 | static const GTypeInfo cell_expander_info = | |
| 88 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
89 | sizeof (PidginCellRendererExpanderClass), |
| 14623 | 90 | NULL, /* base_init */ |
| 91 | NULL, /* base_finalize */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
92 | (GClassInitFunc) pidgin_cell_renderer_expander_class_init, |
| 14623 | 93 | NULL, /* class_finalize */ |
| 94 | NULL, /* class_data */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
95 | sizeof (PidginCellRendererExpander), |
| 14623 | 96 | 0, /* n_preallocs */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
97 | (GInstanceInitFunc) pidgin_cell_renderer_expander_init, |
| 14623 | 98 | NULL /* value_table */ |
| 99 | }; | |
| 100 | ||
| 101 | cell_expander_type = | |
| 102 | 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
|
103 | "PidginCellRendererExpander", |
| 14623 | 104 | &cell_expander_info, 0); |
| 105 | } | |
| 106 | ||
| 107 | return cell_expander_type; | |
| 108 | } | |
| 109 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
110 | static void pidgin_cell_renderer_expander_init (PidginCellRendererExpander *cellexpander) |
| 14623 | 111 | { |
| 112 | GTK_CELL_RENDERER(cellexpander)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; | |
| 14653 | 113 | GTK_CELL_RENDERER(cellexpander)->xpad = 0; |
| 14623 | 114 | GTK_CELL_RENDERER(cellexpander)->ypad = 2; |
| 115 | } | |
| 116 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
117 | static void pidgin_cell_renderer_expander_class_init (PidginCellRendererExpanderClass *class) |
| 14623 | 118 | { |
| 119 | GObjectClass *object_class = G_OBJECT_CLASS(class); | |
| 120 | GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class); | |
| 121 | ||
| 122 | 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
|
123 | object_class->finalize = pidgin_cell_renderer_expander_finalize; |
| 14623 | 124 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
125 | object_class->get_property = pidgin_cell_renderer_expander_get_property; |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
126 | object_class->set_property = pidgin_cell_renderer_expander_set_property; |
| 14623 | 127 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
128 | cell_class->get_size = pidgin_cell_renderer_expander_get_size; |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
129 | cell_class->render = pidgin_cell_renderer_expander_render; |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
130 | cell_class->activate = pidgin_cell_renderer_expander_activate; |
| 14623 | 131 | |
| 132 | g_object_class_install_property (object_class, | |
| 133 | PROP_IS_EXPANDER, | |
| 134 | g_param_spec_boolean ("expander-visible", | |
| 135 | "Is Expander", | |
| 136 | "True if the renderer should draw an expander", | |
| 137 | FALSE, | |
| 138 | G_PARAM_READWRITE)); | |
| 139 | } | |
| 140 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
141 | static void pidgin_cell_renderer_expander_finalize (GObject *object) |
| 14623 | 142 | { |
| 143 | /* | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
144 | PidginCellRendererExpander *cellexpander = PIDGIN_CELL_RENDERER_EXPANDER(object); |
| 14623 | 145 | */ |
| 146 | ||
| 147 | (* G_OBJECT_CLASS (parent_class)->finalize) (object); | |
| 148 | } | |
| 149 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
150 | static void pidgin_cell_renderer_expander_get_property (GObject *object, |
| 14623 | 151 | guint param_id, |
| 152 | GValue *value, | |
| 153 | GParamSpec *psec) | |
| 154 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
155 | PidginCellRendererExpander *cellexpander = PIDGIN_CELL_RENDERER_EXPANDER(object); |
| 14623 | 156 | |
| 157 | switch (param_id) | |
| 158 | { | |
| 159 | case PROP_IS_EXPANDER: | |
| 160 | g_value_set_boolean(value, cellexpander->is_expander); | |
| 161 | break; | |
| 162 | default: | |
| 163 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, psec); | |
| 164 | break; | |
| 165 | ||
| 166 | } | |
| 167 | } | |
| 168 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
169 | static void pidgin_cell_renderer_expander_set_property (GObject *object, |
| 14623 | 170 | guint param_id, |
| 171 | const GValue *value, | |
| 172 | GParamSpec *pspec) | |
| 173 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
174 | PidginCellRendererExpander *cellexpander = PIDGIN_CELL_RENDERER_EXPANDER (object); |
| 14623 | 175 | |
| 176 | switch (param_id) | |
| 177 | { | |
| 178 | case PROP_IS_EXPANDER: | |
| 179 | cellexpander->is_expander = g_value_get_boolean(value); | |
| 180 | break; | |
| 181 | default: | |
| 182 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); | |
| 183 | break; | |
| 184 | } | |
| 185 | } | |
| 186 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
187 | GtkCellRenderer *pidgin_cell_renderer_expander_new(void) |
| 14623 | 188 | { |
|
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
|
189 | return g_object_new(PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER, NULL); |
| 14623 | 190 | } |
| 191 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
192 | static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell, |
| 14623 | 193 | GtkWidget *widget, |
| 194 | GdkRectangle *cell_area, | |
| 195 | gint *x_offset, | |
| 196 | gint *y_offset, | |
| 197 | gint *width, | |
| 198 | gint *height) | |
| 199 | { | |
| 200 | gint calc_width; | |
| 201 | gint calc_height; | |
| 202 | gint expander_size; | |
| 203 | ||
| 204 | gtk_widget_style_get(widget, "expander-size", &expander_size, NULL); | |
| 205 | ||
| 206 | calc_width = (gint) cell->xpad * 2 + expander_size; | |
| 207 | calc_height = (gint) cell->ypad * 2 + expander_size; | |
| 208 | ||
| 209 | if (width) | |
| 210 | *width = calc_width; | |
| 211 | ||
| 212 | if (height) | |
| 213 | *height = calc_height; | |
| 214 | ||
| 215 | if (cell_area) | |
| 216 | { | |
| 217 | if (x_offset) | |
| 218 | { | |
| 219 | *x_offset = cell->xalign * (cell_area->width - calc_width); | |
| 220 | *x_offset = MAX (*x_offset, 0); | |
| 221 | } | |
| 222 | if (y_offset) | |
| 223 | { | |
| 224 | *y_offset = cell->yalign * (cell_area->height - calc_height); | |
| 225 | *y_offset = MAX (*y_offset, 0); | |
| 226 | } | |
| 227 | } | |
| 228 | } | |
| 229 | ||
| 230 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
231 | static void pidgin_cell_renderer_expander_render (GtkCellRenderer *cell, |
| 14623 | 232 | GdkWindow *window, |
| 233 | GtkWidget *widget, | |
| 234 | GdkRectangle *background_area, | |
| 235 | GdkRectangle *cell_area, | |
| 236 | GdkRectangle *expose_area, | |
| 237 | guint flags) | |
| 238 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
239 | PidginCellRendererExpander *cellexpander = (PidginCellRendererExpander *) cell; |
| 14623 | 240 | |
| 241 | gint width, height; | |
| 242 | GtkStateType state; | |
| 243 | ||
| 244 | if (!cellexpander->is_expander) | |
| 245 | return; | |
| 246 | ||
| 247 | width = cell_area->width; | |
| 248 | height = cell_area->height; | |
| 249 | ||
|
14719
d2bad68670ed
[gaim-migrate @ 17403]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14654
diff
changeset
|
250 | #if GTK_CHECK_VERSION(2,6,0) |
| 14623 | 251 | if (!cell->sensitive) |
| 252 | state = GTK_STATE_INSENSITIVE; | |
|
14719
d2bad68670ed
[gaim-migrate @ 17403]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14654
diff
changeset
|
253 | #else |
|
d2bad68670ed
[gaim-migrate @ 17403]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14654
diff
changeset
|
254 | if (GTK_WIDGET_STATE(widget) == GTK_STATE_INSENSITIVE) |
|
d2bad68670ed
[gaim-migrate @ 17403]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14654
diff
changeset
|
255 | state = GTK_STATE_INSENSITIVE; |
|
d2bad68670ed
[gaim-migrate @ 17403]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14654
diff
changeset
|
256 | #endif |
| 14623 | 257 | else if (flags & GTK_CELL_RENDERER_PRELIT) |
| 258 | state = GTK_STATE_PRELIGHT; | |
| 259 | else if (GTK_WIDGET_HAS_FOCUS (widget) && flags & GTK_CELL_RENDERER_SELECTED) | |
| 260 | state = GTK_STATE_ACTIVE; | |
| 261 | else | |
| 262 | state = GTK_STATE_NORMAL; | |
| 263 | ||
| 264 | width -= cell->xpad*2; | |
| 265 | height -= cell->ypad*2; | |
| 266 | ||
| 267 | gtk_paint_expander (widget->style, | |
| 268 | window, state, | |
| 269 | NULL, widget, "treeview", | |
| 270 | cell_area->x + cell->xpad + (width / 2), | |
| 271 | cell_area->y + cell->ypad + (height / 2), | |
| 272 | cell->is_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED); | |
|
20327
658f3acfbf1f
only draw line on expanded group headers
Sean Egan <seanegan@pidgin.im>
parents:
20308
diff
changeset
|
273 | if (cell->is_expanded) |
|
658f3acfbf1f
only draw line on expanded group headers
Sean Egan <seanegan@pidgin.im>
parents:
20308
diff
changeset
|
274 | gtk_paint_hline (widget->style, window, state, NULL, widget, NULL, 0, |
|
658f3acfbf1f
only draw line on expanded group headers
Sean Egan <seanegan@pidgin.im>
parents:
20308
diff
changeset
|
275 | widget->allocation.width, cell_area->y + cell_area->height); |
| 14623 | 276 | } |
| 277 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
278 | static gboolean pidgin_cell_renderer_expander_activate(GtkCellRenderer *r, |
| 14623 | 279 | GdkEvent *event, |
| 280 | GtkWidget *widget, | |
| 281 | const gchar *p, | |
| 282 | GdkRectangle *bg, | |
| 283 | GdkRectangle *cell, | |
| 284 | GtkCellRendererState flags) | |
| 285 | { | |
| 286 | GtkTreePath *path = gtk_tree_path_new_from_string(p); | |
| 287 | if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path)) | |
| 288 | gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path); | |
| 289 | else | |
| 290 | gtk_tree_view_expand_row(GTK_TREE_VIEW(widget),path,FALSE); | |
| 291 | gtk_tree_path_free(path); | |
|
14626
964677efbddf
[gaim-migrate @ 17287]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14623
diff
changeset
|
292 | return FALSE; |
| 14623 | 293 | } |