comparison src/dialogs.c @ 7062:86ed8b2aa665

[gaim-migrate @ 7626] g_show_info_text() is gone! Mwahahaha. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 30 Sep 2003 06:43:17 +0000
parents 9946001989a3
children 7fdac700deb1
comparison
equal deleted inserted replaced
7061:80fd120e180b 7062:86ed8b2aa665
118 char *username; 118 char *username;
119 gboolean block; 119 gboolean block;
120 GaimConnection *gc; 120 GaimConnection *gc;
121 121
122 } GaimGtkBlockData; 122 } GaimGtkBlockData;
123
124 static GSList *info_dlgs = NULL;
125
126 static struct info_dlg *find_info_dlg(GaimConnection *gc, const char *who)
127 {
128 GSList *i = info_dlgs;
129 while (i) {
130 struct info_dlg *d = i->data;
131 i = i->next;
132 if (d->gc != gc)
133 continue;
134 if (d->who == NULL)
135 continue;
136 if (!who)
137 continue;
138 if (!gaim_utf8_strcasecmp(normalize(who), d->who))
139 return d;
140 }
141 return NULL;
142 }
143 123
144 struct set_info_dlg { 124 struct set_info_dlg {
145 GtkWidget *window; 125 GtkWidget *window;
146 GtkWidget *menu; 126 GtkWidget *menu;
147 GaimAccount *account; 127 GaimAccount *account;
1215 g_signal_connect(G_OBJECT(b->cancel), "clicked", G_CALLBACK(destroy_dialog), b->window); 1195 g_signal_connect(G_OBJECT(b->cancel), "clicked", G_CALLBACK(destroy_dialog), b->window);
1216 1196
1217 gtk_widget_show_all(b->window); 1197 gtk_widget_show_all(b->window);
1218 } 1198 }
1219 1199
1220 /*------------------------------------------------------------------------*/
1221 /* The dialog for the info requests */
1222 /*------------------------------------------------------------------------*/
1223
1224 static void info_dlg_free(GtkWidget *b, struct info_dlg *d)
1225 {
1226 if (g_slist_find(info_dlgs, d))
1227 info_dlgs = g_slist_remove(info_dlgs, d);
1228 g_free(d->who);
1229 g_free(d);
1230 }
1231
1232 /* if away is 0, show regardless and try to get away message
1233 * 1, don't show if regular info isn't shown
1234 * 2, show regardless but don't try to get away message
1235 *
1236 * i wish this were my client. if i were i wouldn't have to deal with this shit.
1237 */
1238 void g_show_info_text(GaimConnection *gc, const char *who, int away, const char *info, ...)
1239 {
1240 GtkWidget *ok;
1241 GtkWidget *label;
1242 GtkWidget *text;
1243 GtkWidget *bbox;
1244 GtkWidget *sw;
1245 gint options = 0;
1246 gchar *linkifyinated;
1247 va_list ap;
1248 char *more_info;
1249
1250 struct info_dlg *b = find_info_dlg(gc, who);
1251 if (!b && (away == 1))
1252 return;
1253 if (!b) {
1254 b = g_new0(struct info_dlg, 1);
1255 b->gc = gc;
1256 b->who = who ? g_strdup(normalize(who)) : NULL;
1257 info_dlgs = g_slist_append(info_dlgs, b);
1258
1259 GAIM_DIALOG(b->window);
1260 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim");
1261 gtk_window_set_role(GTK_WINDOW(b->window), "get_info");
1262 gtk_container_set_border_width(GTK_CONTAINER(b->window), 5);
1263 gtk_widget_realize(GTK_WIDGET(b->window));
1264 g_signal_connect(G_OBJECT(b->window), "destroy", G_CALLBACK(info_dlg_free), b);
1265
1266 bbox = gtk_vbox_new(FALSE, 5);
1267 gtk_container_add(GTK_CONTAINER(b->window), bbox);
1268
1269 label = gtk_label_new(_("Below are the results of your search: "));
1270 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
1271
1272 sw = gtk_scrolled_window_new(NULL, NULL);
1273 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1274 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
1275 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 0);
1276
1277 text = gtk_imhtml_new(NULL, NULL);
1278 b->text = text;
1279 gtk_container_add(GTK_CONTAINER(sw), text);
1280 gtk_widget_set_size_request(sw, 300, 250);
1281 gaim_setup_imhtml(text);
1282
1283 ok = gaim_pixbuf_button_from_stock(_("OK"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL);
1284 g_signal_connect_swapped(G_OBJECT(ok), "clicked", G_CALLBACK(gtk_widget_destroy),
1285 G_OBJECT(b->window));
1286 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
1287
1288 gtk_widget_show_all(b->window);
1289 }
1290
1291 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors"))
1292 options ^= GTK_IMHTML_NO_COLOURS;
1293
1294 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_fonts"))
1295 options ^= GTK_IMHTML_NO_FONTS;
1296
1297 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes"))
1298 options ^= GTK_IMHTML_NO_SIZES;
1299
1300 options ^= GTK_IMHTML_NO_COMMENTS;
1301 options ^= GTK_IMHTML_NO_TITLE;
1302 options ^= GTK_IMHTML_NO_NEWLINE;
1303 options ^= GTK_IMHTML_NO_SCROLL;
1304
1305 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_urls_as_links")) {
1306 linkifyinated = linkify_text(info);
1307 gtk_imhtml_append_text(GTK_IMHTML(b->text), linkifyinated, options);
1308 g_free(linkifyinated);
1309 } else
1310 gtk_imhtml_append_text(GTK_IMHTML(b->text), info, options);
1311
1312 va_start(ap, info);
1313 while ((more_info = va_arg(ap, char *)) != NULL) {
1314 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_urls_as_links")) {
1315 linkifyinated = linkify_text(more_info);
1316 gtk_imhtml_append_text(GTK_IMHTML(b->text), linkifyinated, options);
1317 g_free(linkifyinated);
1318 } else
1319 gtk_imhtml_append_text(GTK_IMHTML(b->text), more_info, options);
1320 }
1321 va_end(ap);
1322
1323 if (away)
1324 info_dlgs = g_slist_remove(info_dlgs, b);
1325 else
1326 serv_get_away(gc, who);
1327 }
1328
1329 1200
1330 /*------------------------------------------------------------------------*/ 1201 /*------------------------------------------------------------------------*/
1331 /* Functions Called To Add A Log */ 1202 /* Functions Called To Add A Log */
1332 /*------------------------------------------------------------------------*/ 1203 /*------------------------------------------------------------------------*/
1333 1204