From adb470c454338fd6e52528c22d44a26eb246732d Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 21 Jan 2016 00:50:55 +0000 Subject: [PATCH 1/8] WIP: Add /theme properties command --- src/command/command.c | 7 +- src/command/commands.c | 2 + src/ui/console.c | 100 ++++++++++++++++++++++++++++ src/ui/ui.h | 1 + src/ui/window.c | 4 ++ tests/unittests/ui/stub_ui.c | 1 + themes/bios | 125 +++++++++++++++++++++++++++++++++++ themes/boothj5 | 2 +- 8 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 themes/bios diff --git a/src/command/command.c b/src/command/command.c index 8bda6d4b..3f4e4a7d 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1727,13 +1727,15 @@ static struct cmd_t command_defs[] = CMD_SYN( "/theme list", "/theme load ", - "/theme colours") + "/theme colours", + "/theme properties") CMD_DESC( "Load a theme, includes colours and UI options.") CMD_ARGS( { "list", "List all available themes." }, { "load ", "Load the specified theme. 'default' will reset to the default theme." }, - { "colours", "Show the colour values as rendered by the terminal." }) + { "colours", "Show the colour values as rendered by the terminal." }, + { "properties", "Show each themed property." }) CMD_EXAMPLES( "/theme list", "/theme load forest") @@ -2106,6 +2108,7 @@ cmd_init(void) autocomplete_add(theme_ac, "load"); autocomplete_add(theme_ac, "list"); autocomplete_add(theme_ac, "colours"); + autocomplete_add(theme_ac, "properties"); disco_ac = autocomplete_new(); autocomplete_add(disco_ac, "info"); diff --git a/src/command/commands.c b/src/command/commands.c index ba84b4bc..7679acb4 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1401,6 +1401,8 @@ cmd_theme(ProfWin *window, const char *const command, gchar **args) // show colours } else if (g_strcmp0(args[0], "colours") == 0) { cons_theme_colours(); + } else if (g_strcmp0(args[0], "properties") == 0) { + cons_theme_properties(); } else { cons_bad_cmd_usage(command); } diff --git a/src/ui/console.c b/src/ui/console.c index 39de1ae7..f4cf3d44 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2003,6 +2003,106 @@ cons_get_string(ProfConsoleWin *conswin) return strdup("Console"); } +void +cons_theme_properties(void) +{ + ProfWin *console = wins_get_console(); + cons_show("Title bar:"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_TEXT, "", "titlebar.text "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_BRACKET, "", "titlebar.brackets"); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_UNENCRYPTED, "", "titlebar.unencrypted "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_ENCRYPTED, "", "titlebar.encrypted "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_UNTRUSTED, "", "titlebar.untrusted "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_TRUSTED, "", "titlebar.trusted"); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_CHAT, "", "titlebar.chat "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_ONLINE, "", "titlebar.online "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_AWAY, "", "titlebar.away "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_XA, "", "titlebar.xa "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_DND, "", "titlebar.dnd "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_OFFLINE, "", "titlebar.offline"); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + + cons_show(""); + cons_show("Status bar:"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_TEXT, "", "statusbar.text "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_STATUS_BRACKET, "", "statusbar.brackets "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_STATUS_ACTIVE, "", "statusbar.active "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_STATUS_NEW, "", "statusbar.new"); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + + cons_show(""); + cons_show("Main text:"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TIME, "", "main.time "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TEXT, "", "main.text "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_SPLASH, "", "main.splash "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_ERROR, "", "error"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_OTR_STARTED_TRUSTED, "", "otr.started.trusted "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_OTR_STARTED_UNTRUSTED, "", "otr.started.untrusted "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_OTR_ENDED, "", "otr.ended "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_OTR_TRUSTED, "", "otr.trusted "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_OTR_UNTRUSTED, "", "otr.untrusted"); + + cons_show(""); + cons_show("Messages:"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_ME, "", "me "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT_ME, "", "main.text.me"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_THEM, "", "them "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT_THEM, "", "main.text.them"); + + cons_show(""); + cons_show("Presence:"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_CHAT, "", "chat "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "online "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_AWAY, "", "away "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_XA, "", "xa "); + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DND, "", "dnd "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "offline"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_SUBSCRIBED, "", "subscribed "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_UNSUBSCRIBED, "", "unsubscribed"); + + cons_show(""); + win_print(console, '-', 0, NULL, 0, THEME_INCOMING, "", "incoming"); + win_print(console, '-', 0, NULL, 0, THEME_TYPING, "", "typing"); + win_print(console, '-', 0, NULL, 0, THEME_GONE, "", "gone"); + + win_print(console, '-', 0, NULL, 0, THEME_ROOMINFO, "", "roominfo"); + win_print(console, '-', 0, NULL, 0, THEME_ROOMMENTION, "", "roommention"); + + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_HEADER, "", "roster.header"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT, "", "roster.chat"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE, "", "roster.online"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY, "", "roster.away"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA, "", "roster.xa"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND, "", "roster.dnd"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE, "", "roster.offline"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_ACTIVE, "", "roster.chat.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_ACTIVE, "", "roster.online.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_ACTIVE, "", "roster.away.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_ACTIVE, "", "roster.xa.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_ACTIVE, "", "roster.dnd.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_ACTIVE, "", "roster.offline.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_UNREAD, "", "roster.chat.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_UNREAD, "", "roster.online.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_UNREAD, "", "roster.away.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_UNREAD, "", "roster.xa.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_UNREAD, "", "roster.dnd.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_UNREAD, "", "roster.offline.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM, "", "roster.room"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM_UNREAD, "", "roster.room.unread"); + + win_print(console, '-', 0, NULL, 0, THEME_OCCUPANTS_HEADER, "", "occupants.header"); + + win_print(console, '-', 0, NULL, 0, THEME_RECEIPT_SENT, "", "receipt.sent"); + + win_print(console, '-', 0, NULL, 0, THEME_INPUT_TEXT, "", "input.text"); + + cons_show(""); +} + void cons_theme_colours(void) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 6398381d..8fea6eb1 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -301,6 +301,7 @@ void cons_autoconnect_setting(void); void cons_inpblock_setting(void); void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); void cons_show_contact_offline(PContact contact, char *resource, char *status); +void cons_theme_properties(void); void cons_theme_colours(void); void cons_show_tlscert(TLSCertificate *cert); void cons_show_tlscert_summary(TLSCertificate *cert); diff --git a/src/ui/window.c b/src/ui/window.c index 33db89c6..d749ac84 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1086,6 +1086,7 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim if ((flags & NO_DATE) == 0) { if (date_fmt && strlen(date_fmt)) { if ((flags & NO_COLOUR_DATE) == 0) { + wbkgdset(window->layout->win, theme_attrs(THEME_TIME)); wattron(window->layout->win, theme_attrs(THEME_TIME)); } wprintw(window->layout->win, "%s %c ", date_fmt, show_char); @@ -1108,6 +1109,7 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim colour = theme_attrs(THEME_RECEIPT_SENT); } + wbkgdset(window->layout->win, colour); wattron(window->layout->win, colour); if (strncmp(message, "/me ", 4) == 0) { wprintw(window->layout->win, "*%s ", from); @@ -1121,8 +1123,10 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim if (!me_message) { if (receipt && !receipt->received) { + wbkgdset(window->layout->win, theme_attrs(THEME_RECEIPT_SENT)); wattron(window->layout->win, theme_attrs(THEME_RECEIPT_SENT)); } else { + wbkgdset(window->layout->win, theme_attrs(theme_item)); wattron(window->layout->win, theme_attrs(theme_item)); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 019ea84e..4235e10f 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -444,6 +444,7 @@ void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *l void cons_show_contact_offline(PContact contact, char *resource, char *status) {} void cons_theme_colours(void) {} +void cons_theme_properties(void) {} // title bar void title_bar_set_presence(contact_presence_t presence) {} diff --git a/themes/bios b/themes/bios new file mode 100644 index 00000000..28239599 --- /dev/null +++ b/themes/bios @@ -0,0 +1,125 @@ +[colours] +bkgnd=blue +titlebar=white +titlebar.text=black +titlebar.brackets=black +titlebar.unencrypted=black +titlebar.encrypted=black +titlebar.untrusted=black +titlebar.trusted=black +titlebar.online=black +titlebar.offline=black +titlebar.away=black +titlebar.xa=black +titlebar.dnd=black +titlebar.chat=black +statusbar=white +statusbar.text=black +statusbar.brackets=black +statusbar.active=black +statusbar.new=black +main.text=white +main.text.me=cyan +main.text.them=bold_white +main.splash=bold_green +main.time=bold_cyan +input.text=bold_white +subscribed=bold_green +unsubscribed=red +otr.started.trusted=green +otr.started.untrusted=yellow +otr.ended=red +otr.trusted=green +otr.untrusted=yellow +online=bold_green +away=bold_cyan +chat=bold_white +dnd=magenta +xa=bold_blue +offline=red +incoming=bold_yellow +typing=yellow +gone=red +error=red +roominfo=yellow +roommention=bold_red +me=blue +them=bold_green +roster.header=bold_yellow +roster.chat=white +roster.online=green +roster.away=cyan +roster.xa=blue +roster.dnd=magenta +roster.offline=red +roster.chat.active=white +roster.online.active=green +roster.away.active=cyan +roster.xa.active=blue +roster.dnd.active=magenta +roster.offline.active=red +roster.chat.unread=bold_white +roster.online.unread=bold_green +roster.away.unread=bold_cyan +roster.xa.unread=bold_blue +roster.dnd.unread=bold_magenta +roster.offline.unread=bold_red +roster.room=green +roster.room.unread=bold_green +occupants.header=bold_yellow +receipt.sent=bold_black + +[ui] +beep=false +flash=false +splash=true +wrap=true +time.console=%H:%M:%S +time.chat=%d/%m/%y %H:%M:%S +time.muc=%d/%m/%y %H:%M:%S +time.mucconfig=off +time.private=%d/%m/%y %H:%M:%S +time.xml=%H:%M:%S +time.statusbar=%H:%M:%S +time.lastactivity=%d/%m/%y %H:%M:%S +privileges=true +presence=true +intype=true +enc.warn=true +resource.title=true +resource.message=true +statuses.console=all +statuses.chat=all +statuses.muc=none +roster=true +roster.offline=true +roster.empty=false +roster.by=group +roster.order=presence +roster.unread=before +roster.count=true +roster.priority=false +roster.size=25 +roster.wrap=true +roster.header.char=@ +roster.contact.indent=1 +roster.resource=true +roster.resource.char=/ +roster.resource.indent=1 +roster.resource.join=true +roster.presence=true +roster.presence.indent=-1 +roster.status=true +roster.contacts=true +roster.rooms=true +roster.rooms.order=name +roster.rooms.unread=before +roster.rooms.pos=last +occupants=true +occupants.size=15 +occupants.jid=false +wins.autotidy=true +otr.char=@ +pgp.char=% +tls.show=true +console.muc=first diff --git a/themes/boothj5 b/themes/boothj5 index 0576fc91..54f186b3 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -1,7 +1,7 @@ [colours] bkgnd=default titlebar=blue -titlebar.text=bold_white +titlebar.text=white titlebar.brackets=white titlebar.unencrypted=bold_red titlebar.encrypted=bold_white From 6b65a9be15bf77ce92ee9892b9e199bebd54dd88 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 21 Jan 2016 01:30:18 +0000 Subject: [PATCH 2/8] Tidied theme properties --- src/ui/console.c | 163 ++++++++++++++++++++++++----------------------- themes/bios | 2 +- 2 files changed, 84 insertions(+), 81 deletions(-) diff --git a/src/ui/console.c b/src/ui/console.c index f4cf3d44..fb55bed2 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2007,98 +2007,101 @@ void cons_theme_properties(void) { ProfWin *console = wins_get_console(); - cons_show("Title bar:"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_TEXT, "", "titlebar.text "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_BRACKET, "", "titlebar.brackets"); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_UNENCRYPTED, "", "titlebar.unencrypted "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_ENCRYPTED, "", "titlebar.encrypted "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_UNTRUSTED, "", "titlebar.untrusted "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_TRUSTED, "", "titlebar.trusted"); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_TEXT, "", " titlebar.text "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_BRACKET, "", " titlebar.brackets "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_CHAT, "", "titlebar.chat "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_ONLINE, "", "titlebar.online "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_AWAY, "", "titlebar.away "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_XA, "", "titlebar.xa "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_DND, "", "titlebar.dnd "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TITLE_OFFLINE, "", "titlebar.offline"); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_UNENCRYPTED, "", " titlebar.unencrypted "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_ENCRYPTED, "", " titlebar.encrypted "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_UNTRUSTED, "", " titlebar.untrusted "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_TRUSTED, "", " titlebar.trusted "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - cons_show(""); - cons_show("Status bar:"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_TEXT, "", "statusbar.text "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_STATUS_BRACKET, "", "statusbar.brackets "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_STATUS_ACTIVE, "", "statusbar.active "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_STATUS_NEW, "", "statusbar.new"); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_CHAT, "", " titlebar.chat "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_ONLINE, "", " titlebar.online "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_AWAY, "", " titlebar.away "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_XA, "", " titlebar.xa "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_DND, "", " titlebar.dnd "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_OFFLINE, "", " titlebar.offline "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - cons_show(""); - cons_show("Main text:"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TIME, "", "main.time "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_TEXT, "", "main.text "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_SPLASH, "", "main.splash "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_ERROR, "", "error"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_OTR_STARTED_TRUSTED, "", "otr.started.trusted "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_OTR_STARTED_UNTRUSTED, "", "otr.started.untrusted "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_OTR_ENDED, "", "otr.ended "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_OTR_TRUSTED, "", "otr.trusted "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_OTR_UNTRUSTED, "", "otr.untrusted"); + win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_TEXT, "", " statusbar.text "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_BRACKET, "", " statusbar.brackets "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_ACTIVE, "", " statusbar.active "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_NEW, "", " statusbar.new "); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - cons_show(""); - cons_show("Messages:"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_ME, "", "me "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT_ME, "", "main.text.me"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_THEM, "", "them "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT_THEM, "", "main.text.them"); + win_print(console, '-', 0, NULL, 0, THEME_TIME, "", "main.time"); + win_print(console, '-', 0, NULL, 0, THEME_TEXT, "", "main.text"); + win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "main.splash"); + win_print(console, '-', 0, NULL, 0, THEME_ERROR, "", "error"); + win_print(console, '-', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "otr.started.trusted"); + win_print(console, '-', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "otr.started.untrusted"); + win_print(console, '-', 0, NULL, 0, THEME_OTR_ENDED, "", "otr.ended"); + win_print(console, '-', 0, NULL, 0, THEME_OTR_TRUSTED, "", "otr.trusted"); + win_print(console, '-', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "otr.untrusted"); - cons_show(""); - cons_show("Presence:"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_CHAT, "", "chat "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "online "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_AWAY, "", "away "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_XA, "", "xa "); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DND, "", "dnd "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "offline"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_SUBSCRIBED, "", "subscribed "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_UNSUBSCRIBED, "", "unsubscribed"); + win_print(console, '-', 0, NULL, 0, THEME_ME, "", "me"); + win_print(console, '-', 0, NULL, 0, THEME_TEXT_ME, "", "main.text.me"); + win_print(console, '-', 0, NULL, 0, THEME_THEM, "", "them"); + win_print(console, '-', 0, NULL, 0, THEME_TEXT_THEM, "", "main.text.them"); - cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_INCOMING, "", "incoming"); - win_print(console, '-', 0, NULL, 0, THEME_TYPING, "", "typing"); - win_print(console, '-', 0, NULL, 0, THEME_GONE, "", "gone"); + win_print(console, '-', 0, NULL, 0, THEME_CHAT, "", "chat"); + win_print(console, '-', 0, NULL, 0, THEME_ONLINE, "", "online"); + win_print(console, '-', 0, NULL, 0, THEME_AWAY, "", "away"); + win_print(console, '-', 0, NULL, 0, THEME_XA, "", "xa"); + win_print(console, '-', 0, NULL, 0, THEME_DND, "", "dnd"); + win_print(console, '-', 0, NULL, 0, THEME_OFFLINE, "", "offline"); + win_print(console, '-', 0, NULL, 0, THEME_SUBSCRIBED, "", "subscribed"); + win_print(console, '-', 0, NULL, 0, THEME_UNSUBSCRIBED, "", "unsubscribed"); - win_print(console, '-', 0, NULL, 0, THEME_ROOMINFO, "", "roominfo"); - win_print(console, '-', 0, NULL, 0, THEME_ROOMMENTION, "", "roommention"); + win_print(console, '-', 0, NULL, 0, THEME_INCOMING, "", "incoming"); + win_print(console, '-', 0, NULL, 0, THEME_TYPING, "", "typing"); + win_print(console, '-', 0, NULL, 0, THEME_GONE, "", "gone"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_HEADER, "", "roster.header"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT, "", "roster.chat"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE, "", "roster.online"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY, "", "roster.away"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA, "", "roster.xa"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND, "", "roster.dnd"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE, "", "roster.offline"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_ACTIVE, "", "roster.chat.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_ACTIVE, "", "roster.online.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_ACTIVE, "", "roster.away.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_ACTIVE, "", "roster.xa.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_ACTIVE, "", "roster.dnd.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_ACTIVE, "", "roster.offline.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_UNREAD, "", "roster.chat.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_UNREAD, "", "roster.online.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_UNREAD, "", "roster.away.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_UNREAD, "", "roster.xa.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_UNREAD, "", "roster.dnd.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_UNREAD, "", "roster.offline.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM, "", "roster.room"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM_UNREAD, "", "roster.room.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROOMINFO, "", "roominfo"); + win_print(console, '-', 0, NULL, 0, THEME_ROOMMENTION, "", "roommention"); - win_print(console, '-', 0, NULL, 0, THEME_OCCUPANTS_HEADER, "", "occupants.header"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_HEADER, "", "roster.header"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT, "", "roster.chat"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE, "", "roster.online"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY, "", "roster.away"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA, "", "roster.xa"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND, "", "roster.dnd"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE, "", "roster.offline"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_ACTIVE, "", "roster.chat.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_ACTIVE, "", "roster.online.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_ACTIVE, "", "roster.away.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_ACTIVE, "", "roster.xa.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_ACTIVE, "", "roster.dnd.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_ACTIVE, "", "roster.offline.active"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_UNREAD, "", "roster.chat.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_UNREAD, "", "roster.online.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_UNREAD, "", "roster.away.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_UNREAD, "", "roster.xa.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_UNREAD, "", "roster.dnd.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_UNREAD, "", "roster.offline.unread"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM, "", "roster.room"); + win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM_UNREAD, "", "roster.room.unread"); - win_print(console, '-', 0, NULL, 0, THEME_RECEIPT_SENT, "", "receipt.sent"); + win_print(console, '-', 0, NULL, 0, THEME_OCCUPANTS_HEADER, "", "occupants.header"); - win_print(console, '-', 0, NULL, 0, THEME_INPUT_TEXT, "", "input.text"); + win_print(console, '-', 0, NULL, 0, THEME_RECEIPT_SENT, "", "receipt.sent"); + + win_print(console, '-', 0, NULL, 0, THEME_INPUT_TEXT, "", "input.text"); cons_show(""); } diff --git a/themes/bios b/themes/bios index 28239599..66d138bc 100644 --- a/themes/bios +++ b/themes/bios @@ -22,7 +22,7 @@ main.text=white main.text.me=cyan main.text.them=bold_white main.splash=bold_green -main.time=bold_cyan +main.time=black input.text=bold_white subscribed=bold_green unsubscribed=red From 37171fe692facfe34cf48ffca443048da9328974 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 21 Jan 2016 02:00:12 +0000 Subject: [PATCH 3/8] Show theme colour value --- src/config/preferences.c | 1 - src/config/theme.c | 14 ++++ src/config/theme.h | 3 +- src/ui/console.c | 173 ++++++++++++++++++++------------------- 4 files changed, 106 insertions(+), 85 deletions(-) diff --git a/src/config/preferences.c b/src/config/preferences.c index 02bf959e..51c72095 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -404,7 +404,6 @@ prefs_free_string(char *pref) } } - void prefs_set_string(preference_t pref, char *value) { diff --git a/src/config/theme.c b/src/config/theme.c index 3d28a129..08c2b5a2 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -557,6 +557,20 @@ _theme_prep_fgnd(char *setting, char *def, GString *lookup_str, gboolean *bold) g_free(val); } +char* +theme_get_string(char *str) +{ + return g_key_file_get_string(theme, "colours", str, NULL); +} + +void +theme_free_string(char *str) +{ + if (str) { + g_free(str); + } +} + int theme_attrs(theme_item_t attrs) { diff --git a/src/config/theme.h b/src/config/theme.h index 7b86d1a7..3c0f0fa9 100644 --- a/src/config/theme.h +++ b/src/config/theme.h @@ -131,7 +131,8 @@ gboolean theme_load(const char *const theme_name); GSList* theme_list(void); void theme_close(void); int theme_attrs(theme_item_t attrs); - +char* theme_get_string(char *str); +void theme_free_string(char *str); theme_item_t theme_main_presence_attrs(const char *const presence); theme_item_t theme_roster_unread_presence_attrs(const char *const presence); theme_item_t theme_roster_active_presence_attrs(const char *const presence); diff --git a/src/ui/console.c b/src/ui/console.c index fb55bed2..260f6d6d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2004,104 +2004,111 @@ cons_get_string(ProfConsoleWin *conswin) } void -cons_theme_properties(void) +_cons_theme_bar_prop(theme_item_t theme, char *prop) { ProfWin *console = wins_get_console(); + GString *str = g_string_new(" "); + char *setting = theme_get_string(prop); + g_string_append_printf(str, "%s=%s ", prop, setting); + theme_free_string(setting); + win_print(console, '-', 0, NULL, NO_EOL, theme, "", str->str); + win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + g_string_free(str, TRUE); +} - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_TEXT, "", " titlebar.text "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_BRACKET, "", " titlebar.brackets "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); +void +_cons_theme_prop(theme_item_t theme, char *prop) +{ + ProfWin *console = wins_get_console(); + GString *str = g_string_new(prop); + char *setting = theme_get_string(prop); + g_string_append_printf(str, "=%s", setting); + theme_free_string(setting); + win_print(console, '-', 0, NULL, 0, theme, "", str->str); + g_string_free(str, TRUE); +} - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_UNENCRYPTED, "", " titlebar.unencrypted "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_ENCRYPTED, "", " titlebar.encrypted "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_UNTRUSTED, "", " titlebar.untrusted "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_TRUSTED, "", " titlebar.trusted "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); +void +cons_theme_properties(void) +{ + _cons_theme_bar_prop(THEME_TITLE_TEXT, "titlebar.text"); + _cons_theme_bar_prop(THEME_TITLE_BRACKET, "titlebar.brackets"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_CHAT, "", " titlebar.chat "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_ONLINE, "", " titlebar.online "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_AWAY, "", " titlebar.away "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_XA, "", " titlebar.xa "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_DND, "", " titlebar.dnd "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TITLE_OFFLINE, "", " titlebar.offline "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + _cons_theme_bar_prop(THEME_TITLE_UNENCRYPTED, "titlebar.unencrypted"); + _cons_theme_bar_prop(THEME_TITLE_ENCRYPTED, "titlebar.encrypted"); + _cons_theme_bar_prop(THEME_TITLE_UNTRUSTED, "titlebar.untrusted"); + _cons_theme_bar_prop(THEME_TITLE_TRUSTED, "titlebar.trusted"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_TEXT, "", " statusbar.text "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_BRACKET, "", " statusbar.brackets "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_ACTIVE, "", " statusbar.active "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); - win_print(console, '-', 0, NULL, NO_EOL, THEME_STATUS_NEW, "", " statusbar.new "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + _cons_theme_bar_prop(THEME_TITLE_CHAT, "titlebar.chat"); + _cons_theme_bar_prop(THEME_TITLE_ONLINE, "titlebar.online"); + _cons_theme_bar_prop(THEME_TITLE_AWAY, "titlebar.away"); + _cons_theme_bar_prop(THEME_TITLE_XA, "titlebar.xa"); + _cons_theme_bar_prop(THEME_TITLE_DND, "titlebar.dnd"); + _cons_theme_bar_prop(THEME_TITLE_OFFLINE, "titlebar.offline"); - win_print(console, '-', 0, NULL, 0, THEME_TIME, "", "main.time"); - win_print(console, '-', 0, NULL, 0, THEME_TEXT, "", "main.text"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "main.splash"); - win_print(console, '-', 0, NULL, 0, THEME_ERROR, "", "error"); - win_print(console, '-', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "otr.started.trusted"); - win_print(console, '-', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "otr.started.untrusted"); - win_print(console, '-', 0, NULL, 0, THEME_OTR_ENDED, "", "otr.ended"); - win_print(console, '-', 0, NULL, 0, THEME_OTR_TRUSTED, "", "otr.trusted"); - win_print(console, '-', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "otr.untrusted"); + _cons_theme_bar_prop(THEME_STATUS_TEXT, "statusbar.text"); + _cons_theme_bar_prop(THEME_STATUS_BRACKET, "statusbar.brackets"); + _cons_theme_bar_prop(THEME_STATUS_ACTIVE, "statusbar.active"); + _cons_theme_bar_prop(THEME_STATUS_NEW, "statusbar.new"); - win_print(console, '-', 0, NULL, 0, THEME_ME, "", "me"); - win_print(console, '-', 0, NULL, 0, THEME_TEXT_ME, "", "main.text.me"); - win_print(console, '-', 0, NULL, 0, THEME_THEM, "", "them"); - win_print(console, '-', 0, NULL, 0, THEME_TEXT_THEM, "", "main.text.them"); + _cons_theme_prop(THEME_TIME, "main.time"); + _cons_theme_prop(THEME_TEXT, "main.text"); + _cons_theme_prop(THEME_SPLASH, "main.splash"); + _cons_theme_prop(THEME_ERROR, "error"); + _cons_theme_prop(THEME_OTR_STARTED_TRUSTED, "otr.started.trusted"); + _cons_theme_prop(THEME_OTR_STARTED_UNTRUSTED, "otr.started.untrusted"); + _cons_theme_prop(THEME_OTR_ENDED, "otr.ended"); + _cons_theme_prop(THEME_OTR_TRUSTED, "otr.trusted"); + _cons_theme_prop(THEME_OTR_UNTRUSTED, "otr.untrusted"); - win_print(console, '-', 0, NULL, 0, THEME_CHAT, "", "chat"); - win_print(console, '-', 0, NULL, 0, THEME_ONLINE, "", "online"); - win_print(console, '-', 0, NULL, 0, THEME_AWAY, "", "away"); - win_print(console, '-', 0, NULL, 0, THEME_XA, "", "xa"); - win_print(console, '-', 0, NULL, 0, THEME_DND, "", "dnd"); - win_print(console, '-', 0, NULL, 0, THEME_OFFLINE, "", "offline"); - win_print(console, '-', 0, NULL, 0, THEME_SUBSCRIBED, "", "subscribed"); - win_print(console, '-', 0, NULL, 0, THEME_UNSUBSCRIBED, "", "unsubscribed"); + _cons_theme_prop(THEME_ME, "me"); + _cons_theme_prop(THEME_TEXT_ME, "main.text.me"); + _cons_theme_prop(THEME_THEM, "them"); + _cons_theme_prop(THEME_TEXT_THEM, "main.text.them"); - win_print(console, '-', 0, NULL, 0, THEME_INCOMING, "", "incoming"); - win_print(console, '-', 0, NULL, 0, THEME_TYPING, "", "typing"); - win_print(console, '-', 0, NULL, 0, THEME_GONE, "", "gone"); + _cons_theme_prop(THEME_CHAT, "chat"); + _cons_theme_prop(THEME_ONLINE, "online"); + _cons_theme_prop(THEME_AWAY, "away"); + _cons_theme_prop(THEME_XA, "xa"); + _cons_theme_prop(THEME_DND, "dnd"); + _cons_theme_prop(THEME_OFFLINE, "offline"); + _cons_theme_prop(THEME_SUBSCRIBED, "subscribed"); + _cons_theme_prop(THEME_UNSUBSCRIBED, "unsubscribed"); - win_print(console, '-', 0, NULL, 0, THEME_ROOMINFO, "", "roominfo"); - win_print(console, '-', 0, NULL, 0, THEME_ROOMMENTION, "", "roommention"); + _cons_theme_prop(THEME_INCOMING, "incoming"); + _cons_theme_prop(THEME_TYPING, "typing"); + _cons_theme_prop(THEME_GONE, "gone"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_HEADER, "", "roster.header"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT, "", "roster.chat"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE, "", "roster.online"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY, "", "roster.away"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA, "", "roster.xa"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND, "", "roster.dnd"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE, "", "roster.offline"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_ACTIVE, "", "roster.chat.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_ACTIVE, "", "roster.online.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_ACTIVE, "", "roster.away.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_ACTIVE, "", "roster.xa.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_ACTIVE, "", "roster.dnd.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_ACTIVE, "", "roster.offline.active"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_CHAT_UNREAD, "", "roster.chat.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ONLINE_UNREAD, "", "roster.online.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_AWAY_UNREAD, "", "roster.away.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_XA_UNREAD, "", "roster.xa.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_DND_UNREAD, "", "roster.dnd.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_OFFLINE_UNREAD, "", "roster.offline.unread"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM, "", "roster.room"); - win_print(console, '-', 0, NULL, 0, THEME_ROSTER_ROOM_UNREAD, "", "roster.room.unread"); + _cons_theme_prop(THEME_ROOMINFO, "roominfo"); + _cons_theme_prop(THEME_ROOMMENTION, "roommention"); - win_print(console, '-', 0, NULL, 0, THEME_OCCUPANTS_HEADER, "", "occupants.header"); + _cons_theme_prop(THEME_ROSTER_HEADER, "roster.header"); + _cons_theme_prop(THEME_ROSTER_CHAT, "roster.chat"); + _cons_theme_prop(THEME_ROSTER_ONLINE, "roster.online"); + _cons_theme_prop(THEME_ROSTER_AWAY, "roster.away"); + _cons_theme_prop(THEME_ROSTER_XA, "roster.xa"); + _cons_theme_prop(THEME_ROSTER_DND, "roster.dnd"); + _cons_theme_prop(THEME_ROSTER_OFFLINE, "roster.offline"); + _cons_theme_prop(THEME_ROSTER_CHAT_ACTIVE, "roster.chat.active"); + _cons_theme_prop(THEME_ROSTER_ONLINE_ACTIVE, "roster.online.active"); + _cons_theme_prop(THEME_ROSTER_AWAY_ACTIVE, "roster.away.active"); + _cons_theme_prop(THEME_ROSTER_XA_ACTIVE, "roster.xa.active"); + _cons_theme_prop(THEME_ROSTER_DND_ACTIVE, "roster.dnd.active"); + _cons_theme_prop(THEME_ROSTER_OFFLINE_ACTIVE, "roster.offline.active"); + _cons_theme_prop(THEME_ROSTER_CHAT_UNREAD, "roster.chat.unread"); + _cons_theme_prop(THEME_ROSTER_ONLINE_UNREAD, "roster.online.unread"); + _cons_theme_prop(THEME_ROSTER_AWAY_UNREAD, "roster.away.unread"); + _cons_theme_prop(THEME_ROSTER_XA_UNREAD, "roster.xa.unread"); + _cons_theme_prop(THEME_ROSTER_DND_UNREAD, "roster.dnd.unread"); + _cons_theme_prop(THEME_ROSTER_OFFLINE_UNREAD, "roster.offline.unread"); + _cons_theme_prop(THEME_ROSTER_ROOM, "roster.room"); + _cons_theme_prop(THEME_ROSTER_ROOM_UNREAD, "roster.room.unread"); - win_print(console, '-', 0, NULL, 0, THEME_RECEIPT_SENT, "", "receipt.sent"); + _cons_theme_prop(THEME_OCCUPANTS_HEADER, "occupants.header"); - win_print(console, '-', 0, NULL, 0, THEME_INPUT_TEXT, "", "input.text"); + _cons_theme_prop(THEME_RECEIPT_SENT, "receipt.sent"); + + _cons_theme_prop(THEME_INPUT_TEXT, "input.text"); cons_show(""); } From 72bbb5c2b9953237c39c4003cabb95ad420afe64 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 21 Jan 2016 23:59:45 +0000 Subject: [PATCH 4/8] Keep cache of default theme properties --- src/config/theme.c | 80 +++++++++++++++++++++++++++++++++++++++++++++- themes/boothj5 | 6 ++-- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/config/theme.c b/src/config/theme.c index 08c2b5a2..b9397a18 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -53,6 +53,7 @@ static GString *theme_loc; static GKeyFile *theme; static GHashTable *bold_items; static GHashTable *str_to_pair; +static GHashTable *defaults; struct colour_string_t { char *str; @@ -73,6 +74,74 @@ theme_init(const char *const theme_name) } str_to_pair = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + defaults = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + + g_hash_table_insert(defaults, strdup("main.text"), strdup("white")); + g_hash_table_insert(defaults, strdup("main.text.me"), strdup("white")); + g_hash_table_insert(defaults, strdup("main.text.them"), strdup("white")); + g_hash_table_insert(defaults, strdup("main.splash"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("error"), strdup("red")); + g_hash_table_insert(defaults, strdup("incoming"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("input.text"), strdup("white")); + g_hash_table_insert(defaults, strdup("main.time"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.text"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.brackets"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("titlebar.unencrypted"), strdup("red")); + g_hash_table_insert(defaults, strdup("titlebar.encrypted"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.untrusted"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("titlebar.trusted"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.online"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.offline"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.away"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.chat"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.dnd"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.xa"), strdup("white")); + g_hash_table_insert(defaults, strdup("statusbar.text"), strdup("white")); + g_hash_table_insert(defaults, strdup("statusbar.brackets"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("statusbar.active"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("statusbar.new"), strdup("white")); + g_hash_table_insert(defaults, strdup("me"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("them"), strdup("green")); + g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red")); + g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("online"), strdup("green")); + g_hash_table_insert(defaults, strdup("offline"), strdup("red")); + g_hash_table_insert(defaults, strdup("away"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("chat"), strdup("green")); + g_hash_table_insert(defaults, strdup("dnd"), strdup("red")); + g_hash_table_insert(defaults, strdup("xa"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("typing"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("gone"), strdup("red")); + g_hash_table_insert(defaults, strdup("subscribed"), strdup("green")); + g_hash_table_insert(defaults, strdup("unsubscribed"), strdup("red")); + g_hash_table_insert(defaults, strdup("otr.started.trusted"), strdup("green")); + g_hash_table_insert(defaults, strdup("otr.started.untrusted"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("otr.ended"), strdup("red")); + g_hash_table_insert(defaults, strdup("otr.trusted"), strdup("green")); + g_hash_table_insert(defaults, strdup("otr.untrusted"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roster.header"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roster.online"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.offline"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.chat"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.away"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.dnd"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.xa"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.online.active"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.offline.active"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.chat.active"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.away.active"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.dnd.active"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.xa.active"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.online.unread"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.offline.unread"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.chat.unread"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.away.unread"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.dnd.unread"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.xa.unread"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.room"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.room.unread"), strdup("green")); + g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow")); } gboolean @@ -152,6 +221,10 @@ theme_close(void) g_hash_table_destroy(str_to_pair); str_to_pair = NULL; } + if (defaults) { + g_hash_table_destroy(defaults); + defaults = NULL; + } } static void @@ -560,7 +633,12 @@ _theme_prep_fgnd(char *setting, char *def, GString *lookup_str, gboolean *bold) char* theme_get_string(char *str) { - return g_key_file_get_string(theme, "colours", str, NULL); + char *res = g_key_file_get_string(theme, "colours", str, NULL); + if (!res) { + return strdup(g_hash_table_lookup(defaults, str)); + } else { + return res; + } } void diff --git a/themes/boothj5 b/themes/boothj5 index 54f186b3..618f7a43 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -1,8 +1,8 @@ [colours] bkgnd=default titlebar=blue -titlebar.text=white -titlebar.brackets=white +titlebar.text=bold_white +titlebar.brackets=bold_white titlebar.unencrypted=bold_red titlebar.encrypted=bold_white titlebar.untrusted=bold_yellow @@ -15,7 +15,7 @@ titlebar.dnd=bold_red titlebar.chat=bold_green statusbar=blue statusbar.text=bold_white -statusbar.brackets=white +statusbar.brackets=bold_white statusbar.active=bold_cyan statusbar.new=bold_white main.text=white From 53fc89f71120a7ceba494cb1eed18667c24d1775 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 22 Jan 2016 01:06:28 +0000 Subject: [PATCH 5/8] Added account theme property --- src/command/command.c | 26 +++++++++++- src/command/commands.c | 55 ++++++++++++++++++++++++++ src/config/account.c | 9 ++++- src/config/account.h | 3 +- src/config/accounts.c | 27 ++++++++++++- src/config/accounts.h | 2 + src/config/theme.c | 16 ++++++++ src/config/theme.h | 1 + src/ui/console.c | 3 ++ src/ui/core.c | 19 +++++++++ tests/unittests/config/stub_accounts.c | 2 + tests/unittests/test_cmd_account.c | 14 +++---- tests/unittests/test_cmd_connect.c | 6 +-- tests/unittests/test_cmd_join.c | 8 ++-- tests/unittests/test_cmd_otr.c | 2 +- tests/unittests/test_cmd_rooms.c | 2 +- 16 files changed, 175 insertions(+), 20 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 3f4e4a7d..ca84591f 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1644,6 +1644,7 @@ static struct cmd_t command_defs[] = "/account set pgpkeyid ", "/account set startscript