mirror of
https://github.com/gryf/wmaker.git
synced 2026-03-25 06:03:31 +01:00
wmaker: allow the screenshot filename template to be set
This patch is adding a new option ScreenshotFilenameTemplate for users to change the default strftime format "screenshot_%Y-%m-%d_at_%H:%M:%S". For example, Teams is not allowing the ':' char in the filename of file to be shared so I always have to rename the file.
This commit is contained in:
committed by
Carlos R. Mafra
parent
412b3eace2
commit
be495bedbc
@@ -505,6 +505,7 @@ extern struct WPreferences {
|
|||||||
Cursor cursor[WCUR_LAST];
|
Cursor cursor[WCUR_LAST];
|
||||||
|
|
||||||
int switch_panel_icon_size; /* icon size in switch panel */
|
int switch_panel_icon_size; /* icon size in switch panel */
|
||||||
|
char *screenshot_filename_template; /* strftime format for screenshot filenames */
|
||||||
|
|
||||||
} wPreferences;
|
} wPreferences;
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ typedef struct {
|
|||||||
/* type converters */
|
/* type converters */
|
||||||
static WDECallbackConvert getBool;
|
static WDECallbackConvert getBool;
|
||||||
static WDECallbackConvert getInt;
|
static WDECallbackConvert getInt;
|
||||||
|
static WDECallbackConvert getString;
|
||||||
static WDECallbackConvert getCoord;
|
static WDECallbackConvert getCoord;
|
||||||
static WDECallbackConvert getPathList;
|
static WDECallbackConvert getPathList;
|
||||||
static WDECallbackConvert getEnum;
|
static WDECallbackConvert getEnum;
|
||||||
@@ -540,6 +541,8 @@ WDefaultEntry optionList[] = {
|
|||||||
&wPreferences.mouse_wheel_focus, getBool, NULL, NULL, NULL},
|
&wPreferences.mouse_wheel_focus, getBool, NULL, NULL, NULL},
|
||||||
{"KeychainTimeoutDelay", "500", NULL,
|
{"KeychainTimeoutDelay", "500", NULL,
|
||||||
&wPreferences.keychain_timeout_delay, getInt, NULL, NULL, NULL},
|
&wPreferences.keychain_timeout_delay, getInt, NULL, NULL, NULL},
|
||||||
|
{"ScreenshotFilenameTemplate", DEF_SCREENSHOT_FILENAME_TEMPLATE, NULL,
|
||||||
|
&wPreferences.screenshot_filename_template, getString, NULL, NULL, NULL},
|
||||||
|
|
||||||
/* style options */
|
/* style options */
|
||||||
|
|
||||||
@@ -1496,6 +1499,29 @@ static int string2index(WMPropList *key, WMPropList *val, const char *def, WOpti
|
|||||||
* ret - is the address to store a pointer to a temporary buffer. ret
|
* ret - is the address to store a pointer to a temporary buffer. ret
|
||||||
* must not be freed and is used by the set functions
|
* must not be freed and is used by the set functions
|
||||||
*/
|
*/
|
||||||
|
static int getString(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
|
||||||
|
{
|
||||||
|
const char *val;
|
||||||
|
char **sptr;
|
||||||
|
|
||||||
|
/* Parameter not used, but tell the compiler that it is ok */
|
||||||
|
(void) scr;
|
||||||
|
|
||||||
|
GET_STRING_OR_DEFAULT("String", val);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
*ret = (void *)val;
|
||||||
|
|
||||||
|
if (addr) {
|
||||||
|
sptr = (char **)addr;
|
||||||
|
if (*sptr)
|
||||||
|
wfree(*sptr);
|
||||||
|
*sptr = wstrdup(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
|
static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
|
||||||
{
|
{
|
||||||
static char data;
|
static char data;
|
||||||
|
|||||||
@@ -1270,7 +1270,14 @@ void ScreenCapture(WScreen *scr, int mode)
|
|||||||
|
|
||||||
s = time(NULL);
|
s = time(NULL);
|
||||||
tm_info = localtime(&s);
|
tm_info = localtime(&s);
|
||||||
strftime(filename_date_part, sizeof(filename_date_part), "screenshot_%Y-%m-%d_at_%H:%M:%S", tm_info);
|
strftime(filename_date_part, sizeof(filename_date_part), wPreferences.screenshot_filename_template, tm_info);
|
||||||
|
|
||||||
|
if (strchr(filename_date_part, '/') != NULL) {
|
||||||
|
wfree(screenshot_dir);
|
||||||
|
werror(_("Unsafe screenshot filename template, it should not contain a path separator"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(filename, filename_date_part);
|
strcpy(filename, filename_date_part);
|
||||||
|
|
||||||
filepath = wstrconcat(screenshot_dir, strcat(filename, filetype));
|
filepath = wstrconcat(screenshot_dir, strcat(filename, filetype));
|
||||||
|
|||||||
@@ -191,6 +191,9 @@
|
|||||||
#define DEF_APPMENU_X 10
|
#define DEF_APPMENU_X 10
|
||||||
#define DEF_APPMENU_Y 10
|
#define DEF_APPMENU_Y 10
|
||||||
|
|
||||||
|
/* default strftime format for screenshot filenames */
|
||||||
|
#define DEF_SCREENSHOT_FILENAME_TEMPLATE "\"screenshot_%Y-%m-%d_at_%H:%M:%S\""
|
||||||
|
|
||||||
/* calculate window edge resistance from edge resistance */
|
/* calculate window edge resistance from edge resistance */
|
||||||
#define WIN_RESISTANCE(x) (((x)*20)/30)
|
#define WIN_RESISTANCE(x) (((x)*20)/30)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user