Ticket #2165: mc-skin-selector-beta3_nolines.patch
File mc-skin-selector-beta3_nolines.patch, 16.4 KB (added by vitalif, 10 years ago) |
---|
-
lib/keybind.c
old new 176 176 {"Jobs", CK_Jobs}, 177 177 #endif 178 178 {"OptionsLayout", CK_OptionsLayout}, 179 {"OptionsAppearance", CK_OptionsAppearance}, 179 180 {"Link", CK_Link}, 180 181 {"PanelListingChange", CK_PanelListingChange}, 181 182 {"PanelListing", CK_PanelListing}, -
lib/keybind.h
old new 155 155 CK_PanelInfo, 156 156 CK_Jobs, 157 157 CK_OptionsLayout, 158 CK_OptionsAppearance, 158 159 CK_Link, 159 160 CK_PanelListing, 160 161 CK_ListMode, -
lib/skin.h
old new 129 129 130 130 /*** declarations of public functions ************************************************************/ 131 131 132 gboolean mc_skin_init ( GError **);132 gboolean mc_skin_init (const gchar *, GError **); 133 133 void mc_skin_deinit (void); 134 134 135 135 int mc_skin_color_get (const gchar *, const gchar *); … … 138 138 139 139 gchar *mc_skin_get (const gchar *, const gchar *, const gchar *); 140 140 141 GArray * mc_skin_list (void); 142 141 143 #endif /* MC_SKIN_H */ -
lib/skin/colors.c
old new 178 178 } 179 179 180 180 /* --------------------------------------------------------------------------------------------- */ 181 181 182 static void 182 183 mc_skin_color_cache_init (void) 183 184 { -
lib/skin/common.c
old new 110 110 /* --------------------------------------------------------------------------------------------- */ 111 111 112 112 gboolean 113 mc_skin_init ( GError ** error)113 mc_skin_init (const gchar *skin_override, GError ** error) 114 114 { 115 115 gboolean is_good_init = TRUE; 116 116 117 117 mc_skin__default.have_256_colors = FALSE; 118 118 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 (); 120 121 121 122 mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, 122 123 g_free, mc_skin_hash_destroy_value); … … 165 166 void 166 167 mc_skin_deinit (void) 167 168 { 169 tty_color_free_all_tmp (); 170 tty_color_free_all_non_tmp (); 171 168 172 g_free (mc_skin__default.name); 169 173 mc_skin__default.name = NULL; 170 174 g_hash_table_destroy (mc_skin__default.colors); -
lib/skin/ini-file.c
old new 27 27 #include <config.h> 28 28 #include <string.h> 29 29 30 #include "lib/global.h" /* <glib.h> */ 31 30 32 #include "internal.h" 31 33 #include "lib/fileloc.h" 32 34 #include "lib/util.h" /* exist_file() */ … … 43 45 44 46 /* --------------------------------------------------------------------------------------------- */ 45 47 48 static void 49 mc_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 81 static 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 46 90 static gboolean 47 91 mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir) 48 92 { … … 75 119 /*** public functions ****************************************************************************/ 76 120 /* --------------------------------------------------------------------------------------------- */ 77 121 122 GArray * 123 mc_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 78 135 gboolean 79 136 mc_skin_ini_file_load (mc_skin_t * mc_skin) 80 137 { -
lib/widget/dialog.c
old new 51 51 /* Color styles for normal and error dialogs */ 52 52 dlg_colors_t dialog_colors; 53 53 dlg_colors_t alarm_colors; 54 dlg_colors_t listbox_colors; 54 55 55 56 /* Primitive way to check if the the current dialog is our dialog */ 56 57 /* This is needed by async routines like load_prompt */ … … 780 781 781 782 new_d->state = DLG_CONSTRUCT; 782 783 new_d->modal = modal; 783 if (colors != NULL) 784 memmove (new_d->color, colors, sizeof (dlg_colors_t)); 784 new_d->color = colors; 785 785 new_d->help_ctx = help_ctx; 786 786 new_d->flags = flags; 787 787 new_d->data = NULL; … … 824 824 alarm_colors[DLG_COLOR_HOT_NORMAL] = ERROR_HOT_NORMAL; 825 825 alarm_colors[DLG_COLOR_HOT_FOCUS] = ERROR_HOT_FOCUS; 826 826 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; 827 833 } 828 834 829 835 /* --------------------------------------------------------------------------------------------- */ -
lib/widget/dialog.h
old new 83 83 gboolean modal; /* type of dialog: modal or not */ 84 84 dlg_flags_t flags; /* User flags */ 85 85 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 */ 87 87 char *title; /* Title of the dialog */ 88 88 89 89 /* Set and received by the user */ … … 111 111 /* Color styles for normal and error dialogs */ 112 112 extern dlg_colors_t dialog_colors; 113 113 extern dlg_colors_t alarm_colors; 114 extern dlg_colors_t listbox_colors; 114 115 115 116 extern GList *top_dlg; 116 117 -
lib/widget/listbox-window.c
old new 60 60 create_listbox_window_centered (int center_y, int center_x, int lines, int cols, 61 61 const char *title, const char *help) 62 62 { 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_COLOR69 };70 71 63 const int space = 4; 72 64 73 65 int xpos, ypos; -
src/filemanager/boxes.c
old new 104 104 static unsigned long panel_listing_types_id, panel_user_format_id; 105 105 static unsigned long mini_user_status_id, mini_user_format_id; 106 106 107 static unsigned long skin_name_id; 108 107 109 #ifdef HAVE_CHARSET 108 110 static int new_display_codepage; 109 111 static unsigned long disp_bits_name_id; … … 113 115 static unsigned long ftpfs_always_use_proxy_id, ftpfs_proxy_host_id; 114 116 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */ 115 117 118 GArray * skin_names; 119 gchar * current_skin_name; 120 116 121 #ifdef ENABLE_BACKGROUND 117 122 static WListbox *bg_list = NULL; 118 123 #endif /* ENABLE_BACKGROUND */ … … 515 520 } 516 521 517 522 /* --------------------------------------------------------------------------------------------- */ 523 524 static void 525 skin_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 545 static cb_ret_t 546 skin_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 553 static int 554 sel_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 597 void 598 appearance_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 /* --------------------------------------------------------------------------------------------- */ 518 639 519 640 void 520 641 panel_options_box (void) -
src/filemanager/boxes.h
old new 19 19 /*** declarations of public functions ************************************************************/ 20 20 21 21 void configure_box (void); 22 void appearance_box (void); 22 23 void panel_options_box (void); 23 24 int panel_listing_box (WPanel * p, char **user, char **mini, int *use_msformat, int num); 24 25 const panel_field_t *sort_box (dir_sort_options_t * op, const panel_field_t * sort_field); -
src/filemanager/midnight.c
old new 337 337 entries = 338 338 g_list_prepend (entries, menu_entry_create (_("C&onfirmation..."), CK_OptionsConfirm)); 339 339 entries = 340 g_list_prepend (entries, menu_entry_create (_("&Appearance..."), CK_OptionsAppearance)); 341 entries = 340 342 g_list_prepend (entries, menu_entry_create (_("&Display bits..."), CK_OptionsDisplayBits)); 341 343 entries = g_list_prepend (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys)); 342 344 #ifdef ENABLE_VFS … … 1250 1252 case CK_OptionsLayout: 1251 1253 layout_box (); 1252 1254 break; 1255 case CK_OptionsAppearance: 1256 appearance_box (); 1257 break; 1253 1258 case CK_LearnKeys: 1254 1259 learn_keys (); 1255 1260 break; … … 1743 1748 { 1744 1749 gboolean ret; 1745 1750 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 1754 1751 #ifdef USE_INTERNAL_EDIT 1755 1752 edit_stack_init (); 1756 1753 #endif 1757 1754 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, 1759 1756 midnight_event, "[main]", NULL, DLG_NONE); 1760 1757 1761 1758 /* Check if we were invoked as an editor or file viewer */ -
src/main.c
old new 352 352 353 353 tty_init_colors (mc_global.tty.disable_colors, mc_args__force_colors); 354 354 355 mc_skin_init (&error); 355 mc_skin_init (NULL, &error); 356 dlg_set_default_colors (); 356 357 if (error != NULL) 357 358 { 358 359 message (D_ERROR, _("Warning"), "%s", error->message); … … 360 361 error = NULL; 361 362 } 362 363 363 dlg_set_default_colors ();364 365 364 #ifdef ENABLE_SUBSHELL 366 365 /* Done here to ensure that the subshell doesn't */ 367 366 /* inherit the file descriptors opened below, etc */