SF.net SVN: geany:[5631] trunk

colombanw at users.sourceforge.net colombanw at xxxxx
Sat Mar 26 17:25:24 UTC 2011


Revision: 5631
          http://geany.svn.sourceforge.net/geany/?rev=5631&view=rev
Author:   colombanw
Date:     2011-03-26 17:25:24 +0000 (Sat, 26 Mar 2011)

Log Message:
-----------
Add possibility to detect the indentation width from the file content

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/geany.html
    trunk/doc/geany.txt
    trunk/geany.glade
    trunk/src/document.c
    trunk/src/editor.h
    trunk/src/interface.c
    trunk/src/interface.h
    trunk/src/keyfile.c
    trunk/src/project.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/ChangeLog	2011-03-26 17:25:24 UTC (rev 5631)
@@ -6,6 +6,11 @@
    Also change the hack used for the selection to be updated in the input
    handlers to call the GtkTreeView's handler manually rather than doing
    the actual job in IDLE callbacks for the TreeView's handler to have run.
+ * doc/geany.html, doc/geany.txt, geany.glade, src/document.c,
+   src/editor.h, src/interface.c, src/interface.h, src/keyfile.c,
+   src/project.c:
+   Add possibility to detect the indentation width from the file content
+   (not supported if indentation type is tabs only).
 
 
 2011-03-25  Colomban Wendling  <colomban(at)geany(dot)org>

Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/doc/geany.html	2011-03-26 17:25:24 UTC (rev 5631)
@@ -2338,6 +2338,12 @@
 <h4><a class="toc-backref" href="#id105">Indentation group</a></h4>
 <p>See <a class="reference internal" href="#indentation">Indentation</a> for more information.</p>
 <dl class="docutils">
+<dt>Width</dt>
+<dd>The width of a single indent size in spaces. By default the indent
+size is equivalent to 4 spaces.</dd>
+<dt>Detect width from file</dt>
+<dd>Try to detect and set the indent width based on file content, when
+a file is opened.</dd>
 <dt>Type</dt>
 <dd><p class="first">When Geany inserts indentation, whether to use:</p>
 <ul class="simple">
@@ -2348,10 +2354,7 @@
 <p class="last">The <em>Tabs and Spaces</em> indent type is also known as <em>Soft tab
 support</em> in some other editors.</p>
 </dd>
-<dt>Width</dt>
-<dd>The width of a single indent size in spaces. By default the indent
-size is equivalent to 4 spaces.</dd>
-<dt>Detect from file</dt>
+<dt>Detect type from file</dt>
 <dd>Try to detect and set the indent type based on file content, when
 a file is opened.</dd>
 <dt>Auto-indent mode</dt>
@@ -6484,7 +6487,7 @@
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="geany.txt">View document source</a>.
-Generated on: 2011-03-24 16:40 UTC.
+Generated on: 2011-03-26 17:15 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>

Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/doc/geany.txt	2011-03-26 17:25:24 UTC (rev 5631)
@@ -1993,6 +1993,14 @@
 
 See `Indentation`_ for more information.
 
+Width
+    The width of a single indent size in spaces. By default the indent
+    size is equivalent to 4 spaces.
+
+Detect width from file
+    Try to detect and set the indent width based on file content, when
+    a file is opened.
+
 Type
     When Geany inserts indentation, whether to use:
 
@@ -2003,11 +2011,7 @@
     The *Tabs and Spaces* indent type is also known as *Soft tab
     support* in some other editors.
 
-Width
-    The width of a single indent size in spaces. By default the indent
-    size is equivalent to 4 spaces.
-
-Detect from file
+Detect type from file
     Try to detect and set the indent type based on file content, when
     a file is opened.
 

Modified: trunk/geany.glade
===================================================================
--- trunk/geany.glade	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/geany.glade	2011-03-26 17:25:24 UTC (rev 5631)
@@ -6138,16 +6138,16 @@
 			      <child>
 				<widget class="GtkTable" id="table13">
 				  <property name="visible">True</property>
-				  <property name="n_rows">6</property>
+				  <property name="n_rows">7</property>
 				  <property name="n_columns">2</property>
 				  <property name="homogeneous">False</property>
 				  <property name="row_spacing">3</property>
 				  <property name="column_spacing">24</property>
 
 				  <child>
-				    <widget class="GtkLabel" id="label183">
+				    <widget class="GtkLabel" id="label222">
 				      <property name="visible">True</property>
-				      <property name="label" translatable="yes">Auto-indent mode:</property>
+				      <property name="label" translatable="yes">Width:</property>
 				      <property name="use_underline">False</property>
 				      <property name="use_markup">False</property>
 				      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -6165,37 +6165,39 @@
 				    <packing>
 				      <property name="left_attach">0</property>
 				      <property name="right_attach">1</property>
-				      <property name="top_attach">5</property>
-				      <property name="bottom_attach">6</property>
+				      <property name="top_attach">0</property>
+				      <property name="bottom_attach">1</property>
 				      <property name="x_options">fill</property>
 				      <property name="y_options"></property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkComboBox" id="combo_auto_indent_mode">
+				    <widget class="GtkSpinButton" id="spin_indent_width">
 				      <property name="visible">True</property>
-				      <property name="items" translatable="yes">None
-Basic
-Current chars
-Match braces</property>
-				      <property name="add_tearoffs">False</property>
-				      <property name="focus_on_click">True</property>
+				      <property name="tooltip" translatable="yes">The width in chars of a single indent</property>
+				      <property name="can_focus">True</property>
+				      <property name="climb_rate">1</property>
+				      <property name="digits">0</property>
+				      <property name="numeric">True</property>
+				      <property name="update_policy">GTK_UPDATE_IF_VALID</property>
+				      <property name="snap_to_ticks">False</property>
+				      <property name="wrap">True</property>
+				      <property name="adjustment">1 1 99 1 10 0</property>
 				    </widget>
 				    <packing>
 				      <property name="left_attach">1</property>
 				      <property name="right_attach">2</property>
-				      <property name="top_attach">5</property>
-				      <property name="bottom_attach">6</property>
-				      <property name="x_options">fill</property>
-				      <property name="y_options">fill</property>
+				      <property name="top_attach">0</property>
+				      <property name="bottom_attach">1</property>
+				      <property name="y_options"></property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkLabel" id="label200">
+				    <widget class="GtkLabel" id="label183">
 				      <property name="visible">True</property>
