Mercurial > pidgin.yaz
annotate src/gtknotify.c @ 12586:218d0aec518d
[gaim-migrate @ 14914]
ignore tweaks...
committer: Tailor Script <tailor@pidgin.im>
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Wed, 21 Dec 2005 00:08:21 +0000 |
parents | d90eae2387b5 |
children | e856f985a0b9 |
rev | line source |
---|---|
5437 | 1 /** |
2 * @file gtknotify.c GTK+ Notification API | |
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. | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
10 * |
5437 | 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 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
27 |
7455 | 28 #include <gdk/gdkkeysyms.h> |
29 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
30 #include "connection.h" |
8284 | 31 #include "debug.h" |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
32 #include "prefs.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10260
diff
changeset
|
33 #include "gtkstock.h" |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
34 #include "util.h" |
5437 | 35 |
10439 | 36 #include "gtkblist.h" |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
37 #include "gtkimhtml.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
38 #include "gtknotify.h" |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
39 #include "gtkutils.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
40 |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
41 typedef struct |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
42 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5543
diff
changeset
|
43 GaimConnection *gc; |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
44 char *url; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
45 GtkWidget *dialog; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
46 GtkWidget *label; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
47 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
48 } GaimNotifyMailData; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
49 |
10439 | 50 typedef struct |
51 { | |
52 GaimAccount *account; | |
53 GtkListStore *model; | |
54 GtkWidget *treeview; | |
55 GtkWidget *window; | |
56 } GaimNotifySearchResultsData; | |
57 | |
11359 | 58 typedef struct |
10439 | 59 { |
11359 | 60 GaimNotifySearchButton *button; |
61 GaimNotifySearchResultsData *data; | |
62 | |
63 } GaimNotifySearchResultsButtonData; | |
10439 | 64 |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
65 static void *gaim_gtk_notify_emails(size_t count, gboolean detailed, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
66 const char **subjects, |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
67 const char **froms, const char **tos, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
68 const char **urls); |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
69 |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
70 static void |
6354
76af8c066f8c
[gaim-migrate @ 6853]
Christian Hammond <chipx86@chipx86.com>
parents:
6106
diff
changeset
|
71 message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
6104 | 72 { |
6357 | 73 gaim_notify_close(GAIM_NOTIFY_MESSAGE, widget); |
6104 | 74 } |
75 | |
76 static void | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
77 email_response_cb(GtkDialog *dialog, gint id, GaimNotifyMailData *data) |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
78 { |
10260 | 79 if (id == GTK_RESPONSE_YES) |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
80 gaim_notify_uri(NULL, data->url); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
81 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
82 gaim_notify_close(GAIM_NOTIFY_EMAILS, data); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
83 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
84 |
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
85 static void |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
86 formatted_close_cb(GtkWidget *win, GdkEvent *event, void *user_data) |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
87 { |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
88 gaim_notify_close(GAIM_NOTIFY_FORMATTED, win); |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
89 } |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
90 |
10439 | 91 static void |
92 searchresults_close_cb(GaimNotifySearchResultsData *data, GdkEvent *event, void *user_data) | |
93 { | |
94 gaim_notify_close(GAIM_NOTIFY_SEARCHRESULTS, data); | |
95 } | |
96 | |
97 static void | |
11359 | 98 searchresults_callback_wrapper_cb(GtkWidget *widget, GaimNotifySearchResultsButtonData *bd) |
10439 | 99 { |
11359 | 100 GaimNotifySearchResultsData *data = bd->data; |
101 | |
10439 | 102 GtkTreeSelection *selection; |
103 GtkTreeModel *model; | |
104 GtkTreeIter iter; | |
11359 | 105 GaimNotifySearchButton *button; |
106 GList *row = NULL; | |
107 gchar *str; | |
108 int i; | |
10439 | 109 |
110 g_return_if_fail(data != NULL); | |
111 | |
112 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->treeview)); | |
113 | |
114 if (gtk_tree_selection_get_selected(selection, &model, &iter)) | |
115 { | |
11359 | 116 for (i = 1; i < gtk_tree_model_get_n_columns(GTK_TREE_MODEL(model)); i++) { |
117 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, i, &str, -1); | |
118 row = g_list_append(row, str); | |
119 } | |
10439 | 120 } |
11359 | 121 |
122 button = bd->button; | |
123 button->callback(gaim_account_get_connection(data->account), row); | |
10439 | 124 } |
125 | |
5437 | 126 static void * |
127 gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title, | |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
128 const char *primary, const char *secondary) |
5437 | 129 { |
130 GtkWidget *dialog; | |
131 GtkWidget *hbox; | |
132 GtkWidget *label; | |
133 GtkWidget *img = NULL; | |
134 char label_text[2048]; | |
135 const char *icon_name = NULL; | |
10774 | 136 char *primary_esc, *secondary_esc; |
5437 | 137 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
138 switch (type) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
139 { |
5437 | 140 case GAIM_NOTIFY_MSG_ERROR: |
141 icon_name = GAIM_STOCK_DIALOG_ERROR; | |
142 break; | |
143 | |
144 case GAIM_NOTIFY_MSG_WARNING: | |
145 icon_name = GAIM_STOCK_DIALOG_WARNING; | |
146 break; | |
147 | |
148 case GAIM_NOTIFY_MSG_INFO: | |
149 icon_name = GAIM_STOCK_DIALOG_INFO; | |
150 break; | |
151 | |
152 default: | |
153 icon_name = NULL; | |
154 break; | |
155 } | |
156 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
157 if (icon_name != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
158 { |
5437 | 159 img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_DIALOG); |
160 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
161 } | |
162 | |
7678 | 163 dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, |
10260 | 164 NULL, 0, GTK_STOCK_CLOSE, |
165 GTK_RESPONSE_CLOSE, NULL); | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
166 |
8523
013d256e8ded
[gaim-migrate @ 9262]
Christian Hammond <chipx86@chipx86.com>
parents:
8356
diff
changeset
|
167 gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog"); |
013d256e8ded
[gaim-migrate @ 9262]
Christian Hammond <chipx86@chipx86.com>
parents:
8356
diff
changeset
|
168 |
5437 | 169 g_signal_connect(G_OBJECT(dialog), "response", |
6104 | 170 G_CALLBACK(message_response_cb), dialog); |
5437 | 171 |
11243 | 172 gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER); |
5437 | 173 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
174 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
11243 | 175 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); |
176 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BOX_SPACE); | |
5437 | 177 |
11243 | 178 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
5437 | 179 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
180 | |
181 if (img != NULL) | |
182 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
183 | |
10774 | 184 primary_esc = g_markup_escape_text(primary, -1); |
185 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
5437 | 186 g_snprintf(label_text, sizeof(label_text), |
187 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", | |
10774 | 188 primary_esc, (secondary ? secondary_esc : "")); |
189 g_free(primary_esc); | |
190 g_free(secondary_esc); | |
5437 | 191 |
192 label = gtk_label_new(NULL); | |
193 | |
194 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
195 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
196 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
197 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
198 | |
199 gtk_widget_show_all(dialog); | |
200 | |
201 return dialog; | |
202 } | |
203 | |
204 static void * | |
205 gaim_gtk_notify_email(const char *subject, const char *from, | |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
206 const char *to, const char *url) |
5437 | 207 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
208 return gaim_gtk_notify_emails(1, TRUE, |
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
209 (subject == NULL ? NULL : &subject), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
210 (from == NULL ? NULL : &from), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
211 (to == NULL ? NULL : &to), |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
212 (url == NULL ? NULL : &url)); |
5437 | 213 } |
214 | |
215 static void * | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
216 gaim_gtk_notify_emails(size_t count, gboolean detailed, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
217 const char **subjects, const char **froms, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
218 const char **tos, const char **urls) |
5437 | 219 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
220 GaimNotifyMailData *data; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
221 GtkWidget *dialog; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
222 GtkWidget *vbox; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
223 GtkWidget *hbox; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
224 GtkWidget *label; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
225 GtkWidget *img; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
226 char *detail_text; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
227 char *label_text; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
228 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
229 data = g_new0(GaimNotifyMailData, 1); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
230 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
231 data->url = g_strdup(urls[0]); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
232 |
10260 | 233 /* Create the dialog */ |
234 dialog = gtk_dialog_new_with_buttons("New Mail", NULL, 0, | |
235 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
236 NULL); | |
237 data->dialog = dialog; | |
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
238 |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
239 if (urls != NULL) |
10260 | 240 gtk_dialog_add_button(GTK_DIALOG(dialog), |
241 GAIM_STOCK_OPEN_MAIL, GTK_RESPONSE_YES); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
242 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
243 g_signal_connect(G_OBJECT(dialog), "response", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
244 G_CALLBACK(email_response_cb), data); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
245 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
246 /* Setup the dialog */ |
11243 | 247 gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BOX_SPACE); |
248 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BOX_SPACE); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
249 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
250 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
11243 | 251 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
252 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
253 /* Setup the main horizontal box */ |
11243 | 254 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
255 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
256 |
10260 | 257 /* Dialog icon */ |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
258 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_INFO, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
259 GTK_ICON_SIZE_DIALOG); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
260 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
261 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
262 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
263 /* Vertical box */ |
11243 | 264 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
265 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
266 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
267 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
268 /* Descriptive label */ |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
269 detail_text = g_strdup_printf(ngettext("%s has %d new message.", |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
270 "%s has %d new messages.", |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
271 (int)count), |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
272 *tos, (int)count); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
273 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
274 if (count == 1) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
275 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
276 char *from_text = NULL, *subject_text = NULL; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
277 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
278 if (froms != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
279 { |
8920 | 280 char *from_enc; |
281 from_enc = g_markup_escape_text(*froms, -1); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
282 from_text = g_strdup_printf( |
8920 | 283 _("<span weight=\"bold\">From:</span> %s\n"), from_enc); |
284 g_free(from_enc); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
285 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
286 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
287 if (subjects != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
288 { |
8920 | 289 char *subject_enc; |
290 subject_enc = g_markup_escape_text(*subjects, -1); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
291 subject_text = g_strdup_printf( |
8920 | 292 _("<span weight=\"bold\">Subject:</span> %s\n"), subject_enc); |
293 g_free(subject_enc); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
294 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
295 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
296 label_text = g_strdup_printf( |
5543 | 297 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
298 "\n\n%s%s%s%s"), | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
299 detail_text, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
300 (from_text == NULL && subject_text == NULL ? "" : "\n\n"), |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
301 (from_text == NULL ? "" : from_text), |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
302 (subject_text == NULL ? "" : subject_text)); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
303 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
304 if (from_text != NULL) |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
305 g_free(from_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
306 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
307 if (subject_text != NULL) |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
308 g_free(subject_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
309 } |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
310 else |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
311 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
312 label_text = g_strdup_printf( |
5543 | 313 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
314 "\n\n%s"), detail_text); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
315 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
316 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
317 g_free(detail_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
318 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
319 label = gtk_label_new(NULL); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
320 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
321 gtk_label_set_markup(GTK_LABEL(label), label_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
322 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
323 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
324 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
325 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
326 g_free(label_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
327 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
328 /* Show everything. */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
329 gtk_widget_show_all(dialog); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
330 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
331 return data; |
5437 | 332 } |
333 | |
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
334 static gboolean |
10875
a118e50116df
[gaim-migrate @ 12566]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10774
diff
changeset
|
335 formatted_input_cb(GtkWidget *win, GdkEventKey *event, gpointer data) |
7455 | 336 { |
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
337 if (event->keyval == GDK_Escape) |
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
338 { |
10875
a118e50116df
[gaim-migrate @ 12566]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10774
diff
changeset
|
339 gaim_notify_close(GAIM_NOTIFY_FORMATTED, win); |
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
340 |
7455 | 341 return TRUE; |
342 } | |
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
343 |
7455 | 344 return FALSE; |
345 } | |
346 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
347 static void * |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
348 gaim_gtk_notify_formatted(const char *title, const char *primary, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
349 const char *secondary, const char *text) |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
350 { |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
351 GtkWidget *window; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
352 GtkWidget *vbox; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
353 GtkWidget *label; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
354 GtkWidget *button; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
355 GtkWidget *imhtml; |
10181 | 356 GtkWidget *frame; |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
357 int options = 0; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
358 char label_text[2048]; |
10774 | 359 char *linked_text, *primary_esc, *secondary_esc; |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
360 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
361 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
8345 | 362 gtk_window_set_title(GTK_WINDOW(window), title); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
363 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); |
11243 | 364 gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
365 |
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
366 g_signal_connect(G_OBJECT(window), "delete_event", |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
367 G_CALLBACK(formatted_close_cb), NULL); |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
368 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
369 /* Setup the main vbox */ |
11243 | 370 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
371 gtk_container_add(GTK_CONTAINER(window), vbox); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
372 gtk_widget_show(vbox); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
373 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
374 /* Setup the descriptive label */ |
10774 | 375 primary_esc = g_markup_escape_text(primary, -1); |
376 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
377 g_snprintf(label_text, sizeof(label_text), |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
378 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", |
10774 | 379 primary_esc, |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
380 (secondary ? "\n" : ""), |
10774 | 381 (secondary ? secondary_esc : "")); |
382 g_free(primary_esc); | |
383 g_free(secondary_esc); | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
384 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
385 label = gtk_label_new(NULL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
386 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
387 gtk_label_set_markup(GTK_LABEL(label), label_text); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
388 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
389 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
390 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
391 gtk_widget_show(label); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
392 |
10181 | 393 /* Add the imhtml */ |
394 frame = gaim_gtk_create_imhtml(FALSE, &imhtml, NULL); | |
9005 | 395 gtk_widget_set_name(imhtml, "gaim_gtknotify_imhtml"); |
11723
9537977703bb
[gaim-migrate @ 14014]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
396 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), |
9537977703bb
[gaim-migrate @ 14014]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
397 gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml)) | GTK_IMHTML_IMAGE); |
10181 | 398 gtk_widget_set_size_request(imhtml, 300, 250); |
399 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
400 gtk_widget_show(frame); | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
401 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
402 /* Add the Close button. */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
403 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
404 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
405 gtk_widget_show(button); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
406 |
6872 | 407 g_signal_connect_swapped(G_OBJECT(button), "clicked", |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
408 G_CALLBACK(formatted_close_cb), window); |
7455 | 409 g_signal_connect(G_OBJECT(window), "key_press_event", |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
410 G_CALLBACK(formatted_input_cb), NULL); |
7455 | 411 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
412 /* Add the text to the gtkimhtml */ |
11293 | 413 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
10497 | 414 options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES; |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
415 |
10503 | 416 options |= GTK_IMHTML_NO_COMMENTS; |
417 options |= GTK_IMHTML_NO_TITLE; | |
418 options |= GTK_IMHTML_NO_NEWLINE; | |
419 options |= GTK_IMHTML_NO_SCROLL; | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
420 |
8882 | 421 /* Make sure URLs are clickable */ |
422 linked_text = gaim_markup_linkify(text); | |
10181 | 423 gtk_imhtml_append_text(GTK_IMHTML(imhtml), linked_text, options); |
8882 | 424 g_free(linked_text); |
7078 | 425 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
426 /* Show the window */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
427 gtk_widget_show(window); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
428 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
429 return window; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
430 } |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
431 |
11359 | 432 static void |
433 gaim_gtk_notify_searchresults_new_rows(GaimConnection *gc, GaimNotifySearchResults *results, | |
12220
64254fbabc7b
[gaim-migrate @ 14522]
Richard Laager <rlaager@wiktel.com>
parents:
11723
diff
changeset
|
434 void *data_, gpointer user_data) |
11359 | 435 { |
436 GaimNotifySearchResultsData *data = data_; | |
437 GtkListStore *model = data->model; | |
438 GtkTreeIter iter; | |
439 GdkPixbuf *icon, *scaled; | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
440 guint col_num; |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
441 guint i; |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
442 guint j; |
11359 | 443 |
444 gtk_list_store_clear(data->model); | |
445 | |
446 icon = gaim_gtk_create_prpl_icon(gaim_connection_get_account(gc)); | |
447 scaled = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); | |
448 | |
449 /* +1 is for the automagically created Status column. */ | |
450 col_num = gaim_notify_searchresults_get_columns_count(results) + 1; | |
451 | |
452 for (i = 0; i < gaim_notify_searchresults_get_rows_count(results); i++) { | |
453 GList *row = gaim_notify_searchresults_row_get(results, i); | |
454 | |
455 gtk_list_store_append(model, &iter); | |
456 gtk_list_store_set(model, &iter, 0, scaled, -1); | |
457 | |
458 for (j = 1; j < col_num; j++) { | |
12227
b4391f2ae8de
[gaim-migrate @ 14529]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
459 GValue v = {0, }; |
11359 | 460 char *escaped = g_markup_escape_text(g_list_nth_data(row, j - 1), -1); |
461 | |
462 g_value_init(&v, G_TYPE_STRING); | |
463 g_value_set_string(&v, escaped); | |
464 gtk_list_store_set_value(model, &iter, j, &v); | |
465 g_free(escaped); | |
466 } | |
467 } | |
468 } | |
469 | |
9797 | 470 static void * |
10439 | 471 gaim_gtk_notify_searchresults(GaimConnection *gc, const char *title, |
472 const char *primary, const char *secondary, | |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
473 GaimNotifySearchResults *results) |
10439 | 474 { |
475 GtkWidget *window; | |
11359 | 476 GtkWidget *treeview; |
477 GtkWidget *button, *close_button; | |
478 GType *col_types; | |
479 GtkListStore *model; | |
480 GtkCellRenderer *renderer; | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
481 guint col_num; |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
482 guint i; |
11359 | 483 GList *buttons = NULL; |
484 | |
10439 | 485 GtkWidget *vbox; |
486 GtkWidget *button_area; | |
487 GtkWidget *label; | |
488 GtkWidget *sw; | |
489 GaimNotifySearchResultsData *data; | |
490 char *label_text; | |
10774 | 491 char *primary_esc, *secondary_esc; |
10439 | 492 |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
493 g_return_val_if_fail(gc != NULL, NULL); |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
494 g_return_val_if_fail(results != NULL, NULL); |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
495 |
10439 | 496 data = g_malloc(sizeof(GaimNotifySearchResultsData)); |
497 | |
498 /* Create the window */ | |
499 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
500 gtk_window_set_title(GTK_WINDOW(window), (title ? title :_("Search Results"))); | |
501 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
11243 | 502 gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); |
10439 | 503 |
504 g_signal_connect_swapped(G_OBJECT(window), "delete_event", | |
505 G_CALLBACK(searchresults_close_cb), data); | |
506 | |
507 /* Setup the main vbox */ | |
11243 | 508 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
10439 | 509 gtk_container_add(GTK_CONTAINER(window), vbox); |
510 gtk_widget_show(vbox); | |
511 | |
512 /* Setup the descriptive label */ | |
10774 | 513 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; |
514 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
10439 | 515 label_text = g_strdup_printf( |
516 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", | |
10774 | 517 (primary ? primary_esc : ""), |
10439 | 518 (primary && secondary ? "\n" : ""), |
10774 | 519 (secondary ? secondary_esc : "")); |
520 g_free(primary_esc); | |
521 g_free(secondary_esc); | |
10439 | 522 label = gtk_label_new(NULL); |
523 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
524 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
525 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
526 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
527 gtk_widget_show(label); | |
528 g_free(label_text); | |
529 | |
11359 | 530 /* +1 is for the automagically created Status column. */ |
531 col_num = gaim_notify_searchresults_get_columns_count(results) + 1; | |
532 | |
10439 | 533 /* Setup the list model */ |
11359 | 534 col_types = g_new0(GType, col_num); |
535 | |
536 /* There always is this first column. */ | |
537 col_types[0] = GDK_TYPE_PIXBUF; | |
538 for (i = 1; i < col_num; i++) { | |
539 col_types[i] = G_TYPE_STRING; | |
540 } | |
541 model = gtk_list_store_newv(col_num, col_types); | |
10439 | 542 |
543 /* Setup the scrolled window containing the treeview */ | |
544 sw = gtk_scrolled_window_new(NULL, NULL); | |
545 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
546 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
547 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
548 GTK_SHADOW_IN); | |
549 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
550 gtk_widget_show(sw); | |
551 | |
552 /* Setup the treeview */ | |
553 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
554 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
11359 | 555 gtk_widget_set_size_request(treeview, 500, 400); |
10439 | 556 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), |
557 GTK_SELECTION_SINGLE); | |
11359 | 558 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), TRUE); |
10439 | 559 gtk_container_add(GTK_CONTAINER(sw), treeview); |
560 gtk_widget_show(treeview); | |
561 | |
11359 | 562 renderer = gtk_cell_renderer_pixbuf_new(); |
10439 | 563 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), |
11359 | 564 -1, "", renderer, "pixbuf", 0, NULL); |
10439 | 565 |
11359 | 566 for (i = 1; i < col_num; i++) { |
567 renderer = gtk_cell_renderer_text_new(); | |
10439 | 568 |
11359 | 569 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), -1, |
570 gaim_notify_searchresults_column_get_title(results, i-1), | |
571 renderer, "text", i, NULL); | |
572 } | |
573 | |
10439 | 574 /* Setup the button area */ |
575 button_area = gtk_hbutton_box_new(); | |
576 gtk_box_pack_start(GTK_BOX(vbox), button_area, FALSE, FALSE, 0); | |
577 gtk_button_box_set_layout(GTK_BUTTON_BOX(button_area), GTK_BUTTONBOX_END); | |
11243 | 578 gtk_box_set_spacing(GTK_BOX(button_area), GAIM_HIG_BORDER); |
10439 | 579 gtk_widget_show(button_area); |
580 | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
581 for (i = 0; i < g_list_length(results->buttons); i++) { |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
582 GaimNotifySearchButton *b = g_list_nth_data(results->buttons, i); |
11359 | 583 button = NULL; |
584 switch (b->type) { | |
585 case GAIM_NOTIFY_BUTTON_CONTINUE: | |
586 button = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD); | |
587 break; | |
588 case GAIM_NOTIFY_BUTTON_ADD_BUDDY: | |
589 button = gtk_button_new_from_stock(GTK_STOCK_ADD); | |
590 break; | |
591 default: | |
592 gaim_debug_warning("gtknotify", "Incorrect button type: %d\n", b->type); | |
593 } | |
594 if (button != NULL) { | |
595 gtk_box_pack_start(GTK_BOX(button_area), button, FALSE, FALSE, 0); | |
596 gtk_widget_show(button); | |
597 buttons = g_list_append(buttons, button); | |
598 } | |
599 } | |
10439 | 600 |
601 /* Add the Close button */ | |
602 close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
603 gtk_box_pack_start(GTK_BOX(button_area), close_button, FALSE, FALSE, 0); | |
604 gtk_widget_show(close_button); | |
605 | |
606 data->account = gc->account; | |
607 data->model = model; | |
608 data->treeview = treeview; | |
609 data->window = window; | |
610 | |
11359 | 611 /* Insert rows. */ |
612 gaim_gtk_notify_searchresults_new_rows(gc, results, data, NULL); | |
613 | |
10439 | 614 /* Connect Signals */ |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
615 for (i = 0; i < g_list_length(results->buttons); i++) { |
11359 | 616 GaimNotifySearchResultsButtonData *bd = g_new0(GaimNotifySearchResultsButtonData, 1); |
617 bd->button = g_list_nth_data(results->buttons, i); | |
618 bd->data = data; | |
619 g_signal_connect(G_OBJECT(g_list_nth_data(buttons, i)), "clicked", | |
620 G_CALLBACK(searchresults_callback_wrapper_cb), bd); | |
621 } | |
622 | |
10439 | 623 g_signal_connect_swapped(G_OBJECT(close_button), "clicked", |
624 G_CALLBACK(searchresults_close_cb), data); | |
625 | |
626 /* Show the window */ | |
627 gtk_widget_show(window); | |
628 return data; | |
629 } | |
630 | |
631 static void * | |
9797 | 632 gaim_gtk_notify_userinfo(GaimConnection *gc, const char *who, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
633 const char *text) |
9797 | 634 { |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11359
diff
changeset
|
635 char *primary; |
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11359
diff
changeset
|
636 void *ui_handle; |
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11359
diff
changeset
|
637 |
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11359
diff
changeset
|
638 primary = g_strdup_printf(_("Info for %s"), who); |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12227
diff
changeset
|
639 ui_handle = gaim_gtk_notify_formatted(_("Buddy Information"), primary, NULL, text); |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11359
diff
changeset
|
640 g_free(primary); |
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11359
diff
changeset
|
641 return ui_handle; |
9797 | 642 } |
643 | |
5437 | 644 static void |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
645 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle) |
5437 | 646 { |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
647 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
648 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
649 GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
650 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
651 gtk_widget_destroy(data->dialog); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
652 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
653 g_free(data->url); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
654 g_free(data); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
655 } |
10439 | 656 else if (type == GAIM_NOTIFY_SEARCHRESULTS) |
657 { | |
658 GaimNotifySearchResultsData *data = (GaimNotifySearchResultsData *)ui_handle; | |
659 | |
660 gtk_widget_destroy(data->window); | |
661 | |
662 g_free(data); | |
663 } | |
10750
d5a00882d118
[gaim-migrate @ 12353]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10732
diff
changeset
|
664 else if (ui_handle != NULL) |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
665 gtk_widget_destroy(GTK_WIDGET(ui_handle)); |
5437 | 666 } |
667 | |
8272 | 668 #ifndef _WIN32 |
669 static gint | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
670 uri_command(const char *command, gboolean sync) |
8272 | 671 { |
9777 | 672 gchar *escaped, *tmp; |
8272 | 673 GError *error = NULL; |
674 gint ret = 0; | |
675 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10503
diff
changeset
|
676 escaped = g_markup_escape_text(command, -1); |
9777 | 677 gaim_debug_misc("gtknotify", "Executing %s\n", escaped); |
8278 | 678 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
679 if (!gaim_program_is_valid(command)) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
680 { |
9777 | 681 tmp = g_strdup_printf(_("The browser command <b>%s</b> is invalid."), |
682 escaped ? escaped : "(none)"); | |
8272 | 683 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
684 g_free(tmp); | |
685 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
686 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
687 else if (sync) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
688 { |
8272 | 689 gint status; |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
690 |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
691 if (!g_spawn_command_line_sync(command, NULL, NULL, &status, &error)) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
692 { |
9777 | 693 tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), |
694 escaped, error->message); | |
8272 | 695 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
696 g_free(tmp); | |
697 g_error_free(error); | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
698 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
699 else |
8272 | 700 ret = status; |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
701 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
702 else |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
703 { |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
704 if (!g_spawn_command_line_async(command, &error)) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
705 { |
9777 | 706 tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), |
707 escaped, error->message); | |
8272 | 708 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
709 g_free(tmp); | |
710 g_error_free(error); | |
711 } | |
712 } | |
713 | |
9777 | 714 g_free(escaped); |
715 | |
8272 | 716 return ret; |
717 } | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
718 #endif /* _WIN32 */ |
8272 | 719 |
7136 | 720 static void * |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
721 gaim_gtk_notify_uri(const char *uri) |
7136 | 722 { |
723 #ifndef _WIN32 | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
724 char *escaped = g_shell_quote(uri); |
7136 | 725 char *command = NULL; |
8272 | 726 char *remote_command = NULL; |
7136 | 727 const char *web_browser; |
8272 | 728 int place; |
7136 | 729 |
730 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); | |
8272 | 731 place = gaim_prefs_get_int("/gaim/gtk/browsers/place"); |
7136 | 732 |
10060 | 733 /* if they are running gnome, use the gnome web browser */ |
10061 | 734 if (gaim_running_gnome() == TRUE) |
10060 | 735 { |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
736 command = g_strdup_printf("gnome-open %s", escaped); |
10061 | 737 } |
10060 | 738 else if (!strcmp(web_browser, "epiphany") || |
9405 | 739 !strcmp(web_browser, "galeon")) |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
740 { |
8272 | 741 if (place == GAIM_BROWSER_NEW_WINDOW) |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
742 command = g_strdup_printf("%s -w %s", web_browser, escaped); |
8272 | 743 else if (place == GAIM_BROWSER_NEW_TAB) |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
744 command = g_strdup_printf("%s -n %s", web_browser, escaped); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
745 else |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
746 command = g_strdup_printf("%s %s", web_browser, escaped); |
9405 | 747 } |
748 else if (!strcmp(web_browser, "gnome-open")) | |
749 { | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
750 command = g_strdup_printf("gnome-open %s", escaped); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
751 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
752 else if (!strcmp(web_browser, "kfmclient")) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
753 { |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
754 command = g_strdup_printf("kfmclient openURL %s", escaped); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
755 /* |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
756 * Does Konqueror have options to open in new tab |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
757 * and/or current window? |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
758 */ |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
759 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
760 else if (!strcmp(web_browser, "mozilla") || |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
761 !strcmp(web_browser, "mozilla-firebird") || |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
762 !strcmp(web_browser, "firefox")) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
763 { |
9399 | 764 char *args = ""; |
765 | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
766 command = g_strdup_printf("%s %s", web_browser, escaped); |
8272 | 767 |
9399 | 768 /* |
769 * Firefox 0.9 and higher require a "-a firefox" option when | |
770 * using -remote commands. This breaks older versions of | |
771 * mozilla. So we include this other handly little string | |
772 * when calling firefox. If the API for remote calls changes | |
773 * any more in firefox then firefox should probably be split | |
774 * apart from mozilla-firebird and mozilla... but this is good | |
775 * for now. | |
776 */ | |
777 if (!strcmp(web_browser, "firefox")) | |
778 args = "-a firefox"; | |
779 | |
8272 | 780 if (place == GAIM_BROWSER_NEW_WINDOW) |
9399 | 781 remote_command = g_strdup_printf("%s %s -remote " |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
782 "openURL(%s,new-window)", |
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
783 web_browser, args, escaped); |
8272 | 784 else if (place == GAIM_BROWSER_NEW_TAB) |
9399 | 785 remote_command = g_strdup_printf("%s %s -remote " |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
786 "openURL(%s,new-tab)", |
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
787 web_browser, args, escaped); |
8272 | 788 else if (place == GAIM_BROWSER_CURRENT) |
9399 | 789 remote_command = g_strdup_printf("%s %s -remote " |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
790 "openURL(%s)", |
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
791 web_browser, args, escaped); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
792 } |
9405 | 793 else if (!strcmp(web_browser, "netscape")) |
794 { | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
795 command = g_strdup_printf("netscape %s", escaped); |
9405 | 796 |
797 if (place == GAIM_BROWSER_NEW_WINDOW) | |
798 { | |
799 remote_command = g_strdup_printf("netscape -remote " | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
800 "openURL(%s,new-window)", |
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
801 escaped); |
9405 | 802 } |
803 else if (place == GAIM_BROWSER_CURRENT) | |
804 { | |
805 remote_command = g_strdup_printf("netscape -remote " | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
806 "openURL(%s)", escaped); |
9405 | 807 } |
808 } | |
809 else if (!strcmp(web_browser, "opera")) | |
810 { | |
811 if (place == GAIM_BROWSER_NEW_WINDOW) | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
812 command = g_strdup_printf("opera -newwindow %s", escaped); |
9405 | 813 else if (place == GAIM_BROWSER_NEW_TAB) |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
814 command = g_strdup_printf("opera -newpage %s", escaped); |
9405 | 815 else if (place == GAIM_BROWSER_CURRENT) |
816 { | |
817 remote_command = g_strdup_printf("opera -remote " | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
818 "openURL(%s)", escaped); |
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
819 command = g_strdup_printf("opera %s", escaped); |
9405 | 820 } |
821 else | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
822 command = g_strdup_printf("opera %s", escaped); |
9405 | 823 |
824 } | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
825 else if (!strcmp(web_browser, "custom")) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
826 { |
7136 | 827 const char *web_command; |
828 | |
829 web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command"); | |
830 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
831 if (web_command == NULL || *web_command == '\0') |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
832 { |
7136 | 833 gaim_notify_error(NULL, NULL, _("Unable to open URL"), |
834 _("The 'Manual' browser command has been " | |
835 "chosen, but no command has been set.")); | |
836 return NULL; | |
837 } | |
838 | |
839 if (strstr(web_command, "%s")) | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
840 command = gaim_strreplace(web_command, "%s", escaped); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
841 else |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
842 { |
7136 | 843 /* |
844 * There is no "%s" in the browser command. Assume the user | |
845 * wanted the URL tacked on to the end of the command. | |
846 */ | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
847 command = g_strdup_printf("%s %s", web_command, escaped); |
7136 | 848 } |
849 } | |
850 | |
12477
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
851 g_free(escaped); |
d90eae2387b5
[gaim-migrate @ 14788]
Richard Laager <rlaager@wiktel.com>
parents:
12257
diff
changeset
|
852 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
853 if (remote_command != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
854 { |
8272 | 855 /* try the remote command first */ |
856 if (uri_command(remote_command, TRUE) != 0) | |
857 uri_command(command, FALSE); | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
858 |
8272 | 859 g_free(remote_command); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
860 |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
861 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
862 else |
8272 | 863 uri_command(command, FALSE); |
7136 | 864 |
865 g_free(command); | |
866 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
867 #else /* !_WIN32 */ |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
868 wgaim_notify_uri(uri); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
869 #endif /* !_WIN32 */ |
7136 | 870 |
871 return NULL; | |
872 } | |
873 | |
5437 | 874 static GaimNotifyUiOps ops = |
875 { | |
876 gaim_gtk_notify_message, | |
877 gaim_gtk_notify_email, | |
878 gaim_gtk_notify_emails, | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
879 gaim_gtk_notify_formatted, |
10439 | 880 gaim_gtk_notify_searchresults, |
11359 | 881 gaim_gtk_notify_searchresults_new_rows, |
9797 | 882 gaim_gtk_notify_userinfo, |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
883 gaim_gtk_notify_uri, |
5437 | 884 gaim_gtk_close_notify |
885 }; | |
886 | |
887 GaimNotifyUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7007
diff
changeset
|
888 gaim_gtk_notify_get_ui_ops(void) |
5437 | 889 { |
890 return &ops; | |
891 } |