Mercurial > pidgin
annotate src/gtknotify.c @ 10497:e6b87f7e8988
[gaim-migrate @ 11789]
Use the unified formatting pref for gtkimhtml notification windows
(e.g. AIM get info results)
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 09 Jan 2005 20:05:08 +0000 |
| parents | 911530134bf8 |
| children | 776586d647e3 |
| 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 | |
| 57 } GaimNotifySearchResultsData; | |
| 58 | |
| 59 enum | |
| 60 { | |
| 61 COLUMN_ICON, | |
| 62 COLUMN_SCREENNAME, | |
| 63 NUM_COLUMNS | |
| 64 }; | |
| 65 | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
66 static void *gaim_gtk_notify_emails(size_t count, gboolean detailed, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
67 const char **subjects, |
|
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
68 const char **froms, const char **tos, |
|
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
69 const char **urls, GCallback cb, |
|
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
70 void *user_data); |
|
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
71 |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
72 static void |
|
6354
76af8c066f8c
[gaim-migrate @ 6853]
Christian Hammond <chipx86@chipx86.com>
parents:
6106
diff
changeset
|
73 message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
| 6104 | 74 { |
| 6357 | 75 gaim_notify_close(GAIM_NOTIFY_MESSAGE, widget); |
| 6104 | 76 } |
| 77 | |
| 78 static void | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
79 email_response_cb(GtkDialog *dialog, gint id, GaimNotifyMailData *data) |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
80 { |
| 10260 | 81 if (id == GTK_RESPONSE_YES) |
|
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
82 gaim_notify_uri(NULL, data->url); |
|
5519
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 gaim_notify_close(GAIM_NOTIFY_EMAILS, data); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
85 } |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
86 |
|
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
87 static void |
|
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
88 formatted_close_cb(GtkWidget *win, GdkEvent *event, void *user_data) |
|
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 gaim_notify_close(GAIM_NOTIFY_FORMATTED, win); |
|
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
91 } |
|
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
92 |
| 10439 | 93 static void |
| 94 searchresults_close_cb(GaimNotifySearchResultsData *data, GdkEvent *event, void *user_data) | |
| 95 { | |
| 96 gaim_notify_close(GAIM_NOTIFY_SEARCHRESULTS, data); | |
| 97 } | |
| 98 | |
| 99 static void | |
| 100 add_buddy_helper_cb(GtkWidget *widget, GaimNotifySearchResultsData *data) | |
| 101 { | |
| 102 GtkTreeSelection *selection; | |
| 103 GtkTreeModel *model; | |
| 104 GtkTreeIter iter; | |
| 105 gchar *buddy; | |
| 106 | |
| 107 g_return_if_fail(data != NULL); | |
| 108 | |
| 109 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->treeview)); | |
| 110 | |
| 111 if (gtk_tree_selection_get_selected(selection, &model, &iter)) | |
| 112 { | |
| 113 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
| 114 COLUMN_SCREENNAME, &buddy, -1); | |
| 115 gaim_blist_request_add_buddy(data->account, buddy, NULL, NULL); | |
| 116 g_free(buddy); | |
| 117 } | |
| 118 } | |
| 119 | |
| 5437 | 120 static void * |
| 121 gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title, | |
| 122 const char *primary, const char *secondary, | |
| 123 GCallback cb, void *user_data) | |
| 124 { | |
| 125 GtkWidget *dialog; | |
| 126 GtkWidget *hbox; | |
| 127 GtkWidget *label; | |
| 128 GtkWidget *img = NULL; | |
| 129 char label_text[2048]; | |
| 130 const char *icon_name = NULL; | |
| 131 | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
132 switch (type) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
133 { |
| 5437 | 134 case GAIM_NOTIFY_MSG_ERROR: |
| 135 icon_name = GAIM_STOCK_DIALOG_ERROR; | |
| 136 break; | |
| 137 | |
| 138 case GAIM_NOTIFY_MSG_WARNING: | |
| 139 icon_name = GAIM_STOCK_DIALOG_WARNING; | |
| 140 break; | |
| 141 | |
| 142 case GAIM_NOTIFY_MSG_INFO: | |
| 143 icon_name = GAIM_STOCK_DIALOG_INFO; | |
| 144 break; | |
| 145 | |
| 146 default: | |
| 147 icon_name = NULL; | |
| 148 break; | |
| 149 } | |
| 150 | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
151 if (icon_name != NULL) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
152 { |
| 5437 | 153 img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_DIALOG); |
| 154 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
| 155 } | |
| 156 | |
| 7678 | 157 dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, |
| 10260 | 158 NULL, 0, GTK_STOCK_CLOSE, |
| 159 GTK_RESPONSE_CLOSE, NULL); | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
160 |
|
8523
013d256e8ded
[gaim-migrate @ 9262]
Christian Hammond <chipx86@chipx86.com>
parents:
8356
diff
changeset
|
161 gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog"); |
|
013d256e8ded
[gaim-migrate @ 9262]
Christian Hammond <chipx86@chipx86.com>
parents:
8356
diff
changeset
|
162 |
| 5437 | 163 g_signal_connect(G_OBJECT(dialog), "response", |
| 6104 | 164 G_CALLBACK(message_response_cb), dialog); |
| 5437 | 165 |
| 166 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); | |
| 167 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
| 168 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 169 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); | |
| 170 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); | |
| 171 | |
| 172 hbox = gtk_hbox_new(FALSE, 12); | |
| 173 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | |
| 174 | |
| 175 if (img != NULL) | |
| 176 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
| 177 | |
| 178 g_snprintf(label_text, sizeof(label_text), | |
| 179 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", | |
| 180 primary, (secondary ? secondary : "")); | |
| 181 | |
| 182 label = gtk_label_new(NULL); | |
| 183 | |
| 184 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
| 185 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
| 186 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 187 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 188 | |
| 189 gtk_widget_show_all(dialog); | |
| 190 | |
| 191 return dialog; | |
| 192 } | |
| 193 | |
| 194 static void * | |
| 195 gaim_gtk_notify_email(const char *subject, const char *from, | |
| 196 const char *to, const char *url, | |
| 197 GCallback cb, void *user_data) | |
| 198 { | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
199 return gaim_gtk_notify_emails(1, TRUE, |
|
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
200 (subject == NULL ? NULL : &subject), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
201 (from == NULL ? NULL : &from), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
202 (to == NULL ? NULL : &to), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
203 (url == NULL ? NULL : &url), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
204 cb, user_data); |
| 5437 | 205 } |
| 206 | |
| 207 static void * | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
208 gaim_gtk_notify_emails(size_t count, gboolean detailed, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
209 const char **subjects, const char **froms, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
210 const char **tos, const char **urls, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
211 GCallback cb, void *user_data) |
| 5437 | 212 { |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
213 GaimNotifyMailData *data; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
214 GtkWidget *dialog; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
215 GtkWidget *vbox; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
216 GtkWidget *hbox; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
217 GtkWidget *label; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
218 GtkWidget *img; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
219 char *detail_text; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
220 char *label_text; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
221 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
222 data = g_new0(GaimNotifyMailData, 1); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
223 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
224 data->url = g_strdup(urls[0]); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
225 |
| 10260 | 226 /* Create the dialog */ |
| 227 dialog = gtk_dialog_new_with_buttons("New Mail", NULL, 0, | |
| 228 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
| 229 NULL); | |
| 230 data->dialog = dialog; | |
|
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
231 |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
232 if (urls != NULL) |
| 10260 | 233 gtk_dialog_add_button(GTK_DIALOG(dialog), |
| 234 GAIM_STOCK_OPEN_MAIL, GTK_RESPONSE_YES); | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
235 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
236 g_signal_connect(G_OBJECT(dialog), "response", |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
237 G_CALLBACK(email_response_cb), data); |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
238 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
239 /* Setup the dialog */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
240 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
241 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
242 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
243 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
244 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); |
|
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 main horizontal box */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
247 hbox = gtk_hbox_new(FALSE, 12); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
248 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
249 |
| 10260 | 250 /* Dialog icon */ |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
251 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_INFO, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
252 GTK_ICON_SIZE_DIALOG); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
253 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
254 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
255 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
256 /* Vertical box */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
257 vbox = gtk_vbox_new(FALSE, 12); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
258 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
259 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
260 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
261 /* Descriptive label */ |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
262 detail_text = g_strdup_printf(ngettext("%s has %d new message.", |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
263 "%s has %d new messages.", |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
264 (int)count), |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
265 *tos, (int)count); |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
266 |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
267 if (count == 1) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
268 { |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
269 char *from_text = NULL, *subject_text = NULL; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
270 |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
271 if (froms != NULL) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
272 { |
| 8920 | 273 char *from_enc; |
| 274 from_enc = g_markup_escape_text(*froms, -1); | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
275 from_text = g_strdup_printf( |
| 8920 | 276 _("<span weight=\"bold\">From:</span> %s\n"), from_enc); |
| 277 g_free(from_enc); | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
278 } |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
279 |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
280 if (subjects != NULL) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
281 { |
| 8920 | 282 char *subject_enc; |
| 283 subject_enc = g_markup_escape_text(*subjects, -1); | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
284 subject_text = g_strdup_printf( |
| 8920 | 285 _("<span weight=\"bold\">Subject:</span> %s\n"), subject_enc); |
| 286 g_free(subject_enc); | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
287 } |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
288 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
289 label_text = g_strdup_printf( |
| 5543 | 290 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
| 291 "\n\n%s%s%s%s"), | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
292 detail_text, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
293 (from_text == NULL && subject_text == NULL ? "" : "\n\n"), |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
294 (from_text == NULL ? "" : from_text), |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
295 (subject_text == NULL ? "" : subject_text)); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
296 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
297 if (from_text != NULL) |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
298 g_free(from_text); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
299 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
300 if (subject_text != NULL) |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
301 g_free(subject_text); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
302 } |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
303 else |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
304 { |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
305 label_text = g_strdup_printf( |
| 5543 | 306 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
| 307 "\n\n%s"), detail_text); | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
308 } |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
309 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
310 g_free(detail_text); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
311 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
312 label = gtk_label_new(NULL); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
313 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
314 gtk_label_set_markup(GTK_LABEL(label), label_text); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
315 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
316 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
317 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
|
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 g_free(label_text); |
|
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 /* Show everything. */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
322 gtk_widget_show_all(dialog); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
323 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
324 return data; |
| 5437 | 325 } |
| 326 | |
|
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
327 static gboolean |
|
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
328 formatted_input_cb(GtkWidget *dialog, GdkEventKey *event, gpointer data) |
| 7455 | 329 { |
|
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
330 if (event->keyval == GDK_Escape) |
|
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
331 { |
|
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
332 gtk_widget_destroy(dialog); |
|
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
333 |
| 7455 | 334 return TRUE; |
| 335 } | |
|
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
336 |
| 7455 | 337 return FALSE; |
| 338 } | |
| 339 | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
340 static void * |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
341 gaim_gtk_notify_formatted(const char *title, const char *primary, |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
342 const char *secondary, const char *text, |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
343 GCallback cb, void *user_data) |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
344 { |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
345 GtkWidget *window; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
346 GtkWidget *vbox; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
347 GtkWidget *label; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
348 GtkWidget *button; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
349 GtkWidget *imhtml; |
| 10181 | 350 GtkWidget *frame; |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
351 int options = 0; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
352 char label_text[2048]; |
| 8272 | 353 char *linked_text; |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
354 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
355 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 8345 | 356 gtk_window_set_title(GTK_WINDOW(window), title); |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
357 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
358 gtk_container_set_border_width(GTK_CONTAINER(window), 12); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
359 |
|
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
360 g_signal_connect(G_OBJECT(window), "delete_event", |
|
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
361 G_CALLBACK(formatted_close_cb), NULL); |
|
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
362 |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
363 /* Setup the main vbox */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
364 vbox = gtk_vbox_new(FALSE, 12); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
365 gtk_container_add(GTK_CONTAINER(window), vbox); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
366 gtk_widget_show(vbox); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
367 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
368 /* Setup the descriptive label */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
369 g_snprintf(label_text, sizeof(label_text), |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
370 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
371 primary, |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
372 (secondary ? "\n" : ""), |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
373 (secondary ? secondary : "")); |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
374 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
375 label = gtk_label_new(NULL); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
376 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
377 gtk_label_set_markup(GTK_LABEL(label), label_text); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
378 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
379 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
380 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
381 gtk_widget_show(label); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
382 |
| 10181 | 383 /* Add the imhtml */ |
| 384 frame = gaim_gtk_create_imhtml(FALSE, &imhtml, NULL); | |
| 9005 | 385 gtk_widget_set_name(imhtml, "gaim_gtknotify_imhtml"); |
| 10181 | 386 gtk_widget_set_size_request(imhtml, 300, 250); |
| 387 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
| 388 gtk_widget_show(frame); | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
389 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
390 /* Add the Close button. */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
391 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
392 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
393 gtk_widget_show(button); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
394 |
| 6872 | 395 g_signal_connect_swapped(G_OBJECT(button), "clicked", |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
396 G_CALLBACK(formatted_close_cb), window); |
| 7455 | 397 g_signal_connect(G_OBJECT(window), "key_press_event", |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
398 G_CALLBACK(formatted_input_cb), NULL); |
| 7455 | 399 |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
400 /* Add the text to the gtkimhtml */ |
| 10497 | 401 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_formatting")) |
| 402 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
|
403 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
404 options ^= GTK_IMHTML_NO_COMMENTS; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
405 options ^= GTK_IMHTML_NO_TITLE; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
406 options ^= GTK_IMHTML_NO_NEWLINE; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
407 options ^= GTK_IMHTML_NO_SCROLL; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
408 |
| 8882 | 409 /* Make sure URLs are clickable */ |
| 410 linked_text = gaim_markup_linkify(text); | |
| 10181 | 411 gtk_imhtml_append_text(GTK_IMHTML(imhtml), linked_text, options); |
| 8882 | 412 g_free(linked_text); |
| 7078 | 413 |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
414 /* Show the window */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
415 gtk_widget_show(window); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
416 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
417 return window; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
418 } |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
419 |
| 9797 | 420 static void * |
| 10439 | 421 gaim_gtk_notify_searchresults(GaimConnection *gc, const char *title, |
| 422 const char *primary, const char *secondary, | |
| 423 const char **results, GCallback cb, | |
| 424 void *user_data) | |
| 425 { | |
| 426 GtkWidget *window; | |
| 427 GtkWidget *vbox; | |
| 428 GtkWidget *button_area; | |
| 429 GtkWidget *label; | |
| 430 GtkWidget *close_button; | |
| 431 GtkWidget *add_button; | |
| 432 GtkWidget *sw; | |
| 433 GtkWidget *treeview; | |
| 434 GdkPixbuf *icon, *scaled; | |
| 435 GaimNotifySearchResultsData *data; | |
| 436 GtkListStore *model; | |
| 437 GtkCellRenderer *renderer; | |
| 438 GtkTreeIter iter; | |
| 439 int i; | |
| 440 char *label_text; | |
| 441 | |
| 442 data = g_malloc(sizeof(GaimNotifySearchResultsData)); | |
| 443 | |
| 444 /* Create the window */ | |
| 445 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 446 gtk_window_set_title(GTK_WINDOW(window), (title ? title :_("Search Results"))); | |
| 447 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
| 448 gtk_container_set_border_width(GTK_CONTAINER(window), 12); | |
| 449 | |
| 450 g_signal_connect_swapped(G_OBJECT(window), "delete_event", | |
| 451 G_CALLBACK(searchresults_close_cb), data); | |
| 452 | |
| 453 /* Setup the main vbox */ | |
| 454 vbox = gtk_vbox_new(FALSE, 12); | |
| 455 gtk_container_add(GTK_CONTAINER(window), vbox); | |
| 456 gtk_widget_show(vbox); | |
| 457 | |
| 458 /* Setup the descriptive label */ | |
| 459 label_text = g_strdup_printf( | |
| 460 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", | |
| 461 (primary ? primary : ""), | |
| 462 (primary && secondary ? "\n" : ""), | |
| 463 (secondary ? secondary : "")); | |
| 464 label = gtk_label_new(NULL); | |
| 465 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
| 466 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
| 467 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 468 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 469 gtk_widget_show(label); | |
| 470 g_free(label_text); | |
| 471 | |
| 472 /* Setup the list model */ | |
| 473 model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING); | |
| 474 | |
| 475 /* Setup the scrolled window containing the treeview */ | |
| 476 sw = gtk_scrolled_window_new(NULL, NULL); | |
| 477 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 478 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
| 479 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
| 480 GTK_SHADOW_IN); | |
| 481 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
| 482 gtk_widget_show(sw); | |
| 483 | |
| 484 /* Setup the treeview */ | |
| 485 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
| 486 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
| 487 gtk_widget_set_size_request(treeview, 250, 150); | |
| 488 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), | |
| 489 GTK_SELECTION_SINGLE); | |
| 490 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
| 491 gtk_container_add(GTK_CONTAINER(sw), treeview); | |
| 492 gtk_widget_show(treeview); | |
| 493 | |
| 494 /* icon column */ | |
| 495 renderer = gtk_cell_renderer_pixbuf_new (); | |
| 496 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | |
| 497 -1, "Icon", renderer, | |
| 498 "pixbuf", COLUMN_ICON, | |
| 499 NULL); | |
| 500 | |
| 501 /* screenname column */ | |
| 502 renderer = gtk_cell_renderer_text_new(); | |
| 503 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | |
| 504 -1, "Screenname", renderer, | |
| 505 "text", COLUMN_SCREENNAME, | |
| 506 NULL); | |
| 507 | |
| 508 /* Setup the button area */ | |
| 509 button_area = gtk_hbutton_box_new(); | |
| 510 gtk_box_pack_start(GTK_BOX(vbox), button_area, FALSE, FALSE, 0); | |
| 511 gtk_button_box_set_layout(GTK_BUTTON_BOX(button_area), GTK_BUTTONBOX_END); | |
| 512 gtk_box_set_spacing(GTK_BOX(button_area), 12); | |
| 513 gtk_widget_show(button_area); | |
| 514 | |
| 515 /* Add the Add button */ | |
| 516 add_button = gtk_button_new_from_stock(GTK_STOCK_ADD); | |
| 517 gtk_box_pack_start(GTK_BOX(button_area), add_button, FALSE, FALSE, 0); | |
| 518 gtk_widget_show(add_button); | |
| 519 | |
| 520 /* Add the Close button */ | |
| 521 close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
| 522 gtk_box_pack_start(GTK_BOX(button_area), close_button, FALSE, FALSE, 0); | |
| 523 gtk_widget_show(close_button); | |
| 524 | |
| 525 /* Add the buddies to the tree view */ | |
| 526 icon = create_prpl_icon(gc->account); | |
| 527 scaled = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); | |
| 528 | |
| 529 for (i = 0; results[i] != NULL; i++) | |
| 530 { | |
| 531 gtk_list_store_append(model, &iter); | |
| 532 gtk_list_store_set(model, &iter, | |
| 533 COLUMN_ICON, scaled, | |
| 534 COLUMN_SCREENNAME, results[i], | |
| 535 -1); | |
| 536 } | |
| 537 | |
| 538 data->account = gc->account; | |
| 539 data->model = model; | |
| 540 data->treeview = treeview; | |
| 541 data->window = window; | |
| 542 | |
| 543 /* Connect Signals */ | |
| 544 g_signal_connect(G_OBJECT(add_button), "clicked", | |
| 545 G_CALLBACK(add_buddy_helper_cb), data); | |
| 546 g_signal_connect_swapped(G_OBJECT(close_button), "clicked", | |
| 547 G_CALLBACK(searchresults_close_cb), data); | |
| 548 | |
| 549 /* Show the window */ | |
| 550 gtk_widget_show(window); | |
| 551 return data; | |
| 552 } | |
| 553 | |
| 554 static void * | |
| 9797 | 555 gaim_gtk_notify_userinfo(GaimConnection *gc, const char *who, |
| 556 const char *title, const char *primary, | |
| 557 const char *secondary, const char *text, | |
| 558 GCallback cb, void *user_data) | |
| 559 { | |
| 9800 | 560 return gaim_gtk_notify_formatted(title, primary, secondary, |
| 561 text, cb, user_data); | |
| 9797 | 562 } |
| 563 | |
| 5437 | 564 static void |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
565 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle) |
| 5437 | 566 { |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
567 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
568 { |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
569 GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
570 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
571 gtk_widget_destroy(data->dialog); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
572 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
573 g_free(data->url); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
574 g_free(data); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
575 } |
| 10439 | 576 else if (type == GAIM_NOTIFY_SEARCHRESULTS) |
| 577 { | |
| 578 GaimNotifySearchResultsData *data = (GaimNotifySearchResultsData *)ui_handle; | |
| 579 | |
| 580 gtk_widget_destroy(data->window); | |
| 581 | |
| 582 g_free(data); | |
| 583 } | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
584 else |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
585 gtk_widget_destroy(GTK_WIDGET(ui_handle)); |
| 5437 | 586 } |
| 587 | |
| 8272 | 588 #ifndef _WIN32 |
| 589 static gint | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
590 uri_command(const char *command, gboolean sync) |
| 8272 | 591 { |
| 9777 | 592 gchar *escaped, *tmp; |
| 8272 | 593 GError *error = NULL; |
| 594 gint ret = 0; | |
| 595 | |
| 9777 | 596 escaped = gaim_escape_html(command); |
| 597 gaim_debug_misc("gtknotify", "Executing %s\n", escaped); | |
| 8278 | 598 |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
599 if (!gaim_program_is_valid(command)) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
600 { |
| 9777 | 601 tmp = g_strdup_printf(_("The browser command <b>%s</b> is invalid."), |
| 602 escaped ? escaped : "(none)"); | |
| 8272 | 603 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
| 604 g_free(tmp); | |
| 605 | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
606 } |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
607 else if (sync) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
608 { |
| 8272 | 609 gint status; |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
610 |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
611 if (!g_spawn_command_line_sync(command, NULL, NULL, &status, &error)) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
612 { |
| 9777 | 613 tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), |
| 614 escaped, error->message); | |
| 8272 | 615 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
| 616 g_free(tmp); | |
| 617 g_error_free(error); | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
618 } |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
619 else |
| 8272 | 620 ret = status; |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
621 } |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
622 else |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
623 { |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
624 if (!g_spawn_command_line_async(command, &error)) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
625 { |
| 9777 | 626 tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), |
| 627 escaped, error->message); | |
| 8272 | 628 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
| 629 g_free(tmp); | |
| 630 g_error_free(error); | |
| 631 } | |
| 632 } | |
| 633 | |
| 9777 | 634 g_free(escaped); |
| 635 | |
| 8272 | 636 return ret; |
| 637 } | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
638 #endif /* _WIN32 */ |
| 8272 | 639 |
| 7136 | 640 static void * |
|
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
641 gaim_gtk_notify_uri(const char *uri) |
| 7136 | 642 { |
| 643 #ifndef _WIN32 | |
| 644 char *command = NULL; | |
| 8272 | 645 char *remote_command = NULL; |
| 7136 | 646 const char *web_browser; |
| 8272 | 647 int place; |
| 7136 | 648 |
| 649 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); | |
| 8272 | 650 place = gaim_prefs_get_int("/gaim/gtk/browsers/place"); |
| 7136 | 651 |
| 10060 | 652 /* if they are running gnome, use the gnome web browser */ |
| 10061 | 653 if (gaim_running_gnome() == TRUE) |
| 10060 | 654 { |
| 655 command = g_strdup_printf("gnome-open \"%s\"", uri); | |
| 10061 | 656 } |
| 10060 | 657 else if (!strcmp(web_browser, "epiphany") || |
| 9405 | 658 !strcmp(web_browser, "galeon")) |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
659 { |
| 8272 | 660 if (place == GAIM_BROWSER_NEW_WINDOW) |
| 9405 | 661 command = g_strdup_printf("%s -w \"%s\"", web_browser, uri); |
| 8272 | 662 else if (place == GAIM_BROWSER_NEW_TAB) |
| 9405 | 663 command = g_strdup_printf("%s -n \"%s\"", web_browser, uri); |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
664 else |
| 9405 | 665 command = g_strdup_printf("%s \"%s\"", web_browser, uri); |
| 666 } | |
| 667 else if (!strcmp(web_browser, "gnome-open")) | |
| 668 { | |
| 669 command = g_strdup_printf("gnome-open \"%s\"", uri); | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
670 } |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
671 else if (!strcmp(web_browser, "kfmclient")) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
672 { |
| 7136 | 673 command = g_strdup_printf("kfmclient openURL \"%s\"", uri); |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
674 /* |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
675 * Does Konqueror have options to open in new tab |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
676 * and/or current window? |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
677 */ |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
678 } |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
679 else if (!strcmp(web_browser, "mozilla") || |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
680 !strcmp(web_browser, "mozilla-firebird") || |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
681 !strcmp(web_browser, "firefox")) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
682 { |
| 9399 | 683 char *args = ""; |
| 684 | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
685 command = g_strdup_printf("%s \"%s\"", web_browser, uri); |
| 8272 | 686 |
| 9399 | 687 /* |
| 688 * Firefox 0.9 and higher require a "-a firefox" option when | |
| 689 * using -remote commands. This breaks older versions of | |
| 690 * mozilla. So we include this other handly little string | |
| 691 * when calling firefox. If the API for remote calls changes | |
| 692 * any more in firefox then firefox should probably be split | |
| 693 * apart from mozilla-firebird and mozilla... but this is good | |
| 694 * for now. | |
| 695 */ | |
| 696 if (!strcmp(web_browser, "firefox")) | |
| 697 args = "-a firefox"; | |
| 698 | |
| 8272 | 699 if (place == GAIM_BROWSER_NEW_WINDOW) |
| 9399 | 700 remote_command = g_strdup_printf("%s %s -remote " |
| 9777 | 701 "\"openURL(%s,new-window)\"", |
| 9399 | 702 web_browser, args, uri); |
| 8272 | 703 else if (place == GAIM_BROWSER_NEW_TAB) |
| 9399 | 704 remote_command = g_strdup_printf("%s %s -remote " |
| 9777 | 705 "\"openURL(%s,new-tab)\"", |
| 9399 | 706 web_browser, args, uri); |
| 8272 | 707 else if (place == GAIM_BROWSER_CURRENT) |
| 9399 | 708 remote_command = g_strdup_printf("%s %s -remote " |
| 9777 | 709 "\"openURL(%s)\"", |
| 9399 | 710 web_browser, args, uri); |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
711 } |
| 9405 | 712 else if (!strcmp(web_browser, "netscape")) |
| 713 { | |
| 714 command = g_strdup_printf("netscape \"%s\"", uri); | |
| 715 | |
| 716 if (place == GAIM_BROWSER_NEW_WINDOW) | |
| 717 { | |
| 718 remote_command = g_strdup_printf("netscape -remote " | |
| 9777 | 719 "\"openURL(%s,new-window)\"", |
| 9405 | 720 uri); |
| 721 } | |
| 722 else if (place == GAIM_BROWSER_CURRENT) | |
| 723 { | |
| 724 remote_command = g_strdup_printf("netscape -remote " | |
| 9777 | 725 "\"openURL(%s)\"", uri); |
| 9405 | 726 } |
| 727 } | |
| 728 else if (!strcmp(web_browser, "opera")) | |
| 729 { | |
| 730 if (place == GAIM_BROWSER_NEW_WINDOW) | |
| 731 command = g_strdup_printf("opera -newwindow \"%s\"", uri); | |
| 732 else if (place == GAIM_BROWSER_NEW_TAB) | |
| 733 command = g_strdup_printf("opera -newpage \"%s\"", uri); | |
| 734 else if (place == GAIM_BROWSER_CURRENT) | |
| 735 { | |
| 736 remote_command = g_strdup_printf("opera -remote " | |
| 9777 | 737 "\"openURL(%s)\"", uri); |
| 9405 | 738 command = g_strdup_printf("opera \"%s\"", uri); |
| 739 } | |
| 740 else | |
| 741 command = g_strdup_printf("opera \"%s\"", uri); | |
| 742 | |
| 743 } | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
744 else if (!strcmp(web_browser, "custom")) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
745 { |
| 7136 | 746 const char *web_command; |
| 747 | |
| 748 web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command"); | |
| 749 | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
750 if (web_command == NULL || *web_command == '\0') |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
751 { |
| 7136 | 752 gaim_notify_error(NULL, NULL, _("Unable to open URL"), |
| 753 _("The 'Manual' browser command has been " | |
| 754 "chosen, but no command has been set.")); | |
| 755 return NULL; | |
| 756 } | |
| 757 | |
| 758 if (strstr(web_command, "%s")) | |
| 759 command = gaim_strreplace(web_command, "%s", uri); | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
760 else |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
761 { |
| 7136 | 762 /* |
| 763 * There is no "%s" in the browser command. Assume the user | |
| 764 * wanted the URL tacked on to the end of the command. | |
| 765 */ | |
| 766 command = g_strdup_printf("%s %s", web_command, uri); | |
| 767 } | |
| 768 } | |
| 769 | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
770 if (remote_command != NULL) |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
771 { |
| 8272 | 772 /* try the remote command first */ |
| 773 if (uri_command(remote_command, TRUE) != 0) | |
| 774 uri_command(command, FALSE); | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
775 |
| 8272 | 776 g_free(remote_command); |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
777 |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
778 } |
|
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
779 else |
| 8272 | 780 uri_command(command, FALSE); |
| 7136 | 781 |
| 782 g_free(command); | |
| 783 | |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
784 #else /* !_WIN32 */ |
|
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
785 wgaim_notify_uri(uri); |
|
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
786 #endif /* !_WIN32 */ |
| 7136 | 787 |
| 788 return NULL; | |
| 789 } | |
| 790 | |
| 5437 | 791 static GaimNotifyUiOps ops = |
| 792 { | |
| 793 gaim_gtk_notify_message, | |
| 794 gaim_gtk_notify_email, | |
| 795 gaim_gtk_notify_emails, | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
796 gaim_gtk_notify_formatted, |
| 10439 | 797 gaim_gtk_notify_searchresults, |
| 9797 | 798 gaim_gtk_notify_userinfo, |
|
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
799 gaim_gtk_notify_uri, |
| 5437 | 800 gaim_gtk_close_notify |
| 801 }; | |
| 802 | |
| 803 GaimNotifyUiOps * | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7007
diff
changeset
|
804 gaim_gtk_notify_get_ui_ops(void) |
| 5437 | 805 { |
| 806 return &ops; | |
| 807 } |