-				      <property name="label" translatable="yes">Type:</property>
+				      <property name="label" translatable="yes">Auto-indent mode:</property>
 				      <property name="use_underline">False</property>
 				      <property name="use_markup">False</property>
 				      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -6213,69 +6215,62 @@
 				    <packing>
 				      <property name="left_attach">0</property>
 				      <property name="right_attach">1</property>
-				      <property name="top_attach">1</property>
-				      <property name="bottom_attach">2</property>
+				      <property name="top_attach">6</property>
+				      <property name="bottom_attach">7</property>
 				      <property name="x_options">fill</property>
 				      <property name="y_options"></property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkLabel" id="label222">
+				    <widget class="GtkComboBox" id="combo_auto_indent_mode">
 				      <property name="visible">True</property>
-				      <property name="label" translatable="yes">Width:</property>
-				      <property name="use_underline">False</property>
-				      <property name="use_markup">False</property>
-				      <property name="justify">GTK_JUSTIFY_LEFT</property>
-				      <property name="wrap">False</property>
-				      <property name="selectable">False</property>
-				      <property name="xalign">0</property>
-				      <property name="yalign">0.5</property>
-				      <property name="xpad">0</property>
-				      <property name="ypad">0</property>
-				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-				      <property name="width_chars">-1</property>
-				      <property name="single_line_mode">False</property>
-				      <property name="angle">0</property>
+				      <property name="items" translatable="yes">None
+Basic
+Current chars
+Match braces</property>
+				      <property name="add_tearoffs">False</property>
+				      <property name="focus_on_click">True</property>
 				    </widget>
 				    <packing>
-				      <property name="left_attach">0</property>
-				      <property name="right_attach">1</property>
-				      <property name="top_attach">0</property>
-				      <property name="bottom_attach">1</property>
+				      <property name="left_attach">1</property>
+				      <property name="right_attach">2</property>
+				      <property name="top_attach">6</property>
+				      <property name="bottom_attach">7</property>
 				      <property name="x_options">fill</property>
-				      <property name="y_options"></property>
+				      <property name="y_options">fill</property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkSpinButton" id="spin_indent_width">
+				    <widget class="GtkCheckButton" id="check_detect_indent_type">
 				      <property name="visible">True</property>
-				      <property name="tooltip" translatable="yes">The width in chars of a single indent</property>
+				      <property name="tooltip" translatable="yes">Whether to detect the indentation type from file contents when a file is opened</property>
 				      <property name="can_focus">True</property>
-				      <property name="climb_rate">1</property>
-				      <property name="digits">0</property>
-				      <property name="numeric">True</property>
-				      <property name="update_policy">GTK_UPDATE_IF_VALID</property>
-				      <property name="snap_to_ticks">False</property>
-				      <property name="wrap">True</property>
-				      <property name="adjustment">1 1 99 1 10 0</property>
+				      <property name="label" translatable="yes">Detect type from file</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
 				    </widget>
 				    <packing>
 				      <property name="left_attach">1</property>
 				      <property name="right_attach">2</property>
-				      <property name="top_attach">0</property>
-				      <property name="bottom_attach">1</property>
+				      <property name="top_attach">5</property>
+				      <property name="bottom_attach">6</property>
+				      <property name="x_options">fill</property>
 				      <property name="y_options"></property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkRadioButton" id="radio_indent_spaces">
+				    <widget class="GtkRadioButton" id="radio_indent_both">
 				      <property name="visible">True</property>
-				      <property name="tooltip" translatable="yes">Use spaces when inserting indentation</property>
+				      <property name="tooltip" translatable="yes">Use spaces if the total indent is less than the tab width, otherwise use both</property>
 				      <property name="can_focus">True</property>
-				      <property name="label" translatable="yes">_Spaces</property>
+				      <property name="label" translatable="yes">T_abs and spaces</property>
 				      <property name="use_underline">True</property>
 				      <property name="relief">GTK_RELIEF_NORMAL</property>
 				      <property name="focus_on_click">True</property>
@@ -6286,67 +6281,67 @@
 				    <packing>
 				      <property name="left_attach">1</property>
 				      <property name="right_attach">2</property>
-				      <property name="top_attach">2</property>
-				      <property name="bottom_attach">3</property>
+				      <property name="top_attach">4</property>
+				      <property name="bottom_attach">5</property>
 				      <property name="x_options">fill</property>
 				      <property name="y_options"></property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkRadioButton" id="radio_indent_tabs">
+				    <widget class="GtkRadioButton" id="radio_indent_spaces">
 				      <property name="visible">True</property>
-				      <property name="tooltip" translatable="yes">Use one tab per indent</property>
+				      <property name="tooltip" translatable="yes">Use spaces when inserting indentation</property>
 				      <property name="can_focus">True</property>
-				      <property name="label" translatable="yes">_Tabs</property>
+				      <property name="label" translatable="yes">_Spaces</property>
 				      <property name="use_underline">True</property>
 				      <property name="relief">GTK_RELIEF_NORMAL</property>
 				      <property name="focus_on_click">True</property>
 				      <property name="active">False</property>
 				      <property name="inconsistent">False</property>
 				      <property name="draw_indicator">True</property>
-				      <property name="group">radio_indent_spaces</property>
+				      <property name="group">radio_indent_both</property>
 				    </widget>
 				    <packing>
 				      <property name="left_attach">1</property>
 				      <property name="right_attach">2</property>
-				      <property name="top_attach">1</property>
-				      <property name="bottom_attach">2</property>
+				      <property name="top_attach">3</property>
+				      <property name="bottom_attach">4</property>
 				      <property name="x_options">fill</property>
 				      <property name="y_options"></property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkRadioButton" id="radio_indent_both">
+				    <widget class="GtkRadioButton" id="radio_indent_tabs">
 				      <property name="visible">True</property>
-				      <property name="tooltip" translatable="yes">Use spaces if the total indent is less than the tab width, otherwise use both</property>
+				      <property name="tooltip" translatable="yes">Use one tab per indent</property>
 				      <property name="can_focus">True</property>
