mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-17 11:10:18 +00:00
fix: surface zoitechat.conf/colors.conf save failures; add missing theme prefs fwd decl
This commit is contained in:
@@ -1104,7 +1104,8 @@ zoitechat_exit (void)
|
||||
plugin_kill_all ();
|
||||
fe_cleanup ();
|
||||
|
||||
save_config ();
|
||||
if (!save_config ())
|
||||
g_printerr ("Could not save zoitechat.conf.\n");
|
||||
if (prefs.save_pevents)
|
||||
{
|
||||
pevent_save (NULL);
|
||||
|
||||
@@ -650,7 +650,8 @@ chanlist_minusers (GtkSpinButton *wid, server *serv)
|
||||
{
|
||||
serv->gui->chanlist_minusers = gtk_spin_button_get_value_as_int (wid);
|
||||
prefs.hex_gui_chanlist_minusers = serv->gui->chanlist_minusers;
|
||||
save_config();
|
||||
if (!save_config ())
|
||||
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||
|
||||
if (serv->gui->chanlist_minusers < serv->gui->chanlist_minusers_downloaded)
|
||||
{
|
||||
@@ -672,7 +673,8 @@ chanlist_maxusers (GtkSpinButton *wid, server *serv)
|
||||
{
|
||||
serv->gui->chanlist_maxusers = gtk_spin_button_get_value_as_int (wid);
|
||||
prefs.hex_gui_chanlist_maxusers = serv->gui->chanlist_maxusers;
|
||||
save_config();
|
||||
if (!save_config ())
|
||||
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -893,7 +895,8 @@ chanlist_opengui (server *serv, int do_refresh)
|
||||
if (prefs.hex_gui_chanlist_minusers < 1 || prefs.hex_gui_chanlist_minusers > 999999)
|
||||
{
|
||||
prefs.hex_gui_chanlist_minusers = 5;
|
||||
save_config();
|
||||
if (!save_config ())
|
||||
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||
}
|
||||
|
||||
serv->gui->chanlist_minusers = prefs.hex_gui_chanlist_minusers;
|
||||
@@ -904,7 +907,8 @@ chanlist_opengui (server *serv, int do_refresh)
|
||||
if (prefs.hex_gui_chanlist_maxusers < 1 || prefs.hex_gui_chanlist_maxusers > 999999)
|
||||
{
|
||||
prefs.hex_gui_chanlist_maxusers = 9999;
|
||||
save_config();
|
||||
if (!save_config ())
|
||||
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||
}
|
||||
|
||||
serv->gui->chanlist_maxusers = prefs.hex_gui_chanlist_maxusers;
|
||||
|
||||
@@ -3683,7 +3683,8 @@ static void
|
||||
search_set_option (GtkToggleButton *but, guint *pref)
|
||||
{
|
||||
*pref = gtk_toggle_button_get_active(but);
|
||||
save_config();
|
||||
if (!save_config ())
|
||||
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1002,7 +1002,8 @@ servlist_savegui (void)
|
||||
sp[0] = 0; /* spaces will break the login */
|
||||
/* strcpy (prefs.hex_irc_real_name, gtk_entry_get_text (GTK_ENTRY (entry_greal))); */
|
||||
servlist_save ();
|
||||
save_config (); /* For nicks stored in zoitechat.conf */
|
||||
if (!save_config ())
|
||||
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2193,8 +2193,10 @@ setup_ok_cb (GtkWidget *but, GtkWidget *win)
|
||||
{
|
||||
gtk_widget_destroy (win);
|
||||
setup_apply (&setup_prefs);
|
||||
save_config ();
|
||||
theme_manager_save_preferences ();
|
||||
if (!save_config ())
|
||||
fe_message (_("Could not save zoitechat.conf."), FE_MSG_ERROR);
|
||||
if (!theme_manager_save_preferences ())
|
||||
fe_message (_("Could not save colors.conf."), FE_MSG_ERROR);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
|
||||
@@ -57,9 +57,10 @@ theme_runtime_load (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
theme_runtime_save (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -119,8 +119,9 @@ void theme_runtime_load (void)
|
||||
{
|
||||
}
|
||||
|
||||
void theme_runtime_save (void)
|
||||
gboolean theme_runtime_save (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean theme_runtime_is_dark_active (void)
|
||||
|
||||
@@ -112,8 +112,9 @@ void theme_runtime_load (void)
|
||||
{
|
||||
}
|
||||
|
||||
void theme_runtime_save (void)
|
||||
gboolean theme_runtime_save (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean theme_runtime_is_dark_active (void)
|
||||
|
||||
@@ -122,8 +122,9 @@ void theme_runtime_load (void)
|
||||
{
|
||||
}
|
||||
|
||||
void theme_runtime_save (void)
|
||||
gboolean theme_runtime_save (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean theme_runtime_is_dark_active (void)
|
||||
|
||||
@@ -66,9 +66,10 @@ theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed)
|
||||
*palette_changed = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
theme_manager_save_preferences (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ThemePaletteBehavior
|
||||
|
||||
@@ -284,10 +284,10 @@ theme_manager_commit_preferences (unsigned int old_mode, gboolean *color_change)
|
||||
fe_set_auto_dark_mode_state (theme_policy_is_dark_mode_active (ZOITECHAT_DARK_MODE_AUTO));
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
theme_manager_save_preferences (void)
|
||||
{
|
||||
theme_runtime_save ();
|
||||
return theme_runtime_save ();
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
||||
@@ -43,7 +43,7 @@ void theme_manager_set_mode (unsigned int mode, gboolean *palette_changed);
|
||||
void theme_manager_set_token_color (unsigned int mode, ThemeSemanticToken token, const GdkRGBA *color, gboolean *palette_changed);
|
||||
void theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed);
|
||||
void theme_manager_commit_preferences (unsigned int old_mode, gboolean *color_change);
|
||||
void theme_manager_save_preferences (void);
|
||||
gboolean theme_manager_save_preferences (void);
|
||||
gboolean theme_changed_event_has_reason (const ThemeChangedEvent *event, ThemeChangedReason reason);
|
||||
void theme_manager_apply_and_dispatch (unsigned int mode, ThemeChangedReason reasons, gboolean *palette_changed);
|
||||
void theme_manager_dispatch_changed (ThemeChangedReason reasons);
|
||||
|
||||
@@ -70,6 +70,9 @@ typedef struct
|
||||
|
||||
#define COLOR_MANAGER_RESPONSE_RESET 1
|
||||
|
||||
static void
|
||||
theme_preferences_show_import_error (GtkWidget *button, const char *message);
|
||||
|
||||
static void
|
||||
theme_preferences_manager_row_free (gpointer data)
|
||||
{
|
||||
@@ -735,8 +738,9 @@ theme_preferences_manage_colors_cb (GtkWidget *button, gpointer user_data)
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
if (color_change_flag && *color_change_flag != old_changed)
|
||||
theme_manager_save_preferences ();
|
||||
if (color_change_flag && *color_change_flag != old_changed &&
|
||||
!theme_manager_save_preferences ())
|
||||
theme_preferences_show_import_error (button, _("Could not save colors.conf."));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -912,8 +916,9 @@ theme_preferences_import_colors_conf_cb (GtkWidget *button, gpointer user_data)
|
||||
|
||||
if (!any_imported)
|
||||
theme_preferences_show_import_error (button, _("No importable colors were found in that colors.conf file."));
|
||||
else if (color_change_flag && *color_change_flag != old_changed)
|
||||
theme_manager_save_preferences ();
|
||||
else if (color_change_flag && *color_change_flag != old_changed &&
|
||||
!theme_manager_save_preferences ())
|
||||
theme_preferences_show_import_error (button, _("Could not save colors.conf."));
|
||||
|
||||
g_free (cfg);
|
||||
g_free (path);
|
||||
|
||||
@@ -276,7 +276,7 @@ theme_runtime_load_migrated_legacy_color (char *cfg,
|
||||
return palette_read_legacy_color (cfg, mode->legacy_prefix, def->legacy_index, out_color);
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
palette_write_token_color (int fh, const char *mode_name, const ThemePaletteTokenDef *def, const GdkRGBA *color)
|
||||
{
|
||||
char prefname[256];
|
||||
@@ -284,13 +284,13 @@ palette_write_token_color (int fh, const char *mode_name, const ThemePaletteToke
|
||||
guint16 green;
|
||||
guint16 blue;
|
||||
|
||||
g_return_if_fail (mode_name != NULL);
|
||||
g_return_if_fail (def != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_val_if_fail (mode_name != NULL, FALSE);
|
||||
g_return_val_if_fail (def != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
g_snprintf (prefname, sizeof prefname, "theme.mode.%s.token.%s", mode_name, def->name);
|
||||
theme_palette_color_get_rgb16 (color, &red, &green, &blue);
|
||||
cfg_put_color (fh, red, green, blue, prefname);
|
||||
return cfg_put_color (fh, red, green, blue, prefname);
|
||||
}
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ theme_runtime_load (void)
|
||||
user_colors_valid = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
theme_runtime_save (void)
|
||||
{
|
||||
size_t i;
|
||||
@@ -487,9 +487,13 @@ theme_runtime_save (void)
|
||||
|
||||
fh = zoitechat_open_file ("colors.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
|
||||
if (fh == -1)
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
cfg_put_int (fh, THEME_PALETTE_MIGRATION_MARKER_VALUE, (char *) THEME_PALETTE_MIGRATION_MARKER_KEY);
|
||||
if (!cfg_put_int (fh, THEME_PALETTE_MIGRATION_MARKER_VALUE, (char *) THEME_PALETTE_MIGRATION_MARKER_KEY))
|
||||
{
|
||||
close (fh);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < mode_count; i++)
|
||||
{
|
||||
@@ -507,11 +511,18 @@ theme_runtime_save (void)
|
||||
if (!custom_tokens[def->token])
|
||||
continue;
|
||||
g_assert (theme_palette_get_color (modes[i].palette, def->token, &color));
|
||||
palette_write_token_color (fh, modes[i].mode_name, def, &color);
|
||||
if (!palette_write_token_color (fh, modes[i].mode_name, def, &color))
|
||||
{
|
||||
close (fh);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close (fh);
|
||||
if (close (fh) == -1)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef struct
|
||||
} ThemeGtkPaletteMap;
|
||||
|
||||
void theme_runtime_load (void);
|
||||
void theme_runtime_save (void);
|
||||
gboolean theme_runtime_save (void);
|
||||
gboolean theme_runtime_apply_mode (unsigned int mode, gboolean *palette_changed);
|
||||
gboolean theme_runtime_apply_dark_mode (gboolean enable);
|
||||
void theme_runtime_user_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
||||
|
||||
Reference in New Issue
Block a user