changeset 13927:9309d27d780c

[gaim-migrate @ 16447] Pseudo-shadow effect for the windows and buttons. Uses non-ASCII emblems for buddies in the buddy-list if locale is set to UTF. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 06 Jul 2006 17:54:46 +0000
parents 756c3d7177d9
children 4ed8330435eb
files console/gntblist.c console/gntconv.c console/gntgaim.c console/libgnt/Makefile.am console/libgnt/gnt.h console/libgnt/gntbox.c console/libgnt/gntmain.c console/libgnt/gnttextview.c console/libgnt/gnttree.c console/libgnt/gntwidget.c console/libgnt/gntwidget.h console/libgnt/test/multiwin.c
diffstat 12 files changed, 74 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntblist.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/gntblist.c	Thu Jul 06 17:54:46 2006 +0000
@@ -141,7 +141,7 @@
 		GaimStatusPrimitive prim;
 		GaimPresence *presence;
 		GaimStatus *now;
-
+		gboolean ascii = gnt_ascii_only();
 		
 		presence = gaim_buddy_get_presence(buddy);
 		now = gaim_presence_get_active_status(presence);
@@ -150,29 +150,15 @@
 
 		switch(prim)
 		{
-#if 1
 			case GAIM_STATUS_OFFLINE:
-				strncpy(status, "x", sizeof(status) - 1);
+				strncpy(status, ascii ? "x" : "⊗", sizeof(status) - 1);
 				break;
 			case GAIM_STATUS_AVAILABLE:
-				strncpy(status, "o", sizeof(status) - 1);
+				strncpy(status, ascii ? "o" : "◯", sizeof(status) - 1);
 				break;
 			default:
-				strncpy(status, ".", sizeof(status) - 1);
-				break;
-#else
-			/* XXX: Let's use these some time */
-			case GAIM_STATUS_OFFLINE:
-				strncpy(status, "⊗", sizeof(status) - 1);
+				strncpy(status, ascii ? "." : "⊖", sizeof(status) - 1);
 				break;
-			case GAIM_STATUS_AVAILABLE:
-				/* XXX: Detect idleness */
-				strncpy(status, "◯", sizeof(status) - 1);
-				break;
-			default:
-				strncpy(status, "⊖", sizeof(status) - 1);
-				break;
-#endif
 		}
 		name = gaim_buddy_get_alias(buddy);
 	}
@@ -412,7 +398,7 @@
 
 	ggblist->tree = gnt_tree_new();
 	GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER);
-	gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr) - 3);
+	gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr) - 4);
 
 	gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree);
 	gnt_widget_show(ggblist->window);
--- a/console/gntconv.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/gntconv.c	Thu Jul 06 17:54:46 2006 +0000
@@ -116,7 +116,7 @@
 	ggc->tv = gnt_text_view_new();
 	gnt_box_add_widget(GNT_BOX(ggc->window), ggc->tv);
 	gnt_widget_set_name(ggc->tv, "conversation-window-textview");
-	gnt_widget_set_size(ggc->tv, getmaxx(stdscr) - 2 - x - width, getmaxy(stdscr) - 4);
+	gnt_widget_set_size(ggc->tv, getmaxx(stdscr) - 3 - x - width, getmaxy(stdscr) - 5);
 
 	ggc->entry = gnt_entry_new(NULL);
 	gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry);
--- a/console/gntgaim.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/gntgaim.c	Thu Jul 06 17:54:46 2006 +0000
@@ -228,7 +228,7 @@
 	 */
 
 	/* Because we don't want debug-messages to show up and corrup the display */
-	gaim_debug_set_enabled(FALSE);
+	gaim_debug_set_enabled(debug_enabled);
 
 	gaim_core_set_ui_ops(gnt_core_get_ui_ops());
 	gaim_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops());
--- a/console/libgnt/Makefile.am	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/Makefile.am	Thu Jul 06 17:54:46 2006 +0000
@@ -40,4 +40,5 @@
 	-lncursesw -lpanelw
 
 AM_CPPFLAGS = \
-	$(GLIB_CFLAGS)
+	$(GLIB_CFLAGS) \
+	-Wall
--- a/console/libgnt/gnt.h	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/gnt.h	Thu Jul 06 17:54:46 2006 +0000
@@ -7,6 +7,8 @@
 
 void gnt_main();
 
