annotate src/gtknotify.c @ 5455:f9658a84d1ed

[gaim-migrate @ 5843] Might as well be thorough. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 20 May 2003 03:33:13 +0000
parents 0031a613a87d
children 9bcd8cd625ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file gtknotify.c GTK+ Notification API
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 * @ingroup gtkui
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "gtknotify.h"
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "stock.h"
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include <gtk/gtk.h>
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 static void *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 const char *primary, const char *secondary,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 GCallback cb, void *user_data)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 GtkWidget *dialog;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 GtkWidget *hbox;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 GtkWidget *label;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 GtkWidget *img = NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 char label_text[2048];
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 const char *icon_name = NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 switch (type) {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 case GAIM_NOTIFY_MSG_ERROR:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 icon_name = GAIM_STOCK_DIALOG_ERROR;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 case GAIM_NOTIFY_MSG_WARNING:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 icon_name = GAIM_STOCK_DIALOG_WARNING;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 case GAIM_NOTIFY_MSG_INFO:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 icon_name = GAIM_STOCK_DIALOG_INFO;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 default:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 icon_name = NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 if (icon_name != NULL) {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_DIALOG);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 dialog = gtk_dialog_new_with_buttons("", NULL, 0,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 NULL);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 g_signal_connect(G_OBJECT(dialog), "response",
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 G_CALLBACK(gtk_widget_destroy), NULL);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 hbox = gtk_hbox_new(FALSE, 12);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 if (img != NULL)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 g_snprintf(label_text, sizeof(label_text),
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 primary, (secondary ? secondary : ""));
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 label = gtk_label_new(NULL);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 gtk_label_set_markup(GTK_LABEL(label), label_text);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 gtk_widget_show_all(dialog);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 return dialog;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 static void *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 gaim_gtk_notify_email(const char *subject, const char *from,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 const char *to, const char *url,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 GCallback cb, void *user_data)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 return NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 static void *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 gaim_gtk_notify_emails(size_t count, const char **subjects,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 const char **froms, const char **tos,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 const char **urls, GCallback cb, void *user_data)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 return NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 static void
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 gaim_gtk_close_notify(GaimNotifyType type, void *ptr)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 gtk_widget_destroy(GTK_WIDGET(ptr));
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 static GaimNotifyUiOps ops =
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 gaim_gtk_notify_message,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 gaim_gtk_notify_email,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 gaim_gtk_notify_emails,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 gaim_gtk_close_notify
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 };
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 GaimNotifyUiOps *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 gaim_get_gtk_notify_ui_ops(void)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 return &ops;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 }