mirror of https://gitlab.com/nakst/essence
desktop: add option to save files without extensions by default
This commit is contained in:
parent
9c4d6f61f8
commit
6fb0a12fd3
|
@ -2253,6 +2253,16 @@ void ApplicationInstanceRequestSave(ApplicationInstance *instance, const char *n
|
|||
m.tabOperation.id = instance->embeddedWindowID;
|
||||
|
||||
if (!instance->documentID) {
|
||||
if (!EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("save_with_file_extensions"))) {
|
||||
for (intptr_t i = newNameBytes - 1; i >= 0; i--) {
|
||||
if (newName[i] == '.') {
|
||||
// Remove the file extension from the default new file name.
|
||||
newNameBytes = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t folderBytes;
|
||||
char *folder = EsSystemConfigurationReadString(EsLiteral("paths"), EsLiteral("default_user_documents"), &folderBytes);
|
||||
char *name = (char *) EsHeapAllocate(folderBytes + newNameBytes + 32, false);
|
||||
|
|
|
@ -171,6 +171,7 @@ void SettingsLoadDefaults() {
|
|||
SettingsPutValue("general", "enable_hover_state", EsLiteral("1"), nullptr, nullptr, true, false);
|
||||
SettingsPutValue("general", "enable_animations", EsLiteral("1"), nullptr, nullptr, true, false);
|
||||
SettingsPutValue("general", "keyboard_layout", EsLiteral("us"), nullptr, nullptr, true, false);
|
||||
SettingsPutValue("general", "save_with_file_extensions", EsLiteral("1"), nullptr, nullptr, true, false);
|
||||
SettingsPutValue("paths", "default_user_documents", EsLiteral("0:/"), nullptr, nullptr, true, false);
|
||||
}
|
||||
|
||||
|
@ -683,6 +684,17 @@ void SettingsPageDisplay(EsElement *element, SettingsPage *page) {
|
|||
100, 400, INTERFACE_STRING(CommonUnitPercent), 0.05, 5);
|
||||
}
|
||||
|
||||
void SettingsPageFiles(EsElement *element, SettingsPage *page) {
|
||||
// TODO.
|
||||
|
||||
EsPanel *content = EsPanelCreate(element, ES_CELL_FILL | ES_PANEL_V_SCROLL_AUTO | ES_PANEL_H_SCROLL_AUTO, EsStyleIntern(&styleSettingsGroupContainer));
|
||||
EsPanel *container = EsPanelCreate(content, ES_PANEL_VERTICAL, EsStyleIntern(&styleSettingsGroupContainer2));
|
||||
SettingsAddTitle(container, page);
|
||||
|
||||
EsPanel *table = EsPanelCreate(container, ES_CELL_H_FILL, EsStyleIntern(&styleSettingsCheckboxGroup));
|
||||
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsFilesSaveWithFileExtension), 'X', "general", "save_with_file_extensions");
|
||||
}
|
||||
|
||||
int SettingsColorButtonMessage(EsElement *element, EsMessage *message) {
|
||||
if (message->type == ES_MSG_PAINT_BACKGROUND) {
|
||||
// HACK This assumes a lot about the workings of the radiobox style...
|
||||
|
@ -868,6 +880,7 @@ SettingsPage settingsPages[] = {
|
|||
// { INTERFACE_STRING(DesktopSettingsAccessibility), ES_ICON_PREFERENCES_DESKTOP_ACCESSIBILITY, SettingsPageUnimplemented, 'A' }, // TODO.
|
||||
// { INTERFACE_STRING(DesktopSettingsDateAndTime), ES_ICON_PREFERENCES_SYSTEM_TIME, SettingsPageUnimplemented, 'C' }, // TODO.
|
||||
{ INTERFACE_STRING(DesktopSettingsDisplay), ES_ICON_PREFERENCES_DESKTOP_DISPLAY, SettingsPageDisplay, 'D' },
|
||||
{ INTERFACE_STRING(DesktopSettingsFiles), ES_ICON_USER_HOME_OPEN, SettingsPageFiles, 'S' },
|
||||
{ INTERFACE_STRING(DesktopSettingsKeyboard), ES_ICON_INPUT_KEYBOARD, SettingsPageKeyboard, 'E' },
|
||||
// { INTERFACE_STRING(DesktopSettingsLocalisation), ES_ICON_PREFERENCES_DESKTOP_LOCALE, SettingsPageUnimplemented, 'F' }, // TODO.
|
||||
{ INTERFACE_STRING(DesktopSettingsMouse), ES_ICON_INPUT_MOUSE, SettingsPageMouse, 'G' },
|
||||
|
|
|
@ -146,6 +146,7 @@ DEFINE_INTERFACE_STRING(DesktopSettingsApplications, "Applications");
|
|||
DEFINE_INTERFACE_STRING(DesktopSettingsDateAndTime, "Date and time");
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsDevices, "Devices");
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsDisplay, "Display");
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsFiles, "Files");
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsKeyboard, "Keyboard");
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsLocalisation, "Localisation");
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsMouse, "Mouse");
|
||||
|
@ -183,6 +184,8 @@ DEFINE_INTERFACE_STRING(DesktopSettingsThemeEnableHoverState, "Highlight the ite
|
|||
DEFINE_INTERFACE_STRING(DesktopSettingsThemeEnableAnimations, "Animate the user interface");
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsThemeWallpaper, "Wallpaper:");
|
||||
|
||||
DEFINE_INTERFACE_STRING(DesktopSettingsFilesSaveWithFileExtension, "Automatically add a file extension when creating files");
|
||||
|
||||
// File operations.
|
||||
|
||||
DEFINE_INTERFACE_STRING(FileCannotSave, "The document was not saved.");
|
||||
|
|
Loading…
Reference in New Issue