comparison finch/gntblist.c @ 24177:c8ed49367d86

Instead of showing error message when trying to interactively add an existing group, treat it as a new empty group (ie. show it even if 'show empty groups' setting is turned off)
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 18 Oct 2008 17:12:27 +0000
parents 95da3ec97c27
children a4a7084ee09d
comparison
equal deleted inserted replaced
24176:c1e58cfd1107 24177:c8ed49367d86
792 static void 792 static void
793 add_group_cb(gpointer null, const char *group) 793 add_group_cb(gpointer null, const char *group)
794 { 794 {
795 PurpleGroup *grp; 795 PurpleGroup *grp;
796 796
797 if (!group || !*group) 797 if (!group || !*group) {
798 {
799 purple_notify_error(NULL, _("Error"), _("Error adding group"), 798 purple_notify_error(NULL, _("Error"), _("Error adding group"),
800 _("You must give a name for the group to add.")); 799 _("You must give a name for the group to add."));
801 return; 800 return;
802 } 801 }
803 802
804 grp = purple_find_group(group); 803 grp = purple_find_group(group);
805 if (!grp) 804 if (!grp) {
806 {
807 grp = purple_group_new(group); 805 grp = purple_group_new(group);
808 if (ggblist) {
809 ggblist->new_group = g_list_prepend(ggblist->new_group, grp);
810 if (!ggblist->new_group_timeout) {
811 ggblist->new_group_timeout = purple_timeout_add_seconds(SHOW_EMPTY_GROUP_TIMEOUT,
812 remove_new_empty_group, NULL);
813 }
814 }
815 purple_blist_add_group(grp, NULL); 806 purple_blist_add_group(grp, NULL);
816 807 }
817 /* Select the new group */ 808
818 if (ggblist && ggblist->tree) { 809 if (!ggblist)
819 FinchBlistNode *fnode = FINCH_GET_DATA((PurpleBlistNode*)grp); 810 return;
820 if (fnode && fnode->row) 811
821 gnt_tree_set_selected(GNT_TREE(ggblist->tree), grp); 812 /* Treat the group as a new group even if it had existed before. This should
822 } 813 * make things easier to add buddies to empty groups (new or old) without having
823 } 814 * to turn on 'show empty groups' setting */
824 else 815 ggblist->new_group = g_list_prepend(ggblist->new_group, grp);
825 { 816 if (ggblist->new_group_timeout)
826 purple_notify_error(NULL, _("Error"), _("Error adding group"), 817 purple_timeout_remove(ggblist->new_group_timeout);
827 _("A group with the name already exists.")); 818 ggblist->new_group_timeout = purple_timeout_add_seconds(SHOW_EMPTY_GROUP_TIMEOUT,
819 remove_new_empty_group, NULL);
820
821 /* Select the group */
822 if (ggblist->tree) {
823 FinchBlistNode *fnode = FINCH_GET_DATA((PurpleBlistNode*)grp);
824 if (!fnode)
825 add_node((PurpleBlistNode*)grp, ggblist);
826 gnt_tree_set_selected(GNT_TREE(ggblist->tree), grp);
828 } 827 }
829 } 828 }
830 829
831 static void 830 static void
832 finch_request_add_group(void) 831 finch_request_add_group(void)