From: Art Cancro Date: Sat, 19 May 2007 20:03:34 +0000 (+0000) Subject: Use the tabbed dialog API from tabs.c for X-Git-Tag: v7.86~3368 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=0a76cdaf6da64dacbc206dbb61c7725384aaa4b1 Use the tabbed dialog API from tabs.c for the address book --- diff --git a/webcit/messages.c b/webcit/messages.c index 9b60f23bc..52a1824ea 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1819,11 +1819,13 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) { int bg = 0; static int NAMESPERPAGE = 60; int num_pages = 0; - int page = 0; int tabfirst = 0; - char tabfirst_label[SIZ]; + char tabfirst_label[64]; int tablast = 0; - char tablast_label[SIZ]; + char tablast_label[64]; + char this_tablabel[64]; + int page = 0; + char **tablabels; if (num_ab == 0) { wprintf("


"); @@ -1836,66 +1838,70 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) { qsort(addrbook, num_ab, sizeof(struct addrbookent), abcmp); } - num_pages = num_ab / NAMESPERPAGE; + num_pages = (num_ab / NAMESPERPAGE) + 1; - page = atoi(bstr("page")); + tablabels = malloc(num_pages * sizeof (char *)); + if (tablabels == NULL) { + wprintf("


"); + wprintf(_("An internal error has occurred.")); + wprintf("
\n"); + return; + } - wprintf("Page: "); - for (i=0; i<=num_pages; ++i) { - if (i != page) { - wprintf("", i); - } - else { - wprintf(""); - } + for (i=0; i (num_ab - 1)) tablast = (num_ab - 1); nametab(tabfirst_label, addrbook[tabfirst].ab_name); nametab(tablast_label, addrbook[tablast].ab_name); - wprintf("[%s - %s]", - tabfirst_label, tablast_label - ); - if (i != page) { - wprintf("\n"); - } - else { - wprintf("\n"); - } + sprintf(this_tablabel, "%s - %s", tabfirst_label, tablast_label); + tablabels[i] = strdup(this_tablabel); } - wprintf("
\n"); - wprintf("\n" - ); + tabbed_dialog(num_pages, tablabels); + page = (-1); for (i=0; i 0) { + wprintf("
\n"); + end_tab(page-1, num_pages); + } + begin_tab(page, num_pages); + wprintf("\n"); + displayed = 0; + } - if ((displayed % 4) == 0) { - if (displayed > 0) { - wprintf("\n"); - } - bg = 1 - bg; - wprintf("", - (bg ? "DDDDDD" : "FFFFFF") - ); + if ((displayed % 4) == 0) { + if (displayed > 0) { + wprintf("\n"); } - - wprintf("\n"); - ++displayed; + bg = 1 - bg; + wprintf("", + (bg ? "DDDDDD" : "FFFFFF") + ); } + + wprintf("\n"); + ++displayed; } wprintf("
"); - - wprintf("", bstr("alpha")); - vcard_n_prettyize(addrbook[i].ab_name); - escputs(addrbook[i].ab_name); - wprintf("
"); + + wprintf("", bstr("alpha")); + vcard_n_prettyize(addrbook[i].ab_name); + escputs(addrbook[i].ab_name); + wprintf("
\n"); + end_tab((num_pages-1), num_pages); + + for (i=0; i\n", tabnum, num_tabs); wprintf("
", tabnum, ( (tabnum == 0) ? "block" : "none" ) @@ -70,7 +71,7 @@ void begin_tab(int tabnum, int num_tabs) { /** * \brief print the tab-footer * \param tabnum number of the tab to print - * \param num_tabs total number oftabs to be printed + * \param num_tabs total number of tabs to be printed */ void end_tab(int tabnum, int num_tabs) { wprintf("
\n"); @@ -82,7 +83,6 @@ void end_tab(int tabnum, int num_tabs) { " Nifty(\"table#TheTabs td\", \"small transparent top\");" "" ); - //" Nifty(\"td#tabtd1\", \"small transparent top\");" } }