[geany/geany] fa20ec: Merge pull request #343 from ntrel/more-project-prefs

Nick Treleaven git-noreply at xxxxx
Mon Oct 6 11:20:15 UTC 2014


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Mon, 06 Oct 2014 11:20:15 UTC
Commit:      fa20ec4ffb89a8f5e9e0a4506565dbd144af2835
             https://github.com/geany/geany/commit/fa20ec4ffb89a8f5e9e0a4506565dbd144af2835

Log Message:
-----------
Merge pull request #343 from ntrel/more-project-prefs

Add project prefs for line breaking column & multiline comment completion


Modified Paths:
--------------
    data/geany.glade
    src/editor.c
    src/editor.h
    src/project.c
    src/projectprivate.h

Modified: data/geany.glade
152 lines changed, 135 insertions(+), 17 deletions(-)
===================================================================
@@ -8884,6 +8884,140 @@
                 <property name="border_width">5</property>
                 <property name="spacing">10</property>
                 <child>
+                  <object class="GtkFrame" id="frame11p">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment8p">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox56p">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkCheckButton" id="check_line_wrapping1">
+                                <property name="label" translatable="yes">Line wrapping</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Wrap the line at the window border and continue it on the next line. Note: line wrapping has a high performance cost for large documents so should be disabled on slow machines.</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox11p">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">12</property>
+                                <child>
+                                  <object class="GtkLabel" id="label209p">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Line breaking column:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="spin_line_break1">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="primary_icon_activatable">False</property>
+                                    <property name="secondary_icon_activatable">False</property>
+                                    <property name="primary_icon_sensitive">True</property>
+                                    <property name="secondary_icon_sensitive">True</property>
+                                    <property name="adjustment">adjustment1</property>
+                                    <property name="climb_rate">1</property>
+                                    <property name="numeric">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label8p">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes"><b>Features</b></property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="frame3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkCheckButton" id="check_auto_multiline1">
+                            <property name="label" translatable="yes">Automatic continuation of multi-line comments</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="tooltip_text" translatable="yes">Continue automatically multi-line comments in languages like C, C++ and Java when a new line is entered inside such a comment</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label23">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes"><b>Completions</b></property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkFrame" id="frame40_project">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
@@ -9026,23 +9160,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="check_line_wrapping1">
-                    <property name="label" translatable="yes">Line wrapping</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="tooltip_text" translatable="yes">Wrap the line at the window border and continue it on the next line. Note: line wrapping has a high performance cost for large documents so should be disabled on slow machines.</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
               </object>


Modified: src/editor.c
19 lines changed, 9 insertions(+), 10 deletions(-)
===================================================================
@@ -404,11 +404,8 @@ static gint editor_get_long_line_column(void)
 }
 
 
-static gboolean editor_get_line_wrapping(void)
-{
-	return app->project ? app->project->priv->line_wrapping : editor_prefs.line_wrapping;
-}
-
+#define get_project_pref(id)\
+	(app->project ? app->project->priv->id : editor_prefs.id)
 
 static const GeanyEditorPrefs *
 get_default_prefs(void)
@@ -421,7 +418,9 @@ get_default_prefs(void)
 	eprefs.indentation = (GeanyIndentPrefs*)editor_get_indent_prefs(NULL);
 	eprefs.long_line_type = editor_get_long_line_type();
 	eprefs.long_line_column = editor_get_long_line_column();
-	eprefs.line_wrapping = editor_get_line_wrapping();
+	eprefs.line_wrapping = get_project_pref(line_wrapping);
+	eprefs.line_break_column = get_project_pref(line_break_column);
+	eprefs.auto_continue_multiline = get_project_pref(auto_continue_multiline);
 	return &eprefs;
 }
 
@@ -560,11 +559,11 @@ static void check_line_breaking(GeanyEditor *editor, gint pos)
 	lstart = sci_get_position_from_line(sci, line);
 
 	/* use column instead of position which might be different with multibyte characters */
-	if (col < editor_prefs.line_break_column)
+	if (col < get_project_pref(line_break_column))
 		return;
 
 	/* look for the last space before line_break_column */
-	pos = MIN(pos, lstart + editor_prefs.line_break_column);
+	pos = MIN(pos, lstart + get_project_pref(line_break_column));
 
 	while (pos > lstart)
 	{
@@ -1241,7 +1240,7 @@ static void on_new_line_added(GeanyEditor *editor)
 		insert_indent_after_line(editor, line - 1);
 	}
 
-	if (editor_prefs.auto_continue_multiline)
+	if (get_project_pref(auto_continue_multiline))
 	{	/* " * " auto completion in multiline C/C++/D/Java comments */
 		auto_multiline(editor, line);
 	}
@@ -4850,7 +4849,7 @@ GeanyEditor *editor_create(GeanyDocument *doc)
 	doc->editor = editor;	/* needed in case some editor functions/callbacks expect it */
 
 	editor->auto_indent = (iprefs->auto_indent_mode != GEANY_AUTOINDENT_NONE);
-	editor->line_wrapping = editor_get_line_wrapping();
+	editor->line_wrapping = get_project_pref(line_wrapping);
 	editor->scroll_percent = -1.0F;
 	editor->line_breaking = FALSE;
 


