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