mirror of
https://github.com/jtheoof/swappy.git
synced 2024-08-17 02:30:47 +03:00
feat(config): add show_panel config
Allows to toggle paint panel on/off upon startup. Closes #12
This commit is contained in:
parent
8a82e796bb
commit
307f57956f
@ -59,12 +59,14 @@ The following lines can be used as swappy's default:
|
||||
```
|
||||
[Default]
|
||||
save_dir=$HOME/Desktop
|
||||
show_panel=false
|
||||
line_size=5
|
||||
text_size=20
|
||||
text_font=sans-serif
|
||||
```
|
||||
|
||||
- `save_dir` is where swappshots will be saved, can contain env variables and must exist in your filesystem
|
||||
- `show_panel` is used to toggle the paint panel on or off upon startup
|
||||
- `line_size` is the default line size (must be between 1 and 50)
|
||||
- `text_size` is the default text size (must be between 10 and 50)
|
||||
- `text_font` is the font used to render text, its format is pango friendly
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define CONFIG_LINE_SIZE_DEFAULT 5
|
||||
#define CONFIG_TEXT_FONT_DEFAULT "sans-serif"
|
||||
#define CONFIG_TEXT_SIZE_DEFAULT 20
|
||||
#define CONFIG_SHOW_PANEL_DEFAULT false
|
||||
|
||||
void config_load(struct swappy_state *state);
|
||||
void config_free(struct swappy_state *state);
|
@ -184,6 +184,7 @@ struct swappy_wayland {
|
||||
struct swappy_config {
|
||||
char *config_file;
|
||||
char *save_dir;
|
||||
gboolean show_panel;
|
||||
guint32 line_size;
|
||||
guint32 text_size;
|
||||
char *text_font;
|
||||
|
@ -658,9 +658,9 @@ static bool load_layout(struct swappy_state *state) {
|
||||
state->ui->window = window;
|
||||
|
||||
compute_window_size(state);
|
||||
|
||||
gtk_widget_set_size_request(area, state->window->width,
|
||||
state->window->height);
|
||||
action_toggle_painting_panel(state, &state->config->show_panel);
|
||||
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
|
||||
|
13
src/config.c
13
src/config.c
@ -13,6 +13,7 @@ static void print_config(struct swappy_config *config) {
|
||||
g_info("printing config:");
|
||||
g_info("config_dir: %s", config->config_file);
|
||||
g_info("save_dir: %s", config->save_dir);
|
||||
g_info("show_panel: %d", config->show_panel);
|
||||
g_info("line_size: %d", config->line_size);
|
||||
g_info("text_font: %s", config->text_font);
|
||||
g_info("text_size: %d", config->text_size);
|
||||
@ -67,6 +68,7 @@ static void load_config_from_file(struct swappy_config *config,
|
||||
GKeyFile *gkf;
|
||||
const gchar *group = "Default";
|
||||
gchar *save_dir = NULL;
|
||||
gboolean show_panel;
|
||||
gchar *save_dir_expanded = NULL;
|
||||
guint64 line_size, text_size;
|
||||
gchar *text_font = NULL;
|
||||
@ -150,6 +152,16 @@ static void load_config_from_file(struct swappy_config *config,
|
||||
error = NULL;
|
||||
}
|
||||
|
||||
show_panel = g_key_file_get_boolean(gkf, group, "show_panel", &error);
|
||||
|
||||
if (error == NULL) {
|
||||
config->show_panel = show_panel;
|
||||
} else {
|
||||
g_info("show_panel is missing in %s (%s)", file, error->message);
|
||||
g_error_free(error);
|
||||
error = NULL;
|
||||
}
|
||||
|
||||
g_key_file_free(gkf);
|
||||
}
|
||||
|
||||
@ -162,6 +174,7 @@ static void load_default_config(struct swappy_config *config) {
|
||||
config->line_size = CONFIG_LINE_SIZE_DEFAULT;
|
||||
config->text_font = g_strdup(CONFIG_TEXT_FONT_DEFAULT);
|
||||
config->text_size = CONFIG_TEXT_SIZE_DEFAULT;
|
||||
config->show_panel = CONFIG_SHOW_PANEL_DEFAULT;
|
||||
}
|
||||
|
||||
void config_load(struct swappy_state *state) {
|
||||
|
@ -62,6 +62,7 @@ The following lines can be used as swappy's default:
|
||||
```
|
||||
[Default]
|
||||
save_dir=$HOME/Desktop
|
||||
show_panel=false
|
||||
blur_level=80
|
||||
line_size=5
|
||||
text_size=20
|
||||
@ -69,6 +70,7 @@ The following lines can be used as swappy's default:
|
||||
```
|
||||
|
||||
- *save_dir* is where swappshots will be saved, can contain env variables and must exist in your filesystem
|
||||
- *show_panel* is used to toggle the paint panel on or off upon startup
|
||||
- *blur_level* is the default blur level (must be between 1 and 500)
|
||||
- *line_size* is the default line size (must be between 1 and 50)
|
||||
- *text_size* is the default text size (must be between 10 and 50)
|
||||
|
Loading…
Reference in New Issue
Block a user