src/gtknotify.c

changeset 6381
53203c44c731
parent 6371
e92b66ee5518
child 6465
bd201d637ff4
equal deleted inserted replaced
6380:6f4accd442df 6381:53203c44c731
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 #include "gtkinternal.h" 23 #include "gtkinternal.h"
24 24
25 #include "connection.h"
25 #include "debug.h" 26 #include "debug.h"
26 #include "connection.h" 27 #include "prefs.h"
27 #include "stock.h" 28 #include "stock.h"
28 29
30 #include "gtkimhtml.h"
29 #include "gtknotify.h" 31 #include "gtknotify.h"
32 #include "gtkutils.h"
30 33
31 #include "ui.h" 34 #include "ui.h"
32 35
33 typedef struct 36 typedef struct
34 { 37 {
247 gtk_widget_show_all(dialog); 250 gtk_widget_show_all(dialog);
248 251
249 return data; 252 return data;
250 } 253 }
251 254
255 static void *
256 gaim_gtk_notify_formatted(const char *title, const char *primary,
257 const char *secondary, const char *text,
258 GCallback cb, void *user_data)
259 {
260 GtkWidget *window;
261 GtkWidget *vbox;
262 GtkWidget *label;
263 GtkWidget *button;
264 GtkWidget *imhtml;
265 GtkWidget *sw;
266 int options = 0;
267 char label_text[2048];
268
269 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
270 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
271 gtk_container_set_border_width(GTK_CONTAINER(window), 12);
272
273 /* Setup the main vbox */
274 vbox = gtk_vbox_new(FALSE, 12);
275 gtk_container_add(GTK_CONTAINER(window), vbox);
276 gtk_widget_show(vbox);
277
278 /* Setup the descriptive label */
279 g_snprintf(label_text, sizeof(label_text),
280 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
281 primary, (secondary ? secondary : ""));
282
283 label = gtk_label_new(NULL);
284
285 gtk_label_set_markup(GTK_LABEL(label), label_text);
286 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
287 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
288 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
289 gtk_widget_show(label);
290
291 /* Setup the scrolled window that we're putting the gtkimhtml in. */
292 sw = gtk_scrolled_window_new(NULL, NULL);
293 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
294 GTK_POLICY_NEVER,
295 GTK_POLICY_ALWAYS);
296 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
297 GTK_SHADOW_IN);
298 gtk_widget_set_size_request(sw, 300, 250);
299 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
300 gtk_widget_show(sw);
301
302 /* Now build that gtkimhtml */
303 imhtml = gtk_imhtml_new(NULL, NULL);
304 gtk_container_add(GTK_CONTAINER(sw), imhtml);
305 gtk_widget_show(imhtml);
306 gaim_setup_imhtml(imhtml);
307
308 /* Add the Close button. */
309 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
310 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
311 gtk_widget_show(button);
312
313 g_signal_connect(G_OBJECT(button), "clicked",
314 G_CALLBACK(gtk_widget_destroy), window);
315
316 /* Add the text to the gtkimhtml */
317 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors"))
318 options ^= GTK_IMHTML_NO_COLOURS;
319
320 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_fonts"))
321 options ^= GTK_IMHTML_NO_FONTS;
322
323 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes"))
324 options ^= GTK_IMHTML_NO_SIZES;
325
326 options ^= GTK_IMHTML_NO_COMMENTS;
327 options ^= GTK_IMHTML_NO_TITLE;
328 options ^= GTK_IMHTML_NO_NEWLINE;
329 options ^= GTK_IMHTML_NO_SCROLL;
330
331 gtk_imhtml_append_text(GTK_IMHTML(imhtml), text, -1, options);
332
333 /* Show the window */
334 gtk_widget_show(window);
335
336 return window;
337 }
338
252 static void 339 static void
253 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle) 340 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle)
254 { 341 {
255 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) { 342 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) {
256 GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle; 343 GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle;
267 static GaimNotifyUiOps ops = 354 static GaimNotifyUiOps ops =
268 { 355 {
269 gaim_gtk_notify_message, 356 gaim_gtk_notify_message,
270 gaim_gtk_notify_email, 357 gaim_gtk_notify_email,
271 gaim_gtk_notify_emails, 358 gaim_gtk_notify_emails,
359 gaim_gtk_notify_formatted,
272 gaim_gtk_close_notify 360 gaim_gtk_close_notify
273 }; 361 };
274 362
275 GaimNotifyUiOps * 363 GaimNotifyUiOps *
276 gaim_get_gtk_notify_ui_ops(void) 364 gaim_get_gtk_notify_ui_ops(void)

mercurial