changeset 3753:764ecb5f984b

[gaim-migrate @ 3892] I never committed this last night. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 19 Oct 2002 22:11:10 +0000
parents b32474e522fa
children 599194293ee5
files src/dialogs.c src/prpl.c
diffstat 2 files changed, 25 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Sat Oct 19 05:22:30 2002 +0000
+++ b/src/dialogs.c	Sat Oct 19 22:11:10 2002 +0000
@@ -463,7 +463,7 @@
 	gtk_widget_show(w->window);
 }
 
-void do_remove_buddy(GtkWidget *w, struct buddy *b)
+void do_remove_buddy(struct buddy *b)
 {
 	struct group *g = find_group_by_buddy(b->gc, b->name);
 	struct gaim_connection *gc = b->gc;
@@ -486,84 +486,14 @@
 
 void show_confirm_del(struct gaim_connection *gc, gchar *name)
 {
-	struct confirm_del *b = g_new0(struct confirm_del, 1);
-	struct buddy *bd;
-	GtkWidget *hbox;
-	GtkWidget *vbox;
-	GtkWidget *fbox;
-	GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
-	gchar tmp[2048];
-	char labeltext[1024 * 2];
-	char *filename;
-	GtkWidget *image;
-
-	GAIM_DIALOG(b->window);
-	dialogwindows = g_list_prepend(dialogwindows, b->window);
-
-	g_snprintf(tmp, sizeof(tmp), _("Gaim - Remove %s?"), name);
-	gtk_container_set_border_width(GTK_CONTAINER(b->window), 6);
-	gtk_window_set_title(GTK_WINDOW(b->window), tmp);
-	gtk_window_set_wmclass(GTK_WINDOW(b->window), "confirm_del", "Gaim");
-	gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, FALSE, TRUE);
-	gtk_signal_connect(GTK_OBJECT(b->window), "delete_event",
-			   GTK_SIGNAL_FUNC(destroy_dialog), b->window);
-
-	gtk_widget_realize(b->window);
-
-	vbox = gtk_vbox_new(FALSE, 0);
-	gtk_box_set_spacing(GTK_BOX(vbox), 12);
-	gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
-	gtk_container_add(GTK_CONTAINER(b->window), vbox);
-	gtk_widget_show(vbox);
-
-	fbox = gtk_hbox_new(FALSE, 0);
-	gtk_box_set_spacing(GTK_BOX(fbox), 6);
-	gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
-	gtk_widget_show(fbox);
-
-	filename = g_build_filename (DATADIR, "pixmaps", "gaim", "dialogs", "gaim_question.png", NULL);
-	debug_printf("Loading: %s\n", filename);
-	image = gtk_image_new_from_file(filename);
-	gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
-	gtk_box_pack_start(GTK_BOX(fbox), image, FALSE, FALSE, 0);
-	gtk_widget_show(image);
-	g_free(filename);
-
-	g_snprintf(labeltext, sizeof(labeltext), "<span weight=\"bold\" size=\"larger\">Remove Buddy</span>\n\nYou are about to remove '%s' from\nyour buddylist.  Do you want to continue?", name);
-	b->label = gtk_label_new(NULL);
-	gtk_label_set_markup(GTK_LABEL(b->label), labeltext);
-	gtk_label_set_line_wrap(GTK_LABEL(b->label), TRUE);
-	gtk_label_set_justify(GTK_LABEL(b->label), GTK_JUSTIFY_LEFT);
-	gtk_misc_set_alignment(GTK_MISC(b->label), 0, 0);
-	gtk_box_pack_start(GTK_BOX(fbox), b->label, FALSE, FALSE, 0);
-	gtk_widget_show(b->label);
-	gtk_box_pack_start(GTK_BOX(vbox), fbox, TRUE, FALSE, 0);
-
-	hbox = gtk_hbox_new(FALSE, 0);
-	gtk_box_set_spacing(GTK_BOX(hbox), 6);
-	gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);
-	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 0);
-	gtk_widget_show(hbox);
-
-	b->ok = gtk_button_new_with_label("Remove Buddy");
-	gtk_widget_show(b->ok);
-	gtk_size_group_add_widget(sg, b->ok);
-	gtk_box_pack_end(GTK_BOX(hbox), b->ok, FALSE, FALSE, 5);
-
-	bd = find_buddy(gc, name);
-
-	if (bd)
-		gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_remove_buddy), bd);
-	
-	gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
-
-	b->cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
-	gtk_widget_show(b->cancel);
-	gtk_size_group_add_widget(sg, b->cancel);
-	gtk_box_pack_end(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 5);
-	gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
-	
-	gtk_widget_show(b->window);	
+	struct buddy *bd = find_buddy(gc, name);
+	char *text;
+	if (!bd)
+		return;
+
+	text = g_strdup_printf("You are about to remove %s from your buddy list.  Do you want to continue?", name);
+	do_ask_dialog("Remove Buddy", text, bd, "Remove Buddy", do_remove_buddy, "Cancel", NULL);
+	g_free(text);
 }
 
 
--- a/src/prpl.c	Sat Oct 19 05:22:30 2002 +0000
+++ b/src/prpl.c	Sat Oct 19 22:11:10 2002 +0000
@@ -165,6 +165,10 @@
 	gtk_widget_destroy(GTK_WIDGET(d));
 }
 
+#define STOCK_ITEMIZE(r, l)       if (!strcmp(r,yestext))  \
+                                           yestext = l;    \
+                                   if (!strcmp(r,notext))  \
+                                           notext = l;     
 
 void do_ask_dialog(const char *prim, const char *sec, void *data, char *yestext, void *doit, char *notext, void *dont)
 {
@@ -183,6 +187,18 @@
 	g_free(filename);
 	gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
 
+	/* This is ugly.  GTK Stock items will take a button with a label "gtk-cancel" and turn it into a 
+	 * Cancel button with a Cancel icon and whatnot.  We want to avoid using anything gtk in the prpls
+	 * so we replace "Cancel" with "gtk-cancel" right here. */
+	STOCK_ITEMIZE("Add", GTK_STOCK_ADD);
+	STOCK_ITEMIZE("Apply", GTK_STOCK_APPLY);
+	STOCK_ITEMIZE("Cancel", GTK_STOCK_CANCEL);
+	STOCK_ITEMIZE("Close", GTK_STOCK_CLOSE);
+	STOCK_ITEMIZE("Delete", GTK_STOCK_DELETE);
+	STOCK_ITEMIZE("Remove", GTK_STOCK_REMOVE);
+	STOCK_ITEMIZE("Yes", GTK_STOCK_YES);
+	STOCK_ITEMIZE("No", GTK_STOCK_NO);
+
 	window = gtk_dialog_new_with_buttons("", NULL, GTK_DIALOG_MODAL, notext, GTK_RESPONSE_NO, yestext, GTK_RESPONSE_YES, NULL);
 	gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_YES);
 	g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_ask_callback), doask);