Ticket #2165: mc_2165_default.patch

File mc_2165_default.patch, 3.1 KB (added by egmont, 6 years ago)

special label for the default skin

  • src/filemanager/boxes.c

    diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c
    index 1de6f7d..f03ed05 100644
    a b skin_apply (const gchar * skin_override) 
    544544 
    545545/* --------------------------------------------------------------------------------------------- */ 
    546546 
     547static const gchar * 
     548skin_name_to_label (const gchar *name) 
     549{ 
     550    if (strcmp (name, "default") == 0) 
     551        return _("< Default >"); 
     552    return name; 
     553} 
     554 
     555/* --------------------------------------------------------------------------------------------- */ 
     556 
    547557static int 
    548558sel_skin_button (WButton * button, int action) 
    549559{ 
    550560    int result; 
    551561    WListbox *skin_list; 
    552562    WDialog *skin_dlg; 
    553     gchar *skin_name; 
     563    const gchar *skin_name; 
    554564    int lxx, lyy; 
    555     unsigned int i; 
     565    unsigned int i, pos; 
    556566 
    557567    (void) action; 
    558568 
    sel_skin_button (WButton * button, int action) 
    563573                    DLG_COMPACT); 
    564574 
    565575    skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL); 
     576    skin_name = "default"; 
     577    listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label(skin_name), (void *) skin_name); 
     578    if (strcmp (skin_name, current_skin_name) == 0) 
     579        listbox_select_entry (skin_list, 0); 
     580    pos = 1; 
    566581    for (i = 0; i < skin_names->len; i++) 
    567582    { 
    568583        skin_name = g_ptr_array_index (skin_names, i); 
    569         listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name, NULL); 
     584        if (strcmp (skin_name, "default") == 0) 
     585            continue; 
     586        listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label(skin_name), (void *) skin_name); 
    570587        if (strcmp (skin_name, current_skin_name) == 0) 
    571             listbox_select_entry (skin_list, i); 
     588            listbox_select_entry (skin_list, pos); 
     589        pos++; 
    572590    } 
    573591 
    574592    add_widget (skin_dlg, skin_list); 
    sel_skin_button (WButton * button, int action) 
    577595    if (result == B_ENTER) 
    578596    { 
    579597        Widget *w; 
     598        gchar *skin_label; 
    580599 
    581         listbox_get_current (skin_list, &skin_name, NULL); 
     600        listbox_get_current (skin_list, &skin_label, (void **) &skin_name); 
    582601        g_free (current_skin_name); 
    583602        current_skin_name = g_strdup (skin_name); 
    584603        skin_apply (skin_name); 
    585604        w = dlg_find_by_id (WIDGET (button)->owner, skin_name_id); 
    586         button_set_text (BUTTON (w), str_fit_to_term (skin_name, 20, J_LEFT_FIT)); 
     605        button_set_text (BUTTON (w), str_fit_to_term (skin_label, 20, J_LEFT_FIT)); 
    587606    } 
    588607    dlg_destroy (skin_dlg); 
    589608    return 0; 
    appearance_box (void) 
    603622            QUICK_START_COLUMNS, 
    604623                QUICK_LABEL (N_("Skin:"), NULL), 
    605624            QUICK_NEXT_COLUMN, 
    606                 QUICK_BUTTON (str_fit_to_term(current_skin_name, 20, J_LEFT_FIT), B_USER, 
    607                               sel_skin_button, &skin_name_id), 
     625                QUICK_BUTTON (str_fit_to_term(skin_name_to_label(current_skin_name), 20, J_LEFT_FIT), 
     626                              B_USER, sel_skin_button, &skin_name_id), 
    608627            QUICK_STOP_COLUMNS, 
    609628            QUICK_BUTTONS_OK_CANCEL, 
    610629            QUICK_END