Ticket #2165: vitalif_skin-selection.diff
File vitalif_skin-selection.diff, 11.2 KB (added by vitalif, 10 years ago) |
---|
-
lib/keybind.h
commit 023aeb3da9a7be530dfc882c628caecb02736dfd Author: Vitaliy Filippov <vitalif@yourcmc.ru> Date: Fri Feb 7 03:54:37 2014 +0400 Skin selection UI
old new 154 154 CK_ConnectSmb, 155 155 CK_PanelInfo, 156 156 CK_Jobs, 157 CK_OptionsSkin, 157 158 CK_OptionsLayout, 158 159 CK_Link, 159 160 CK_PanelListing, -
lib/skin.h
old new 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/ini-file.c
old new 124 124 125 125 /* --------------------------------------------------------------------------------------------- */ 126 126 127 static void 128 mc_skin_get_list_from_dir (const gchar * base_dir, GArray * list) 129 { 130 unsigned int i; 131 char *dir_name; 132 DIR *dir; 133 gchar *name; 134 135 dir_name = g_build_filename (base_dir, MC_SKINS_SUBDIR, NULL); 136 dir = opendir (dir_name); 137 if (dir != NULL) 138 { 139 struct dirent *de; 140 while ((de = readdir(dir)) != NULL) 141 { 142 if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) 143 continue; 144 if (strlen(de->d_name) > 4 && !strcmp(de->d_name + strlen(de->d_name) - 4, ".ini")) 145 de->d_name[strlen(de->d_name) - 4] = '\0'; 146 for (i = 0; i < list->len; i++) 147 if (!strcmp(de->d_name, g_array_index(list, gchar *, i))) 148 break; 149 if (i < list->len) 150 continue; 151 name = g_strdup(de->d_name); 152 g_array_append_val(list, name); 153 } 154 closedir(dir); 155 } 156 g_free(dir_name); 157 } 158 159 /* --------------------------------------------------------------------------------------------- */ 160 161 static int pstrcmp (char **a, char **b) 162 { 163 return strcmp(*a, *b); 164 } 165 166 /* --------------------------------------------------------------------------------------------- */ 167 168 GArray * 169 mc_skin_list () 170 { 171 GArray *list = g_array_new(FALSE, FALSE, sizeof(gchar *)); 172 /* ${XDG_DATA_HOME}/mc/skins/ */ 173 mc_skin_get_list_from_dir (mc_config_get_data_path (), list); 174 /* /etc/mc/skins/ */ 175 mc_skin_get_list_from_dir (mc_global.sysconfig_dir, list); 176 /* /usr/share/mc/skins/ */ 177 mc_skin_get_list_from_dir (mc_global.share_data_dir, list); 178 g_array_sort(list, (GCompareFunc) pstrcmp); 179 return list; 180 } 181 182 /* --------------------------------------------------------------------------------------------- */ 183 127 184 void 128 185 mc_skin_set_hardcoded_skin (mc_skin_t * mc_skin) 129 186 { -
po/ru.po
old new 3065 3065 msgid "Layout" 3066 3066 msgstr "Внешний вид" 3067 3067 3068 msgid "&Skin..." 3069 msgstr "&Оформление..." 3070 3071 msgid "Choose skin" 3072 msgstr "Выберите оформление" 3073 3074 msgid "< Default >" 3075 msgstr "< По умолчанию >" 3076 3068 3077 msgid "File listin&g" 3069 3078 msgstr "&Список файлов" 3070 3079 -
src/filemanager/Makefile.am
old new 5 5 achown.c achown.h \ 6 6 boxes.c boxes.h \ 7 7 chmod.c chmod.h \ 8 chooseskin.c chooseskin.h \ 8 9 chown.c chown.h \ 9 10 cmd.c cmd.h \ 10 11 command.c command.h \ -
new file mc-4.8.11/src/filemanager/chooseskin.c
- + 1 /* 2 User interface for skin selection. 3 4 Copyright (C) 2014 5 Vitaliy Filippov <vitalif at mail ru> 6 7 Written by: 8 Vitaliy Filippov <vitalif at mail ru> 9 10 This file is part of the Midnight Commander. 11 12 The Midnight Commander is free software: you can redistribute it 13 and/or modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation, either version 3 of the License, 15 or (at your option) any later version. 16 17 The Midnight Commander is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program. If not, see <http://www.gnu.org/licenses/>. 24 */ 25 26 /** \file 27 * \brief Source: user %interface for skin %selection 28 * \author Vitaliy Filippov 29 * \date 2014 30 */ 31 32 #include <config.h> 33 34 #include <stdlib.h> 35 #include <sys/types.h> 36 37 #include "lib/global.h" 38 #include "lib/widget.h" /* Listbox */ 39 #include "lib/skin.h" 40 #include "midnight.h" 41 #include "chooseskin.h" 42 43 /*** global variables ****************************************************************************/ 44 45 /*** file scope macro definitions ****************************************************************/ 46 47 #define MAX_ENTRY_LEN 40 48 #define LIST_LINES 14 49 #define N_DFLT_ENTRIES 1 50 51 /*** file scope type declarations ****************************************************************/ 52 53 /*** file scope variables ************************************************************************/ 54 55 /*** file scope functions ************************************************************************/ 56 57 static int 58 exec_skin_dialog (GArray *names, const char *current_skin) 59 { 60 int i; 61 62 Listbox *skinlist = create_listbox_window (LIST_LINES, MAX_ENTRY_LEN, 63 _("Choose skin"), NULL); 64 LISTBOX_APPEND_TEXT (skinlist, 'A', _("< Default >"), NULL); 65 66 for (i = 0; i < names->len; i++) 67 { 68 LISTBOX_APPEND_TEXT (skinlist, 0, g_array_index(names, char*, i), NULL); 69 if (current_skin && !strcmp(g_array_index(names, char*, i), current_skin)) 70 listbox_select_entry (skinlist->list, i+N_DFLT_ENTRIES); 71 } 72 73 return run_listbox (skinlist); 74 } 75 76 /* --------------------------------------------------------------------------------------------- */ 77 /*** public functions ****************************************************************************/ 78 /* --------------------------------------------------------------------------------------------- */ 79 80 void 81 filemanager_skin_dialog () 82 { 83 int skin; 84 85 GArray *names = mc_skin_list (); 86 char *current_skin = mc_skin__default.name; 87 skin = exec_skin_dialog (names, current_skin); 88 89 if (skin >= 0) 90 { 91 GError *error = NULL; 92 dlg_colors_t midnight_colors; 93 mc_skin_deinit (); 94 if (mc_global.tty.skin) 95 { 96 g_free(mc_global.tty.skin); 97 } 98 if (skin == 0) 99 { 100 /* default skin */ 101 mc_global.tty.skin = g_strdup ("default"); 102 } 103 else 104 { 105 mc_global.tty.skin = g_strdup (g_array_index (names, char *, skin-N_DFLT_ENTRIES)); 106 } 107 mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, "skin", mc_global.tty.skin); 108 mc_skin_init (&error); 109 if (error != NULL) 110 { 111 message (D_ERROR, _("Warning"), "%s", error->message); 112 g_error_free (error); 113 error = NULL; 114 } 115 116 /* refresh panel colors */ 117 panel_deinit (); 118 panel_init (); 119 120 /* refresh global dialog colors */ 121 midnight_colors[DLG_COLOR_NORMAL] = mc_skin_color_get ("dialog", "_default_"); 122 midnight_colors[DLG_COLOR_FOCUS] = mc_skin_color_get ("dialog", "focus"); 123 midnight_colors[DLG_COLOR_HOT_NORMAL] = mc_skin_color_get ("dialog", "hotnormal"); 124 midnight_colors[DLG_COLOR_HOT_FOCUS] = mc_skin_color_get ("dialog", "hotfocus"); 125 midnight_colors[DLG_COLOR_TITLE] = mc_skin_color_get ("dialog", "title"); 126 memmove (midnight_dlg->color, midnight_colors, sizeof (dlg_colors_t)); 127 128 /* refresh highlighting colors */ 129 mc_fhl_free (&mc_filehighlight); 130 mc_filehighlight = mc_fhl_new (TRUE); 131 132 dlg_redraw(midnight_dlg); 133 } 134 135 for (skin = 0; skin < names->len; skin++) 136 g_free (g_array_index (names, char *, skin)); 137 g_array_free (names, TRUE); 138 } 139 140 /* --------------------------------------------------------------------------------------------- */ -
new file mc-4.8.11/src/filemanager/chooseskin.h
- + 1 /** \file chooseskin.h 2 * \brief Header: skin choose dialog for Midnight Commander 3 */ 4 5 #ifndef MC__CHOOSESKIN_H 6 #define MC__CHOOSESKIN_H 7 8 /*** typedefs(not structures) and defined constants **********************************************/ 9 10 /*** enums ***************************************************************************************/ 11 12 /*** structures declarations (and typedefs of structures)*****************************************/ 13 14 /*** global variables defined in .c file *********************************************************/ 15 16 /*** declarations of public functions ************************************************************/ 17 18 void filemanager_skin_dialog (void); 19 20 /*** inline functions ****************************************************************************/ 21 22 #endif /* MC__CHOOSESKIN_H */ -
src/filemanager/midnight.c
old new 77 77 #include "chmod.h" 78 78 #include "chown.h" 79 79 #include "achown.h" 80 #include "chooseskin.h" 80 81 81 82 #ifdef USE_INTERNAL_EDIT 82 83 #include "src/editor/edit.h" … … 332 333 GList *entries = NULL; 333 334 334 335 entries = g_list_prepend (entries, menu_entry_create (_("&Configuration..."), CK_Options)); 336 entries = g_list_prepend (entries, menu_entry_create (_("&Skin..."), CK_OptionsSkin)); 335 337 entries = g_list_prepend (entries, menu_entry_create (_("&Layout..."), CK_OptionsLayout)); 336 338 entries = g_list_prepend (entries, menu_entry_create (_("&Panel options..."), CK_OptionsPanel)); 337 339 entries = … … 1247 1249 jobs_cmd (); 1248 1250 break; 1249 1251 #endif 1252 case CK_OptionsSkin: 1253 filemanager_skin_dialog (); 1254 break; 1250 1255 case CK_OptionsLayout: 1251 1256 layout_box (); 1252 1257 break;