First, let me introduce myself.
I am André, 22, from Germany and got 8 years programming experience. I am coding for Wine since january and used Geany all the time for that.
Now that Geany is a great tool i also want to help to improve it.
While my work with Geany i found some behaviors, which i would like to be different. So i am willing to fix it.
Thats what my patch is about:
When i changed a file in Geany and made e.g. a git checkout or an other change with the file on disk, Geany asks me to reload(thats great so far).
After i choose "no", as i want to keep my changes i made in Geany, i am not able to save the file immediatly after that.
The save-button is grayed and i first have to do a little change in the file before i can save again.
This patch fixes this by adding a preference for it. I already had some talk about the feature on IRC with Enrico already.
As this is my first Geany-patch, i guess i made some mistakes against your guidlines, but i hope to get some feedback.
PS: the last change in that diff removes a trailing space, as git doesnt like those.
---
geany.glade | 23 +++++++++++++++++++++++
src/document.c | 3 ++-
src/document.h | 1 +
src/interface.c | 7 +++++++
src/prefs.c | 5 ++++-
5 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/geany.glade b/geany.glade
index 0f142b4..add475b 100644
--- a/geany.glade
+++ b/geany.glade
@@ -7407,6 +7407,29 @@ Match braces</property>
<property name="fill">False</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkCheckButton" id="check_reenable_save">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">When the file changes on disk and you choose not to reload it, this allows you to save it anyway</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Reenable Save after changes on Disk</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>
+ <accessibility>
+ <atkproperty name="AtkObject::accessible_description" translatable="yes">When the file changes on disk and you choose not to reload it, this allows you to save it anyway</atkproperty>
+ </accessibility>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/document.c b/src/document.c
index bf40a85..06b5e7d 100644
--- a/src/document.c
+++ b/src/document.c
@@ -2948,7 +2948,8 @@ gboolean document_check_disk_status(GeanyDocument *doc, gboolean force)
}
else if (doc->priv->mtime < st.st_mtime)
{
- monitor_reload_file(doc);
+ if(!monitor_reload_file(doc) && file_prefs.reenable_save)
+ document_set_text_changed(doc, TRUE);
doc->priv->mtime = st.st_mtime;
ret = TRUE;
}
diff --git a/src/document.h b/src/document.h
index c121a54..e8c3cb4 100644
--- a/src/document.h
+++ b/src/document.h
@@ -57,6 +57,7 @@ typedef struct GeanyFilePrefs
gint disk_check_timeout;
gboolean cmdline_new_files; /* New file if command-line filename doesn't exist */
gboolean use_safe_file_saving;
+ gboolean reenable_save;
}
GeanyFilePrefs;
diff --git a/src/interface.c b/src/interface.c
index 80d1b11..9e1e80e 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -2552,6 +2552,7 @@ create_prefs_dialog (void)
GtkWidget *check_new_line;
GtkWidget *check_trailing_spaces;
GtkWidget *check_replace_tabs;
+ GtkWidget *check_reenable_save;
GtkWidget *label19;
GtkWidget *frame17;
GtkWidget *alignment20;
@@ -4059,6 +4060,11 @@ create_prefs_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox6), check_replace_tabs, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_replace_tabs, _("Replaces all tabs in document by spaces"), NULL);
+ check_reenable_save = gtk_check_button_new_with_mnemonic (_("Reenable Save after changes on disk"));
+ gtk_widget_show (check_reenable_save);
+ gtk_box_pack_start (GTK_BOX (vbox6), check_reenable_save, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip (tooltips, check_reenable_save, _("When the file changes on disk and you choose not to reload it, this allows you to save it anyway"), NULL);
+
label19 = gtk_label_new (_("<b>Saving files</b>"));
gtk_widget_show (label19);
gtk_frame_set_label_widget (GTK_FRAME (frame2), label19);
@@ -4867,6 +4873,7 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, check_new_line, "check_new_line");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_trailing_spaces, "check_trailing_spaces");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_replace_tabs, "check_replace_tabs");
+ GLADE_HOOKUP_OBJECT (prefs_dialog, check_reenable_save, "check_reenable_save");
GLADE_HOOKUP_OBJECT (prefs_dialog, label19, "label19");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame17, "frame17");
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment20, "alignment20");
diff --git a/src/prefs.c b/src/prefs.c
index 4fe4f78..ded223b 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -497,6 +497,9 @@ static void prefs_init_dialog(void)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_new_line");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.final_new_line);
+ widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_reenable_save");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.reenable_save);
+
/* Editor settings */
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_toggle_mark");
gtk_entry_set_text(GTK_ENTRY(widget), editor_prefs.comment_toggle_mark);
@@ -1581,7 +1584,7 @@ void prefs_show_dialog(void)
"font-set", G_CALLBACK(on_prefs_font_choosed), GINT_TO_POINTER(3));
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "long_line_color"),
"color-set", G_CALLBACK(on_prefs_color_choosed), GINT_TO_POINTER(1));
- /* file chooser buttons in the tools tab
+ /* file chooser buttons in the tools tab
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "button_make"),
"clicked", G_CALLBACK(on_prefs_tools_button_clicked), ui_lookup_widget(ui_widgets.prefs_dialog, "entry_com_make")); */
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "button_term"),
--
Best Regards, André Hentschel