comparison src/gtkconv.c @ 8290:84ec38c3efcc

[gaim-migrate @ 9014] Moved the Get User Info and Insert Link dialogs to the request API. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 19 Feb 2004 08:06:23 +0000
parents 1d86096ae0f4
children 6f549c1d0829
comparison
equal deleted inserted replaced
8289:e39ea2b4f6cd 8290:84ec38c3efcc
311 gtkconv->dialogs.image = NULL; 311 gtkconv->dialogs.image = NULL;
312 } 312 }
313 } 313 }
314 314
315 static void 315 static void
316 do_insert_link_cb(GaimConversation *conv, GaimRequestFields *fields)
317 {
318 GaimGtkConversation *gtkconv;
319 const char *url, *description;
320
321 gtkconv = GAIM_GTK_CONVERSATION(conv);
322
323 url = gaim_request_fields_get_string(fields, "url");
324 description = gaim_request_fields_get_string(fields, "description");
325
326 if (description == NULL)
327 description = url;
328
329 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), url, description);
330 gaim_gtk_advance_past(gtkconv, "<A HREF>", "</A>");
331
332 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link),
333 FALSE);
334
335 gtkconv->dialogs.link = NULL;
336 }
337
338 static void
339 cancel_link_cb(GaimConversation *conv, GaimRequestFields *fields)
340 {
341 GAIM_GTK_CONVERSATION(conv)->dialogs.link = NULL;
342 }
343
344 static void
345 show_link_dialog(GaimConversation *conv)
346 {
347 GaimGtkConversation *gtkconv;
348 GaimRequestFields *fields;
349 GaimRequestFieldGroup *group;
350 GaimRequestField *field;
351
352 gtkconv = GAIM_GTK_CONVERSATION(conv);
353
354 fields = gaim_request_fields_new();
355
356 group = gaim_request_field_group_new(NULL);
357 gaim_request_fields_add_group(fields, group);
358
359 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE);
360 gaim_request_field_set_required(field, TRUE);
361 gaim_request_field_group_add_field(group, field);
362
363 field = gaim_request_field_string_new("description", _("_Description"),
364 NULL, FALSE);
365 gaim_request_field_group_add_field(group, field);
366
367 gtkconv->dialogs.link =
368 gaim_request_fields(conv, _("Insert Link"),
369 NULL,
370 _("Please enter the URL and description of the "
371 "link that you want to insert. The description "
372 "is optional."),
373 fields,
374 _("_Insert"), G_CALLBACK(do_insert_link_cb),
375 _("Cancel"), G_CALLBACK(cancel_link_cb),
376 conv);
377 }
378
379 static void
380 close_link_dialog(GaimConversation *conv)
381 {
382 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
383
384 if (gtkconv->dialogs.link != NULL)
385 {
386 gaim_request_close(GAIM_REQUEST_FIELDS, gtkconv->dialogs.link);
387
388 gtkconv->dialogs.link = NULL;
389 }
390 }
391
392 static void
316 insert_link_cb(GtkWidget *w, GaimConversation *conv) 393 insert_link_cb(GtkWidget *w, GaimConversation *conv)
317 { 394 {
318 GaimGtkConversation *gtkconv; 395 GaimGtkConversation *gtkconv;
319 396
320 gtkconv = GAIM_GTK_CONVERSATION(conv); 397 gtkconv = GAIM_GTK_CONVERSATION(conv);
321 398
322 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link))) 399 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link)))
323 dialog_link_show(conv); 400 show_link_dialog(conv);
324 else 401 else
325 dialog_link_destroy(conv); 402 close_link_dialog(conv);
326 403
327 gtk_widget_grab_focus(gtkconv->entry); 404 gtk_widget_grab_focus(gtkconv->entry);
328 } 405 }
329 406
330 static void 407 static void
4740 4817
4741 if (gtkconv->dialogs.smiley != NULL) 4818 if (gtkconv->dialogs.smiley != NULL)
4742 gtk_widget_destroy(gtkconv->dialogs.smiley); 4819 gtk_widget_destroy(gtkconv->dialogs.smiley);
4743 4820
4744 if (gtkconv->dialogs.link != NULL) 4821 if (gtkconv->dialogs.link != NULL)
4745 gtk_widget_destroy(gtkconv->dialogs.link); 4822 close_link_dialog(conv);
4746 4823
4747 if (gtkconv->dialogs.log != NULL) 4824 if (gtkconv->dialogs.log != NULL)
4748 gtk_widget_destroy(gtkconv->dialogs.log); 4825 gtk_widget_destroy(gtkconv->dialogs.log);
4749 4826
4750 gtk_widget_destroy(gtkconv->tab_cont); 4827 gtk_widget_destroy(gtkconv->tab_cont);