about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-16 23:37:07 +0000
committerJames Booth <boothj5@gmail.com>2014-11-16 23:37:07 +0000
commit74d99375730f3be30ed8070c84148c6c1902ad7c (patch)
tree8223f9cd974304075c426e6485634167056f5bce
parentb60a5b08c0835cd4035fcc3d909e4d65b4d424b7 (diff)
downloadprofani-tty-74d99375730f3be30ed8070c84148c6c1902ad7c.tar.gz
Changed type to enum for presence colour attributes
-rw-r--r--src/config/theme.c18
-rw-r--r--src/config/theme.h1
-rw-r--r--src/ui/console.c14
-rw-r--r--src/ui/core.c14
-rw-r--r--src/ui/window.c30
-rw-r--r--src/ui/window.h1
6 files changed, 39 insertions, 39 deletions
diff --git a/src/config/theme.c b/src/config/theme.c
index f71859fe..ffdff732 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -558,6 +558,24 @@ _theme_find(const char * const theme_name)
     return path;
 }
 
+theme_item_t
+theme_main_presence_attrs(const char * const presence)
+{
+    if (g_strcmp0(presence, "online") == 0) {
+        return THEME_ONLINE;
+    } else if (g_strcmp0(presence, "away") == 0) {
+        return THEME_AWAY;
+    } else if (g_strcmp0(presence, "chat") == 0) {
+        return THEME_CHAT;
+    } else if (g_strcmp0(presence, "dnd") == 0) {
+        return THEME_DND;
+    } else if (g_strcmp0(presence, "xa") == 0) {
+        return THEME_XA;
+    } else {
+        return THEME_OFFLINE;
+    }
+}
+
 int
 theme_attrs(theme_item_t attrs)
 {
diff --git a/src/config/theme.h b/src/config/theme.h
index ebd963b1..23abab63 100644
--- a/src/config/theme.h
+++ b/src/config/theme.h
@@ -99,5 +99,6 @@ gboolean theme_load(const char * const theme_name);
 GSList* theme_list(void);
 void theme_close(void);
 int theme_attrs(theme_item_t attrs);
+theme_item_t theme_main_presence_attrs(const char * const presence);
 
 #endif
diff --git a/src/ui/console.c b/src/ui/console.c
index 2e502284..32f040e0 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -230,7 +230,7 @@ _cons_show_login_success(ProfAccount *account)
     resource_presence_t presence = accounts_get_login_presence(account->name);
     const char *presence_str = string_from_resource_presence(presence);
 
-    int presence_colour = win_presence_colour(presence_str);
+    theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
     win_save_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str);
     win_save_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)",
         accounts_get_priority_for_presence_type(account->name, presence));
@@ -292,7 +292,7 @@ _cons_show_caps(const char * const fulljid, resource_presence_t presence)
     if (caps) {
         const char *resource_presence = string_from_resource_presence(presence);
 
-        int presence_colour = win_presence_colour(resource_presence);
+        theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
         win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "%s", fulljid);
         win_save_print(console, '-', NULL, NO_DATE, 0, "", ":");
 
@@ -359,7 +359,7 @@ _cons_show_software_version(const char * const jid, const char * const  presence
     ProfWin *console = wins_get_console();
     if ((name != NULL) || (version != NULL) || (os != NULL)) {
         cons_show("");
-        int presence_colour = win_presence_colour(presence);
+        theme_item_t presence_colour = theme_main_presence_attrs(presence);
         win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "%s", jid);
         win_save_print(console, '-', NULL, NO_DATE, 0, "", ":");
     }
