changeset 1942:3e39a336a992

Use guards for colors (Myhailo Danylenko) Merge patch from isbear's mcabber-experimental repository.
author Mikael Berthe <mikael@lilotux.net>
date Sun, 27 Feb 2011 18:15:27 +0100
parents 2256d0626730
children 11bda6d8daab
files mcabber/mcabber/screen.c
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/screen.c	Sun Feb 27 17:42:27 2011 +0100
+++ b/mcabber/mcabber/screen.c	Sun Feb 27 18:15:27 2011 +0100
@@ -72,6 +72,7 @@
 
 static unsigned short int Log_Win_Height;
 static unsigned short int Roster_Width;
+static gboolean colors_stalled = FALSE;
 
 // Default attention sign trigger levels
 static guint ui_attn_sign_prio_level_muc = ROSTER_UI_PRIO_MUC_HL_MESSAGE;
@@ -560,6 +561,8 @@
       (*nickcols)->color_attrib = A_NORMAL;
     }
   }
+
+  colors_stalled = FALSE;
 }
 
 static void init_keycodes(void)
@@ -752,6 +755,13 @@
   return Curses;
 }
 
+static gchar *scr_color_guard(const gchar *key, const gchar *new_value)
+{
+  if (g_strcmp0(settings_opt_get(key), new_value))
+    colors_stalled = TRUE;
+  return g_strdup(new_value);
+}
+
 void scr_init_curses(void)
 {
   /* Key sequences initialization */
@@ -779,6 +789,20 @@
 
   parse_colors();
 
+  settings_set_guard("color_background", scr_color_guard);
+  settings_set_guard("color_general", scr_color_guard);
+  settings_set_guard("color_info", scr_color_guard);
+  settings_set_guard("color_msgin", scr_color_guard);
+  settings_set_guard("color_msgout", scr_color_guard);
+  settings_set_guard("color_msghl", scr_color_guard);
+  settings_set_guard("color_bgstatus", scr_color_guard);
+  settings_set_guard("color_status", scr_color_guard);
+  settings_set_guard("color_roster", scr_color_guard);
+  settings_set_guard("color_bgrostersel", scr_color_guard);
+  settings_set_guard("color_rostersel", scr_color_guard);
+  settings_set_guard("color_rosterselmsg", scr_color_guard);
+  settings_set_guard("color_rosternewmsg", scr_color_guard);
+
   getmaxyx(stdscr, maxY, maxX);
   Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
   // Note scr_draw_main_window() should be called early after scr_init_curses()
@@ -3970,6 +3994,8 @@
 
 void scr_do_update(void)
 {
+  if (colors_stalled)
+    parse_colors();
   doupdate();
 }