-				      <property name="label" translatable="yes">T_abs and spaces</property>
+				      <property name="label" translatable="yes">_Tabs</property>
 				      <property name="use_underline">True</property>
 				      <property name="relief">GTK_RELIEF_NORMAL</property>
 				      <property name="focus_on_click">True</property>
 				      <property name="active">False</property>
 				      <property name="inconsistent">False</property>
 				      <property name="draw_indicator">True</property>
-				      <property name="group">radio_indent_spaces</property>
+				      <property name="group">radio_indent_both</property>
 				    </widget>
 				    <packing>
 				      <property name="left_attach">1</property>
 				      <property name="right_attach">2</property>
-				      <property name="top_attach">3</property>
-				      <property name="bottom_attach">4</property>
+				      <property name="top_attach">2</property>
+				      <property name="bottom_attach">3</property>
 				      <property name="x_options">fill</property>
 				      <property name="y_options"></property>
 				    </packing>
 				  </child>
 
 				  <child>
-				    <widget class="GtkCheckButton" id="check_detect_indent">
+				    <widget class="GtkCheckButton" id="check_detect_indent_width">
 				      <property name="visible">True</property>
-				      <property name="tooltip" translatable="yes">Whether to detect the indentation type from file contents when a file is opened</property>
+				      <property name="tooltip" translatable="yes">Whether to detect the indentation width from file contents when a file is opened</property>
 				      <property name="can_focus">True</property>
-				      <property name="label" translatable="yes">Detect from file</property>
+				      <property name="label" translatable="yes">Detect width from file</property>
 				      <property name="use_underline">True</property>
 				      <property name="relief">GTK_RELIEF_NORMAL</property>
 				      <property name="focus_on_click">True</property>
@@ -6357,12 +6352,40 @@
 				    <packing>
 				      <property name="left_attach">1</property>
 				      <property name="right_attach">2</property>
-				      <property name="top_attach">4</property>
-				      <property name="bottom_attach">5</property>
+				      <property name="top_attach">1</property>
+				      <property name="bottom_attach">2</property>
 				      <property name="x_options">fill</property>
 				      <property name="y_options"></property>
 				    </packing>
 				  </child>
+
+				  <child>
+				    <widget class="GtkLabel" id="label200">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">Type:</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="left_attach">0</property>
+				      <property name="right_attach">1</property>
+				      <property name="top_attach">2</property>
+				      <property name="bottom_attach">3</property>
+				      <property name="x_options">fill</property>
+				      <property name="y_options"></property>
+				    </packing>
+				  </child>
 				</widget>
 				<packing>
 				  <property name="padding">0</property>
@@ -10128,16 +10151,16 @@
 	    <widget class="GtkTable" id="table17">
 	      <property name="border_width">6</property>
 	      <property name="visible">True</property>
-	      <property name="n_rows">6</property>
+	      <property name="n_rows">7</property>
 	      <property name="n_columns">2</property>
 	      <property name="homogeneous">False</property>
 	      <property name="row_spacing">3</property>
 	      <property name="column_spacing">24</property>
 
 	      <child>
-		<widget class="GtkLabel" id="label228">
+		<widget class="GtkLabel" id="label230">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Auto-indent mode:</property>
+		  <property name="label" translatable="yes">Width:</property>
 		  <property name="use_underline">False</property>
 		  <property name="use_markup">False</property>
 		  <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -10155,37 +10178,39 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">1</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">6</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">1</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkComboBox" id="combo_auto_indent_mode">
+		<widget class="GtkSpinButton" id="spin_indent_width">
 		  <property name="visible">True</property>
-		  <property name="items" translatable="yes">None
-Basic
-Current chars
-Match braces</property>
-		  <property name="add_tearoffs">False</property>
-		  <property name="focus_on_click">True</property>
+		  <property name="tooltip" translatable="yes">The width in chars of a single indent</property>
+		  <property name="can_focus">True</property>
+		  <property name="climb_rate">1</property>
+		  <property name="digits">0</property>
+		  <property name="numeric">True</property>
+		  <property name="update_policy">GTK_UPDATE_IF_VALID</property>
+		  <property name="snap_to_ticks">False</property>
+		  <property name="wrap">True</property>
+		  <property name="adjustment">1 1 99 1 10 0</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">6</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options">fill</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">1</property>
+		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkLabel" id="label229">
+		<widget class="GtkLabel" id="label228">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Type:</property>
+		  <property name="label" translatable="yes">Auto-indent mode:</property>
 		  <property name="use_underline">False</property>
 		  <property name="use_markup">False</property>
 		  <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -10203,69 +10228,62 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">1</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkLabel" id="label230">
+		<widget class="GtkComboBox" id="combo_auto_indent_mode">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Width:</property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">0</property>
-		  <property name="ypad">0</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
+		  <property name="items" translatable="yes">None
+Basic
+Current chars
+Match braces</property>
+		  <property name="add_tearoffs">False</property>
+		  <property name="focus_on_click">True</property>
 		</widget>
 		<packing>
-		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
 		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
+		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkSpinButton" id="spin_indent_width">
+		<widget class="GtkCheckButton" id="check_detect_indent_type">
 		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">The width in chars of a single indent</property>
+		  <property name="tooltip" translatable="yes">Whether to detect the indentation type from file contents when a file is opened</property>
 		  <property name="can_focus">True</property>
-		  <property name="climb_rate">1</property>
-		  <property name="digits">0</property>
-		  <property name="numeric">True</property>
-		  <property name="update_policy">GTK_UPDATE_IF_VALID</property>
-		  <property name="snap_to_ticks">False</property>
-		  <property name="wrap">True</property>
-		  <property name="adjustment">1 1 99 1 10 0</property>
+		  <property name="label" translatable="yes">Detect type from file</property>
+		  <property name="use_underline">True</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+		  <property name="active">False</property>
+		  <property name="inconsistent">False</property>
+		  <property name="draw_indicator">True</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
+		  <property name="top_attach">5</property>
+		  <property name="bottom_attach">6</property>
+		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkRadioButton" id="radio_indent_spaces">
+		<widget class="GtkRadioButton" id="radio_indent_both">
 		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Use spaces when inserting indentation</property>
+		  <property name="tooltip" translatable="yes">Use spaces if the total indent is less than the tab width, otherwise use both</property>
 		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">_Spaces</property>
+		  <property name="label" translatable="yes">T_abs and spaces</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
 		  <property name="focus_on_click">True</property>
