im.pidgin.cpw.resiak.disconnectreason: 0ac25a1f38ae28654c967caa143f1c0d12ef2e1c

resiak at soc.pidgin.im resiak at soc.pidgin.im
Wed Nov 7 06:40:36 EST 2007


-----------------------------------------------------------------
Revision: 0ac25a1f38ae28654c967caa143f1c0d12ef2e1c
Ancestor: 9659d225bc8a1dce3d5d6d13c45877019798ae4b
Author: resiak at soc.pidgin.im
Date: 2007-11-07T11:23:03
Branch: im.pidgin.cpw.resiak.disconnectreason

Modified files:
        pidgin/minidialog.c

ChangeLog: 

Make mini-dialogs follow the blist's size changes.

-------------- next part --------------
============================================================
--- pidgin/minidialog.c	667e68a68e9179b52b34a3870999af59b2e2ebca
+++ pidgin/minidialog.c	055a7000f0c7471d0808b251dd2919925f386fac
@@ -232,6 +232,9 @@ mini_dialog_set_description(PidginMiniDi
 	{
 		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 @@ pidgin_mini_dialog_finalize(GObject *obj
 	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 @@ pidgin_mini_dialog_class_init(PidginMini
 #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 @@ pidgin_mini_dialog_init(PidginMiniDialog
 	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 @@ pidgin_mini_dialog_init(PidginMiniDialog
 	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 @@ pidgin_mini_dialog_init(PidginMiniDialog
 	 */
 	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));


More information about the Commits mailing list