Mercurial > pidgin.yaz
annotate src/gtkcellrendererprogress.c @ 11261:b53606580f68
[gaim-migrate @ 13439]
Patch #1226486 from Levi Bard
Fixes bug #1224178
If you change the topic in a chat room and that topic change is rejected, the
topic field is wrong -- it shows the new topic even thought it didn't get set.
This patch resets the GUI's topic immediately when you hit enter. Then, if the
topic change is successful, the server will echo the topic change back to us
and we'll update the GUI to the new topic.
The only question is, does the server always echo the topic back to us? From the
core's point of view, I'm ready to assume yes. It's the case for both IRC and
Jabber*. If someone could test changing a topic in SILC or Zephyr, that'd be
great. If servers using those protocols do not echo the topic back, the prpl
will have to fake it as appropriate.
* I didn't actually test on Jabber, but Nathan said the server will echo the
topic change back. If it's broken, let me know.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 14 Aug 2005 06:55:57 +0000 |
parents | ec140184437b |
children | e856f985a0b9 |
rev | line source |
---|---|
10297 | 1 /* |
2 * @file gtkcellrendererprogress.c GTK+ Cell Renderer Progress | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
3832 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
26 | |
27 /* This is taken largely from GtkCellRenderer[Text|Pixbuf|Toggle] by | |
28 * Jonathon Blandford <jrb@redhat.com> for RedHat, Inc. | |
29 */ | |
30 | |
31 #include "gtkcellrendererprogress.h" | |
32 | |
9898 | 33 static void gaim_gtk_cell_renderer_progress_get_property (GObject *object, |
3832 | 34 guint param_id, |
35 GValue *value, | |
36 GParamSpec *pspec); | |
9898 | 37 static void gaim_gtk_cell_renderer_progress_set_property (GObject *object, |
3832 | 38 guint param_id, |
39 const GValue *value, | |
40 GParamSpec *pspec); | |
9898 | 41 static void gaim_gtk_cell_renderer_progress_init (GaimGtkCellRendererProgress *cellprogress); |
42 static void gaim_gtk_cell_renderer_progress_class_init (GaimGtkCellRendererProgressClass *class); | |
43 static void gaim_gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell, | |
3832 | 44 GtkWidget *widget, |
45 GdkRectangle *cell_area, | |
46 gint *x_offset, | |
47 gint *y_offset, | |
48 gint *width, | |
49 gint *height); | |
9898 | 50 static void gaim_gtk_cell_renderer_progress_render (GtkCellRenderer *cell, |
3832 | 51 GdkWindow *window, |
52 GtkWidget *widget, | |
53 GdkRectangle *background_area, | |
54 GdkRectangle *cell_area, | |
55 GdkRectangle *expose_area, | |
56 guint flags); | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
57 #if 0 |
9898 | 58 static gboolean gaim_gtk_cell_renderer_progress_activate (GtkCellRenderer *cell, |
3832 | 59 GdkEvent *event, |
60 GtkWidget *widget, | |
61 const gchar *path, | |
62 GdkRectangle *background_area, | |
63 GdkRectangle *cell_area, | |
64 guint flags); | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
65 #endif |
9898 | 66 static void gaim_gtk_cell_renderer_progress_finalize (GObject *gobject); |
3832 | 67 |
68 enum { | |
69 LAST_SIGNAL | |
70 }; | |
71 | |
72 enum { | |
73 PROP_0, | |
74 PROP_PERCENTAGE, | |
75 PROP_TEXT, | |
76 PROP_SHOW_TEXT | |
77 }; | |
78 | |
79 static gpointer parent_class; | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
80 /* static guint progress_cell_renderer_signals [LAST_SIGNAL]; */ |
3832 | 81 |
9898 | 82 GType gaim_gtk_cell_renderer_progress_get_type (void) |
3832 | 83 { |
84 static GType cell_progress_type = 0; | |
85 | |
86 if (!cell_progress_type) | |
87 { | |
88 static const GTypeInfo cell_progress_info = | |
89 { | |
9898 | 90 sizeof (GaimGtkCellRendererProgressClass), |
3832 | 91 NULL, /* base_init */ |
92 NULL, /* base_finalize */ | |
9898 | 93 (GClassInitFunc) gaim_gtk_cell_renderer_progress_class_init, |
3832 | 94 NULL, /* class_finalize */ |
95 NULL, /* class_data */ | |
9898 | 96 sizeof (GaimGtkCellRendererProgress), |
3832 | 97 0, /* n_preallocs */ |
9898 | 98 (GInstanceInitFunc) gaim_gtk_cell_renderer_progress_init, |
3832 | 99 }; |
100 | |
101 cell_progress_type = | |
9898 | 102 g_type_register_static (GTK_TYPE_CELL_RENDERER, |
103 "GaimGtkCellRendererProgress", | |
104 &cell_progress_info, 0); | |
3832 | 105 } |
106 | |
107 return cell_progress_type; | |
108 } | |
109 | |
9898 | 110 static void gaim_gtk_cell_renderer_progress_init (GaimGtkCellRendererProgress *cellprogress) |
3832 | 111 { |
112 GTK_CELL_RENDERER(cellprogress)->mode = GTK_CELL_RENDERER_MODE_INERT; | |
113 GTK_CELL_RENDERER(cellprogress)->xpad = 2; | |
114 GTK_CELL_RENDERER(cellprogress)->ypad = 2; | |
115 } | |
116 | |
9898 | 117 static void gaim_gtk_cell_renderer_progress_class_init (GaimGtkCellRendererProgressClass *class) |
3832 | 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); | |
9898 | 123 object_class->finalize = gaim_gtk_cell_renderer_progress_finalize; |
3832 | 124 |
9898 | 125 object_class->get_property = gaim_gtk_cell_renderer_progress_get_property; |
126 object_class->set_property = gaim_gtk_cell_renderer_progress_set_property; | |
3832 | 127 |
9898 | 128 cell_class->get_size = gaim_gtk_cell_renderer_progress_get_size; |
129 cell_class->render = gaim_gtk_cell_renderer_progress_render; | |
3832 | 130 |
131 g_object_class_install_property (object_class, | |
132 PROP_PERCENTAGE, | |
133 g_param_spec_double ("percentage", | |
134 "Percentage", | |
135 "The fractional progress to display", | |
136 0, 1, 0, | |
137 G_PARAM_READWRITE)); | |
138 g_object_class_install_property (object_class, | |
139 PROP_TEXT, | |
140 g_param_spec_string ("text", | |
141 "Text", | |
142 "Text to overlay over progress bar", | |
143 NULL, | |
144 G_PARAM_READWRITE)); | |
145 g_object_class_install_property(object_class, | |
146 PROP_SHOW_TEXT, | |
147 g_param_spec_string("text_set", | |
148 "Text set", | |
149 "Whether to overlay text on the progress bar", | |
150 FALSE, | |
151 G_PARAM_READABLE | G_PARAM_WRITABLE)); | |
152 } | |
153 | |
9898 | 154 static void gaim_gtk_cell_renderer_progress_finalize (GObject *object) |
3832 | 155 { |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
156 /* |
9898 | 157 GaimGtkCellRendererProgress *cellprogress = GAIM_GTK_CELL_RENDERER_PROGRESS(object); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
3832
diff
changeset
|
158 */ |
3832 | 159 |
160 (* G_OBJECT_CLASS (parent_class)->finalize) (object); | |
161 } | |
162 | |
9898 | 163 static void gaim_gtk_cell_renderer_progress_get_property (GObject *object, |
3832 | 164 guint param_id, |
165 GValue *value, | |
166 GParamSpec *psec) | |
167 { | |
9898 | 168 GaimGtkCellRendererProgress *cellprogress = GAIM_GTK_CELL_RENDERER_PROGRESS(object); |
3832 | 169 |
170 switch (param_id) | |
171 { | |
172 case PROP_PERCENTAGE: | |
173 g_value_set_double(value, cellprogress->progress); | |
174 break; | |
175 case PROP_TEXT: | |
176 g_value_set_string(value, cellprogress->text); | |
177 break; | |
178 case PROP_SHOW_TEXT: | |
179 g_value_set_boolean(value, cellprogress->text_set); | |
180 break; | |
181 default: | |
182 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, psec); | |
183 break; | |
184 } | |
185 } | |
186 | |
9898 | 187 static void gaim_gtk_cell_renderer_progress_set_property (GObject *object, |
3832 | 188 guint param_id, |
189 const GValue *value, | |
190 GParamSpec *pspec) | |
191 { | |
9898 | 192 GaimGtkCellRendererProgress *cellprogress = GAIM_GTK_CELL_RENDERER_PROGRESS (object); |
3832 | 193 |
194 switch (param_id) | |
195 { | |
196 case PROP_PERCENTAGE: | |
197 cellprogress->progress = g_value_get_double(value); | |
198 break; | |
199 case PROP_TEXT: | |
200 if (cellprogress->text) | |
201 g_free(cellprogress->text); | |
202 cellprogress->text = g_strdup(g_value_get_string(value)); | |
203 g_object_notify(object, "text"); | |
204 break; | |
205 case PROP_SHOW_TEXT: | |
206 cellprogress->text_set = g_value_get_boolean(value); | |
207 break; | |
208 default: | |
209 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); | |
210 break; | |
211 } | |
212 } | |
213 | |
9898 | 214 GtkCellRenderer *gaim_gtk_cell_renderer_progress_new(void) |
3832 | 215 { |
9898 | 216 return g_object_new(GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS, NULL); |
3832 | 217 } |
218 | |
9898 | 219 static void gaim_gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell, |
3832 | 220 GtkWidget *widget, |
221 GdkRectangle *cell_area, | |
222 gint *x_offset, | |
223 gint *y_offset, | |
224 gint *width, | |
225 gint *height) | |
226 { | |
227 gint calc_width; | |
228 gint calc_height; | |
229 | |
230 calc_width = (gint) cell->xpad * 2 + 50; | |
7705 | 231 calc_height = (gint) cell->ypad * 2 + 12; |
3832 | 232 |
233 if (width) | |
234 *width = calc_width; | |
235 | |
236 if (height) | |
237 *height = calc_height; | |
238 | |
239 if (cell_area) | |
240 { | |
241 if (x_offset) | |
242 { | |
243 *x_offset = cell->xalign * (cell_area->width - calc_width); | |
244 *x_offset = MAX (*x_offset, 0); | |
245 } | |
246 if (y_offset) | |
247 { | |
248 *y_offset = cell->yalign * (cell_area->height - calc_height); | |
249 *y_offset = MAX (*y_offset, 0); | |
250 } | |
251 } | |
252 } | |
253 | |
254 | |
9898 | 255 static void gaim_gtk_cell_renderer_progress_render (GtkCellRenderer *cell, |
3832 | 256 GdkWindow *window, |
257 GtkWidget *widget, | |
258 GdkRectangle *background_area, | |
259 GdkRectangle *cell_area, | |
260 GdkRectangle *expose_area, | |
261 guint flags) | |
262 { | |
9898 | 263 GaimGtkCellRendererProgress *cellprogress = (GaimGtkCellRendererProgress *) cell; |
3832 | 264 |
265 gint width, height; | |
266 GtkStateType state; | |
267 | |
7738 | 268 width = cell_area->width; |
269 height = cell_area->height; | |
3832 | 270 |
271 if (GTK_WIDGET_HAS_FOCUS (widget)) | |
272 state = GTK_STATE_ACTIVE; | |
273 else | |
274 state = GTK_STATE_NORMAL; | |
9898 | 275 |
3832 | 276 width -= cell->xpad*2; |
277 height -= cell->ypad*2; | |
9898 | 278 |
3832 | 279 gtk_paint_box (widget->style, |
280 window, | |
281 GTK_STATE_NORMAL, GTK_SHADOW_IN, | |
282 NULL, widget, "trough", | |
7738 | 283 cell_area->x + cell->xpad, |
284 cell_area->y + cell->ypad, | |
3832 | 285 width - 1, height - 1); |
286 gtk_paint_box (widget->style, | |
287 window, | |
288 state, GTK_SHADOW_OUT, | |
289 NULL, widget, "bar", | |
7738 | 290 cell_area->x + cell->xpad + 1, |
291 cell_area->y + cell->ypad + 1, | |
7705 | 292 (width - 3) * cellprogress->progress, |
293 height - 3); | |
3832 | 294 } |