@@ -10276,67 +10294,95 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">2</property>
-		  <property name="bottom_attach">3</property>
+		  <property name="top_attach">4</property>
+		  <property name="bottom_attach">5</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkRadioButton" id="radio_indent_tabs">
+		<widget class="GtkRadioButton" id="radio_indent_spaces">
 		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Use one tab per indent</property>
+		  <property name="tooltip" translatable="yes">Use spaces when inserting indentation</property>
 		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">_Tabs</property>
+		  <property name="label" translatable="yes">_Spaces</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
 		  <property name="focus_on_click">True</property>
 		  <property name="active">False</property>
 		  <property name="inconsistent">False</property>
 		  <property name="draw_indicator">True</property>
-		  <property name="group">radio_indent_spaces</property>
+		  <property name="group">radio_indent_both</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
+		  <property name="top_attach">3</property>
+		  <property name="bottom_attach">4</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkRadioButton" id="radio_indent_both">
+		<widget class="GtkRadioButton" id="radio_indent_tabs">
 		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Use spaces if the total indent is less than the tab width, otherwise use both</property>
+		  <property name="tooltip" translatable="yes">Use one tab per indent</property>
 		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">T_abs and spaces</property>
+		  <property name="label" translatable="yes">_Tabs</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
 		  <property name="focus_on_click">True</property>
 		  <property name="active">False</property>
 		  <property name="inconsistent">False</property>
 		  <property name="draw_indicator">True</property>
-		  <property name="group">radio_indent_spaces</property>
+		  <property name="group">radio_indent_both</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">3</property>
-		  <property name="bottom_attach">4</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkCheckButton" id="check_detect_indent">
+		<widget class="GtkLabel" id="label229">
 		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Whether to detect the indentation type from file contents when a file is opened</property>
+		  <property name="label" translatable="yes">Type:</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkCheckButton" id="check_detect_indent_width">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">Whether to detect the indentation width from file contents when a file is opened</property>
 		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">Detect from file</property>
+		  <property name="label" translatable="yes">Detect width from file</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
 		  <property name="focus_on_click">True</property>
@@ -10347,8 +10393,8 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">4</property>
-		  <property name="bottom_attach">5</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -10637,4 +10683,17 @@
   </child>
 </widget>
 
+<widget class="GtkCheckButton" id="checkbutton3">
+  <property name="visible">True</property>
+  <property name="tooltip" translatable="yes">Whether to detect the indentation type from file contents when a file is opened</property>
+  <property name="can_focus">True</property>
+  <property name="label" translatable="yes">Detect from file</property>
+  <property name="use_underline">True</property>
+  <property name="relief">GTK_RELIEF_NORMAL</property>
+  <property name="focus_on_click">True</property>
+  <property name="active">False</property>
+  <property name="inconsistent">False</property>
+  <property name="draw_indicator">True</property>
+</widget>
+
 </glade-interface>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/src/document.c	2011-03-26 17:25:24 UTC (rev 5631)
@@ -997,22 +997,72 @@
 }
 
 
-static gboolean apply_forced_indent_settings(GeanyDocument *doc)
+/* Detect the indent width based on counting the leading indent characters for each line. */
+static gint detect_indent_width(GeanyEditor *editor, GeanyIndentType type)
 {
-	const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);
+	const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
+	ScintillaObject *sci = editor->sci;
+	guint line, line_count;
+	gint widths[7] = { 0 }; /* width can be from 2 to 8 */
+	gint count, width, i;
 
+	/* can't easily detect the supposed width of a tab, guess the default is OK */
+	if (type == GEANY_INDENT_TYPE_TABS)
+		return iprefs->width;
+
+	/* force 8 at detection time for tab & spaces -- anyway we don't use tabs at this point */
+	sci_set_tab_width(sci, 8);
+
+	line_count = sci_get_line_count(sci);
+	for (line = 0; line < line_count; line++)
+	{
+		width = sci_get_line_indentation(sci, line);
+		/* most code will have indent total <= 24, otherwise it's more likely to be
+		 * alignment than indentation */
+		if (width > 24)
+			continue;
+		/* < 2 is no indentation */
+		if (width < 2)
+			continue;
+
+		for (i = G_N_ELEMENTS(widths) - 1; i >= 0; i--)
+		{
+			if ((width % (i + 2)) == 0)
+			{
+				widths[i]++;
+				break;
+			}
+		}
+	}
+	count = 0;
+	width = iprefs->width;
+	for (i = 0; i < G_N_ELEMENTS(widths); i++)
+	{
+		/* give small lengths higher weight not for nested blocks to confuse detection */
+		if (widths[i] > count * 4)
+		{
+			width = i + 2;
+			count = widths[i];
+		}
+	}
+
+	return width;
+}
+
+
+/* returns the forced indent type or -1 if none is forced */
+static gint get_forced_indent_type(GeanyDocument *doc)
+{
 	switch (doc->file_type->id)
 	{
 		case GEANY_FILETYPES_MAKE:
 			/* force using tabs for indentation for Makefiles */
-			editor_set_indent(doc->editor, GEANY_INDENT_TYPE_TABS, iprefs->width);
-			return TRUE;
+			return GEANY_INDENT_TYPE_TABS;
 		case GEANY_FILETYPES_F77:
 			/* force using spaces for indentation for Fortran 77 */
-			editor_set_indent(doc->editor, GEANY_INDENT_TYPE_SPACES, iprefs->width);
-			return TRUE;
+			return GEANY_INDENT_TYPE_SPACES;
 		default:
-			return FALSE;
+			return -1;
 	}
 }
 
@@ -1020,11 +1070,13 @@
 void document_apply_indent_settings(GeanyDocument *doc)
 {
 	const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);
-	GeanyIndentType type = iprefs->type;
+	gint type;
+	gint width = iprefs->width;
 
-	if (apply_forced_indent_settings(doc))
-		return;
-	if (iprefs->detect_type)
+	type = get_forced_indent_type(doc);
+	if (type < 0 && ! iprefs->detect_type)
+		type = iprefs->type;
+	else if (type < 0)
 	{
 		type = detect_indent_type(doc->editor);
 
@@ -1050,7 +1102,17 @@
 				DOC_FILENAME(doc));
 		}
 	}