Modified: src/editor.h
7 lines changed, 2 insertions(+), 5 deletions(-)
===================================================================
@@ -112,17 +112,15 @@ GeanyIndentPrefs;
 
 /** Default prefs when creating a new editor window.
  * Some of these can be overridden per document or per project. */
-/* See editor_get_prefs(). */
+/* @warning Use @c editor_get_prefs() instead to include project overrides. */
 typedef struct GeanyEditorPrefs
 {
 	GeanyIndentPrefs *indentation;	/* Default indentation prefs. Use editor_get_indent_prefs(). */
 	gboolean	show_white_space;
 	gboolean	show_indent_guide;
 	gboolean	show_line_endings;
-	/* 0 - line, 1 - background, 2 - disabled.
-	 * This setting may be overridden when a project is opened. Use @c editor_get_prefs(). */
+	/* 0 - line, 1 - background, 2 - disabled. */
 	gint		long_line_type;
-	/* This setting may be overridden when a project is opened. Use @c editor_get_prefs(). */
 	gint		long_line_column;
 	gchar		*long_line_color;
 	gboolean	show_markers_margin;		/* view menu */
@@ -154,7 +152,6 @@ typedef struct GeanyEditorPrefs
 	gboolean	completion_drops_rest_of_word;
 	gchar		*color_scheme;
 	gint 		show_virtual_space;
-	/* This setting may be overridden when a project is opened. Use @c editor_get_prefs(). */
 	gboolean	long_line_enabled;
 	gint		autocompletion_update_freq;
 }


Modified: src/project.c
23 lines changed, 14 insertions(+), 9 deletions(-)
===================================================================
@@ -515,7 +515,7 @@ static void insert_build_page(PropertyDialogElements *e)
 
 static void create_properties_dialog(PropertyDialogElements *e)
 {
-	GtkWidget *base_path_button;
+	GtkWidget *wid;
 	static guint base_path_button_handler_id = 0;
 	static guint radio_long_line_handler_id = 0;
 
@@ -536,21 +536,21 @@ static void create_properties_dialog(PropertyDialogElements *e)
 	/* Workaround for bug in Glade 3.8.1, see comment above signal handler */
 	if (base_path_button_handler_id == 0)
 	{
-		base_path_button = ui_lookup_widget(e->dialog, "button_project_dialog_base_path");
+		wid = ui_lookup_widget(e->dialog, "button_project_dialog_base_path");
 		base_path_button_handler_id =
-			g_signal_connect(base_path_button, "clicked",
-			G_CALLBACK(on_project_properties_base_path_button_clicked),
-			e->base_path);
+			g_signal_connect(wid, "clicked",
+				G_CALLBACK(on_project_properties_base_path_button_clicked),
+				e->base_path);
 	}
 
 	/* Same as above, should be in Glade but can't due to bug in 3.8.1 */
 	if (radio_long_line_handler_id == 0)
 	{
+		wid = ui_lookup_widget(e->dialog, "radio_long_line_custom_project");
 		radio_long_line_handler_id =
-			g_signal_connect(ui_lookup_widget(e->dialog,
-			"radio_long_line_custom_project"), "toggled",
-			G_CALLBACK(on_radio_long_line_custom_toggled),
-			ui_lookup_widget(e->dialog, "spin_long_line_project"));
+			g_signal_connect(wid, "toggled",
+				G_CALLBACK(on_radio_long_line_custom_toggled),
+				ui_lookup_widget(e->dialog, "spin_long_line_project"));
 	}
 }
 
@@ -1302,6 +1302,11 @@ static void init_stash_prefs(void)
 	group = stash_group_new("editor");
 	stash_group_add_toggle_button(group, &priv.line_wrapping,
 		"line_wrapping", editor_prefs.line_wrapping, "check_line_wrapping1");
+	stash_group_add_spin_button_integer(group, &priv.line_break_column,
+		"line_break_column", editor_prefs.line_break_column, "spin_line_break1");
+	stash_group_add_toggle_button(group, &priv.auto_continue_multiline,
+		"auto_continue_multiline", editor_prefs.auto_continue_multiline,
+		"check_auto_multiline1");
 	add_stash_group(group, TRUE);
 }
 


Modified: src/projectprivate.h
14 lines changed, 10 insertions(+), 4 deletions(-)
===================================================================
@@ -31,15 +31,21 @@ G_BEGIN_DECLS
 
 typedef struct GeanyProjectPrivate
 {
-	struct GeanyIndentPrefs *indentation;
+	// file prefs
 	gboolean	final_new_line;
 	gboolean	strip_trailing_spaces;
 	gboolean	replace_tabs;
 	gboolean	ensure_convert_new_lines;
+
+	// editor prefs
+	struct GeanyIndentPrefs *indentation;
+	gboolean	line_wrapping;
+	gint		line_break_column;
+	gboolean	auto_continue_multiline;
+	gint		long_line_behaviour; /* 0 - disabled, 1 - follow global settings, 2 - enabled (custom) */
+	gint		long_line_column; /* Long line marker position. */
+
 	GPtrArray *build_filetypes_list; /* Project has custom filetype builds for these. */
-	gint long_line_behaviour; /* 0 - disabled, 1 - follow global settings, 2 - enabled (custom) */
-	gint long_line_column; /* Long line marker position. */
-	gboolean line_wrapping;
 }
 GeanyProjectPrivate;
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list