+gboolean gnt_ascii_only();
+
 void gnt_screen_occupy(GntWidget *widget);
 
 void gnt_screen_release(GntWidget *widget);
--- a/console/libgnt/gntbox.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/gntbox.c	Thu Jul 06 17:54:46 2006 +0000
@@ -383,15 +383,18 @@
 	for (iter = box->list; iter; iter = iter->next)
 	{
 		GntWidget *w = GNT_WIDGET(iter->data);
+		int height, width;
 
 		if (GNT_IS_BOX(w))
 			gnt_box_sync_children(GNT_BOX(w));
 
+		gnt_widget_get_size(w, &width, &height);
+
 		copywin(w->window, widget->window, 0, 0,
 				w->priv.y - widget->priv.y,
 				w->priv.x - widget->priv.x,
-				w->priv.y - widget->priv.y + w->priv.height - 1,
-				w->priv.x - widget->priv.x + w->priv.width - 1,
+				w->priv.y - widget->priv.y + height - 1,
+				w->priv.x - widget->priv.x + width - 1,
 				FALSE);
 	}
 }
--- a/console/libgnt/gntmain.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/gntmain.c	Thu Jul 06 17:54:46 2006 +0000
@@ -20,6 +20,8 @@
 static int Y_MIN;
 static int Y_MAX;
 
+static gboolean ascii_only;
+
 static GMainLoop *loop;
 static struct
 {
@@ -314,10 +316,12 @@
 				}
 				else if (strcmp(buffer + 1, "m") == 0 && focus_list)
 				{
+					/* Move a window */
 					mode = GNT_KP_MODE_MOVE;
 				}
 				else if (strcmp(buffer + 1, "w") == 0 && focus_list)
 				{
+					/* Window list */
 					mode = GNT_KP_MODE_WINDOW_LIST;
 					show_window_list();
 				}
@@ -375,11 +379,11 @@
 
 			if (changed)
 			{
-				lock_focus_list = 1;
-				gnt_widget_hide(widget);
+				GntNode *node = g_hash_table_lookup(nodes, widget);
 				gnt_widget_set_position(widget, x, y);
-				gnt_widget_show(widget);
-				lock_focus_list = 0;
+				move_panel(node->panel, y, x);
+				update_panels();
+				doupdate();
 			}
 		}
 		else if (*buffer == '\r')
@@ -419,8 +423,13 @@
 	int result = g_io_add_watch(channel, 
 					(G_IO_IN | G_IO_HUP | G_IO_ERR),
 					io_invoke, NULL);
+	const char *locale = setlocale(LC_ALL, "");
 
-	setlocale(LC_ALL, "");
+	if (locale && (strstr(locale, "UTF") || strstr(locale, "utf")))
+		ascii_only = FALSE;
+	else
+		ascii_only = TRUE;
+
 	initscr();
 	start_color();
 	gnt_init_colors();
@@ -459,6 +468,7 @@
 free_node(gpointer data)
 {
 	GntNode *node = data;
+	hide_panel(node->panel);
 	del_panel(node->panel);
 	g_free(node);
 }
@@ -582,3 +592,8 @@
 	endwin();
 }
 
+gboolean gnt_ascii_only()
+{
+	return ascii_only;
+}
+
--- a/console/libgnt/gnttextview.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/gnttextview.c	Thu Jul 06 17:54:46 2006 +0000
@@ -152,7 +152,7 @@
 	GntTextView *view = GNT_TEXT_VIEW(widget);
 	GntTextLine *line = g_new0(GntTextLine, 1);
 
-	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER);
+	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
 
 	view->list = g_list_append(view->list, line);
 
@@ -198,7 +198,7 @@
 		{
 			GntTextSegment *seg = g_new0(GntTextSegment, 1);
 			seg->flags = fl;
-			seg->text = g_new0(char, len);		/* XXX: MUST be improved */
+			seg->text = g_new0(char, len + 1);		/* XXX: MUST be improved */
 			g_utf8_strncpy(seg->text, iter, widget->priv.width - line->length - 1);
 			line->segments = g_list_append(line->segments, seg);
 
--- a/console/libgnt/gnttree.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/gnttree.c	Thu Jul 06 17:54:46 2006 +0000
@@ -216,10 +216,14 @@
 			else
 				wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D));
 			mvwprintw(widget->window, start, pos, str);
+			whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1));
 			wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
 		}
 		else
+		{
 			mvwprintw(widget->window, start, pos, str);
+			whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1));
+		}
 		tree->bottom = row;
 	}
 
@@ -505,7 +509,7 @@
 	}
 	else
 	{
-		int position;
+		int position = 0;
 
 		if (bigbro)
 		{
@@ -671,7 +675,7 @@
 	GntTreeRow *row = g_hash_table_lookup(tree->hash, key);
 
 	if (!row)
-		return;
+		return FALSE;
 	g_return_val_if_fail(row->choice, FALSE);
 
 	return row->isselected;
--- a/console/libgnt/gntwidget.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/gntwidget.c	Thu Jul 06 17:54:46 2006 +0000
@@ -263,34 +263,32 @@
 
 	if (widget->window == NULL)
 	{
-		/* XXX: It may be necessary to make sure the size hasn't changed */
-		widget->window = newwin(widget->priv.height, widget->priv.width,
+		gboolean shadow = TRUE;
+
+		if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_SHADOW))
+			shadow = FALSE;
+		
+		widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow,
 						widget->priv.y, widget->priv.x);
 		wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL));
 
 		if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_NO_BORDER))
-			box(widget->window, 0, 0);
+		{
+			WINDOW *tmp = derwin(widget->window, widget->priv.height, widget->priv.width, 0, 0);
+			box(tmp, 0, 0);
+			delwin(tmp);
+		}
 		else
 			werase(widget->window);
+
+		if (shadow)
+		{
+			wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_SHADOW));
+			mvwvline(widget->window, 1, widget->priv.width, ' ', widget->priv.height);
+			mvwhline(widget->window, widget->priv.height, 1, ' ', widget->priv.width);
+		}
 	}
 
-#if 0
-	/* XXX: No shadow for now :( */
-	if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_NO_SHADOW))
-	{
-		widget->back = newwin(widget->priv.height, widget->priv.width,
-						widget->priv.y + 1, widget->priv.x + 1);
-		wbkgd(widget->back, COLOR_PAIR(GNT_COLOR_SHADOW));
-		werase(widget->back);
-
-		mvwchgat(widget->back, 0, 0, widget->priv.height,
-					A_REVERSE | A_BLINK, 0, 0);
-		touchline(widget->back, 0, widget->priv.height);
-		wrefresh(widget->back);
-	}
-
-	wrefresh(widget->window);
-#endif
 	g_signal_emit(widget, signals[SIG_DRAW], 0);
 	gnt_widget_queue_update(widget);
 	GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_DRAWING);
@@ -316,6 +314,11 @@
 gnt_widget_hide(GntWidget *widget)
 {
 	wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
+#if 1
+	/* XXX: I have no clue why, but this seems to be necessary. */
+	if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_SHADOW))
+		mvwvline(widget->window, 1, widget->priv.width, ' ', widget->priv.height);
+#endif
 	gnt_screen_release(widget);
 	GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_MAPPED);
 }
@@ -327,10 +330,6 @@
 	wid->priv.x = x;
 	wid->priv.y = y;
 	
-	/* XXX: I am supposed to move_panel ... but that seems to crash */
-	if (wid->window)
-		mvwin(wid->window, y, x);
-
 	g_signal_emit(wid, signals[SIG_POSITION], 0, x, y);
 }
 
@@ -352,10 +351,15 @@
 void
 gnt_widget_get_size(GntWidget *wid, int *width, int *height)
 {
+	gboolean shadow = TRUE;
+	if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_NO_SHADOW))
+		shadow = FALSE;
+
 	if (width)
-		*width = wid->priv.width;
+		*width = wid->priv.width + shadow;
 	if (height)
-		*height = wid->priv.height;
+		*height = wid->priv.height + shadow;
+	
 }
 
 void
--- a/console/libgnt/gntwidget.h	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/gntwidget.h	Thu Jul 06 17:54:46 2006 +0000
@@ -61,7 +61,6 @@
 
 	GntWidgetPriv priv;
 	WINDOW *window;
-	WINDOW *back;
 
     void (*gnt_reserved1)(void);
     void (*gnt_reserved2)(void);
--- a/console/libgnt/test/multiwin.c	Thu Jul 06 09:21:57 2006 +0000
+++ b/console/libgnt/test/multiwin.c	Thu Jul 06 17:54:46 2006 +0000
@@ -8,7 +8,6 @@
 
 gboolean show(GntWidget *w)
 {
-	gnt_widget_destroy(w);
 	return FALSE;
 }