-	editor_set_indent(doc->editor, type, iprefs->width);
+	if (iprefs->detect_width)
+	{
+		width = detect_indent_width(doc->editor, type);
+
+		if (width != iprefs->width)
+		{
+			ui_set_statusbar(TRUE, _("Setting indentation width to %d for %s."), width,
+				DOC_FILENAME(doc));
+		}
+	}
+	editor_set_indent(doc->editor, type, width);
 }
 
 
@@ -2417,8 +2479,13 @@
 
 	if (ft_changed)
 	{
-		if (apply_forced_indent_settings(doc)) /* update forced indents, like Makefiles and F77 */
+		gint forced_indent_type = get_forced_indent_type(doc);
+
+		if (forced_indent_type >= 0)
+		{	/* update forced indents, like Makefiles and F77 */
+			editor_set_indent_type(doc->editor, forced_indent_type);
 			ui_document_show_hide(doc);
+		}
 		sidebar_openfiles_update(doc); /* to update the icon */
 		g_signal_emit_by_name(geany_object, "document-filetype-set", doc, old_ft);
 	}

Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/src/editor.h	2011-03-26 17:25:24 UTC (rev 5631)
@@ -96,6 +96,7 @@
 	gint			hard_tab_width;
 	GeanyAutoIndent	auto_indent_mode;
 	gboolean		detect_type;
+	gboolean		detect_width;
 }
 GeanyIndentPrefs;
 

Modified: trunk/src/interface.c
===================================================================
--- trunk/src/interface.c	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/src/interface.c	2011-03-26 17:25:24 UTC (rev 5631)
@@ -2676,17 +2676,18 @@
   GtkWidget *alignment30;
   GtkWidget *vbox25;
   GtkWidget *table13;
-  GtkWidget *label183;
-  GtkWidget *combo_auto_indent_mode;
-  GtkWidget *label200;
   GtkWidget *label222;
   GtkObject *spin_indent_width_adj;
   GtkWidget *spin_indent_width;
+  GtkWidget *label183;
+  GtkWidget *combo_auto_indent_mode;
+  GtkWidget *check_detect_indent_type;
+  GtkWidget *radio_indent_both;
+  GSList *radio_indent_both_group = NULL;
   GtkWidget *radio_indent_spaces;
-  GSList *radio_indent_spaces_group = NULL;
   GtkWidget *radio_indent_tabs;
-  GtkWidget *radio_indent_both;
-  GtkWidget *check_detect_indent;
+  GtkWidget *check_detect_indent_width;
+  GtkWidget *label200;
   GtkWidget *check_tab_key_indents;
   GtkWidget *label195;
   GtkWidget *label232;
@@ -3834,22 +3835,40 @@
   gtk_widget_show (vbox25);
   gtk_container_add (GTK_CONTAINER (alignment30), vbox25);
 
-  table13 = gtk_table_new (6, 2, FALSE);
+  table13 = gtk_table_new (7, 2, FALSE);
   gtk_widget_show (table13);
   gtk_box_pack_start (GTK_BOX (vbox25), table13, FALSE, TRUE, 0);
   gtk_table_set_row_spacings (GTK_TABLE (table13), 3);
   gtk_table_set_col_spacings (GTK_TABLE (table13), 24);
 
+  label222 = gtk_label_new (_("Width:"));
+  gtk_widget_show (label222);
+  gtk_table_attach (GTK_TABLE (table13), label222, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label222), 0, 0.5);
+
+  spin_indent_width_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 0);
+  spin_indent_width = gtk_spin_button_new (GTK_ADJUSTMENT (spin_indent_width_adj), 1, 0);
+  gtk_widget_show (spin_indent_width);
+  gtk_table_attach (GTK_TABLE (table13), spin_indent_width, 1, 2, 0, 1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, spin_indent_width, _("The width in chars of a single indent"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
+  gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spin_indent_width), GTK_UPDATE_IF_VALID);
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
+
   label183 = gtk_label_new (_("Auto-indent mode:"));
   gtk_widget_show (label183);
-  gtk_table_attach (GTK_TABLE (table13), label183, 0, 1, 5, 6,
+  gtk_table_attach (GTK_TABLE (table13), label183, 0, 1, 6, 7,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
   gtk_misc_set_alignment (GTK_MISC (label183), 0, 0.5);
 
   combo_auto_indent_mode = gtk_combo_box_new_text ();
   gtk_widget_show (combo_auto_indent_mode);
-  gtk_table_attach (GTK_TABLE (table13), combo_auto_indent_mode, 1, 2, 5, 6,
+  gtk_table_attach (GTK_TABLE (table13), combo_auto_indent_mode, 1, 2, 6, 7,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_FILL), 0, 0);
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("None"));
@@ -3857,64 +3876,53 @@
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Current chars"));
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Match braces"));
 
-  label200 = gtk_label_new (_("Type:"));
-  gtk_widget_show (label200);
-  gtk_table_attach (GTK_TABLE (table13), label200, 0, 1, 1, 2,
+  check_detect_indent_type = gtk_check_button_new_with_mnemonic (_("Detect type from file"));
+  gtk_widget_show (check_detect_indent_type);
+  gtk_table_attach (GTK_TABLE (table13), check_detect_indent_type, 1, 2, 5, 6,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_misc_set_alignment (GTK_MISC (label200), 0, 0.5);
+  gtk_tooltips_set_tip (tooltips, check_detect_indent_type, _("Whether to detect the indentation type from file contents when a file is opened"), NULL);
 
-  label222 = gtk_label_new (_("Width:"));
-  gtk_widget_show (label222);
-  gtk_table_attach (GTK_TABLE (table13), label222, 0, 1, 0, 1,
+  radio_indent_both = gtk_radio_button_new_with_mnemonic (NULL, _("T_abs and spaces"));
+  gtk_widget_show (radio_indent_both);
+  gtk_table_attach (GTK_TABLE (table13), radio_indent_both, 1, 2, 4, 5,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_misc_set_alignment (GTK_MISC (label222), 0, 0.5);
+  gtk_tooltips_set_tip (tooltips, radio_indent_both, _("Use spaces if the total indent is less than the tab width, otherwise use both"), NULL);
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_both), radio_indent_both_group);
+  radio_indent_both_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_both));
 
-  spin_indent_width_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 0);
-  spin_indent_width = gtk_spin_button_new (GTK_ADJUSTMENT (spin_indent_width_adj), 1, 0);
-  gtk_widget_show (spin_indent_width);
-  gtk_table_attach (GTK_TABLE (table13), spin_indent_width, 1, 2, 0, 1,
-                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-                    (GtkAttachOptions) (0), 0, 0);
-  gtk_tooltips_set_tip (tooltips, spin_indent_width, _("The width in chars of a single indent"), NULL);
-  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
-  gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spin_indent_width), GTK_UPDATE_IF_VALID);
-  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
-
   radio_indent_spaces = gtk_radio_button_new_with_mnemonic (NULL, _("_Spaces"));
   gtk_widget_show (radio_indent_spaces);