@@ -611,7 +611,7 @@ _cons_show_account_list(gchar **accounts)
             if ((jabber_get_connection_status() == JABBER_CONNECTED) &&
                     (g_strcmp0(jabber_get_account_name(), accounts[i]) == 0)) {
                 resource_presence_t presence = accounts_get_last_presence(accounts[i]);
-                int presence_colour = win_presence_colour(string_from_resource_presence(presence));
+                theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence));
                 win_save_vprint(console, '-', NULL, 0, presence_colour, "", "%s", accounts[i]);
             } else {
                 cons_show(accounts[i]);
@@ -730,7 +730,7 @@ _cons_show_account(ProfAccount *account)
         while (ordered_resources != NULL) {
             Resource *resource = ordered_resources->data;
             const char *resource_presence = string_from_resource_presence(resource->presence);
-            int presence_colour = win_presence_colour(resource_presence);
+            theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
             win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "  %s (%d), %s", resource->name, resource->priority, resource_presence);
 
             if (resource->status != NULL) {
@@ -1524,9 +1524,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
         const char *presence = p_contact_presence(contact);
         theme_item_t presence_colour = THEME_TEXT;
         if (p_contact_subscribed(contact)) {
-            presence_colour = win_presence_colour(presence);
+            presence_colour = theme_main_presence_attrs(presence);
         } else {
-            presence_colour = win_presence_colour("offline");
+            presence_colour = theme_main_presence_attrs("offline");
         }
         win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", title->str);
 
diff --git a/src/ui/core.c b/src/ui/core.c
index 896a6ba4..e6a4437e 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1576,7 +1576,7 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese
                 Occupant *occupant = roster->data;
                 const char *presence_str = string_from_resource_presence(occupant->presence);
 
-                int presence_colour = win_presence_colour(presence_str);
+                theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
                 win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick);
 
                 if (roster->next != NULL) {
@@ -2830,7 +2830,7 @@ _ui_roster_contact(PContact contact)
 
         if ((g_strcmp0(presence, "offline") != 0) || ((g_strcmp0(presence, "offline") == 0) &&
                 (prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
-            theme_item_t presence_colour = win_presence_colour(presence);
+            theme_item_t presence_colour = theme_main_presence_attrs(presence);
 
             wattron(window->subwin, theme_attrs(presence_colour));
 
@@ -2847,7 +2847,7 @@ _ui_roster_contact(PContact contact)
                 while (curr_resource) {
                     Resource *resource = curr_resource->data;
                     const char *resource_presence = string_from_resource_presence(resource->presence);
-                    theme_item_t resource_presence_colour = win_presence_colour(resource_presence);
+                    theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence);
                     wattron(window->subwin, theme_attrs(resource_presence_colour));
 
                     GString *msg = g_string_new("     ");
@@ -2989,7 +2989,7 @@ _ui_muc_roster(const char * const room)
                     Occupant *occupant = roster_curr->data;
                     if (occupant->role == MUC_ROLE_MODERATOR) {
                         const char *presence_str = string_from_resource_presence(occupant->presence);
-                        theme_item_t presence_colour = win_presence_colour(presence_str);
+                        theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
                         wattron(window->subwin, theme_attrs(presence_colour));
 
                         GString *msg = g_string_new("   ");
@@ -3010,7 +3010,7 @@ _ui_muc_roster(const char * const room)
                     Occupant *occupant = roster_curr->data;
                     if (occupant->role == MUC_ROLE_PARTICIPANT) {
                         const char *presence_str = string_from_resource_presence(occupant->presence);
-                        theme_item_t presence_colour = win_presence_colour(presence_str);
+                        theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
                         wattron(window->subwin, theme_attrs(presence_colour));
 
                         GString *msg = g_string_new("   ");
@@ -3031,7 +3031,7 @@ _ui_muc_roster(const char * const room)
                     Occupant *occupant = roster_curr->data;
                     if (occupant->role == MUC_ROLE_VISITOR) {
                         const char *presence_str = string_from_resource_presence(occupant->presence);
-                        theme_item_t presence_colour = win_presence_colour(presence_str);
+                        theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
                         wattron(window->subwin, theme_attrs(presence_colour));
 
                         GString *msg = g_string_new("   ");
@@ -3051,7 +3051,7 @@ _ui_muc_roster(const char * const room)
                 while (roster_curr) {
                     Occupant *occupant = roster_curr->data;
                     const char *presence_str = string_from_resource_presence(occupant->presence);
-                    theme_item_t presence_colour = win_presence_colour(presence_str);
+                    theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
                     wattron(window->subwin, theme_attrs(presence_colour));
 
                     GString *msg = g_string_new("   ");
diff --git a/src/ui/window.c b/src/ui/window.c
index 3c4dc35e..ca4b6cb2 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -191,30 +191,12 @@ win_move_to_end(ProfWin *window)
     }
 }
 
-theme_item_t
-win_presence_colour(const char * const presence)
-{
-    if (g_strcmp0(presence, "online") == 0) {
-        return THEME_ONLINE;
-    } else if (g_strcmp0(presence, "away") == 0) {
-        return THEME_AWAY;
-    } else if (g_strcmp0(presence, "chat") == 0) {
-        return THEME_CHAT;
-    } else if (g_strcmp0(presence, "dnd") == 0) {
-        return THEME_DND;
-    } else if (g_strcmp0(presence, "xa") == 0) {
-        return THEME_XA;
-    } else {
-        return THEME_OFFLINE;
-    }
-}
-
 void
 win_show_occupant(ProfWin *window, Occupant *occupant)
 {
     const char *presence_str = string_from_resource_presence(occupant->presence);
 
-    theme_item_t presence_colour = win_presence_colour(presence_str);
+    theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
 
     win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", occupant->nick);
     win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
@@ -235,7 +217,7 @@ win_show_contact(ProfWin *window, PContact contact)
     const char *status = p_contact_status(contact);
     GDateTime *last_activity = p_contact_last_activity(contact);
 
-    theme_item_t presence_colour = win_presence_colour(presence);
+    theme_item_t presence_colour = theme_main_presence_attrs(presence);
 
     if (name != NULL) {
         win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", name);
@@ -277,7 +259,7 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
     const char *occupant_affiliation = muc_occupant_affiliation_str(occupant);
     const char *occupant_role = muc_occupant_role_str(occupant);
 
-    theme_item_t presence_colour = win_presence_colour(presence_str);
+    theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
 
     win_save_print(window, '!', NULL, NO_EOL, presence_colour, "", occupant->nick);
     win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
@@ -355,7 +337,7 @@ win_show_info(ProfWin *window, PContact contact)
     GList *ordered_resources = NULL;
     GDateTime *last_activity = p_contact_last_activity(contact);
 
-    theme_item_t presence_colour = win_presence_colour(presence);
+    theme_item_t presence_colour = theme_main_presence_attrs(presence);
 
     win_save_print(window, '-', NULL, 0, 0, "", "");
     win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", barejid);
@@ -403,7 +385,7 @@ win_show_info(ProfWin *window, PContact contact)
     while (ordered_resources != NULL) {
         Resource *resource = ordered_resources->data;
         const char *resource_presence = string_from_resource_presence(resource->presence);
-        int presence_colour = win_presence_colour(resource_presence);
+        theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
         win_save_vprint(window, '-', NULL, NO_EOL, presence_colour, "", "  %s (%d), %s", resource->name, resource->priority, resource_presence);
         if (resource->status != NULL) {
             win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status);
@@ -469,7 +451,7 @@ win_show_status_string(ProfWin *window, const char * const from,
     theme_item_t presence_colour;
 
     if (show != NULL) {
-        presence_colour = win_presence_colour(show);
+        presence_colour = theme_main_presence_attrs(show);
     } else if (strcmp(default_show, "online") == 0) {
         presence_colour = THEME_ONLINE;
     } else {
diff --git a/src/ui/window.h b/src/ui/window.h
index 5cc08a8d..e131fbfc 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -86,7 +86,6 @@ ProfWin* win_create(const char * const title, win_type_t type);
 void win_free(ProfWin *window);
 void win_update_virtual(ProfWin *window);
 void win_move_to_end(ProfWin *window);
-theme_item_t win_presence_colour(const char * const presence);
 void win_show_contact(ProfWin *window, PContact contact);
 void win_show_occupant(ProfWin *window, Occupant *occupant);
 void win_show_status_string(ProfWin *window, const char * const from,