wallpaper: bundle stock wallpapers and default to geminux-dark.png
This commit is contained in:
1 parent
8a7d466655
commit
5472d4273a
9 files changed
+94
-19
No files matched your search
@@ -215,6 +215,13 @@ static void wp_conf_path(char *out, size_t sz) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool wp_load_user_or_default_cfg(geminux_wp_cfg_t *cfg) {
|
||||
char cpath[560];
|
||||
wp_conf_path(cpath, sizeof(cpath));
|
||||
if (geminux_wp_cfg_load(cpath, cfg)) return true;
|
||||
return geminux_wp_cfg_load("/etc/skel/.config/geminux/wallpaper.conf", cfg);
|
||||
}
|
||||
|
||||
static void set_focus_input(themes_state_t *st, int hit_id, char *buf, size_t cap) {
|
||||
st->focus_id = hit_id;
|
||||
st->focus_buf = buf;
|
||||
@@ -851,9 +858,7 @@ static void wp_select_first_image_if_dir(themes_state_t *st) {
|
||||
|
||||
static void wp_init_state(themes_state_t *st) {
|
||||
st->wp_initialized = true;
|
||||
char cpath[560];
|
||||
wp_conf_path(cpath, sizeof(cpath));
|
||||
geminux_wp_cfg_load(cpath, &st->wp_cfg);
|
||||
wp_load_user_or_default_cfg(&st->wp_cfg);
|
||||
wp_sync_rgb_from_cfg(st);
|
||||
snprintf(st->wp_path_input, sizeof(st->wp_path_input), "%.*s",
|
||||
(int)(sizeof(st->wp_path_input) - 1), st->wp_cfg.path);
|
||||
@@ -1407,25 +1412,36 @@ static void draw_wallpaper_view(themes_state_t *st, cairo_t *cr, int w, int h) {
|
||||
int left_rem_h = (y + body_h) - ly;
|
||||
if (st->wp_cfg.type == GEMINUX_WP_IMAGE) {
|
||||
int in_h = 52;
|
||||
int gap = 10;
|
||||
int all_w = 110;
|
||||
int qbw = (left_w - all_w - gap * 4) / 4;
|
||||
int gap = 8;
|
||||
int all_w = 96;
|
||||
int avail_w = left_w - all_w - gap * 5;
|
||||
const char *home = getenv("HOME");
|
||||
const char *hdir = (home && home[0]) ? home : "/";
|
||||
char pics_dir[560];
|
||||
snprintf(pics_dir, sizeof(pics_dir), "%s/Pictures", strcmp(hdir, "/") == 0 ? "" : hdir);
|
||||
bool q_active[4] = {
|
||||
char sys_dir[128];
|
||||
if (!wp_find_system_dir(sys_dir, sizeof(sys_dir))) {
|
||||
snprintf(sys_dir, sizeof(sys_dir), "/usr/share/geminux/wallpapers");
|
||||
}
|
||||
bool q_active[5] = {
|
||||
strcmp(st->wp_dir, sys_dir) == 0,
|
||||
strcmp(st->wp_dir, hdir) == 0,
|
||||
strcmp(st->wp_dir, pics_dir) == 0,
|
||||
strcmp(st->wp_dir, "/media/sdcard") == 0,
|
||||
strcmp(st->wp_dir, "/") == 0,
|
||||
};
|
||||
const char *qnames[4] = {"Home", "Pictures", "SD Card", "Root /"};
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gemui_draw_button(st->app, cr, (gemui_rect_t){pad + i * (qbw + gap), ly, qbw, in_h},
|
||||
const char *qnames[5] = {"Stock", "Home", "Pictures", "SD Card", "/"};
|
||||
const int qweights[5] = {18, 16, 22, 20, 10};
|
||||
int cur_x = pad;
|
||||
int used_w = 0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int bw = (i < 4) ? (avail_w * qweights[i]) / 86 : (avail_w - used_w);
|
||||
gemui_draw_button(st->app, cr, (gemui_rect_t){cur_x, ly, bw, in_h},
|
||||
qnames[i], HIT_WP_QUICK_DIR, i, false, q_active[i], false);
|
||||
cur_x += bw + gap;
|
||||
used_w += bw;
|
||||
}
|
||||
gemui_draw_button(st->app, cr, (gemui_rect_t){pad + 4 * (qbw + gap), ly, left_w - 4 * (qbw + gap), in_h},
|
||||
gemui_draw_button(st->app, cr, (gemui_rect_t){cur_x, ly, (pad + left_w) - cur_x, in_h},
|
||||
"All", HIT_WP_TOGGLE_ALL, 0, false, st->wp_show_all, false);
|
||||
ly += in_h + 12;
|
||||
|
||||
@@ -2135,11 +2151,15 @@ static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, v
|
||||
const char *home = getenv("HOME");
|
||||
const char *h = (home && home[0]) ? home : "/";
|
||||
char target[640] = "";
|
||||
if (hit->val == 1) {
|
||||
snprintf(target, sizeof(target), "%s/Pictures", strcmp(h, "/") == 0 ? "" : h);
|
||||
if (hit->val == 0) {
|
||||
if (!wp_find_system_dir(target, sizeof(target))) snprintf(target, sizeof(target), "%s", h);
|
||||
} else if (hit->val == 1) {
|
||||
snprintf(target, sizeof(target), "%s", h);
|
||||
} else if (hit->val == 2) {
|
||||
snprintf(target, sizeof(target), "/media/sdcard");
|
||||
snprintf(target, sizeof(target), "%s/Pictures", strcmp(h, "/") == 0 ? "" : h);
|
||||
} else if (hit->val == 3) {
|
||||
snprintf(target, sizeof(target), "/media/sdcard");
|
||||
} else if (hit->val == 4) {
|
||||
snprintf(target, sizeof(target), "/");
|
||||
} else {
|
||||
snprintf(target, sizeof(target), "%s", h);
|
||||
@@ -2224,10 +2244,8 @@ static void print_wallpaper_usage(FILE *out) {
|
||||
}
|
||||
|
||||
static int cli_restore_wallpaper(void) {
|
||||
char cpath[560];
|
||||
wp_conf_path(cpath, sizeof(cpath));
|
||||
geminux_wp_cfg_t cfg;
|
||||
if (!geminux_wp_cfg_load(cpath, &cfg)) {
|
||||
if (!wp_load_user_or_default_cfg(&cfg)) {
|
||||
return 0;
|
||||
}
|
||||
if (cfg.type == GEMINUX_WP_IMAGE && !cfg.path[0]) {
|
||||
|
||||
Reference in new issue
Block a user