-  gtk_table_attach (GTK_TABLE (table13), radio_indent_spaces, 1, 2, 2, 3,
+  gtk_table_attach (GTK_TABLE (table13), radio_indent_spaces, 1, 2, 3, 4,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
   gtk_tooltips_set_tip (tooltips, radio_indent_spaces, _("Use spaces when inserting indentation"), NULL);
-  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_spaces), radio_indent_spaces_group);
-  radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_spaces));
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_spaces), radio_indent_both_group);
+  radio_indent_both_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_spaces));
 
   radio_indent_tabs = gtk_radio_button_new_with_mnemonic (NULL, _("_Tabs"));
   gtk_widget_show (radio_indent_tabs);
-  gtk_table_attach (GTK_TABLE (table13), radio_indent_tabs, 1, 2, 1, 2,
+  gtk_table_attach (GTK_TABLE (table13), radio_indent_tabs, 1, 2, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
   gtk_tooltips_set_tip (tooltips, radio_indent_tabs, _("Use one tab per indent"), NULL);
-  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_tabs), radio_indent_spaces_group);
-  radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_tabs));
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_tabs), radio_indent_both_group);
+  radio_indent_both_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_tabs));
 
-  radio_indent_both = gtk_radio_button_new_with_mnemonic (NULL, _("T_abs and spaces"));
-  gtk_widget_show (radio_indent_both);
-  gtk_table_attach (GTK_TABLE (table13), radio_indent_both, 1, 2, 3, 4,
+  check_detect_indent_width = gtk_check_button_new_with_mnemonic (_("Detect width from file"));
+  gtk_widget_show (check_detect_indent_width);
+  gtk_table_attach (GTK_TABLE (table13), check_detect_indent_width, 1, 2, 1, 2,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_tooltips_set_tip (tooltips, radio_indent_both, _("Use spaces if the total indent is less than the tab width, otherwise use both"), NULL);
-  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_both), radio_indent_spaces_group);
-  radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_both));
+  gtk_tooltips_set_tip (tooltips, check_detect_indent_width, _("Whether to detect the indentation width from file contents when a file is opened"), NULL);
 
-  check_detect_indent = gtk_check_button_new_with_mnemonic (_("Detect from file"));
-  gtk_widget_show (check_detect_indent);
-  gtk_table_attach (GTK_TABLE (table13), check_detect_indent, 1, 2, 4, 5,
+  label200 = gtk_label_new (_("Type:"));
+  gtk_widget_show (label200);
+  gtk_table_attach (GTK_TABLE (table13), label200, 0, 1, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_tooltips_set_tip (tooltips, check_detect_indent, _("Whether to detect the indentation type from file contents when a file is opened"), NULL);
+  gtk_misc_set_alignment (GTK_MISC (label200), 0, 0.5);
 
   check_tab_key_indents = gtk_check_button_new_with_mnemonic (_("Tab key indents"));
   gtk_widget_show (check_tab_key_indents);
@@ -5206,15 +5214,16 @@
   GLADE_HOOKUP_OBJECT (prefs_dialog, alignment30, "alignment30");
   GLADE_HOOKUP_OBJECT (prefs_dialog, vbox25, "vbox25");
   GLADE_HOOKUP_OBJECT (prefs_dialog, table13, "table13");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, label222, "label222");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, spin_indent_width, "spin_indent_width");
   GLADE_HOOKUP_OBJECT (prefs_dialog, label183, "label183");
   GLADE_HOOKUP_OBJECT (prefs_dialog, combo_auto_indent_mode, "combo_auto_indent_mode");
-  GLADE_HOOKUP_OBJECT (prefs_dialog, label200, "label200");
-  GLADE_HOOKUP_OBJECT (prefs_dialog, label222, "label222");
-  GLADE_HOOKUP_OBJECT (prefs_dialog, spin_indent_width, "spin_indent_width");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, check_detect_indent_type, "check_detect_indent_type");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, radio_indent_both, "radio_indent_both");
   GLADE_HOOKUP_OBJECT (prefs_dialog, radio_indent_spaces, "radio_indent_spaces");
   GLADE_HOOKUP_OBJECT (prefs_dialog, radio_indent_tabs, "radio_indent_tabs");
-  GLADE_HOOKUP_OBJECT (prefs_dialog, radio_indent_both, "radio_indent_both");
-  GLADE_HOOKUP_OBJECT (prefs_dialog, check_detect_indent, "check_detect_indent");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, check_detect_indent_width, "check_detect_indent_width");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, label200, "label200");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_tab_key_indents, "check_tab_key_indents");
   GLADE_HOOKUP_OBJECT (prefs_dialog, label195, "label195");
   GLADE_HOOKUP_OBJECT (prefs_dialog, label232, "label232");
@@ -5430,17 +5439,18 @@
   GtkWidget *dialog_vbox4;
   GtkWidget *project_notebook;
   GtkWidget *table17;
-  GtkWidget *label228;
-  GtkWidget *combo_auto_indent_mode;
-  GtkWidget *label229;
   GtkWidget *label230;
   GtkObject *spin_indent_width_adj;
   GtkWidget *spin_indent_width;
+  GtkWidget *label228;
+  GtkWidget *combo_auto_indent_mode;
+  GtkWidget *check_detect_indent_type;
+  GtkWidget *radio_indent_both;
+  GSList *radio_indent_both_group = NULL;
   GtkWidget *radio_indent_spaces;
-  GSList *radio_indent_spaces_group = NULL;
   GtkWidget *radio_indent_tabs;
-  GtkWidget *radio_indent_both;
-  GtkWidget *check_detect_indent;
+  GtkWidget *label229;
+  GtkWidget *check_detect_indent_width;
   GtkWidget *label227;
   GtkWidget *vbox47;
   GtkWidget *frame40;
