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