comparison src/dialogs.c @ 2344:19ea44f74a88

[gaim-migrate @ 2357] well, it still needs some work, but I did promise that I'd commit it tonight. I need to make it check to make sure the file exists, and need to make it display the current buddy icon. I'll do this tomorrow and will commit it. If there's any errors, I'll grab them then. I've had a couple drinks tonight, so it's very possible that I did something dumb or extremely brilliant. ;-) committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sat, 22 Sep 2001 07:02:30 +0000
parents b53cd5b63a99
children 25e7c2a68ed2
comparison
equal deleted inserted replaced
2343:29449a6b79e6 2344:19ea44f74a88
83 83
84 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ 84 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */
85 static GtkWidget *infodialog = NULL; 85 static GtkWidget *infodialog = NULL;
86 static GList *dialogwindows = NULL; 86 static GList *dialogwindows = NULL;
87 static GtkWidget *exportdialog, *importdialog; 87 static GtkWidget *exportdialog, *importdialog;
88 static GtkWidget *icondlg;
88 static GtkWidget *aliasdlg = NULL; 89 static GtkWidget *aliasdlg = NULL;
89 static GtkWidget *aliasentry = NULL; 90 static GtkWidget *aliasentry = NULL;
90 static GtkWidget *aliasname = NULL; 91 static GtkWidget *aliasname = NULL;
91 static GtkWidget *rename_dialog = NULL; 92 static GtkWidget *rename_dialog = NULL;
92 static GtkWidget *rename_bud_dialog = NULL; 93 static GtkWidget *rename_bud_dialog = NULL;
171 GtkWidget *text; 172 GtkWidget *text;
172 GtkWidget *save; 173 GtkWidget *save;
173 GtkWidget *cancel; 174 GtkWidget *cancel;
174 }; 175 };
175 176
177 struct set_icon_dlg {
178 GtkWidget *window;
179 struct aim_user *user;
180 GtkWidget *ok;
181 GtkWidget *cancel;
182 GtkWidget *entry;
183 };
184
176 struct set_dir_dlg { 185 struct set_dir_dlg {
177 struct gaim_connection *gc; 186 struct gaim_connection *gc;
178 GtkWidget *window; 187 GtkWidget *window;
179 GtkWidget *first; 188 GtkWidget *first;
180 GtkWidget *middle; 189 GtkWidget *middle;
276 exportdialog = NULL; 285 exportdialog = NULL;
277 286
278 if (dest == importdialog) 287 if (dest == importdialog)
279 importdialog = NULL; 288 importdialog = NULL;
280 289
290 if (dest == icondlg)
291 icondlg = NULL;
292
281 if (dest == aliasdlg) { 293 if (dest == aliasdlg) {
282 aliasdlg = NULL; 294 aliasdlg = NULL;
283 aliasentry = NULL; 295 aliasentry = NULL;
284 aliasname = NULL; 296 aliasname = NULL;
285 } 297 }
327 } 339 }
328 340
329 if (importdialog) { 341 if (importdialog) {
330 destroy_dialog(NULL, importdialog); 342 destroy_dialog(NULL, importdialog);
331 importdialog = NULL; 343 importdialog = NULL;
344 }
345
346 if (icondlg) {
347 destroy_dialog(NULL, icondlg);
348 icondlg = NULL;
332 } 349 }
333 } 350 }
334 351
335 static void do_warn(GtkWidget *widget, struct warning *w) 352 static void do_warn(GtkWidget *widget, struct warning *w)
336 { 353 {
1514 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", 1531 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked",
1515 GTK_SIGNAL_FUNC(do_change_password), b); 1532 GTK_SIGNAL_FUNC(do_change_password), b);
1516 1533
1517 1534
1518 gtk_widget_show(b->window); 1535 gtk_widget_show(b->window);
1536 }
1537
1538 void do_user_icon(GtkWidget *w, gpointer data)
1539 {
1540 struct set_icon_dlg *b = (struct set_icon_dlg *)data;
1541 char *file;
1542
1543 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(icondlg));
1544
1545 if (file_is_dir(file, icondlg))
1546 return;
1547
1548 if (b && b->entry) {
1549 gtk_entry_set_text(GTK_ENTRY(b->entry), file);
1550 }
1551
1552 destroy_dialog(NULL, icondlg);
1553 icondlg = NULL;
1554
1555 }
1556
1557 void show_icon_dialog(GtkWidget *w, gpointer data)
1558 {
1559 struct set_icon_dlg *b = (struct set_icon_dlg *)data;
1560 char *buf = g_malloc(BUF_LEN);
1561
1562 if (!icondlg) {
1563 icondlg = gtk_file_selection_new(_("Gaim - Load User Icon"));
1564
1565 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(icondlg));
1566
1567 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME"));
1568
1569 gtk_file_selection_set_filename(GTK_FILE_SELECTION(icondlg), buf);
1570 gtk_signal_connect(GTK_OBJECT(icondlg), "destroy",
1571 GTK_SIGNAL_FUNC(destroy_dialog), icondlg);
1572
1573 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(icondlg)->ok_button),
1574 "clicked", GTK_SIGNAL_FUNC(do_user_icon), b);
1575 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(icondlg)->cancel_button),
1576 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), icondlg);
1577
1578
1579 }
1580
1581 g_free(buf);
1582 gtk_widget_show(icondlg);
1583 gdk_window_raise(icondlg->window);
1584 }
1585
1586 void do_save_icon(GtkWidget *w, struct set_icon_dlg *b)
1587 {
1588 char *file = gtk_entry_get_text(GTK_ENTRY(b->entry));
1589
1590 if (file)
1591 g_snprintf(b->user->iconfile, sizeof(b->user->iconfile), "%s", file);
1592 else
1593 b->user->iconfile[0] = 0;
1594
1595 save_prefs();
1596
1597 destroy_dialog(NULL, b->window);
1598 }
1599
1600 void do_clear_icon(GtkWidget *w, struct set_icon_dlg *b)
1601 {
1602 gtk_entry_set_text(GTK_ENTRY(b->entry), "");
1603 }
1604
1605 void show_set_icon(struct gaim_connection *gc)
1606 {
1607 GtkWidget *label;
1608 GtkWidget *frame;
1609 GtkWidget *buttons;
1610 GtkWidget *button;
1611 GtkWidget *vbox;
1612 GtkWidget *hbox;
1613 GtkWidget *hbox2;
1614 GtkWidget *rbox;
1615 /* GtkWidget *sep; */
1616
1617 struct aim_user *tmp;
1618 struct set_icon_dlg *b = g_new0(struct set_icon_dlg, 1);
1619
1620 if (!g_slist_find(connections, gc))
1621 gc = connections->data;
1622
1623 tmp = gc->user;
1624 b->user = tmp;
1625
1626 b->window = gtk_window_new(GTK_WINDOW_DIALOG);
1627 gtk_container_set_border_width(GTK_CONTAINER(b->window), 5);
1628 gtk_window_set_wmclass(GTK_WINDOW(b->window), "set_icon", "Gaim");
1629 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Set User Icon"));
1630 gtk_signal_connect(GTK_OBJECT(b->window), "destroy",
1631 GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1632 gtk_widget_realize(b->window);
1633 aol_icon(b->window->window);
1634 dialogwindows = g_list_prepend(dialogwindows, b->window);
1635
1636 /* the box that holds everything */
1637 vbox = gtk_vbox_new(FALSE, 5);
1638 gtk_widget_show(vbox);
1639 gtk_container_add(GTK_CONTAINER(b->window), vbox);
1640
1641 /* and the frame that umm frames shit */
1642 frame = gtk_frame_new(_("User Icon"));
1643 gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
1644 gtk_widget_show(frame);
1645 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
1646
1647 /* the inner boxie */
1648 hbox = gtk_hbox_new(FALSE, 0);
1649 gtk_widget_show(hbox);
1650 gtk_container_add(GTK_CONTAINER(frame), hbox);
1651
1652 /*
1653 sep = gtk_vseparator_new();
1654 gtk_widget_show(sep);
1655 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 5);
1656 */
1657
1658 /* A boxy */
1659 rbox = gtk_vbox_new(FALSE, 5);
1660 gtk_widget_show(rbox);
1661 gtk_box_pack_start(GTK_BOX(hbox), rbox, FALSE, FALSE, 5);
1662
1663 label = gtk_label_new(_("Please select an icon to be viewed when you chat with\nother users."));
1664 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
1665 gtk_widget_show(label);
1666 gtk_box_pack_start(GTK_BOX(rbox), label, FALSE, FALSE, 5);
1667
1668 hbox2 = gtk_hbox_new(FALSE, 5);
1669 gtk_widget_show(hbox2);
1670 gtk_box_pack_start(GTK_BOX(rbox), hbox2, FALSE, FALSE, 5);
1671
1672 b->entry = gtk_entry_new();
1673
1674 if (strlen(gc->user->iconfile)) {
1675 gtk_entry_set_text(GTK_ENTRY(b->entry), gc->user->iconfile);
1676 }
1677
1678 gtk_widget_show(b->entry);
1679 gtk_box_pack_start(GTK_BOX(hbox2), b->entry, TRUE, TRUE, 5);
1680
1681 button = gtk_button_new_with_label(_("Browse"));
1682 gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 5);
1683 gtk_signal_connect(GTK_OBJECT(button), "clicked",
1684 GTK_SIGNAL_FUNC(show_icon_dialog), b);
1685 gtk_widget_show(button);
1686
1687 button = gtk_button_new_with_label(_("Clear"));
1688 gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 5);
1689 gtk_signal_connect(GTK_OBJECT(button), "clicked",
1690 GTK_SIGNAL_FUNC(do_clear_icon), b);
1691
1692 gtk_widget_show(button);
1693
1694 /* button buttons */
1695 buttons = gtk_hbox_new(FALSE, 5);
1696 gtk_box_pack_start(GTK_BOX(vbox), buttons, FALSE, FALSE, 0);
1697 gtk_widget_show(buttons);
1698
1699 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
1700 gtk_box_pack_end(GTK_BOX(buttons), b->cancel, FALSE, FALSE, 0);
1701 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked",
1702 GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1703
1704 b->ok = picture_button(b->window, _("Ok"), ok_xpm);
1705 gtk_box_pack_end(GTK_BOX(buttons), b->ok, FALSE, FALSE, 0);
1706
1707 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked",
1708 GTK_SIGNAL_FUNC(do_save_icon), b);
1709
1710 /* Show it */
1711 gtk_widget_show(b->window);
1712
1519 } 1713 }
1520 1714
1521 void show_set_info(struct gaim_connection *gc) 1715 void show_set_info(struct gaim_connection *gc)
1522 { 1716 {
1523 GtkWidget *buttons; 1717 GtkWidget *buttons;