pidgin: dfd94759: Show a little prpl icon in request dialo...

sadrul at pidgin.im sadrul at pidgin.im
Sun Nov 1 19:16:46 EST 2009


-----------------------------------------------------------------
Revision: dfd9475969579acbe9cf0dd4095147f0a94ce393
Ancestor: 9045ccd8ac58880d5eb07820e9fd0172aa0e60f8
Author: sadrul at pidgin.im
Date: 2009-11-02T00:11:37
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/dfd9475969579acbe9cf0dd4095147f0a94ce393

Modified files:
        pidgin/gtkrequest.c

ChangeLog: 

Show a little prpl icon in request dialogs, when possible.

The little icons show up at the top-right corner of the dialog, and the
tooltip gives the name of the account. This can be useful when/if the
text in the dialog doesn't clearly state what account the dialog is meant
to operate on.

-------------- next part --------------
============================================================
--- pidgin/gtkrequest.c	d61ed4211e527cc244a8b5c22f20096abfe6939f
+++ pidgin/gtkrequest.c	9f3195f34e3f8fe3ea4e7c33bfa660b56a7115d6
@@ -81,6 +81,33 @@ static void
 } PidginRequestData;
 
 static void
+pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account)
+{
+	GtkWidget *image;
+	GdkPixbuf *pixbuf;
+	GtkTooltips *tips;
+
+	if (!account)
+		return;
+
+	pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
+	image = gtk_image_new_from_pixbuf(pixbuf);
+	g_object_unref(G_OBJECT(pixbuf));
+
+	tips = gtk_tooltips_new();
+	gtk_tooltips_set_tip(tips, image, purple_account_get_username(account), NULL);
+
+	if (GTK_IS_DIALOG(cont)) {
+		gtk_box_pack_start(GTK_BOX(GTK_DIALOG(cont)->action_area), image, FALSE, TRUE, 0);
+		gtk_box_reorder_child(GTK_BOX(GTK_DIALOG(cont)->action_area), image, 0);
+	} else if (GTK_IS_HBOX(cont)) {
+		gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
+		gtk_box_pack_end(GTK_BOX(cont), image, FALSE, TRUE, 0);
+	}
+	gtk_widget_show(image);
+}
+
+static void
 generic_response_start(PidginRequestData *data)
 {
 	g_return_if_fail(data != NULL);
@@ -347,6 +374,8 @@ pidgin_request_input(const char *title, 
 
 	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
 
+	pidgin_widget_decorate_account(hbox, account);
+
 	/* Descriptive label */
 	primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL;
 	secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL;
@@ -515,6 +544,8 @@ pidgin_request_choice(const char *title,
 	gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
 
+	pidgin_widget_decorate_account(hbox, account);
+
 	/* Vertical box */
 	vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
 	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
@@ -639,6 +670,8 @@ pidgin_request_action(const char *title,
 	vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
 	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
 
+	pidgin_widget_decorate_account(hbox, account);
+
 	/* Descriptive label */
 	primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL;
 	secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL;
@@ -1144,6 +1177,8 @@ pidgin_request_fields(const char *title,
 	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
 	gtk_window_set_default(GTK_WINDOW(win), button);
 
+	pidgin_widget_decorate_account(hbox, account);
+
 	/* Setup the vbox */
 	vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
 	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);


More information about the Commits mailing list