summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-06-25 07:15:34 -0400
committerVictor Kareh <[email protected]>2019-06-28 08:38:58 -0400
commitcc81a57b2a6164defdc6059bcdf2e8ff9cafbfa4 (patch)
tree725e5a04bacfe5af53b0362bca677af374852add
parent2dad68c9ccdd7921292d0afb6b7855dcfdd6e3ac (diff)
downloadpluma-cc81a57b2a6164defdc6059bcdf2e8ff9cafbfa4.tar.bz2
pluma-cc81a57b2a6164defdc6059bcdf2e8ff9cafbfa4.tar.xz
preferences: Fix inconsistent active state of trailing characters
When unchecking and then re-checking draw_spaces (or tabs) while draw_trailing_spaces is active, the trailing preference is no longer set, but the button shows up as set. This change makes it so that it unsets the option prior to disabling the checkbox.
-rw-r--r--pluma/dialogs/pluma-preferences-dialog.c62
1 files changed, 38 insertions, 24 deletions
diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c
index f0204a02..d7726bd3 100644
--- a/pluma/dialogs/pluma-preferences-dialog.c
+++ b/pluma/dialogs/pluma-preferences-dialog.c
@@ -216,20 +216,22 @@ static void
draw_spaces_checkbutton_toggled (GtkToggleButton *button,
PlumaPreferencesDialog *dlg)
{
- int v;
+ DrawSpacesSettings setting;
pluma_debug (DEBUG_PREFS);
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_spaces_checkbutton));
if (gtk_toggle_button_get_active (button))
- v = DRAW_ALL;
+ setting = DRAW_ALL;
else
- v = DRAW_NONE;
+ setting = DRAW_NONE;
- pluma_prefs_manager_set_draw_spaces (v);
+ pluma_prefs_manager_set_draw_spaces (setting);
#ifdef GTK_SOURCE_VERSION_3_24
- gtk_widget_set_sensitive (GTK_WIDGET (dlg->priv->draw_trailing_spaces_checkbutton), v > DRAW_NONE);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton), v == DRAW_NONE);
+ if (setting == DRAW_NONE)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (dlg->priv->draw_trailing_spaces_checkbutton), setting > DRAW_NONE);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton), setting == DRAW_NONE);
#endif
}
@@ -245,27 +247,34 @@ draw_trailing_spaces_checkbutton_toggled (GtkToggleButton *button,
if (gtk_toggle_button_get_active (button))
pluma_prefs_manager_set_draw_spaces (DRAW_TRAILING);
else
- pluma_prefs_manager_set_draw_spaces (DRAW_ALL);
+ {
+ if (pluma_prefs_manager_get_draw_spaces ())
+ pluma_prefs_manager_set_draw_spaces (DRAW_ALL);
+ else
+ pluma_prefs_manager_set_draw_spaces (DRAW_NONE);
+ }
}
static void
draw_tabs_checkbutton_toggled (GtkToggleButton *button,
PlumaPreferencesDialog *dlg)
{
- int v;
+ DrawSpacesSettings setting;
pluma_debug (DEBUG_PREFS);
g_return_if_fail (button == GTK_TOGGLE_BUTTON(dlg->priv->draw_tabs_checkbutton));
if (gtk_toggle_button_get_active (button))
- v = DRAW_ALL;
+ setting = DRAW_ALL;
else
- v = DRAW_NONE;
+ setting = DRAW_NONE;
- pluma_prefs_manager_set_draw_tabs (v);
+ pluma_prefs_manager_set_draw_tabs (setting);
#ifdef GTK_SOURCE_VERSION_3_24
- gtk_widget_set_sensitive (GTK_WIDGET(dlg->priv->draw_trailing_tabs_checkbutton), v > DRAW_NONE);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON(dlg->priv->draw_trailing_tabs_checkbutton), v == DRAW_NONE);
+ if (setting == DRAW_NONE)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_tabs_checkbutton), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET(dlg->priv->draw_trailing_tabs_checkbutton), setting > DRAW_NONE);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON(dlg->priv->draw_trailing_tabs_checkbutton), setting == DRAW_NONE);
#endif
}
@@ -280,7 +289,12 @@ draw_trailing_tabs_checkbutton_toggled (GtkToggleButton *button,
if (gtk_toggle_button_get_active (button))
pluma_prefs_manager_set_draw_tabs (DRAW_TRAILING);
else
- pluma_prefs_manager_set_draw_tabs (DRAW_ALL);
+ {
+ if (pluma_prefs_manager_get_draw_tabs ())
+ pluma_prefs_manager_set_draw_tabs (DRAW_ALL);
+ else
+ pluma_prefs_manager_set_draw_tabs (DRAW_NONE);
+ }
}
static void
@@ -348,33 +362,33 @@ setup_editor_page (PlumaPreferencesDialog *dlg)
/* Set initial state */
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->tabs_width_spinbutton),
(guint) pluma_prefs_manager_get_tabs_size ());
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->insert_spaces_checkbutton),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->insert_spaces_checkbutton),
pluma_prefs_manager_get_insert_spaces ());
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_indent_checkbutton),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_indent_checkbutton),
pluma_prefs_manager_get_auto_indent ());
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_spaces_checkbutton),
- pluma_prefs_manager_get_draw_spaces () > 0);
+ pluma_prefs_manager_get_draw_spaces () > DRAW_NONE);
#ifdef GTK_SOURCE_VERSION_3_24
gtk_widget_set_sensitive (GTK_WIDGET (dlg->priv->draw_trailing_spaces_checkbutton),
- pluma_prefs_manager_get_draw_spaces () > 0);
+ pluma_prefs_manager_get_draw_spaces () > DRAW_NONE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton),
- pluma_prefs_manager_get_draw_spaces () == 0);
+ pluma_prefs_manager_get_draw_spaces () == DRAW_NONE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton),
- pluma_prefs_manager_get_draw_spaces () == 1);
+ pluma_prefs_manager_get_draw_spaces () == DRAW_TRAILING);
#else
gtk_widget_set_sensitive (GTK_WIDGET (dlg->priv->draw_trailing_spaces_checkbutton), FALSE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton), FALSE);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_tabs_checkbutton),
- pluma_prefs_manager_get_draw_tabs () > 0);
+ pluma_prefs_manager_get_draw_tabs () > DRAW_NONE);
#ifdef GTK_SOURCE_VERSION_3_24
gtk_widget_set_sensitive (GTK_WIDGET (dlg->priv->draw_trailing_tabs_checkbutton),
- pluma_prefs_manager_get_draw_tabs () > 0);
+ pluma_prefs_manager_get_draw_tabs () > DRAW_NONE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_tabs_checkbutton),
- pluma_prefs_manager_get_draw_tabs () == 0);
+ pluma_prefs_manager_get_draw_tabs () == DRAW_NONE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_tabs_checkbutton),
- pluma_prefs_manager_get_draw_tabs () == 1);
+ pluma_prefs_manager_get_draw_tabs () == DRAW_TRAILING);
#else
gtk_widget_set_sensitive (GTK_WIDGET (dlg->priv->draw_trailing_tabs_checkbutton), FALSE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_tabs_checkbutton), FALSE);