diff console/gntblist.c @ 13853:bbf0470cb348

[gaim-migrate @ 16312] Improvement/fixing of GntTree. Do the scrolling and stuff without 'reliably'. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 23 Jun 2006 00:45:45 +0000
parents 0e1e59770cb0
children d341b5ac1a78
line wrap: on
line diff
--- a/console/gntblist.c	Thu Jun 22 23:08:05 2006 +0000
+++ b/console/gntblist.c	Fri Jun 23 00:45:45 2006 +0000
@@ -8,30 +8,9 @@
 #include "gntbox.h"
 #include "gnttree.h"
 
-#define	TAB_SIZE 3
-
-/**
- * NOTES:
- *
- * 1. signal-callbacks should check for module_in_focus() before redrawing anything.
- * 2. call module_lost_focus() before opening a new window, and module_gained_focus() when
- * 		the new window is closed. This is to make sure the signal callbacks don't screw up
- * 		the display.
- */
+#include "gntblist.h"
 
-static GaimBlistUiOps blist_ui_ops = 
-{
-	NULL,
-	NULL,
-	NULL,
-	NULL,		/* This doesn't do crap */
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
+#define	TAB_SIZE 3
 
 typedef struct
 {
@@ -41,6 +20,43 @@
 
 GGBlist *ggblist;
 
+static void
+new_node(GaimBlistNode *node)
+{
+}
+
+static void
+node_update(GaimBuddyList *list, GaimBlistNode *node)
+{
+}
+
+static void
+node_remove(GaimBuddyList *list, GaimBlistNode *node)
+{
+}
+
+static void
+new_list(GaimBuddyList *list)
+{
+	if (ggblist == NULL)
+		gg_blist_init();
+	list->ui_data = ggblist;
+}
+
+static GaimBlistUiOps blist_ui_ops = 
+{
+	new_list,
+	new_node,
+	NULL,
+	node_update,		/* This doesn't do crap */
+	node_remove,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
 static gpointer
 gg_blist_get_handle()
 {
@@ -61,11 +77,15 @@
 }
 
 static void
-buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist)
+add_buddy(GaimBuddy *buddy, GGBlist *ggblist)
 {
-	GaimGroup *group = gaim_buddy_get_group(buddy);
 	char *text;
+	GaimGroup *group;
+	GaimBlistNode *node = (GaimBlistNode *)buddy;
+	if (node->ui_data)
+		return;
 
+	group = gaim_buddy_get_group(buddy);
 	add_group(group, ggblist);
 
 	text = g_strdup_printf("%*s%s", TAB_SIZE, "", gaim_buddy_get_alias(buddy));
@@ -74,6 +94,12 @@
 }
 
 static void
+buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist)
+{
+	add_buddy(buddy, ggblist);
+}
+
+static void
 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist)
 {
 	gnt_tree_remove(GNT_TREE(ggblist->tree), buddy);
@@ -92,13 +118,17 @@
 
 void gg_blist_init()
 {
-	ggblist = g_new0(GGBlist, 1);
+	if (ggblist == NULL)
+		ggblist = g_new0(GGBlist, 1);
 
 	ggblist->window = gnt_box_new(FALSE, FALSE);
+	GNT_WIDGET_UNSET_FLAGS(ggblist->window, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
 	gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List"));
+	gnt_box_set_pad(GNT_BOX(ggblist->window), 0);
 
 	ggblist->tree = gnt_tree_new();
-	gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr));
+	GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER);
+	gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr) - 2);
 
 	gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree);
 	gnt_widget_show(ggblist->window);