diff options
-rw-r--r-- | pluma/dialogs/pluma-preferences-dialog.c | 169 | ||||
-rw-r--r-- | pluma/pluma-prefs-manager-app.c | 206 | ||||
-rw-r--r-- | pluma/pluma-prefs-manager.c | 8 | ||||
-rw-r--r-- | pluma/pluma-prefs-manager.h | 27 | ||||
-rw-r--r-- | pluma/pluma-view.c | 114 | ||||
-rw-r--r-- | pluma/pluma-view.h | 4 |
6 files changed, 261 insertions, 267 deletions
diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c index d7726bd3..771726a9 100644 --- a/pluma/dialogs/pluma-preferences-dialog.c +++ b/pluma/dialogs/pluma-preferences-dialog.c @@ -73,9 +73,9 @@ enum typedef enum { - DRAW_NONE = 0, - DRAW_TRAILING = 1, - DRAW_ALL = 2 + DRAW_NONE = 0, + DRAW_TRAILING = 1, + DRAW_ALL = 2 } DrawSpacesSettings; #define PLUMA_PREFERENCES_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \ @@ -108,11 +108,11 @@ struct _PlumaPreferencesDialogPrivate GtkWidget *auto_indent_checkbutton; /* Draw spaces... */ - GtkWidget *draw_spaces_checkbutton; - GtkWidget *draw_trailing_spaces_checkbutton; - GtkWidget *draw_tabs_checkbutton; - GtkWidget *draw_trailing_tabs_checkbutton; - GtkWidget *draw_newlines_checkbutton; + GtkWidget *draw_spaces_checkbutton; + GtkWidget *draw_trailing_spaces_checkbutton; + GtkWidget *draw_tabs_checkbutton; + GtkWidget *draw_trailing_tabs_checkbutton; + GtkWidget *draw_newlines_checkbutton; /* Text Wrapping */ GtkWidget *wrap_text_checkbutton; @@ -216,65 +216,64 @@ static void draw_spaces_checkbutton_toggled (GtkToggleButton *button, PlumaPreferencesDialog *dlg) { - DrawSpacesSettings setting; - pluma_debug (DEBUG_PREFS); + DrawSpacesSettings setting; + pluma_debug (DEBUG_PREFS); - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_spaces_checkbutton)); + g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_spaces_checkbutton)); - if (gtk_toggle_button_get_active (button)) - setting = DRAW_ALL; - else - setting = DRAW_NONE; + if (gtk_toggle_button_get_active (button)) + setting = DRAW_ALL; + else + setting = DRAW_NONE; - pluma_prefs_manager_set_draw_spaces (setting); + pluma_prefs_manager_set_draw_spaces (setting); #ifdef GTK_SOURCE_VERSION_3_24 - 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); + 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 - } static void draw_trailing_spaces_checkbutton_toggled (GtkToggleButton *button, PlumaPreferencesDialog *dlg) { - pluma_debug (DEBUG_PREFS); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton)); - - if (gtk_toggle_button_get_active (button)) - pluma_prefs_manager_set_draw_spaces (DRAW_TRAILING); - else - { - if (pluma_prefs_manager_get_draw_spaces ()) - pluma_prefs_manager_set_draw_spaces (DRAW_ALL); - else - pluma_prefs_manager_set_draw_spaces (DRAW_NONE); - } + pluma_debug (DEBUG_PREFS); + + g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_spaces_checkbutton)); + + if (gtk_toggle_button_get_active (button)) + pluma_prefs_manager_set_draw_spaces (DRAW_TRAILING); + else + { + 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) { - DrawSpacesSettings setting; - pluma_debug (DEBUG_PREFS); + DrawSpacesSettings setting; + pluma_debug (DEBUG_PREFS); - g_return_if_fail (button == GTK_TOGGLE_BUTTON(dlg->priv->draw_tabs_checkbutton)); + g_return_if_fail (button == GTK_TOGGLE_BUTTON(dlg->priv->draw_tabs_checkbutton)); - if (gtk_toggle_button_get_active (button)) - setting = DRAW_ALL; - else - setting = DRAW_NONE; + if (gtk_toggle_button_get_active (button)) + setting = DRAW_ALL; + else + setting = DRAW_NONE; - pluma_prefs_manager_set_draw_tabs (setting); + pluma_prefs_manager_set_draw_tabs (setting); #ifdef GTK_SOURCE_VERSION_3_24 - 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); + 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 } @@ -282,30 +281,30 @@ static void draw_trailing_tabs_checkbutton_toggled (GtkToggleButton *button, PlumaPreferencesDialog *dlg) { - pluma_debug (DEBUG_PREFS); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_tabs_checkbutton)); - - if (gtk_toggle_button_get_active (button)) - pluma_prefs_manager_set_draw_tabs (DRAW_TRAILING); - else - { - if (pluma_prefs_manager_get_draw_tabs ()) - pluma_prefs_manager_set_draw_tabs (DRAW_ALL); - else - pluma_prefs_manager_set_draw_tabs (DRAW_NONE); - } + pluma_debug (DEBUG_PREFS); + + g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_tabs_checkbutton)); + + if (gtk_toggle_button_get_active (button)) + pluma_prefs_manager_set_draw_tabs (DRAW_TRAILING); + else + { + 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 draw_newlines_checkbutton_toggled (GtkToggleButton *button, PlumaPreferencesDialog *dlg) { - pluma_debug (DEBUG_PREFS); + pluma_debug (DEBUG_PREFS); - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_newlines_checkbutton)); + g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->draw_newlines_checkbutton)); - pluma_prefs_manager_set_draw_newlines (gtk_toggle_button_get_active (button)); + pluma_prefs_manager_set_draw_newlines (gtk_toggle_button_get_active (button)); } static void @@ -370,32 +369,32 @@ setup_editor_page (PlumaPreferencesDialog *dlg) 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 () > DRAW_NONE); + 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 () == DRAW_NONE); + 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 () == DRAW_TRAILING); + 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 () > DRAW_NONE); + 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 () > DRAW_NONE); + 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 () == DRAW_NONE); + 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 () == DRAW_TRAILING); + 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); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_trailing_tabs_checkbutton), FALSE); #endif gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->draw_newlines_checkbutton), - pluma_prefs_manager_get_draw_newlines ()); + pluma_prefs_manager_get_draw_newlines ()); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton), pluma_prefs_manager_get_create_backup_copy ()); @@ -445,25 +444,25 @@ setup_editor_page (PlumaPreferencesDialog *dlg) G_CALLBACK (auto_indent_checkbutton_toggled), dlg); g_signal_connect (dlg->priv->draw_spaces_checkbutton, - "toggled", - G_CALLBACK (draw_spaces_checkbutton_toggled), - dlg); + "toggled", + G_CALLBACK (draw_spaces_checkbutton_toggled), + dlg); g_signal_connect (dlg->priv->draw_trailing_spaces_checkbutton, - "toggled", - G_CALLBACK (draw_trailing_spaces_checkbutton_toggled), - dlg); + "toggled", + G_CALLBACK (draw_trailing_spaces_checkbutton_toggled), + dlg); g_signal_connect (dlg->priv->draw_tabs_checkbutton, - "toggled", - G_CALLBACK (draw_tabs_checkbutton_toggled), - dlg); + "toggled", + G_CALLBACK (draw_tabs_checkbutton_toggled), + dlg); g_signal_connect (dlg->priv->draw_trailing_tabs_checkbutton, - "toggled", - G_CALLBACK (draw_trailing_tabs_checkbutton_toggled), - dlg); + "toggled", + G_CALLBACK (draw_trailing_tabs_checkbutton_toggled), + dlg); g_signal_connect (dlg->priv->draw_newlines_checkbutton, - "toggled", - G_CALLBACK (draw_newlines_checkbutton_toggled), - dlg); + "toggled", + G_CALLBACK (draw_newlines_checkbutton_toggled), + dlg); g_signal_connect (dlg->priv->auto_save_checkbutton, "toggled", G_CALLBACK (auto_save_checkbutton_toggled), diff --git a/pluma/pluma-prefs-manager-app.c b/pluma/pluma-prefs-manager-app.c index c1887f96..47f18b07 100644 --- a/pluma/pluma-prefs-manager-app.c +++ b/pluma/pluma-prefs-manager-app.c @@ -116,21 +116,21 @@ static void pluma_prefs_manager_lockdown_changed (GSettings *settings, gchar *key, gpointer user_data); -static void pluma_prefs_manager_draw_spaces_changed (GSettings *settings, - gchar *key, - gpointer user_data); +static void pluma_prefs_manager_draw_spaces_changed (GSettings *settings, + gchar *key, + gpointer user_data); -static void pluma_prefs_manager_draw_tabs_changed (GSettings *settings, - gchar *key, - gpointer user_data); +static void pluma_prefs_manager_draw_tabs_changed (GSettings *settings, + gchar *key, + gpointer user_data); -static void pluma_prefs_manager_draw_newlines_changed (GSettings *settings, - gchar *key, - gpointer user_data); +static void pluma_prefs_manager_draw_newlines_changed (GSettings *settings, + gchar *key, + gpointer user_data); -static void pluma_prefs_manager_draw_nbsp_changed (GSettings *settings, - gchar *key, - gpointer user_data); +static void pluma_prefs_manager_draw_nbsp_changed (GSettings *settings, + gchar *key, + gpointer user_data); /* GUI state is serialized to a .desktop file, not in GSettings */ @@ -731,24 +731,24 @@ pluma_prefs_manager_app_init (void) NULL); g_signal_connect (pluma_prefs_manager->settings, - "changed::" GPM_SPACE_DRAWER_SPACE, - G_CALLBACK (pluma_prefs_manager_draw_spaces_changed), - NULL); + "changed::" GPM_SPACE_DRAWER_SPACE, + G_CALLBACK (pluma_prefs_manager_draw_spaces_changed), + NULL); g_signal_connect (pluma_prefs_manager->settings, - "changed::" GPM_SPACE_DRAWER_TAB, - G_CALLBACK (pluma_prefs_manager_draw_tabs_changed), - NULL); + "changed::" GPM_SPACE_DRAWER_TAB, + G_CALLBACK (pluma_prefs_manager_draw_tabs_changed), + NULL); g_signal_connect (pluma_prefs_manager->settings, - "changed::" GPM_SPACE_DRAWER_NEWLINE, - G_CALLBACK (pluma_prefs_manager_draw_newlines_changed), - NULL); + "changed::" GPM_SPACE_DRAWER_NEWLINE, + G_CALLBACK (pluma_prefs_manager_draw_newlines_changed), + NULL); g_signal_connect (pluma_prefs_manager->settings, - "changed::" GPM_SPACE_DRAWER_NBSP, - G_CALLBACK (pluma_prefs_manager_draw_nbsp_changed), - NULL); + "changed::" GPM_SPACE_DRAWER_NBSP, + G_CALLBACK (pluma_prefs_manager_draw_nbsp_changed), + NULL); } @@ -1479,143 +1479,141 @@ pluma_prefs_manager_lockdown_changed (GSettings *settings, #ifdef GTK_SOURCE_VERSION_3_24 static void -pluma_prefs_manager_space_drawer_generic (GSettings *settings, - gint level, +pluma_prefs_manager_space_drawer_generic (GSettings *settings, + gint level, GtkSourceSpaceTypeFlags type) { - GList *views; - GList *l; + GList *views; + GList *l; - pluma_debug (DEBUG_PREFS); + pluma_debug (DEBUG_PREFS); - views = pluma_app_get_views (pluma_app_get_default ()); - l = views; + views = pluma_app_get_views (pluma_app_get_default ()); + l = views; - while (l != NULL) - { + while (l != NULL) + { pluma_set_source_space_drawer_by_level (GTK_SOURCE_VIEW (l->data), - level, type); - l = l->next; - } + level, type); + l = l->next; + } - g_list_free (views); + g_list_free (views); } #else static void -pluma_prefs_manager_draw_generic (GSettings *settings, - gint level, - GtkSourceDrawSpacesFlags type) +pluma_prefs_manager_draw_generic (GSettings *settings, + gint level, + GtkSourceSpaceTypeFlags type) { - GList *views; - GList *l; + GList *views; + GList *l; - pluma_debug (DEBUG_PREFS); + pluma_debug (DEBUG_PREFS); - views = pluma_app_get_views (pluma_app_get_default ()); - l = views; + views = pluma_app_get_views (pluma_app_get_default ()); + l = views; - while (l != NULL) - { - GtkSourceSpaceTypeFlags value; + while (l != NULL) + { + GtkSourceSpaceTypeFlags value; - value = gtk_source_view_get_draw_spaces (GTK_SOURCE_VIEW (l->data)); - if (level > 0) - value |= type; - else - value &= ~type; - gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (l->data), - value); - l = l->next; - } + value = gtk_source_view_get_draw_spaces (GTK_SOURCE_VIEW (l->data)); + if (level > 0) + value |= type; + else + value &= ~type; + gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (l->data), + value); + l = l->next; + } - g_list_free (views); + g_list_free (views); } #endif static void pluma_prefs_manager_draw_spaces_changed (GSettings *settings, - gchar *key, - gpointer user_data) + gchar *key, + gpointer user_data) { - pluma_debug (DEBUG_PREFS); + pluma_debug (DEBUG_PREFS); - if (strcmp (key, GPM_SPACE_DRAWER_SPACE)) - return; + if (strcmp (key, GPM_SPACE_DRAWER_SPACE)) + return; #ifdef GTK_SOURCE_VERSION_3_24 - pluma_prefs_manager_space_drawer_generic (settings, - g_settings_get_enum (settings, key), - GTK_SOURCE_SPACE_TYPE_SPACE); + pluma_prefs_manager_space_drawer_generic (settings, + g_settings_get_enum (settings, key), + GTK_SOURCE_SPACE_TYPE_SPACE); #else - pluma_prefs_manager_draw_generic (settings, - g_settings_get_enum (settings, key), - GTK_SOURCE_DRAW_SPACES_SPACE); + pluma_prefs_manager_draw_generic (settings, + g_settings_get_enum (settings, key), + GTK_SOURCE_DRAW_SPACES_SPACE); #endif } static void pluma_prefs_manager_draw_tabs_changed (GSettings *settings, - gchar *key, - gpointer user_data) + gchar *key, + gpointer user_data) { - pluma_debug (DEBUG_PREFS); + pluma_debug (DEBUG_PREFS); - if (strcmp (key, GPM_SPACE_DRAWER_TAB)) - return; + if (strcmp (key, GPM_SPACE_DRAWER_TAB)) + return; #ifdef GTK_SOURCE_VERSION_3_24 - pluma_prefs_manager_space_drawer_generic (settings, - g_settings_get_enum (settings, key), - GTK_SOURCE_SPACE_TYPE_TAB); + pluma_prefs_manager_space_drawer_generic (settings, + g_settings_get_enum (settings, key), + GTK_SOURCE_SPACE_TYPE_TAB); #else - pluma_prefs_manager_draw_generic (settings, - g_settings_get_enum (settings, key), - GTK_SOURCE_DRAW_SPACES_TAB); + pluma_prefs_manager_draw_generic (settings, + g_settings_get_enum (settings, key), + GTK_SOURCE_DRAW_SPACES_TAB); #endif - } static void pluma_prefs_manager_draw_newlines_changed (GSettings *settings, - gchar *key, - gpointer user_data) + gchar *key, + gpointer user_data) { - pluma_debug (DEBUG_PREFS); + pluma_debug (DEBUG_PREFS); - if (strcmp (key, GPM_SPACE_DRAWER_NEWLINE)) - return; + if (strcmp (key, GPM_SPACE_DRAWER_NEWLINE)) + return; #ifdef GTK_SOURCE_VERSION_3_24 - pluma_prefs_manager_space_drawer_generic (settings, - g_settings_get_boolean (settings, key) ? 1 : 0, - GTK_SOURCE_SPACE_TYPE_NEWLINE); + pluma_prefs_manager_space_drawer_generic (settings, + g_settings_get_boolean (settings, key) ? 1 : 0, + GTK_SOURCE_SPACE_TYPE_NEWLINE); #else - pluma_prefs_manager_draw_generic (settings, - g_settings_get_boolean (settings, key) ? 1 : 0, - GTK_SOURCE_DRAW_SPACES_NEWLINE); + pluma_prefs_manager_draw_generic (settings, + g_settings_get_boolean (settings, key) ? 1 : 0, + GTK_SOURCE_DRAW_SPACES_NEWLINE); #endif - } static void pluma_prefs_manager_draw_nbsp_changed (GSettings *settings, - gchar *key, - gpointer user_data) + gchar *key, + gpointer user_data) { - pluma_debug (DEBUG_PREFS); + pluma_debug (DEBUG_PREFS); - if (strcmp (key, GPM_SPACE_DRAWER_NBSP)) - return; + if (strcmp (key, GPM_SPACE_DRAWER_NBSP)) + return; #ifdef GTK_SOURCE_VERSION_3_24 - pluma_prefs_manager_space_drawer_generic (settings, - g_settings_get_enum (settings, key), - GTK_SOURCE_SPACE_TYPE_NBSP); + pluma_prefs_manager_space_drawer_generic (settings, + g_settings_get_enum (settings, key), + GTK_SOURCE_SPACE_TYPE_NBSP); #else - pluma_prefs_manager_draw_generic (settings, - g_settings_get_enum (settings, key), - GTK_SOURCE_DRAW_SPACES_NBSP); + pluma_prefs_manager_draw_generic (settings, + g_settings_get_enum (settings, key), + GTK_SOURCE_DRAW_SPACES_NBSP); #endif } diff --git a/pluma/pluma-prefs-manager.c b/pluma/pluma-prefs-manager.c index e83f44ed..01434bbd 100644 --- a/pluma/pluma-prefs-manager.c +++ b/pluma/pluma-prefs-manager.c @@ -990,16 +990,16 @@ pluma_prefs_manager_get_lockdown (void) /* enable drawing 'normal' spaces */ DEFINE_ENUM_PREF(draw_spaces, - GPM_SPACE_DRAWER_SPACE) + GPM_SPACE_DRAWER_SPACE) /* enable drawing tabs */ DEFINE_ENUM_PREF(draw_tabs, - GPM_SPACE_DRAWER_TAB) + GPM_SPACE_DRAWER_TAB) /* enable drawing newline */ DEFINE_BOOL_PREF(draw_newlines, - GPM_SPACE_DRAWER_NEWLINE) + GPM_SPACE_DRAWER_NEWLINE) /* enable drawing nbsp */ DEFINE_ENUM_PREF(draw_nbsp, - GPM_SPACE_DRAWER_NBSP) + GPM_SPACE_DRAWER_NBSP) diff --git a/pluma/pluma-prefs-manager.h b/pluma/pluma-prefs-manager.h index 8124b1fd..3d170dcb 100644 --- a/pluma/pluma-prefs-manager.h +++ b/pluma/pluma-prefs-manager.h @@ -337,26 +337,23 @@ GSList* pluma_prefs_manager_get_gslist (GSettings *settings, const gchar *ke void pluma_prefs_manager_set_gslist (GSettings *settings, const gchar *key, GSList *list); /* Enable drawing space */ -gint pluma_prefs_manager_get_draw_spaces (void); -void pluma_prefs_manager_set_draw_spaces (gint enable_draw_spaces); -gboolean pluma_prefs_manager_draw_spaces_can_set (void); +gint pluma_prefs_manager_get_draw_spaces (void); +void pluma_prefs_manager_set_draw_spaces (gint enable_draw_spaces); +gboolean pluma_prefs_manager_draw_spaces_can_set (void); /* Enable drawing tab */ -gint pluma_prefs_manager_get_draw_tabs (void); -void pluma_prefs_manager_set_draw_tabs (gint enable_draw_tabs); -gboolean pluma_prefs_manager_draw_tabs_can_set (void); +gint pluma_prefs_manager_get_draw_tabs (void); +void pluma_prefs_manager_set_draw_tabs (gint enable_draw_tabs); +gboolean pluma_prefs_manager_draw_tabs_can_set (void); /* Enable drawing newline */ -gboolean pluma_prefs_manager_get_draw_newlines (void); -void pluma_prefs_manager_set_draw_newlines (gboolean enable_draw_newlines); -gboolean pluma_prefs_manager_draw_newlines_can_set (void); +gboolean pluma_prefs_manager_get_draw_newlines (void); +void pluma_prefs_manager_set_draw_newlines (gboolean enable_draw_newlines); +gboolean pluma_prefs_manager_draw_newlines_can_set (void); /* Enable drawing nbsp */ -gint pluma_prefs_manager_get_draw_nbsp (void); -void pluma_prefs_manager_set_draw_nbsp (gint enable_draw_nbsp); -gboolean pluma_prefs_manager_draw_nbsp_can_set (void); - +gint pluma_prefs_manager_get_draw_nbsp (void); +void pluma_prefs_manager_set_draw_nbsp (gint enable_draw_nbsp); +gboolean pluma_prefs_manager_draw_nbsp_can_set (void); #endif /* __PLUMA_PREFS_MANAGER_H__ */ - - diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c index ed146b21..835c0764 100644 --- a/pluma/pluma-view.c +++ b/pluma/pluma-view.c @@ -378,35 +378,35 @@ pluma_set_source_space_drawer_by_level (GtkSourceView *view, gint level, GtkSourceSpaceTypeFlags type) { - GtkSourceSpaceLocationFlags locs[] = {GTK_SOURCE_SPACE_LOCATION_LEADING, - GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT, - GTK_SOURCE_SPACE_LOCATION_TRAILING}; - /* this array links the level to the location */ - GtkSourceSpaceLocationFlags levels[] = { - 0, - GTK_SOURCE_SPACE_LOCATION_TRAILING, - GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT | - GTK_SOURCE_SPACE_LOCATION_TRAILING | - GTK_SOURCE_SPACE_LOCATION_LEADING - }; - - gint i; - - GtkSourceSpaceDrawer *drawer = gtk_source_view_get_space_drawer (view); - - if (level >= G_N_ELEMENTS(levels) || level < 0) - level = 0; - - for (i = 0 ; i < G_N_ELEMENTS(locs) ; i++ ) { - GtkSourceSpaceTypeFlags f; - f = gtk_source_space_drawer_get_types_for_locations (drawer, - locs[i]); - if (locs[i] & levels[level]) - f |= type; - else - f &= ~type; - gtk_source_space_drawer_set_types_for_locations (drawer, locs[i], f); - } + GtkSourceSpaceLocationFlags locs[] = {GTK_SOURCE_SPACE_LOCATION_LEADING, + GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT, + GTK_SOURCE_SPACE_LOCATION_TRAILING}; + /* this array links the level to the location */ + GtkSourceSpaceLocationFlags levels[] = { + 0, + GTK_SOURCE_SPACE_LOCATION_TRAILING, + GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT | + GTK_SOURCE_SPACE_LOCATION_TRAILING | + GTK_SOURCE_SPACE_LOCATION_LEADING + }; + + gint i; + + GtkSourceSpaceDrawer *drawer = gtk_source_view_get_space_drawer (view); + + if (level >= G_N_ELEMENTS(levels) || level < 0) + level = 0; + + for (i = 0 ; i < G_N_ELEMENTS(locs) ; i++ ) { + GtkSourceSpaceTypeFlags f; + f = gtk_source_space_drawer_get_types_for_locations (drawer, + locs[i]); + if (locs[i] & levels[level]) + f |= type; + else + f &= ~type; + gtk_source_space_drawer_set_types_for_locations (drawer, locs[i], f); + } } #endif @@ -414,42 +414,42 @@ pluma_set_source_space_drawer_by_level (GtkSourceView *view, static void pluma_set_source_space_drawer (GtkSourceView *view) { - pluma_set_source_space_drawer_by_level (view, - pluma_prefs_manager_get_draw_spaces (), - GTK_SOURCE_SPACE_TYPE_SPACE); - pluma_set_source_space_drawer_by_level (view, - pluma_prefs_manager_get_draw_tabs (), - GTK_SOURCE_SPACE_TYPE_TAB); - pluma_set_source_space_drawer_by_level (view, - pluma_prefs_manager_get_draw_newlines () ? 2 : 0, - GTK_SOURCE_SPACE_TYPE_NEWLINE); - pluma_set_source_space_drawer_by_level (view, - pluma_prefs_manager_get_draw_nbsp (), - GTK_SOURCE_SPACE_TYPE_NBSP); - gtk_source_space_drawer_set_enable_matrix (gtk_source_view_get_space_drawer (view), - TRUE); + pluma_set_source_space_drawer_by_level (view, + pluma_prefs_manager_get_draw_spaces (), + GTK_SOURCE_SPACE_TYPE_SPACE); + pluma_set_source_space_drawer_by_level (view, + pluma_prefs_manager_get_draw_tabs (), + GTK_SOURCE_SPACE_TYPE_TAB); + pluma_set_source_space_drawer_by_level (view, + pluma_prefs_manager_get_draw_newlines () ? 2 : 0, + GTK_SOURCE_SPACE_TYPE_NEWLINE); + pluma_set_source_space_drawer_by_level (view, + pluma_prefs_manager_get_draw_nbsp (), + GTK_SOURCE_SPACE_TYPE_NBSP); + gtk_source_space_drawer_set_enable_matrix (gtk_source_view_get_space_drawer (view), + TRUE); } #else static void pluma_set_source_space_drawer (GtkSourceView *view) { - GtkSourceSpaceTypeFlags flags = 0; + GtkSourceSpaceTypeFlags flags = 0; - if (pluma_prefs_manager_get_draw_spaces () > 0) - flags |= GTK_SOURCE_DRAW_SPACES_SPACE; - if (pluma_prefs_manager_get_draw_tabs () > 0) - flags |= GTK_SOURCE_DRAW_SPACES_TAB; - if (pluma_prefs_manager_get_draw_newlines ()) - flags |= GTK_SOURCE_DRAW_SPACES_NEWLINE; - if (pluma_prefs_manager_get_draw_nbsp () > 0) - flags |= GTK_SOURCE_DRAW_SPACES_NBSP; + if (pluma_prefs_manager_get_draw_spaces () > 0) + flags |= GTK_SOURCE_DRAW_SPACES_SPACE; + if (pluma_prefs_manager_get_draw_tabs () > 0) + flags |= GTK_SOURCE_DRAW_SPACES_TAB; + if (pluma_prefs_manager_get_draw_newlines ()) + flags |= GTK_SOURCE_DRAW_SPACES_NEWLINE; + if (pluma_prefs_manager_get_draw_nbsp () > 0) + flags |= GTK_SOURCE_DRAW_SPACES_NBSP; - flags |= GTK_SOURCE_DRAW_SPACES_TRAILING | - GTK_SOURCE_DRAW_SPACES_TEXT | - GTK_SOURCE_DRAW_SPACES_LEADING; + flags |= GTK_SOURCE_DRAW_SPACES_TRAILING | + GTK_SOURCE_DRAW_SPACES_TEXT | + GTK_SOURCE_DRAW_SPACES_LEADING; - gtk_source_view_set_draw_spaces (view, flags); + gtk_source_view_set_draw_spaces (view, flags); } #endif @@ -494,7 +494,7 @@ pluma_view_init (PlumaView *view) "indent_on_tab", TRUE, NULL); - pluma_set_source_space_drawer(GTK_SOURCE_VIEW (view)); + pluma_set_source_space_drawer (GTK_SOURCE_VIEW (view)); view->priv->typeselect_flush_timeout = 0; view->priv->wrap_around = TRUE; diff --git a/pluma/pluma-view.h b/pluma/pluma-view.h index b8286205..c259f394 100644 --- a/pluma/pluma-view.h +++ b/pluma/pluma-view.h @@ -109,8 +109,8 @@ void pluma_view_set_font (PlumaView *view, #ifdef GTK_SOURCE_VERSION_3_24 void -pluma_set_source_space_drawer_by_level (GtkSourceView *view, - gint level, +pluma_set_source_space_drawer_by_level (GtkSourceView *view, + gint level, GtkSourceSpaceTypeFlags type); #endif |