Ticket #2165: mc-skin-selector-beta3_nolines.patch

File mc-skin-selector-beta3_nolines.patch, 16.4 KB (added by vitalif, 6 years ago)

Patch with removed double line / underline hotkeys settings

  • lib/keybind.c

    old new  
    176176    {"Jobs", CK_Jobs}, 
    177177#endif 
    178178    {"OptionsLayout", CK_OptionsLayout}, 
     179    {"OptionsAppearance", CK_OptionsAppearance}, 
    179180    {"Link", CK_Link}, 
    180181    {"PanelListingChange", CK_PanelListingChange}, 
    181182    {"PanelListing", CK_PanelListing}, 
  • lib/keybind.h

    old new  
    155155    CK_PanelInfo, 
    156156    CK_Jobs, 
    157157    CK_OptionsLayout, 
     158    CK_OptionsAppearance, 
    158159    CK_Link, 
    159160    CK_PanelListing, 
    160161    CK_ListMode, 
  • lib/skin.h

    old new  
    129129 
    130130/*** declarations of public functions ************************************************************/ 
    131131 
    132 gboolean mc_skin_init (GError **); 
     132gboolean mc_skin_init (const gchar *, GError **); 
    133133void mc_skin_deinit (void); 
    134134 
    135135int mc_skin_color_get (const gchar *, const gchar *); 
     
    138138 
    139139gchar *mc_skin_get (const gchar *, const gchar *, const gchar *); 
    140140 
     141GArray * mc_skin_list (void); 
     142 
    141143#endif /* MC_SKIN_H */ 
  • lib/skin/colors.c

    old new  
    178178} 
    179179 
    180180/* --------------------------------------------------------------------------------------------- */ 
     181 
    181182static void 
    182183mc_skin_color_cache_init (void) 
    183184{ 
  • lib/skin/common.c

    old new  
    110110/* --------------------------------------------------------------------------------------------- */ 
    111111 
    112112gboolean 
    113 mc_skin_init (GError ** error) 
     113mc_skin_init (const gchar *skin_override, GError ** error) 
    114114{ 
    115115    gboolean is_good_init = TRUE; 
    116116 
    117117    mc_skin__default.have_256_colors = FALSE; 
    118118 
    119     mc_skin__default.name = mc_skin_get_default_name (); 
     119    mc_skin__default.name = 
     120        skin_override != NULL ? g_strdup(skin_override) : mc_skin_get_default_name (); 
    120121 
    121122    mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, 
    122123                                                     g_free, mc_skin_hash_destroy_value); 
     
    165166void 
    166167mc_skin_deinit (void) 
    167168{ 
     169    tty_color_free_all_tmp (); 
     170    tty_color_free_all_non_tmp (); 
     171 
    168172    g_free (mc_skin__default.name); 
    169173    mc_skin__default.name = NULL; 
    170174    g_hash_table_destroy (mc_skin__default.colors); 
  • lib/skin/ini-file.c

    old new  
    2727#include <config.h> 
    2828#include <string.h> 
    2929 
     30#include "lib/global.h"         /* <glib.h> */ 
     31 
    3032#include "internal.h" 
    3133#include "lib/fileloc.h" 
    3234#include "lib/util.h"           /* exist_file() */ 
     
    4345 
    4446/* --------------------------------------------------------------------------------------------- */ 
    4547 
     48static void 
     49mc_skin_get_list_from_dir (const gchar * base_dir, GArray * list) 
     50{ 
     51    unsigned int i; 
     52    char *dir_name; 
     53    DIR *dir; 
     54    gchar *name; 
     55 
     56    dir_name = g_build_filename (base_dir, MC_SKINS_SUBDIR, NULL); 
     57    dir = opendir (dir_name); 
     58    if (dir != NULL) { 
     59        struct dirent *de; 
     60        while ((de = readdir(dir)) != NULL) { 
     61            if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) 
     62                continue; 
     63            if (strlen(de->d_name) > 4 && !strcmp(de->d_name + strlen(de->d_name) - 4, ".ini")) 
     64                de->d_name[strlen(de->d_name) - 4] = '\0'; 
     65            for (i = 0; i < list->len; i++) { 
     66                if (!strcmp(de->d_name, g_array_index(list, gchar *, i))) 
     67                    break; 
     68            } 
     69            if (i < list->len) 
     70                continue; 
     71            name = g_strdup(de->d_name); 
     72            g_array_append_val(list, name); 
     73        } 
     74        closedir(dir); 
     75    } 
     76    g_free(dir_name); 
     77} 
     78 
     79/* --------------------------------------------------------------------------------------------- */ 
     80 
     81static int string_array_comparator (gconstpointer a, gconstpointer b) 
     82{ 
     83    char *aa = *(char **) a; 
     84    char *bb = *(char **) b; 
     85    return strcmp(aa, bb); 
     86} 
     87 
     88/* --------------------------------------------------------------------------------------------- */ 
     89 
    4690static gboolean 
    4791mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir) 
    4892{ 
     
    75119/*** public functions ****************************************************************************/ 
    76120/* --------------------------------------------------------------------------------------------- */ 
    77121 
     122GArray * 
     123mc_skin_list (void) 
     124{ 
     125    GArray *list = g_array_new(FALSE, FALSE, sizeof(gchar *)); 
     126    mc_skin_get_list_from_dir(mc_config_get_data_path (), list); 
     127    mc_skin_get_list_from_dir(mc_global.sysconfig_dir, list); 
     128    mc_skin_get_list_from_dir(mc_global.share_data_dir, list); 
     129    g_array_sort(list, (GCompareFunc) string_array_comparator); 
     130    return list; 
     131} 
     132 
     133/* --------------------------------------------------------------------------------------------- */ 
     134 
    78135gboolean 
    79136mc_skin_ini_file_load (mc_skin_t * mc_skin) 
    80137{ 
  • lib/widget/dialog.c

    old new  
    5151/* Color styles for normal and error dialogs */ 
    5252dlg_colors_t dialog_colors; 
    5353dlg_colors_t alarm_colors; 
     54dlg_colors_t listbox_colors; 
    5455 
    5556/* Primitive way to check if the the current dialog is our dialog */ 
    5657/* This is needed by async routines like load_prompt */ 
     
    780781 
    781782    new_d->state = DLG_CONSTRUCT; 
    782783    new_d->modal = modal; 
    783     if (colors != NULL) 
    784         memmove (new_d->color, colors, sizeof (dlg_colors_t)); 
     784    new_d->color = colors; 
    785785    new_d->help_ctx = help_ctx; 
    786786    new_d->flags = flags; 
    787787    new_d->data = NULL; 
     
    824824    alarm_colors[DLG_COLOR_HOT_NORMAL] = ERROR_HOT_NORMAL; 
    825825    alarm_colors[DLG_COLOR_HOT_FOCUS] = ERROR_HOT_FOCUS; 
    826826    alarm_colors[DLG_COLOR_TITLE] = ERROR_TITLE; 
     827 
     828    listbox_colors[DLG_COLOR_NORMAL] = PMENU_ENTRY_COLOR; 
     829    listbox_colors[DLG_COLOR_FOCUS] = PMENU_SELECTED_COLOR; 
     830    listbox_colors[DLG_COLOR_HOT_NORMAL] = PMENU_ENTRY_COLOR; 
     831    listbox_colors[DLG_COLOR_HOT_FOCUS] = PMENU_SELECTED_COLOR; 
     832    listbox_colors[DLG_COLOR_TITLE]= PMENU_TITLE_COLOR; 
    827833} 
    828834 
    829835/* --------------------------------------------------------------------------------------------- */ 
  • lib/widget/dialog.h

    old new  
    8383    gboolean modal;             /* type of dialog: modal or not */ 
    8484    dlg_flags_t flags;          /* User flags */ 
    8585    const char *help_ctx;       /* Name of the help entry */ 
    86     dlg_colors_t color;         /* Color set. Unused in viewer and editor */ 
     86    const int *color;           /* Color set. Unused in viewer and editor */ 
    8787    char *title;                /* Title of the dialog */ 
    8888 
    8989    /* Set and received by the user */ 
     
    111111/* Color styles for normal and error dialogs */ 
    112112extern dlg_colors_t dialog_colors; 
    113113extern dlg_colors_t alarm_colors; 
     114extern dlg_colors_t listbox_colors; 
    114115 
    115116extern GList *top_dlg; 
    116117 
  • lib/widget/listbox-window.c

    old new  
    6060create_listbox_window_centered (int center_y, int center_x, int lines, int cols, 
    6161                                const char *title, const char *help) 
    6262{ 
    63     const dlg_colors_t listbox_colors = { 
    64         PMENU_ENTRY_COLOR, 
    65         PMENU_SELECTED_COLOR, 
    66         PMENU_ENTRY_COLOR, 
    67         PMENU_SELECTED_COLOR, 
    68         PMENU_TITLE_COLOR 
    69     }; 
    70  
    7163    const int space = 4; 
    7264 
    7365    int xpos, ypos; 
  • src/filemanager/boxes.c

    old new  
    104104static unsigned long panel_listing_types_id, panel_user_format_id; 
    105105static unsigned long mini_user_status_id, mini_user_format_id; 
    106106 
     107static unsigned long skin_name_id; 
     108 
    107109#ifdef HAVE_CHARSET 
    108110static int new_display_codepage; 
    109111static unsigned long disp_bits_name_id; 
     
    113115static unsigned long ftpfs_always_use_proxy_id, ftpfs_proxy_host_id; 
    114116#endif /* ENABLE_VFS && ENABLE_VFS_FTP */ 
    115117 
     118GArray * skin_names; 
     119gchar * current_skin_name; 
     120 
    116121#ifdef ENABLE_BACKGROUND 
    117122static WListbox *bg_list = NULL; 
    118123#endif /* ENABLE_BACKGROUND */ 
     
    515520} 
    516521 
    517522/* --------------------------------------------------------------------------------------------- */ 
     523 
     524static void 
     525skin_apply (const gchar *skin_override) 
     526{ 
     527    GError *error = NULL; 
     528    mc_skin_deinit (); 
     529    mc_skin_init (skin_override, &error); 
     530    mc_fhl_free (&mc_filehighlight); 
     531    mc_filehighlight = mc_fhl_new (TRUE); 
     532    dlg_set_default_colors (); 
     533    panel_deinit (); 
     534    panel_init (); 
     535    repaint_screen (); 
     536    if (error != NULL) 
     537    { 
     538        message (D_ERROR, _("Warning"), "%s", error->message); 
     539        g_error_free (error); 
     540    } 
     541} 
     542 
     543/* --------------------------------------------------------------------------------------------- */ 
     544 
     545static cb_ret_t 
     546skin_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) 
     547{ 
     548    return dlg_default_callback (w, sender, msg, parm, data); 
     549} 
     550 
     551/* --------------------------------------------------------------------------------------------- */ 
     552 
     553static int 
     554sel_skin_button (WButton * button, int action) 
     555{ 
     556    int result; 
     557    WListbox *skin_list; 
     558    WDialog *skin_dlg; 
     559    gchar *skin_name; 
     560    int lxx, lyy; 
     561    unsigned int i; 
     562 
     563    (void) action; 
     564 
     565    lxx = COLS / 2; 
     566    lyy = (LINES - 13) / 2; 
     567    skin_dlg = 
     568        dlg_create (TRUE, lyy, lxx, 13, 24, dialog_colors, skin_callback, NULL, 
     569                    "[Skins]", _("Skin"), DLG_COMPACT); 
     570 
     571    skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL); 
     572    for (i = 0; i < skin_names->len; i++) { 
     573        skin_name = g_array_index(skin_names, gchar *, i); 
     574        listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name, NULL); 
     575        if (!strcmp(skin_name, current_skin_name)) 
     576            listbox_select_entry (skin_list, i); 
     577    } 
     578 
     579    add_widget (skin_dlg, skin_list); 
     580 
     581    result = dlg_run (skin_dlg); 
     582    if (result == B_ENTER) { 
     583        Widget *w; 
     584        listbox_get_current (skin_list, &skin_name, NULL); 
     585        g_free (current_skin_name); 
     586        current_skin_name = g_strdup(skin_name); 
     587        skin_apply (skin_name); 
     588        w = dlg_find_by_id (WIDGET (button)->owner, skin_name_id); 
     589        button_set_text (BUTTON (w), str_fit_to_term(skin_name, 20, J_LEFT_FIT)); 
     590    } 
     591    dlg_destroy (skin_dlg); 
     592    return 0; 
     593} 
     594 
     595/* --------------------------------------------------------------------------------------------- */ 
     596 
     597void 
     598appearance_box (void) 
     599{ 
     600    unsigned int i; 
     601 
     602    current_skin_name = g_strdup(mc_skin__default.name); 
     603    skin_names = mc_skin_list(); 
     604 
     605    { 
     606        quick_widget_t quick_widgets[] = { 
     607            /* *INDENT-OFF* */ 
     608            QUICK_START_COLUMNS, 
     609                QUICK_LABEL (N_("Skin:"), NULL), 
     610            QUICK_NEXT_COLUMN, 
     611                QUICK_BUTTON (str_fit_to_term(current_skin_name, 20, J_LEFT_FIT), 
     612                              B_USER, sel_skin_button, &skin_name_id), 
     613            QUICK_STOP_COLUMNS, 
     614            QUICK_BUTTONS_OK_CANCEL, 
     615            QUICK_END 
     616            /* *INDENT-ON* */ 
     617        }; 
     618 
     619        quick_dialog_t qdlg = { 
     620            -1, -1, 54, 
     621            _("Appearance"), "[Skins]", 
     622            quick_widgets, dlg_default_callback, NULL 
     623        }; 
     624 
     625        if (quick_dialog (&qdlg) == B_ENTER) { 
     626            mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, "skin", current_skin_name); 
     627        } else { 
     628            skin_apply (NULL); 
     629        } 
     630    } 
     631 
     632    g_free (current_skin_name); 
     633    for (i = 0; i < skin_names->len; i++) 
     634        g_free (g_array_index (skin_names, gchar *, i)); 
     635    g_array_free (skin_names, TRUE); 
     636} 
     637 
     638/* --------------------------------------------------------------------------------------------- */ 
    518639 
    519640void 
    520641panel_options_box (void) 
  • src/filemanager/boxes.h

    old new  
    1919/*** declarations of public functions ************************************************************/ 
    2020 
    2121void configure_box (void); 
     22void appearance_box (void); 
    2223void panel_options_box (void); 
    2324int panel_listing_box (WPanel * p, char **user, char **mini, int *use_msformat, int num); 
    2425const panel_field_t *sort_box (dir_sort_options_t * op, const panel_field_t * sort_field); 
  • src/filemanager/midnight.c

    old new  
    337337    entries = 
    338338        g_list_prepend (entries, menu_entry_create (_("C&onfirmation..."), CK_OptionsConfirm)); 
    339339    entries = 
     340        g_list_prepend (entries, menu_entry_create (_("&Appearance..."), CK_OptionsAppearance)); 
     341    entries = 
    340342        g_list_prepend (entries, menu_entry_create (_("&Display bits..."), CK_OptionsDisplayBits)); 
    341343    entries = g_list_prepend (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys)); 
    342344#ifdef ENABLE_VFS 
     
    12501252    case CK_OptionsLayout: 
    12511253        layout_box (); 
    12521254        break; 
     1255    case CK_OptionsAppearance: 
     1256        appearance_box (); 
     1257        break; 
    12531258    case CK_LearnKeys: 
    12541259        learn_keys (); 
    12551260        break; 
     
    17431748{ 
    17441749    gboolean ret; 
    17451750 
    1746     dlg_colors_t midnight_colors; 
    1747  
    1748     midnight_colors[DLG_COLOR_NORMAL] = mc_skin_color_get ("dialog", "_default_"); 
    1749     midnight_colors[DLG_COLOR_FOCUS] = mc_skin_color_get ("dialog", "focus"); 
    1750     midnight_colors[DLG_COLOR_HOT_NORMAL] = mc_skin_color_get ("dialog", "hotnormal"); 
    1751     midnight_colors[DLG_COLOR_HOT_FOCUS] = mc_skin_color_get ("dialog", "hotfocus"); 
    1752     midnight_colors[DLG_COLOR_TITLE] = mc_skin_color_get ("dialog", "title"); 
    1753  
    17541751#ifdef USE_INTERNAL_EDIT 
    17551752    edit_stack_init (); 
    17561753#endif 
    17571754 
    1758     midnight_dlg = dlg_create (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback, 
     1755    midnight_dlg = dlg_create (FALSE, 0, 0, LINES, COLS, dialog_colors, midnight_callback, 
    17591756                               midnight_event, "[main]", NULL, DLG_NONE); 
    17601757 
    17611758    /* Check if we were invoked as an editor or file viewer */ 
  • src/main.c

    old new  
    352352 
    353353    tty_init_colors (mc_global.tty.disable_colors, mc_args__force_colors); 
    354354 
    355     mc_skin_init (&error); 
     355    mc_skin_init (NULL, &error); 
     356    dlg_set_default_colors (); 
    356357    if (error != NULL) 
    357358    { 
    358359        message (D_ERROR, _("Warning"), "%s", error->message); 
     
    360361        error = NULL; 
    361362    } 
    362363 
    363     dlg_set_default_colors (); 
    364  
    365364#ifdef ENABLE_SUBSHELL 
    366365    /* Done here to ensure that the subshell doesn't  */ 
    367366    /* inherit the file descriptors opened below, etc */