@@ -5474,23 +5484,41 @@
   gtk_widget_show (project_notebook);
   gtk_box_pack_start (GTK_BOX (dialog_vbox4), project_notebook, TRUE, TRUE, 0);
 
-  table17 = gtk_table_new (6, 2, FALSE);
+  table17 = gtk_table_new (7, 2, FALSE);
   gtk_widget_show (table17);
   gtk_container_add (GTK_CONTAINER (project_notebook), table17);
   gtk_container_set_border_width (GTK_CONTAINER (table17), 6);
   gtk_table_set_row_spacings (GTK_TABLE (table17), 3);
   gtk_table_set_col_spacings (GTK_TABLE (table17), 24);
 
+  label230 = gtk_label_new (_("Width:"));
+  gtk_widget_show (label230);
+  gtk_table_attach (GTK_TABLE (table17), label230, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label230), 0, 0.5);
+
+  spin_indent_width_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 0);
+  spin_indent_width = gtk_spin_button_new (GTK_ADJUSTMENT (spin_indent_width_adj), 1, 0);
+  gtk_widget_show (spin_indent_width);
+  gtk_table_attach (GTK_TABLE (table17), spin_indent_width, 1, 2, 0, 1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, spin_indent_width, _("The width in chars of a single indent"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
+  gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spin_indent_width), GTK_UPDATE_IF_VALID);
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
+
   label228 = gtk_label_new (_("Auto-indent mode:"));
   gtk_widget_show (label228);
-  gtk_table_attach (GTK_TABLE (table17), label228, 0, 1, 5, 6,
+  gtk_table_attach (GTK_TABLE (table17), label228, 0, 1, 6, 7,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
   gtk_misc_set_alignment (GTK_MISC (label228), 0, 0.5);
 
   combo_auto_indent_mode = gtk_combo_box_new_text ();
   gtk_widget_show (combo_auto_indent_mode);
-  gtk_table_attach (GTK_TABLE (table17), combo_auto_indent_mode, 1, 2, 5, 6,
+  gtk_table_attach (GTK_TABLE (table17), combo_auto_indent_mode, 1, 2, 6, 7,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_FILL), 0, 0);
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("None"));
@@ -5498,64 +5526,53 @@
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Current chars"));
   gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Match braces"));
 
-  label229 = gtk_label_new (_("Type:"));
-  gtk_widget_show (label229);
-  gtk_table_attach (GTK_TABLE (table17), label229, 0, 1, 1, 2,
+  check_detect_indent_type = gtk_check_button_new_with_mnemonic (_("Detect type from file"));
+  gtk_widget_show (check_detect_indent_type);
+  gtk_table_attach (GTK_TABLE (table17), check_detect_indent_type, 1, 2, 5, 6,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_misc_set_alignment (GTK_MISC (label229), 0, 0.5);
+  gtk_tooltips_set_tip (tooltips, check_detect_indent_type, _("Whether to detect the indentation type from file contents when a file is opened"), NULL);
 
-  label230 = gtk_label_new (_("Width:"));
-  gtk_widget_show (label230);
-  gtk_table_attach (GTK_TABLE (table17), label230, 0, 1, 0, 1,
+  radio_indent_both = gtk_radio_button_new_with_mnemonic (NULL, _("T_abs and spaces"));
+  gtk_widget_show (radio_indent_both);
+  gtk_table_attach (GTK_TABLE (table17), radio_indent_both, 1, 2, 4, 5,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_misc_set_alignment (GTK_MISC (label230), 0, 0.5);
+  gtk_tooltips_set_tip (tooltips, radio_indent_both, _("Use spaces if the total indent is less than the tab width, otherwise use both"), NULL);
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_both), radio_indent_both_group);
+  radio_indent_both_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_both));
 
-  spin_indent_width_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 0);
-  spin_indent_width = gtk_spin_button_new (GTK_ADJUSTMENT (spin_indent_width_adj), 1, 0);
-  gtk_widget_show (spin_indent_width);
-  gtk_table_attach (GTK_TABLE (table17), spin_indent_width, 1, 2, 0, 1,
-                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-                    (GtkAttachOptions) (0), 0, 0);
-  gtk_tooltips_set_tip (tooltips, spin_indent_width, _("The width in chars of a single indent"), NULL);
-  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
-  gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spin_indent_width), GTK_UPDATE_IF_VALID);
-  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spin_indent_width), TRUE);
-
   radio_indent_spaces = gtk_radio_button_new_with_mnemonic (NULL, _("_Spaces"));
   gtk_widget_show (radio_indent_spaces);
-  gtk_table_attach (GTK_TABLE (table17), radio_indent_spaces, 1, 2, 2, 3,
+  gtk_table_attach (GTK_TABLE (table17), radio_indent_spaces, 1, 2, 3, 4,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
   gtk_tooltips_set_tip (tooltips, radio_indent_spaces, _("Use spaces when inserting indentation"), NULL);
-  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_spaces), radio_indent_spaces_group);
-  radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_spaces));
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_spaces), radio_indent_both_group);
+  radio_indent_both_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_spaces));
 
   radio_indent_tabs = gtk_radio_button_new_with_mnemonic (NULL, _("_Tabs"));
   gtk_widget_show (radio_indent_tabs);
-  gtk_table_attach (GTK_TABLE (table17), radio_indent_tabs, 1, 2, 1, 2,
+  gtk_table_attach (GTK_TABLE (table17), radio_indent_tabs, 1, 2, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
   gtk_tooltips_set_tip (tooltips, radio_indent_tabs, _("Use one tab per indent"), NULL);
-  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_tabs), radio_indent_spaces_group);
-  radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_tabs));
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_tabs), radio_indent_both_group);
+  radio_indent_both_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_tabs));
 
-  radio_indent_both = gtk_radio_button_new_with_mnemonic (NULL, _("T_abs and spaces"));
-  gtk_widget_show (radio_indent_both);
-  gtk_table_attach (GTK_TABLE (table17), radio_indent_both, 1, 2, 3, 4,
+  label229 = gtk_label_new (_("Type:"));
+  gtk_widget_show (label229);
+  gtk_table_attach (GTK_TABLE (table17), label229, 0, 1, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_tooltips_set_tip (tooltips, radio_indent_both, _("Use spaces if the total indent is less than the tab width, otherwise use both"), NULL);
-  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_both), radio_indent_spaces_group);
-  radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_both));
+  gtk_misc_set_alignment (GTK_MISC (label229), 0, 0.5);
 
