annotate console/gntnotify.c @ 14019:19a1812e6c46

[gaim-migrate @ 16615] Fix a crash. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 02 Aug 2006 06:24:38 +0000
parents 4d5cc9e4cb12
children eaf7f35635bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #include <gnt.h>
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #include <gntbox.h>
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 #include <gntbutton.h>
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #include <gntlabel.h>
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
5 #include <gnttree.h>
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 #include <util.h>
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 #include "gntnotify.h"
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 #include "gntgaim.h"
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
12 static struct
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
13 {
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
14 GntWidget *window;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
15 GntWidget *tree;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
16 } emaildialog;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
17
13988
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
18 static void
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
19 notify_msg_window_destroy_cb(GntWidget *window, GaimNotifyMsgType type)
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
20 {
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
21 gaim_notify_close(type, window);
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
22 }
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
23
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 static void *
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 gg_notify_message(GaimNotifyMsgType type, const char *title,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 const char *primary, const char *secondary)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 GntWidget *window, *button;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 GntTextFormatFlags pf = 0, sf = 0;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 switch (type)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 case GAIM_NOTIFY_MSG_ERROR:
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 sf |= GNT_TEXT_FLAG_BOLD;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 case GAIM_NOTIFY_MSG_WARNING:
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 pf |= GNT_TEXT_FLAG_UNDERLINE;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 case GAIM_NOTIFY_MSG_INFO:
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 pf |= GNT_TEXT_FLAG_BOLD;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 break;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 window = gnt_box_new(FALSE, TRUE);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 gnt_box_set_title(GNT_BOX(window), title);
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
45 gnt_box_set_fill(GNT_BOX(window), FALSE);
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
46 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 if (primary)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 gnt_box_add_widget(GNT_BOX(window),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 gnt_label_new_with_format(primary, pf));
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 if (secondary)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 gnt_box_add_widget(GNT_BOX(window),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 gnt_label_new_with_format(secondary, sf));
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 button = gnt_button_new(_("OK"));
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 gnt_box_add_widget(GNT_BOX(window), button);
13988
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
57 g_signal_connect_swapped(G_OBJECT(button), "activate",
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
58 G_CALLBACK(gnt_widget_destroy), window);
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
59 g_signal_connect(G_OBJECT(window), "destroy",
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
60 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type));
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 gnt_widget_show(window);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 return window;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 /* handle is, in all/most occasions, a GntWidget * */
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 static void gg_close_notify(GaimNotifyType type, void *handle)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 {
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
69 GntWidget *widget = handle;
13988
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
70
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
71 if (!widget)
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
72 return;
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
73
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
74 while (widget->parent)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
75 widget = widget->parent;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
76
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
77 if (type == GAIM_NOTIFY_SEARCHRESULTS)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
78 gaim_notify_searchresults_free(g_object_get_data(handle, "notify-results"));
13988
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
79 #if 0
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
80 /* This does not seem to be necessary */
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
81 g_signal_handlers_disconnect_by_func(G_OBJECT(widget),
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
82 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type));
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
83 #endif
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
84 gnt_widget_destroy(widget);
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 static void *gg_notify_formatted(const char *title, const char *primary,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 const char *secondary, const char *text)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 /* XXX: For now, simply strip the html and use _notify_message. For future use,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 * there should be some way of parsing the makrups from GntTextView */
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 char *unformat = gaim_markup_strip_html(text);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 char *t = g_strdup_printf("%s%s%s",
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 secondary ? secondary : "",
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 secondary ? "\n" : "",
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 unformat ? unformat : "");
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97
13988
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
98 void *ret = gg_notify_message(GAIM_NOTIFY_FORMATTED, title, primary, t);
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 g_free(t);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 g_free(unformat);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 return ret;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
106 static void
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
107 reset_email_dialog()
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
108 {
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
109 emaildialog.window = NULL;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
110 emaildialog.tree = NULL;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
111 }
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
112
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
113 static void
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
114 setup_email_dialog()
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
115 {
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
116 GntWidget *box, *tree, *button;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
117 if (emaildialog.window)
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
118 return;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
119
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
120 emaildialog.window = box = gnt_vbox_new(FALSE);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
121 gnt_box_set_toplevel(GNT_BOX(box), TRUE);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
122 gnt_box_set_title(GNT_BOX(box), _("Emails"));
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
123 gnt_box_set_fill(GNT_BOX(box), FALSE);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
124 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
125 gnt_box_set_pad(GNT_BOX(box), 0);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
126
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
127 gnt_box_add_widget(GNT_BOX(box),
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
128 gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD));
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
129
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
130 emaildialog.tree = tree = gnt_tree_new_with_columns(3);
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
131 gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("From"), _("Subject"));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
132 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
133 gnt_tree_set_col_width(GNT_TREE(tree), 0, 15);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
134 gnt_tree_set_col_width(GNT_TREE(tree), 1, 25);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
135 gnt_tree_set_col_width(GNT_TREE(tree), 2, 25);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
136
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
137 gnt_box_add_widget(GNT_BOX(box), tree);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
138
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
139 button = gnt_button_new(_("Close"));
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
140 gnt_box_add_widget(GNT_BOX(box), button);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
141
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
142 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), box);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
143 g_signal_connect(G_OBJECT(box), "destroy", G_CALLBACK(reset_email_dialog), NULL);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
144 }
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
145
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 static void *
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 gg_notify_emails(GaimConnection *gc, size_t count, gboolean detailed,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 const char **subjects, const char **froms, const char **tos,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 const char **urls)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 GaimAccount *account = gaim_connection_get_account(gc);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 GString *message = g_string_new(NULL);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 void *ret;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155 if (!detailed)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 g_string_append_printf(message,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 ngettext("%s (%s) has %d new message.",
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 "%s (%s) has %d new messages.",
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 (int)count),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 tos ? *tos : gaim_account_get_username(account),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 gaim_account_get_protocol_name(account), (int)count);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 else
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 {
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
166 setup_email_dialog();
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
167
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
168 gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(time(NULL)),
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
169 gnt_tree_create_row(GNT_TREE(emaildialog.tree),
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
170 tos ? *tos : gaim_account_get_username(account), /* XXX: Perhaps add the prpl-name */
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
171 froms ? *froms : "[Unknown sender]",
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
172 *subjects),
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
173 NULL, NULL);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
174 gnt_widget_show(emaildialog.window);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
175 return NULL;
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177
13988
4d5cc9e4cb12 [gaim-migrate @ 16561]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
178 ret = gg_notify_message(GAIM_NOTIFY_EMAIL, _("New Mail"), _("You have mail!"), message->str);
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 g_string_free(message, TRUE);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 return ret;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 static void *
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 gg_notify_email(GaimConnection *gc, const char *subject, const char *from,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 const char *to, const char *url)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 return gg_notify_emails(gc, 1, subject != NULL,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 subject ? &subject : NULL,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 from ? &from : NULL,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 to ? &to : NULL,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 url ? &url : NULL);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 static void *
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 gg_notify_userinfo(GaimConnection *gc, const char *who, const char *text)
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 /* Xeroxed from gtknotify.c */
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 char *primary;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 void *ui_handle;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 primary = g_strdup_printf(_("Info for %s"), who);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 ui_handle = gg_notify_formatted(_("Buddy Information"), primary, NULL, text);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 g_free(primary);
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 return ui_handle;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
207 static void
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
208 notify_button_activated(GntWidget *widget, GaimNotifySearchButton *b)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
209 {
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
210 GList *list = NULL;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
211 GaimAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
212 gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
213
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
214 list = gnt_tree_get_selection_text_list(GNT_TREE(widget));
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
215
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
216 b->callback(gaim_account_get_connection(account), list, data);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
217 g_list_foreach(list, (GFunc)g_free, NULL);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
218 g_list_free(list);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
219 }
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
220
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
221 static void
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
222 gg_notify_sr_new_rows(GaimConnection *gc,
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
223 GaimNotifySearchResults *results, void *data)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
224 {
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
225 GntTree *tree = GNT_TREE(data);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
226 GList *o;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
227
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
228 /* XXX: Do I need to empty the tree here? */
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
229
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
230 for (o = results->rows; o; o = o->next)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
231 {
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
232 gnt_tree_add_row_after(GNT_TREE(tree), o->data,
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
233 gnt_tree_create_row_from_list(GNT_TREE(tree), o->data),
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
234 NULL, NULL);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
235 }
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
236 }
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
237
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
238 static void *
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
239 gg_notify_searchresults(GaimConnection *gc, const char *title,
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
240 const char *primary, const char *secondary,
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
241 GaimNotifySearchResults *results, gpointer data)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
242 {
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
243 GntWidget *window, *tree, *box, *button;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
244 GList *iter;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
245
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
246 window = gnt_vbox_new(FALSE);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
247 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
248 gnt_box_set_title(GNT_BOX(window), title);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
249 gnt_box_set_fill(GNT_BOX(window), FALSE);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
250 gnt_box_set_pad(GNT_BOX(window), 0);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
251 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
252
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
253 gnt_box_add_widget(GNT_BOX(window),
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
254 gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD));
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
255 gnt_box_add_widget(GNT_BOX(window),
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
256 gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL));
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
257
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
258 tree = gnt_tree_new_with_columns(g_list_length(results->columns));
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
259 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
260 gnt_box_add_widget(GNT_BOX(window), tree);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
261
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
262 box = gnt_hbox_new(TRUE);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
263
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
264 for (iter = results->buttons; iter; iter = iter->next)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
265 {
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
266 GaimNotifySearchButton *b = iter->data;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
267 const char *text;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
268
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
269 switch (b->type)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
270 {
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
271 case GAIM_NOTIFY_BUTTON_LABELED:
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
272 text = b->label;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
273 break;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
274 case GAIM_NOTIFY_BUTTON_CONTINUE:
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
275 text = _("Continue");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
276 break;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
277 case GAIM_NOTIFY_BUTTON_ADD:
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
278 text = _("Add");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
279 break;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
280 case GAIM_NOTIFY_BUTTON_INFO:
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
281 text = _("Info");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
282 break;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
283 case GAIM_NOTIFY_BUTTON_IM:
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
284 text = _("IM");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
285 break;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
286 case GAIM_NOTIFY_BUTTON_JOIN:
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
287 text = _("Join");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
288 break;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
289 case GAIM_NOTIFY_BUTTON_INVITE:
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
290 text = _("Invite");
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
291 break;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
292 }
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
293
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
294 button = gnt_button_new(text);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
295 g_object_set_data(G_OBJECT(button), "notify-account", gaim_connection_get_account(gc));
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
296 g_object_set_data(G_OBJECT(button), "notify-data", data);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
297 g_signal_connect_swapped(G_OBJECT(button), "activate",
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
298 G_CALLBACK(notify_button_activated), b);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
299
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
300 gnt_box_add_widget(GNT_BOX(box), button);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
301 }
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
302
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
303 gnt_box_add_widget(GNT_BOX(window), box);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
304
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
305 gg_notify_sr_new_rows(gc, results, tree);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
306
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
307 gnt_widget_show(window);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
308 g_object_set_data(G_OBJECT(window), "notify-results", results);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
309
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
310 return tree;
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
311 }
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
312
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 static GaimNotifyUiOps ops =
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 .notify_message = gg_notify_message,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 .close_notify = gg_close_notify, /* The rest of the notify-uiops return a GntWidget.
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 These widgets should be destroyed from here. */
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318 .notify_formatted = gg_notify_formatted,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319 .notify_email = gg_notify_email,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 .notify_emails = gg_notify_emails,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 .notify_userinfo = gg_notify_userinfo,
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
322
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
323 .notify_searchresults = gg_notify_searchresults,
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13971
diff changeset
324 .notify_searchresults_new_rows = gg_notify_sr_new_rows,
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325 .notify_uri = NULL /* This is of low-priority to me */
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326 };
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328 GaimNotifyUiOps *gg_notify_get_ui_ops()
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 return &ops;
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
333 void gg_notify_init()
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
334 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
335 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
337 void gg_notify_uninit()
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
338 {
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
339 }
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
340
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
341