changeset 24233:55c7c41ce84c

merge of '77f42c8f25c38b4f966158a64ab3be36f00e0aa8' and 'e8631a127deaf18b86db54656bab3e03cdf6e083'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 13 Oct 2008 18:54:37 +0000
parents e93ca60b97dc (current diff) bfe33e14f4b2 (diff)
children 499739e4c5d5
files
diffstat 2 files changed, 101 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntblist.c	Sun Oct 12 22:02:07 2008 +0000
+++ b/finch/gntblist.c	Mon Oct 13 18:54:37 2008 +0000
@@ -63,6 +63,8 @@
 #define PREF_ROOT "/finch/blist"
 #define TYPING_TIMEOUT 4000
 
+#define SHOW_EMPTY_GROUP_TIMEOUT  60
+
 typedef struct
 {
 	GntWidget *window;
@@ -86,6 +88,13 @@
 	GntMenuItem *plugins;
 	GntMenuItem *grouping;
 
+	/* When a new group is manually added, it is empty, but we still want to show it
+	 * for a while (SHOW_EMPTY_GROUP_TIMEOUT seconds) even if 'show empty groups' is
+	 * not selected.
+	 */
+	GList *new_group;
+	guint new_group_timeout;
+
 	FinchBlistManager *manager;
 } FinchBlist;
 
@@ -194,6 +203,9 @@
 			if (default_can_add_node(nd))
 				return TRUE;
 		}
+
+		if (ggblist && ggblist->new_group && g_list_find(ggblist->new_group, node))
+			return TRUE;
 	}
 
 	return FALSE;
@@ -489,9 +501,13 @@
 	FinchBlist *ggblist = FINCH_GET_DATA(list);
 	PurpleBlistNode *parent;
 
-	if (ggblist == NULL || FINCH_GET_DATA(node)== NULL)
+	if (ggblist == NULL || FINCH_GET_DATA(node) == NULL)
 		return;
 
+	if (PURPLE_BLIST_NODE_IS_GROUP(node) && ggblist->new_group) {
+		ggblist->new_group = g_list_remove(ggblist->new_group, node);
+	}
+
 	gnt_tree_remove(GNT_TREE(ggblist->tree), node);
 	reset_blist_node_ui_data(node);
 	if (ggblist->tagged)
@@ -572,6 +588,27 @@
 		ggblist->manager = &default_manager;
 }
 
+static gboolean
+remove_new_empty_group(gpointer data)
+{
+	PurpleBuddyList *list;
+
+	if (!ggblist)
+		return FALSE;
+
+	list = purple_get_blist();
+	g_return_val_if_fail(list, FALSE);
+
+	ggblist->new_group_timeout = 0;
+	while (ggblist->new_group) {
+		PurpleBlistNode *group = ggblist->new_group->data;
+		ggblist->new_group = g_list_delete_link(ggblist->new_group, ggblist->new_group);
+		node_update(list, group);
+	}
+
+	return FALSE;
+}
+
 static void
 add_buddy_cb(void *data, PurpleRequestFields *allfields)
 {
@@ -768,7 +805,21 @@
 	if (!grp)
 	{
 		grp = purple_group_new(group);
+		if (ggblist) {
+			ggblist->new_group = g_list_prepend(ggblist->new_group, grp);
+			if (!ggblist->new_group_timeout) {
+				ggblist->new_group_timeout = purple_timeout_add_seconds(SHOW_EMPTY_GROUP_TIMEOUT,
+						remove_new_empty_group, NULL);
+			}
+		}
 		purple_blist_add_group(grp, NULL);
+
+		/* Select the new group */
+		if (ggblist && ggblist->tree) {
+			FinchBlistNode *fnode = FINCH_GET_DATA((PurpleBlistNode*)grp);
+			if (fnode && fnode->row)
+				gnt_tree_set_selected(GNT_TREE(ggblist->tree), grp);
+		}
 	}
 	else
 	{
@@ -1955,6 +2006,12 @@
 	remove_peripherals(ggblist);
 	if (ggblist->tagged)
 		g_list_free(ggblist->tagged);
+
+	if (ggblist->new_group_timeout)
+		purple_timeout_remove(ggblist->new_group_timeout);
+	if (ggblist->new_group)
+		g_list_free(ggblist->new_group);
+
 	g_free(ggblist);
 	ggblist = NULL;
 }
--- a/finch/libgnt/wms/irssi.c	Sun Oct 12 22:02:07 2008 +0000
+++ b/finch/libgnt/wms/irssi.c	Mon Oct 13 18:54:37 2008 +0000
@@ -1,3 +1,25 @@
+/*
+ * GNT - The GLib Ncurses Toolkit
+ *
+ * GNT is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
 /**
  * 1. Buddylist is aligned on the left.
  * 2. The rest of the screen is split into MxN grid for conversation windows.
@@ -136,6 +158,7 @@
 				gnt_widget_set_position(win, x, y);
 				mvwin(win->window, y, x);
 			} else {
+				gnt_window_set_maximize(GNT_WINDOW(win), GNT_WINDOW_MAXIMIZE_Y);
 				remove_border_set_position_size(wm, win, 0, 0, -1, getmaxy(stdscr) - 1);
 				gnt_widget_get_size(win, &((Irssi*)wm)->buddylistwidth, NULL);
 				draw_line_separators((Irssi*)wm);
@@ -251,9 +274,29 @@
 }
 
 static void
+refresh_window(GntWidget *widget, GntNode *node, Irssi *irssi)
+{
+	int vert, hor;
+	int x, y, w, h;
+
+	if (!GNT_IS_WINDOW(widget))
+		return;
+
+	if (is_budddylist(widget)) {
+		return;
+	}
+
+	find_window_position(irssi, widget, &hor, &vert);
+	get_xywh_for_frame(irssi, hor, vert, &x, &y, &w, &h);
+	gnt_wm_move_window(GNT_WM(irssi), widget, x, y);
+	gnt_wm_resize_window(GNT_WM(irssi), widget, w, h);
+}
+
+static void
 irssi_terminal_refresh(GntWM *wm)
 {
 	draw_line_separators((Irssi*)wm);
+	g_hash_table_foreach(wm->nodes, (GHFunc)refresh_window, wm);
 }
 
 static void