SF.net SVN: geany:[5228] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Sep 14 15:01:30 UTC 2010
Revision: 5228
http://geany.svn.sourceforge.net/geany/?rev=5228&view=rev
Author: ntrel
Date: 2010-09-14 15:01:29 +0000 (Tue, 14 Sep 2010)
Log Message:
-----------
Allow per-document indent width setting (patch by Ji?\197?\153?\195?\173 Techet,
updated by Erik de Castro Lopo - thanks).
Modified Paths:
--------------
trunk/ChangeLog
trunk/geany.glade
trunk/src/callbacks.c
trunk/src/callbacks.h
trunk/src/document.c
trunk/src/editor.c
trunk/src/editor.h
trunk/src/interface.c
trunk/src/keyfile.c
trunk/src/ui_utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/ChangeLog 2010-09-14 15:01:29 UTC (rev 5228)
@@ -5,6 +5,11 @@
Erik de Castro Lopo, thanks).
* tagmanager/c.c:
Parse D function template names.
+ * src/interface.c, src/callbacks.c, src/callbacks.h, src/keyfile.c,
+ src/document.c, src/editor.c, src/editor.h, src/ui_utils.c,
+ geany.glade:
+ Allow per-document indent width setting (patch by Jiří Techet,
+ updated by Erik de Castro Lopo - thanks).
2010-09-13 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/geany.glade
===================================================================
--- trunk/geany.glade 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/geany.glade 2010-09-14 15:01:29 UTC (rev 5228)
@@ -1424,6 +1424,106 @@
</child>
<child>
+ <widget class="GtkMenuItem" id="indent_width1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Indent Widt_h</property>
+ <property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="indent_width1_menu">
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_1</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <signal name="activate" handler="on_indent_width_1_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_2</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="group">indent_width_1</property>
+ <signal name="activate" handler="on_indent_width_2_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_3</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="group">indent_width_1</property>
+ <signal name="activate" handler="on_indent_width_3_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_4</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="group">indent_width_1</property>
+ <signal name="activate" handler="on_indent_width_4_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_5</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="group">indent_width_1</property>
+ <signal name="activate" handler="on_indent_width_5_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_6</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="group">indent_width_1</property>
+ <signal name="activate" handler="on_indent_width_6_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_7</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="group">indent_width_1</property>
+ <signal name="activate" handler="on_indent_width_7_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="indent_width_8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_8</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="group">indent_width_1</property>
+ <signal name="activate" handler="on_indent_width_8_activate" last_modification_time="Mon, 09 Aug 2010 21:16:01 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
<widget class="GtkSeparatorMenuItem" id="separator45">
<property name="visible">True</property>
</widget>
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/callbacks.c 2010-09-14 15:01:29 UTC (rev 5228)
@@ -2025,7 +2025,7 @@
doc = document_get_current();
g_return_if_fail(doc != NULL);
- editor_set_indent_type(doc->editor, type);
+ editor_set_indent(doc->editor, type, doc->editor->indent_width);
ui_update_statusbar(doc, -1);
}
@@ -2347,3 +2347,81 @@
}
+
+static void set_indent_width(guint width)
+{
+ GeanyDocument *doc;
+
+ 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_1_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(1);
+}
+
+
+void
+on_indent_width_2_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(2);
+}
+
+
+void
+on_indent_width_3_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(3);
+}
+
+
+void
+on_indent_width_4_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(4);
+}
+
+
+void
+on_indent_width_5_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(5);
+}
+
+
+void
+on_indent_width_6_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(6);
+}
+
+
+void
+on_indent_width_7_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(7);
+}
+
+
+void
+on_indent_width_8_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ set_indent_width(8);
+}
+
Modified: trunk/src/callbacks.h
===================================================================
--- trunk/src/callbacks.h 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/callbacks.h 2010-09-14 15:01:29 UTC (rev 5228)
@@ -644,3 +644,35 @@
void
on_goto_tag_declaration1 (GtkMenuItem *menuitem,
gpointer user_data);
+
+void
+on_indent_width_1_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_indent_width_2_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_indent_width_3_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_indent_width_4_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_indent_width_5_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_indent_width_6_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_indent_width_7_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_indent_width_8_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/document.c 2010-09-14 15:01:29 UTC (rev 5228)
@@ -1143,11 +1143,11 @@
{
case GEANY_FILETYPES_MAKE:
/* force using tabs for indentation for Makefiles */
- editor_set_indent_type(doc->editor, GEANY_INDENT_TYPE_TABS);
+ editor_set_indent(doc->editor, GEANY_INDENT_TYPE_TABS, iprefs->width);
return;
case GEANY_FILETYPES_F77:
/* force using spaces for indentation for Fortran 77 */
- editor_set_indent_type(doc->editor, GEANY_INDENT_TYPE_SPACES);
+ editor_set_indent(doc->editor, GEANY_INDENT_TYPE_SPACES, iprefs->width);
return;
}
if (iprefs->detect_type)
@@ -1176,7 +1176,7 @@
DOC_FILENAME(doc));
}
}
- editor_set_indent_type(doc->editor, type);
+ editor_set_indent(doc->editor, type, iprefs->width);
}
@@ -1325,7 +1325,7 @@
/* set indentation settings after setting the filetype */
if (reload)
- editor_set_indent_type(doc->editor, doc->editor->indent_type); /* resetup sci */
+ editor_set_indent(doc->editor, doc->editor->indent_type, doc->editor->indent_width); /* resetup sci */
else
document_apply_indent_settings(doc);
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/editor.c 2010-09-14 15:01:29 UTC (rev 5228)
@@ -1064,6 +1064,7 @@
return &iprefs;
iprefs.type = editor->indent_type;
+ iprefs.width = editor->indent_width;
/* if per-document auto-indent is enabled, but we don't have a global mode set,
* just use basic auto-indenting */
@@ -4568,11 +4569,18 @@
*/
void editor_set_indent_type(GeanyEditor *editor, GeanyIndentType type)
{
+ editor_set_indent(editor, type, editor->indent_width);
+}
+
+
+void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width)
+{
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
ScintillaObject *sci = editor->sci;
gboolean use_tabs = type != GEANY_INDENT_TYPE_SPACES;
editor->indent_type = type;
+ editor->indent_width = width;
sci_set_use_tabs(sci, use_tabs);
if (type == GEANY_INDENT_TYPE_BOTH)
@@ -4588,9 +4596,9 @@
}
}
else
- sci_set_tab_width(sci, iprefs->width);
+ sci_set_tab_width(sci, width);
- SSM(sci, SCI_SETINDENT, iprefs->width, 0);
+ SSM(sci, SCI_SETINDENT, width, 0);
/* remove indent spaces on backspace, if using any spaces to indent */
SSM(sci, SCI_SETBACKSPACEUNINDENTS, type != GEANY_INDENT_TYPE_TABS, 0);
@@ -4827,7 +4835,7 @@
sci = create_new_sci(editor);
editor->sci = sci;
- editor_set_indent_type(editor, iprefs->type);
+ editor_set_indent(editor, iprefs->type, iprefs->width);
editor_set_font(editor, interface_prefs.editor_font);
editor_apply_update_prefs(editor);
@@ -4998,7 +5006,7 @@
editor_get_long_line_column(), editor_prefs.long_line_color);
/* update indent width, tab width */
- editor_set_indent_type(editor, editor->indent_type);
+ editor_set_indent(editor, editor->indent_type, editor->indent_width);
sci_set_tab_indents(sci, editor_prefs.use_tab_to_indent);
sci_set_autoc_max_height(sci, editor_prefs.symbolcompletion_max_height);
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/editor.h 2010-09-14 15:01:29 UTC (rev 5228)
@@ -162,6 +162,7 @@
gfloat scroll_percent;
GeanyIndentType indent_type; /* Use editor_get_indent_prefs() instead. */
gboolean line_breaking; /**< Whether to split long lines as you type. */
+ gint indent_width;
};
@@ -286,6 +287,8 @@
void editor_set_indent_type(GeanyEditor *editor, GeanyIndentType type);
+void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width);
+
void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap);
gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark);
Modified: trunk/src/interface.c
===================================================================
--- trunk/src/interface.c 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/interface.c 2010-09-14 15:01:29 UTC (rev 5228)
@@ -197,6 +197,17 @@
GtkWidget *tabs1;
GtkWidget *spaces1;
GtkWidget *tabs_and_spaces1;
+ GtkWidget *indent_width1;
+ GtkWidget *indent_width1_menu;
+ GSList *indent_width_1_group = NULL;
+ GtkWidget *indent_width_1;
+ GtkWidget *indent_width_2;
+ GtkWidget *indent_width_3;
+ GtkWidget *indent_width_4;
+ GtkWidget *indent_width_5;
+ GtkWidget *indent_width_6;
+ GtkWidget *indent_width_7;
+ GtkWidget *indent_width_8;
GtkWidget *separator45;
GtkWidget *set_file_readonly1;
GtkWidget *menu_write_unicode_bom1;
@@ -967,6 +978,61 @@
gtk_container_add (GTK_CONTAINER (indent_type1_menu), tabs_and_spaces1);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (tabs_and_spaces1), TRUE);
+ indent_width1 = gtk_menu_item_new_with_mnemonic (_("Indent Widt_h"));
+ gtk_widget_show (indent_width1);
+ gtk_container_add (GTK_CONTAINER (menu_document1_menu), indent_width1);
+
+ indent_width1_menu = gtk_menu_new ();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (indent_width1), indent_width1_menu);
+
+ indent_width_1 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_1"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_1));
+ gtk_widget_show (indent_width_1);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_1);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_1), TRUE);
+
+ indent_width_2 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_2"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_2));
+ gtk_widget_show (indent_width_2);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_2);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_2), TRUE);
+
+ indent_width_3 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_3"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_3));
+ gtk_widget_show (indent_width_3);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_3);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_3), TRUE);
+
+ indent_width_4 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_4"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_4));
+ gtk_widget_show (indent_width_4);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_4);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_4), TRUE);
+
+ indent_width_5 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_5"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_5));
+ gtk_widget_show (indent_width_5);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_5);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_5), TRUE);
+
+ indent_width_6 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_6"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_6));
+ gtk_widget_show (indent_width_6);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_6);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_6), TRUE);
+
+ indent_width_7 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_7"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_7));
+ gtk_widget_show (indent_width_7);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_7);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_7), TRUE);
+
+ indent_width_8 = gtk_radio_menu_item_new_with_mnemonic (indent_width_1_group, _("_8"));
+ indent_width_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (indent_width_8));
+ gtk_widget_show (indent_width_8);
+ gtk_container_add (GTK_CONTAINER (indent_width1_menu), indent_width_8);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (indent_width_8), TRUE);
+
separator45 = gtk_separator_menu_item_new ();
gtk_widget_show (separator45);
gtk_container_add (GTK_CONTAINER (menu_document1_menu), separator45);
@@ -1584,6 +1650,30 @@
g_signal_connect ((gpointer) tabs_and_spaces1, "activate",
G_CALLBACK (on_tabs_and_spaces1_activate),
NULL);
+ g_signal_connect ((gpointer) indent_width_1, "activate",
+ G_CALLBACK (on_indent_width_1_activate),
+ NULL);
+ g_signal_connect ((gpointer) indent_width_2, "activate",
+ G_CALLBACK (on_indent_width_2_activate),
+ NULL);
+ g_signal_connect ((gpointer) indent_width_3, "activate",
+ G_CALLBACK (on_indent_width_3_activate),
+ NULL);
+ g_signal_connect ((gpointer) indent_width_4, "activate",
+ G_CALLBACK (on_indent_width_4_activate),
+ NULL);
+ g_signal_connect ((gpointer) indent_width_5, "activate",
+ G_CALLBACK (on_indent_width_5_activate),
+ NULL);
+ g_signal_connect ((gpointer) indent_width_6, "activate",
+ G_CALLBACK (on_indent_width_6_activate),
+ NULL);
+ g_signal_connect ((gpointer) indent_width_7, "activate",
+ G_CALLBACK (on_indent_width_7_activate),
+ NULL);
+ g_signal_connect ((gpointer) indent_width_8, "activate",
+ G_CALLBACK (on_indent_width_8_activate),
+ NULL);
g_signal_connect ((gpointer) set_file_readonly1, "toggled",
G_CALLBACK (on_set_file_readonly1_toggled),
NULL);
@@ -1846,6 +1936,16 @@
GLADE_HOOKUP_OBJECT (window1, tabs1, "tabs1");
GLADE_HOOKUP_OBJECT (window1, spaces1, "spaces1");
GLADE_HOOKUP_OBJECT (window1, tabs_and_spaces1, "tabs_and_spaces1");
+ GLADE_HOOKUP_OBJECT (window1, indent_width1, "indent_width1");
+ GLADE_HOOKUP_OBJECT (window1, indent_width1_menu, "indent_width1_menu");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_1, "indent_width_1");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_2, "indent_width_2");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_3, "indent_width_3");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_4, "indent_width_4");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_5, "indent_width_5");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_6, "indent_width_6");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_7, "indent_width_7");
+ GLADE_HOOKUP_OBJECT (window1, indent_width_8, "indent_width_8");
GLADE_HOOKUP_OBJECT (window1, separator45, "separator45");
GLADE_HOOKUP_OBJECT (window1, set_file_readonly1, "set_file_readonly1");
GLADE_HOOKUP_OBJECT (window1, menu_write_unicode_bom1, "menu_write_unicode_bom1");
Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/keyfile.c 2010-09-14 15:01:29 UTC (rev 5228)
@@ -988,7 +988,7 @@
if (doc)
{
- editor_set_indent_type(doc->editor, indent_type);
+ editor_set_indent(doc->editor, indent_type, doc->editor->indent_width);
editor_set_line_wrapping(doc->editor, line_wrapping);
doc->editor->line_breaking = line_breaking;
doc->editor->auto_indent = auto_indent;
Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c 2010-09-14 11:57:38 UTC (rev 5227)
+++ trunk/src/ui_utils.c 2010-09-14 15:01:29 UTC (rev 5228)
@@ -886,6 +886,16 @@
item = ui_lookup_widget(main_widgets.window, widget_name);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
+ if (iprefs->width >= 1 && iprefs->width <= 8)
+ {
+ gchar *name;
+
+ name = g_strdup_printf("indent_width_%d", iprefs->width);
+ item = ui_lookup_widget(main_widgets.window, name);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
+ g_free(name);
+ }
+
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "set_file_readonly1")),
doc->readonly);
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