changeset 22026:7f657dd7ebaa

merge of 'd11aaeee05a52eb367ad7d81f82a36b7a0501bcf' and 'd50f362e369f486aaf9a95a0d79ec0632743f07d'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 07 Jan 2008 06:19:57 +0000
parents 57cac5dfda2a (diff) 6f452e8d13a2 (current diff)
children e8cb4df7b60a
files
diffstat 3 files changed, 58 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntroomlist.c	Mon Jan 07 00:32:26 2008 +0000
+++ b/finch/gntroomlist.c	Mon Jan 07 06:19:57 2008 +0000
@@ -38,6 +38,8 @@
 
 #include "debug.h"
 
+#define PREF_ROOT "/finch/roomlist"
+
 /* Yes, just one roomlist at a time. Let's not get greedy. Aight? */
 struct _FinchRoomlist
 {
@@ -138,9 +140,13 @@
 			purple_roomlist_room_join(froomlist.roomlist, room);
 			break;
 		case PURPLE_ROOMLIST_ROOMTYPE_CATEGORY:
-			purple_roomlist_expand_category(froomlist.roomlist, room);
+			if (!room->expanded_once) {
+				purple_roomlist_expand_category(froomlist.roomlist, room);
+				room->expanded_once = TRUE;
+			}
 			break;
 	}
+	gnt_tree_set_expanded(GNT_TREE(widget), room, TRUE);
 }
 
 static void
@@ -191,8 +197,10 @@
 	}
 
 	if (purple_roomlist_room_get_type(room) == PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) {
+		if (!first)
+			gnt_text_view_append_text_with_flags(tv, "\n", GNT_TEXT_FLAG_NORMAL);
 		gnt_text_view_append_text_with_flags(tv,
-				_("\nHit 'Enter' to find more rooms of this category."),
+				_("Hit 'Enter' to find more rooms of this category."),
 				GNT_TEXT_FLAG_NORMAL);
 	}
 }
@@ -238,6 +246,15 @@
 }
 
 static void
+size_changed_cb(GntWidget *widget, int oldw, int oldh)
+{
+	int w, h;
+	gnt_widget_get_size(widget, &w, &h);
+	purple_prefs_set_int(PREF_ROOT "/size/width", w);
+	purple_prefs_set_int(PREF_ROOT "/size/height", h);
+}
+
+static void
 setup_roomlist(PurpleAccount *account)
 {
 	GntWidget *window, *tree, *hbox, *accounts;
@@ -284,7 +301,7 @@
 	froomlist.details = gnt_text_view_new();
 	gnt_text_view_set_flag(GNT_TEXT_VIEW(froomlist.details), GNT_TEXT_VIEW_TOP_ALIGN);
 	gnt_box_add_widget(GNT_BOX(window), froomlist.details);
-	gnt_widget_set_size(froomlist.details, -1, 10);
+	gnt_widget_set_size(froomlist.details, -1, 8);
 
 	hbox = gnt_hbox_new(FALSE);
 	gnt_box_add_widget(GNT_BOX(window), hbox);
@@ -306,6 +323,13 @@
 fl_show_with_account(PurpleAccount *account)
 {
 	setup_roomlist(account);
+	g_signal_handlers_disconnect_matched(G_OBJECT(froomlist.window), G_SIGNAL_MATCH_FUNC,
+			0, 0, NULL, G_CALLBACK(size_changed_cb), NULL);
+	gnt_widget_show(froomlist.window);
+	gnt_screen_resize_widget(froomlist.window,
+			purple_prefs_get_int(PREF_ROOT "/size/width"),
+			purple_prefs_get_int(PREF_ROOT "/size/height"));
+	g_signal_connect(G_OBJECT(froomlist.window), "size_changed", G_CALLBACK(size_changed_cb), NULL);
 	gnt_window_present(froomlist.window);
 }
 
@@ -325,15 +349,18 @@
 static void
 fl_add_room(PurpleRoomlist *roomlist, PurpleRoomlistRoom *room)
 {
+	gboolean category;
 	if (froomlist.roomlist != roomlist)
 		return;
 
+	category = (purple_roomlist_room_get_type(room) == PURPLE_ROOMLIST_ROOMTYPE_CATEGORY);
 	gnt_tree_remove(GNT_TREE(froomlist.tree), room);
 	gnt_tree_add_row_after(GNT_TREE(froomlist.tree), room,
 			gnt_tree_create_row(GNT_TREE(froomlist.tree),
 				purple_roomlist_room_get_name(room),
-				purple_roomlist_room_get_type(room) == PURPLE_ROOMLIST_ROOMTYPE_CATEGORY ? "<" : ""),
+				category ? "<" : ""),
 			purple_roomlist_room_get_parent(room), NULL);
+	gnt_tree_set_expanded(GNT_TREE(froomlist.tree), room, !category);
 }
 
 static void
@@ -363,6 +390,7 @@
 	NULL, /* void (*_purple_reserved3)(void); */
 	NULL /* void (*_purple_reserved4)(void); */
 };
+
 PurpleRoomlistUiOps *finch_roomlist_get_ui_ops(void)
 {
 	return &ui_ops;
@@ -373,3 +401,15 @@
 	purple_roomlist_show_with_account(NULL);
 }
 
+void finch_roomlist_init(void)
+{
+	purple_prefs_add_none(PREF_ROOT);
+	purple_prefs_add_none(PREF_ROOT "/size");
+	purple_prefs_add_int(PREF_ROOT "/size/width", 60);
+	purple_prefs_add_int(PREF_ROOT "/size/height", 15);
+}
+
+void finch_roomlist_uninit(void)
+{
+}
+
--- a/finch/gntroomlist.h	Mon Jan 07 00:32:26 2008 +0000
+++ b/finch/gntroomlist.h	Mon Jan 07 06:19:57 2008 +0000
@@ -34,6 +34,11 @@
 /*@{*/
 
 /**
+ * Initialize the roomlist subsystem.
+ */
+void finch_roomlist_init(void);
+
+/**
  * Get the ui-functions.
  *
  * @return The PurpleRoomlistUiOps structure populated with the appropriate functions.
@@ -45,6 +50,11 @@
  */
 void finch_roomlist_show_all(void);
 
+/**
+ * Uninitialize the roomlist subsystem.
+ */
+void finch_roomlist_uninit(void);
+
 /*@}*/
 
 #endif
--- a/finch/gntui.c	Mon Jan 07 00:32:26 2008 +0000
+++ b/finch/gntui.c	Mon Jan 07 06:19:57 2008 +0000
@@ -84,6 +84,7 @@
 	purple_xfers_set_ui_ops(finch_xfers_get_ui_ops());
 
 	/* Roomlist */
+	finch_roomlist_init();
 	purple_roomlist_set_ui_ops(finch_roomlist_get_ui_ops());
 
 	gnt_register_action(_("Accounts"), finch_accounts_show_all);
@@ -126,6 +127,9 @@
 	finch_xfers_uninit();
 	purple_xfers_set_ui_ops(NULL);
 
+	finch_roomlist_uninit();
+	purple_roomlist_set_ui_ops(NULL);
+
 	gnt_quit();
 #endif
 }