From de6bc223dfdd1610064317c44e892523b05a0cb7 Mon Sep 17 00:00:00 2001 From: mbkma Date: Sat, 1 Aug 2020 10:46:20 +0200 Subject: add optional grid background pattern --- pluma/dialogs/pluma-preferences-dialog.c | 30 ++++++++++++ pluma/dialogs/pluma-preferences-dialog.ui | 80 +++++++++++++++++++++++++++++++ pluma/dialogs/ui-a11y.suppr | 2 + pluma/pluma-settings.h | 1 + pluma/pluma-view.c | 6 +++ 5 files changed, 119 insertions(+) (limited to 'pluma') diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c index 4ba26378..178c54bc 100644 --- a/pluma/dialogs/pluma-preferences-dialog.c +++ b/pluma/dialogs/pluma-preferences-dialog.c @@ -130,6 +130,9 @@ struct _PlumaPreferencesDialogPrivate /* Highlight matching bracket */ GtkWidget *bracket_matching_checkbutton; + /* Display grid pattern */ + GtkWidget *display_grid_checkbutton; + /* Display overview map */ GtkWidget *display_overview_map_checkbutton; @@ -463,10 +466,25 @@ right_margin_checkbutton_toggled (GtkToggleButton *button, active); } +static void +grid_checkbutton_toggled (GtkToggleButton *button, + PlumaPreferencesDialog *dlg) +{ + GtkSourceBackgroundPatternType background_type; + + background_type = gtk_toggle_button_get_active (button) ? + GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID : + GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE; + g_settings_set_enum (dlg->priv->editor_settings, + PLUMA_SETTINGS_BACKGROUND_PATTERN, + background_type); +} + static void setup_view_page (PlumaPreferencesDialog *dlg) { GtkWrapMode wrap_mode; + GtkSourceBackgroundPatternType background_pattern; gboolean display_right_margin; pluma_debug (DEBUG_PREFS); @@ -479,6 +497,9 @@ setup_view_page (PlumaPreferencesDialog *dlg) wrap_mode = pluma_settings_get_wrap_mode (dlg->priv->editor_settings, PLUMA_SETTINGS_WRAP_MODE); + background_pattern = g_settings_get_enum (dlg->priv->editor_settings, + PLUMA_SETTINGS_BACKGROUND_PATTERN); + switch (wrap_mode) { case GTK_WRAP_WORD: @@ -506,6 +527,10 @@ setup_view_page (PlumaPreferencesDialog *dlg) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->right_margin_checkbutton), display_right_margin); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (dlg->priv->display_grid_checkbutton), + background_pattern == GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID); + /* Set widgets sensitivity */ gtk_widget_set_sensitive (dlg->priv->split_checkbutton, (wrap_mode != GTK_WRAP_NONE)); @@ -549,6 +574,10 @@ setup_view_page (PlumaPreferencesDialog *dlg) "toggled", G_CALLBACK (right_margin_checkbutton_toggled), dlg); + g_signal_connect (dlg->priv->display_grid_checkbutton, + "toggled", + G_CALLBACK (grid_checkbutton_toggled), + dlg); } static void @@ -1231,6 +1260,7 @@ pluma_preferences_dialog_init (PlumaPreferencesDialog *dlg) "highlight_current_line_checkbutton", &dlg->priv->highlight_current_line_checkbutton, "bracket_matching_checkbutton", &dlg->priv->bracket_matching_checkbutton, "display_overview_map_checkbutton", &dlg->priv->display_overview_map_checkbutton, + "display_grid_checkbutton", &dlg->priv->display_grid_checkbutton, "wrap_text_checkbutton", &dlg->priv->wrap_text_checkbutton, "split_checkbutton", &dlg->priv->split_checkbutton, diff --git a/pluma/dialogs/pluma-preferences-dialog.ui b/pluma/dialogs/pluma-preferences-dialog.ui index 7825e305..fd03f283 100644 --- a/pluma/dialogs/pluma-preferences-dialog.ui +++ b/pluma/dialogs/pluma-preferences-dialog.ui @@ -645,6 +645,86 @@ 5 + + + True + False + vertical + 6 + + + True + False + start + Grid pattern + + + + + + False + False + 0 + + + + + True + False + + + True + False + + + + False + False + 0 + + + + + True + False + vertical + 6 + + + Display _grid pattern + True + True + False + True + True + + + False + False + 0 + + + + + False + True + 1 + + + + + False + True + 1 + + + + + False + True + 6 + + diff --git a/pluma/dialogs/ui-a11y.suppr b/pluma/dialogs/ui-a11y.suppr index 30900bc7..1bef4a9c 100644 --- a/pluma/dialogs/ui-a11y.suppr +++ b/pluma/dialogs/ui-a11y.suppr @@ -28,6 +28,8 @@ pluma-preferences-dialog.ui://GtkLabel[@id='label798'] orphan-label pluma-preferences-dialog.ui://GtkLabel[@id='label797'] orphan-label pluma-preferences-dialog.ui://GtkLabel[@id='label5'] orphan-label pluma-preferences-dialog.ui://GtkLabel[@id='label6'] orphan-label +pluma-preferences-dialog.ui://GtkLabel[@id='label7'] orphan-label +pluma-preferences-dialog.ui://GtkLabel[@id='label8'] orphan-label pluma-preferences-dialog.ui://GtkTreeView[@id='schemes_treeview'] no-labelled-by pluma-search-dialog.ui://GtkLabel[@id='search_label'] orphan-label pluma-search-dialog.ui://GtkLabel[@id='replace_with_label'] orphan-label diff --git a/pluma/pluma-settings.h b/pluma/pluma-settings.h index 1796f978..464ddaeb 100644 --- a/pluma/pluma-settings.h +++ b/pluma/pluma-settings.h @@ -141,6 +141,7 @@ GSList * pluma_settings_get_writable_vfs_schemes (GSettings *sett #define PLUMA_SETTINGS_DRAWER_NEWLINE "enable-space-drawer-newline" #define PLUMA_SETTINGS_DRAWER_NBSP "enable-space-drawer-nbsp" #define PLUMA_SETTINGS_DISPLAY_OVERVIEW_MAP "display-overview-map" +#define PLUMA_SETTINGS_BACKGROUND_PATTERN "background-pattern" /* White list of writable mate-vfs methods */ #define PLUMA_SETTINGS_WRITABLE_VFS_SCHEMES "writable-vfs-schemes" diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c index 1c376877..9c8098b9 100644 --- a/pluma/pluma-view.c +++ b/pluma/pluma-view.c @@ -552,6 +552,12 @@ pluma_view_init (PlumaView *view) "indent_on_tab", TRUE, NULL); + g_settings_bind (view->priv->editor_settings, + PLUMA_SETTINGS_BACKGROUND_PATTERN, + view, + "background-pattern", + G_SETTINGS_BIND_DEFAULT); + pluma_set_source_space_drawer (view->priv->editor_settings, GTK_SOURCE_VIEW (view)); view->priv->typeselect_flush_timeout = 0; -- cgit v1.2.1