Ticket #2165: mc-runtime-skin-change-demo-ticket2165.patch

File mc-runtime-skin-change-demo-ticket2165.patch, 1.9 KB (added by egmont, 6 years ago)

Demo for runtime skin change

  • lib/skin/common.c

    diff -ur mc-4.8.11.orig/lib/skin/common.c mc-4.8.11/lib/skin/common.c
    old new  
    6363static char * 
    6464mc_skin_get_default_name (void) 
    6565{ 
     66static int n = 0; 
     67char *skins[] = {"darkfar", "default", "double-lines", "gotar", "nicedark", "modarin256", "sand256", "xoria256"}; 
    6668    char *tmp_str; 
    6769 
    6870    /* from command line */ 
     
    7476    if (tmp_str != NULL) 
    7577        return g_strdup (tmp_str); 
    7678 
     79return g_strdup(skins[n++ % 8]); 
     80 
    7781    /*  from config. Or 'default' if no present in config */ 
    7882    return mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "skin", "default"); 
    7983} 
    8084 
    8185/* --------------------------------------------------------------------------------------------- */ 
    8286 
    83 static void 
     87void 
    8488mc_skin_reinit (void) 
    8589{ 
     90    GError *error = NULL; 
    8691    mc_skin_deinit (); 
    87     mc_skin__default.name = mc_skin_get_default_name (); 
    88     mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, 
    89                                                      g_free, mc_skin_hash_destroy_value); 
     92    tty_color_free_all_tmp (); 
     93    tty_color_free_all_non_tmp (); 
     94    mc_skin_init (&error); 
    9095} 
    9196 
    9297/* --------------------------------------------------------------------------------------------- */ 
  • src/filemanager/layout.c

    diff -ur mc-4.8.11.orig/src/filemanager/layout.c mc-4.8.11/src/filemanager/layout.c
    old new  
    10901090void 
    10911091swap_panels (void) 
    10921092{ 
     1093    mc_skin_reinit (); 
     1094    mc_fhl_free (&mc_filehighlight); 
     1095    mc_filehighlight = mc_fhl_new (TRUE); 
     1096    dlg_set_default_colors (); 
     1097    panel_deinit (); 
     1098    panel_init (); 
     1099    return; 
     1100 
    10931101    WPanel *panel1, *panel2; 
    10941102    Widget *tmp_widget; 
    10951103