-  check_detect_indent = gtk_check_button_new_with_mnemonic (_("Detect from file"));
-  gtk_widget_show (check_detect_indent);
-  gtk_table_attach (GTK_TABLE (table17), check_detect_indent, 1, 2, 4, 5,
+  check_detect_indent_width = gtk_check_button_new_with_mnemonic (_("Detect width from file"));
+  gtk_widget_show (check_detect_indent_width);
+  gtk_table_attach (GTK_TABLE (table17), check_detect_indent_width, 1, 2, 1, 2,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gtk_tooltips_set_tip (tooltips, check_detect_indent, _("Whether to detect the indentation type from file contents when a file is opened"), NULL);
+  gtk_tooltips_set_tip (tooltips, check_detect_indent_width, _("Whether to detect the indentation width from file contents when a file is opened"), NULL);
 
   label227 = gtk_label_new (_("Indentation"));
   gtk_widget_show (label227);
@@ -5657,15 +5674,16 @@
   GLADE_HOOKUP_OBJECT_NO_REF (project_dialog, dialog_vbox4, "dialog_vbox4");
   GLADE_HOOKUP_OBJECT (project_dialog, project_notebook, "project_notebook");
   GLADE_HOOKUP_OBJECT (project_dialog, table17, "table17");
+  GLADE_HOOKUP_OBJECT (project_dialog, label230, "label230");
+  GLADE_HOOKUP_OBJECT (project_dialog, spin_indent_width, "spin_indent_width");
   GLADE_HOOKUP_OBJECT (project_dialog, label228, "label228");
   GLADE_HOOKUP_OBJECT (project_dialog, combo_auto_indent_mode, "combo_auto_indent_mode");
-  GLADE_HOOKUP_OBJECT (project_dialog, label229, "label229");
-  GLADE_HOOKUP_OBJECT (project_dialog, label230, "label230");
-  GLADE_HOOKUP_OBJECT (project_dialog, spin_indent_width, "spin_indent_width");
+  GLADE_HOOKUP_OBJECT (project_dialog, check_detect_indent_type, "check_detect_indent_type");
+  GLADE_HOOKUP_OBJECT (project_dialog, radio_indent_both, "radio_indent_both");
   GLADE_HOOKUP_OBJECT (project_dialog, radio_indent_spaces, "radio_indent_spaces");
   GLADE_HOOKUP_OBJECT (project_dialog, radio_indent_tabs, "radio_indent_tabs");
-  GLADE_HOOKUP_OBJECT (project_dialog, radio_indent_both, "radio_indent_both");
-  GLADE_HOOKUP_OBJECT (project_dialog, check_detect_indent, "check_detect_indent");
+  GLADE_HOOKUP_OBJECT (project_dialog, label229, "label229");
+  GLADE_HOOKUP_OBJECT (project_dialog, check_detect_indent_width, "check_detect_indent_width");
   GLADE_HOOKUP_OBJECT (project_dialog, label227, "label227");
   GLADE_HOOKUP_OBJECT (project_dialog, vbox47, "vbox47");
   GLADE_HOOKUP_OBJECT (project_dialog, frame40, "frame40");
@@ -5687,3 +5705,21 @@
   return project_dialog;
 }
 
+GtkWidget*
+create_checkbutton3 (void)
+{
+  GtkWidget *checkbutton3;
+  GtkTooltips *tooltips;
+
+  tooltips = gtk_tooltips_new ();
+
+  checkbutton3 = gtk_check_button_new_with_mnemonic (_("Detect from file"));
+  gtk_tooltips_set_tip (tooltips, checkbutton3, _("Whether to detect the indentation type from file contents when a file is opened"), NULL);
+
+  /* Store pointers to all widgets, for use by lookup_widget(). */
+  GLADE_HOOKUP_OBJECT_NO_REF (checkbutton3, checkbutton3, "checkbutton3");
+  GLADE_HOOKUP_OBJECT_NO_REF (checkbutton3, tooltips, "tooltips");
+
+  return checkbutton3;
+}
+

Modified: trunk/src/interface.h
===================================================================
--- trunk/src/interface.h	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/src/interface.h	2011-03-26 17:25:24 UTC (rev 5631)
@@ -7,3 +7,4 @@
 GtkWidget* create_edit_menu1 (void);
 GtkWidget* create_prefs_dialog (void);
 GtkWidget* create_project_dialog (void);
+GtkWidget* create_checkbutton3 (void);

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/src/keyfile.c	2011-03-26 17:25:24 UTC (rev 5631)
@@ -140,7 +140,9 @@
 
 	/* editor */
 	stash_group_add_toggle_button(group, &editor_prefs.indentation->detect_type,
-		"check_detect_indent", FALSE, "check_detect_indent");
+		"check_detect_indent", FALSE, "check_detect_indent_type");
+	stash_group_add_toggle_button(group, &editor_prefs.indentation->detect_width,
+		"detect_indent_width", FALSE, "check_detect_indent_width");
 	stash_group_add_toggle_button(group, &editor_prefs.use_tab_to_indent,
 		"use_tab_to_indent", TRUE, "check_tab_key_indents");
 	stash_group_add_spin_button_integer(group, &editor_prefs.indentation->width,

Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c	2011-03-26 03:12:50 UTC (rev 5630)
+++ trunk/src/project.c	2011-03-26 17:25:24 UTC (rev 5631)
@@ -1209,7 +1209,9 @@
 	stash_group_add_integer(group, &indentation.hard_tab_width,
 		"indent_hard_tab_width", 8);
 	stash_group_add_toggle_button(group, &indentation.detect_type,
-		"detect_indent", FALSE, "check_detect_indent");
+		"detect_indent", FALSE, "check_detect_indent_type");
+	stash_group_add_toggle_button(group, &indentation.detect_width,
+		"detect_indent_width", FALSE, "check_detect_indent_width");
 	stash_group_add_combo_box(group, (gint*)(gpointer)&indentation.auto_indent_mode,
 		"indent_mode", GEANY_AUTOINDENT_CURRENTCHARS, "combo_auto_indent_mode");
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list