Mercurial > pidgin
diff console/libgnt/gntmain.c @ 13897:eaaf73de9188
[gaim-migrate @ 16382]
I have added a sort of a taskbar, useful in showing the active windows.
I have also readjusted the blue color a little bit, since this is the
one I am using in a few places right now. And also getting rid of some
code-duplication.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 01 Jul 2006 04:24:31 +0000 |
parents | a621329e8c85 |
children | cc60d0861337 |
line wrap: on
line diff
--- a/console/libgnt/gntmain.c Sat Jul 01 00:56:05 2006 +0000 +++ b/console/libgnt/gntmain.c Sat Jul 01 04:24:31 2006 +0000 @@ -23,6 +23,7 @@ static GHashTable *nodes; static void free_node(gpointer data); +static void draw_taskbar(); void gnt_screen_take_focus(GntWidget *widget) { @@ -33,6 +34,7 @@ gnt_widget_set_focus(widget, TRUE); if (w) gnt_widget_set_focus(w, FALSE); + draw_taskbar(); } void gnt_screen_remove_widget(GntWidget *widget) @@ -43,6 +45,7 @@ gnt_widget_set_focus(focus_list->data, TRUE); gnt_widget_draw(focus_list->data); } + draw_taskbar(); } static void @@ -66,6 +69,53 @@ } } +static void +draw_taskbar() +{ + static WINDOW *taskbar = NULL; + GList *iter; + int n, width; + int i; + + if (taskbar == NULL) + { + taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); + } + + werase(taskbar); + + n = g_list_length(g_list_first(focus_list)); + if (n) + width = getmaxx(stdscr) / n; + + for (i = 0, iter = g_list_first(focus_list); iter; iter = iter->next, i++) + { + GntWidget *w = iter->data; + int color; + + if (w == focus_list->data) + { + /* This is the current window in focus */ + color = GNT_COLOR_TITLE; + GNT_WIDGET_UNSET_FLAGS(w, GNT_WIDGET_URGENT); + } + else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) + { + /* This is a window with the URGENT hint set */ + color = GNT_COLOR_TITLE_D; + } + else + { + color = GNT_COLOR_NORMAL; + } + wbkgdset(taskbar, '\0' | COLOR_PAIR(color)); + mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width); + mvwprintw(taskbar, 0, width * i, "%s", GNT_BOX(w)->title); + } + + wrefresh(taskbar); +} + static gboolean io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) { @@ -135,6 +185,8 @@ gnt_widget_set_focus(w, FALSE); } } + + draw_taskbar(); refresh(); return TRUE; @@ -345,3 +397,15 @@ return FALSE; } +void gnt_widget_set_urgent(GntWidget *widget) +{ + while (widget->parent) + widget = widget->parent; + + if (focus_list && focus_list->data == widget) + return; + + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT); + draw_taskbar(); +} +