From 3440b6770f71597f884f00a0797751d392125cbd Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Thu, 25 Aug 2011 20:14:40 +0000 Subject: [PATCH] Add and use editor_set_indent_width() to only set indentation width git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5903 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 2 ++ src/callbacks.c | 24 +++++++++--------------- src/editor.c | 6 ++++++ src/editor.h | 2 ++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe71cb6e..4eb94fbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ doc/geany.html, data/filetypes.*: Add support for filetype-specific indentation settings (closes #3339420 and #3390435). + * src/callbacks.c, src/editor.c, src/editor.h: + Add editor_set_indent_width() to only set indentation width. 2011-08-24 Colomban Wendling diff --git a/src/callbacks.c b/src/callbacks.c index 9f6f4411..49723441 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -2066,28 +2066,22 @@ void on_plugin_preferences1_activate(GtkMenuItem *menuitem, gpointer user_data) } -static void set_indent_width(guint width) +void on_indent_width_activate(GtkMenuItem *menuitem, gpointer user_data) { GeanyDocument *doc; + gchar *label; + gint width; if (ignore_callback) return; - doc = document_get_current(); - g_return_if_fail(doc != NULL); - - editor_set_indent(doc->editor, doc->editor->indent_type, width); -} - - -void on_indent_width_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - gchar *label = ui_menu_item_get_text(menuitem); - gint width = atoi(label); - + label = ui_menu_item_get_text(menuitem); + width = atoi(label); g_free(label); - if (width) - set_indent_width(width); + + doc = document_get_current(); + if (doc != NULL && width > 0) + editor_set_indent_width(doc->editor, width); } diff --git a/src/editor.c b/src/editor.c index fa391eac..b8419a02 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4468,6 +4468,12 @@ void editor_set_indent_type(GeanyEditor *editor, GeanyIndentType type) } +void editor_set_indent_width(GeanyEditor *editor, gint width) +{ + editor_set_indent(editor, editor->indent_type, width); +} + + void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width) { const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor); diff --git a/src/editor.h b/src/editor.h index f72bbc13..9da00c48 100644 --- a/src/editor.h +++ b/src/editor.h @@ -294,6 +294,8 @@ const GeanyIndentPrefs *editor_get_indent_prefs(GeanyEditor *editor); void editor_set_indent_type(GeanyEditor *editor, GeanyIndentType type); +void editor_set_indent_width(GeanyEditor *editor, gint width); + void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width); void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap);