Skip to content

Commit

Permalink
add theme setting to utox_save
Browse files Browse the repository at this point in the history
while we're at it
  • Loading branch information
stal888 committed Apr 6, 2015
1 parent baf8e80 commit 3c447f9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion main.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ typedef struct
uint8_t zero : 2;
uint16_t audio_device_in;
uint16_t audio_device_out;
uint16_t unused[32];
uint8_t theme;
uint8_t nothing;
uint16_t unused[31];
uint8_t proxy_ip[0];
}UTOX_SAVE;

Expand Down
1 change: 1 addition & 0 deletions theme.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void theme_load(char loadtheme)
{
// Update the settings dropdown UI
dropdown_theme.selected = loadtheme;
theme = loadtheme;

// ==== Default theme ====
//---- Main chat area ----
Expand Down
5 changes: 3 additions & 2 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ UTOX_SAVE* config_load(void)
save->proxy_ip[0] = 0;
save->filter = 0;
save->audio_device_in = ~0;
// save->theme = 0;
save->theme = 0;

config_osdefaults(save);
NEXT:
Expand All @@ -643,7 +643,7 @@ UTOX_SAVE* config_load(void)
dropdown_audible_notification.selected = dropdown_audible_notification.over = !save->audible_notifications_enabled;
dropdown_audio_filtering.selected = dropdown_audio_filtering.over = !save->audio_filtering_enabled;
dropdown_filter.selected = FILTER = save->filter;
// dropdown_theme_onselect.selected = dropdown_theme_onselect.over = save->theme;
//dropdown_theme_onselect.selected = dropdown_theme_onselect.over = save->theme;

options.ipv6_enabled = save->enableipv6;
options.udp_enabled = !save->disableudp;
Expand Down Expand Up @@ -697,6 +697,7 @@ void config_save(UTOX_SAVE *save)

save->audio_device_in = dropdown_audio_in.selected;
save->audio_device_out = dropdown_audio_out.selected;
save->theme = theme;
memset(save->unused, 0, sizeof(save->unused));

debug("Writing uTox Save ::\n");
Expand Down
13 changes: 11 additions & 2 deletions xlib/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ _Bool parse_args_wait_for_theme;
int main(int argc, char *argv[])
{
parse_args_wait_for_theme = 0;
_Bool theme_was_set_on_argv = 0;
theme = THEME_DEFAULT;

if (argc > 1)
Expand All @@ -886,21 +887,25 @@ int main(int argc, char *argv[])
if(!strcmp(argv[i], "default")) {
theme = THEME_DEFAULT;
parse_args_wait_for_theme = 0;
theme_was_set_on_argv = 1;
continue;
}
if(!strcmp(argv[i], "dark")) {
theme = THEME_DARK;
parse_args_wait_for_theme = 0;
theme_was_set_on_argv = 1;
continue;
}
if(!strcmp(argv[i], "light")) {
theme = THEME_LIGHT;
parse_args_wait_for_theme = 0;
theme_was_set_on_argv = 1;
continue;
}
if(!strcmp(argv[i], "highcontrast")) {
theme = THEME_HIGHCONTRAST;
parse_args_wait_for_theme = 0;
theme_was_set_on_argv = 1;
continue;
}
debug("Please specify correct theme (please check user manual for list of correct values).");
Expand Down Expand Up @@ -955,11 +960,14 @@ int main(int argc, char *argv[])
PropertyChangeMask,
};

theme_load(theme);

/* load save data */
UTOX_SAVE *save = config_load();

if (!theme_was_set_on_argv)
theme = save->theme;
printf("%d\n", theme);
theme_load(theme);

/* create window */
window = XCreateWindow(display, RootWindow(display, screen), save->window_x, save->window_y, save->window_width, save->window_height, 0, depth, InputOutput, visual, CWBackPixmap | CWBorderPixel | CWEventMask, &attrib);

Expand Down Expand Up @@ -1152,6 +1160,7 @@ int main(int argc, char *argv[])
.window_y = y_return < 0 ? 0 : y_return,
.window_width = width_return,
.window_height = height_return,
.theme = theme,
};

config_save(&d);
Expand Down

0 comments on commit 3c447f9

Please sign in to comment.