changeset 14464:a9f8d3964d62

[gaim-migrate @ 17178] This commit adds a confirmation dialog to GTKgaim when merging two groups. committer: Tailor Script <tailor@pidgin.im>
author Aaron Sheldon <aaronsheldon>
date Wed, 06 Sep 2006 05:24:13 +0000
parents 7df4ab213577
children 8395297271c6
files gtk/gtkblist.c gtk/gtkdialogs.c gtk/gtkdialogs.h
diffstat 3 files changed, 42 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkblist.c	Wed Sep 06 03:58:53 2006 +0000
+++ b/gtk/gtkblist.c	Wed Sep 06 05:24:13 2006 +0000
@@ -317,6 +317,7 @@
 	GtkTreePath *path;
 	GValue val;
 	GaimBlistNode *node;
+	GaimGroup *dest;
 
 	path = gtk_tree_path_new_from_string (arg1);
 	gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
@@ -350,7 +351,11 @@
 			serv_alias_buddy((GaimBuddy *)node);
 			break;
 		case GAIM_BLIST_GROUP_NODE:
-			gaim_blist_rename_group((GaimGroup*)node, arg2);
+			dest = gaim_find_group(arg2);
+			if (dest != NULL && strcmp(arg2, ((GaimGroup*) node)->name)) {
+				gaim_gtkdialogs_merge_groups((GaimGroup*) node, arg2);
+			} else
+				gaim_blist_rename_group((GaimGroup*)node, arg2);
 			break;
 		case GAIM_BLIST_CHAT_NODE:
 			gaim_blist_alias_chat((GaimChat*)node, arg2);
--- a/gtk/gtkdialogs.c	Wed Sep 06 03:58:53 2006 +0000
+++ b/gtk/gtkdialogs.c	Wed Sep 06 05:24:13 2006 +0000
@@ -43,6 +43,11 @@
 
 static GtkWidget *about = NULL;
 
+struct _GaimGroupMergeObject {
+	GaimGroup* parent;
+	char *new_name;
+};
+
 struct developer {
 	char *name;
 	char *role;
@@ -996,6 +1001,36 @@
 	}
 }
 
+void
+gaim_gtkdialogs_merge_groups_cb(struct _GaimGroupMergeObject *GGP)
+{
+	gaim_blist_rename_group(GGP->parent, GGP->new_name);
+}
+
+void
+gaim_gtkdialogs_merge_groups(GaimGroup *source, const char *new_name)
+{
+	gchar *text;
+	struct _GaimGroupMergeObject *ggp;
+
+	g_return_if_fail(source != NULL);
+	g_return_if_fail(new_name != NULL);
+
+	text = g_strdup_printf(
+				"You are about to merge the group called %s into the group "
+				"called %s. Do you want to continue?", source->name, new_name);
+
+	ggp = g_new(struct _GaimGroupMergeObject, 1);
+	ggp->parent = source;
+	ggp->new_name = g_strdup(new_name);
+	
+	gaim_request_action(source, NULL, _("Merge Groups"), text, 0, ggp, 2,
+			_("_Merge Groups"), G_CALLBACK(gaim_gtkdialogs_merge_groups_cb),
+			_("Cancel"), NULL);
+
+	g_free(text);
+}
+
 static void
 gaim_gtkdialogs_remove_group_cb(GaimGroup *group)
 {
--- a/gtk/gtkdialogs.h	Wed Sep 06 03:58:53 2006 +0000
+++ b/gtk/gtkdialogs.h	Wed Sep 06 05:24:13 2006 +0000
@@ -44,6 +44,7 @@
 void gaim_gtkdialogs_remove_group(GaimGroup *);
 void gaim_gtkdialogs_remove_chat(GaimChat *);
 void gaim_gtkdialogs_remove_contact(GaimContact *);
+void gaim_gtkdialogs_merge_groups(GaimGroup *, const char *);
 
 /* Everything after this should probably be moved elsewhere */