changeset 21417:21bea7c72a80

Make mini-dialogs follow the blist's size changes.
author Will Thompson <will.thompson@collabora.co.uk>
date Wed, 07 Nov 2007 11:23:03 +0000
parents 0f469b9a4302
children 38cc722159ff
files pidgin/minidialog.c
diffstat 1 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/minidialog.c	Mon Nov 05 16:48:02 2007 +0000
+++ b/pidgin/minidialog.c	Wed Nov 07 11:23:03 2007 +0000
@@ -232,6 +232,9 @@
 	{
 		gtk_label_set_text(priv->desc, NULL);
 		gtk_widget_hide(GTK_WIDGET(priv->desc));
+		/* make calling show_all() on the minidialog not affect desc
+		 * even though it's packed inside it.
+	 	 */
 		g_object_set(G_OBJECT(priv->desc), "no-show-all", TRUE, NULL);
 	}
 }
@@ -270,6 +273,8 @@
 	g_free(priv);
 	self->priv = NULL;
 
+	purple_prefs_disconnect_by_handle(self);
+
 	G_OBJECT_CLASS (pidgin_mini_dialog_parent_class)->finalize (object);
 }
 
@@ -313,11 +318,29 @@
 #define BLIST_WIDTH_OTHER_THAN_LABEL \
 	((PIDGIN_HIG_BOX_SPACE * 3) + 16)
 
+#define BLIST_WIDTH_PREF \
+	(PIDGIN_PREFS_ROOT "/blist/width")
+
+static void
+blist_width_changed_cb(const char *name,
+                       PurplePrefType type,
+                       gconstpointer val,
+                       gpointer data)
+{
+	PidginMiniDialog *self = PIDGIN_MINI_DIALOG(data);
+	PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self);
+	guint blist_width = GPOINTER_TO_INT(val);
+	guint label_width = blist_width - BLIST_WIDTH_OTHER_THAN_LABEL;
+
+	gtk_widget_set_size_request(GTK_WIDGET(priv->title), label_width, -1);
+	gtk_widget_set_size_request(GTK_WIDGET(priv->desc), label_width, -1);
+}
+
 static void
 pidgin_mini_dialog_init(PidginMiniDialog *self)
 {
 	GtkBox *self_box = GTK_BOX(self);
-	guint blist_width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/width");
+	guint blist_width = purple_prefs_get_int(BLIST_WIDTH_PREF);
 	guint label_width = blist_width - BLIST_WIDTH_OTHER_THAN_LABEL;
 
 	PidginMiniDialogPrivate *priv = g_new0(PidginMiniDialogPrivate, 1);
@@ -331,7 +354,6 @@
 	gtk_misc_set_alignment(GTK_MISC(priv->icon), 0, 0);
 
 	priv->title = GTK_LABEL(gtk_label_new(NULL));
-	/* TODO: update this request when /blist/width updates. */
 	gtk_widget_set_size_request(GTK_WIDGET(priv->title), label_width, -1);
 	gtk_label_set_line_wrap(priv->title, TRUE);
 	gtk_misc_set_alignment(GTK_MISC(priv->title), 0, 0);
@@ -340,7 +362,6 @@
 	gtk_box_pack_start(priv->title_box, GTK_WIDGET(priv->title), TRUE, TRUE, 0);
 
 	priv->desc = GTK_LABEL(gtk_label_new(NULL));
-	/* TODO: update this request when /blist/width updates. */
 	gtk_widget_set_size_request(GTK_WIDGET(priv->desc), label_width, -1);
 	gtk_label_set_line_wrap(priv->desc, TRUE);
 	gtk_misc_set_alignment(GTK_MISC(priv->desc), 0, 0);
@@ -349,6 +370,9 @@
 	 */
 	g_object_set(G_OBJECT(priv->desc), "no-show-all", TRUE, NULL);
 
+	purple_prefs_connect_callback(self, BLIST_WIDTH_PREF,
+		blist_width_changed_cb, self);
+
 	self->contents = GTK_BOX(gtk_vbox_new(FALSE, 0));
 
 	priv->buttons = GTK_BOX(gtk_hbox_new(FALSE, 0));