[geany/geany] 85006b: Add 'Document->Clone' menu command
Nick Treleaven
git-noreply at geany.org
Fri Nov 23 15:37:00 UTC 2012
Branch: refs/heads/master
Author: Nick Treleaven <nick.treleaven at btinternet.com>
Committer: Nick Treleaven <nick.treleaven at btinternet.com>
Date: Fri, 23 Nov 2012 15:37:00 UTC
Commit: 85006b6d0b5c2d2aee48d700f646fecc48ed1034
https://github.com/geany/geany/commit/85006b6d0b5c2d2aee48d700f646fecc48ed1034
Log Message:
-----------
Add 'Document->Clone' menu command
This copies the current document text and properties into a new
document, similar to the old Save As 'Open file in a new tab'
option, but easier to understand and decoupled from saving.
One notable difference is that the new document does not copy the
filename - the old behaviour was confusing and error-prone for the
user (e.g. editing two documents with the same filename).
Modified Paths:
--------------
data/geany.glade
src/document.c
src/document.h
Modified: data/geany.glade
10 files changed, 10 insertions(+), 0 deletions(-)
===================================================================
@@ -8865,6 +8865,16 @@
</object>
</child>
<child>
+ <object class="GtkMenuItem" id="clone1">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Clone</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_clone1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuItem" id="strip_trailing_spaces1">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
Modified: src/document.c
11 files changed, 6 insertions(+), 5 deletions(-)
===================================================================
@@ -2737,19 +2737,20 @@ GeanyDocument *document_index(gint idx)
/* create a new file and copy file content and properties */
-GeanyDocument *document_clone(GeanyDocument *old_doc, const gchar *utf8_filename)
+G_MODULE_EXPORT void on_clone1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
gint len;
gchar *text;
GeanyDocument *doc;
+ GeanyDocument *old_doc = document_get_current();
- g_return_val_if_fail(old_doc != NULL, NULL);
+ if (!old_doc)
+ return;
len = sci_get_length(old_doc->editor->sci) + 1;
text = (gchar*) g_malloc(len);
sci_get_text(old_doc->editor->sci, len, text);
- /* use old file type (or maybe NULL for auto detect would be better?) */
- doc = document_new_file(utf8_filename, old_doc->file_type, text);
+ doc = document_new_file(NULL, old_doc->file_type, text);
g_free(text);
/* copy file properties */
@@ -2760,8 +2761,8 @@ GeanyDocument *document_clone(GeanyDocument *old_doc, const gchar *utf8_filename
sci_set_lines_wrapped(doc->editor->sci, doc->editor->line_wrapping);
sci_set_readonly(doc->editor->sci, doc->readonly);
+ /* update ui */
ui_document_show_hide(doc);
- return doc;
}
Modified: src/document.h
2 files changed, 0 insertions(+), 2 deletions(-)
===================================================================
@@ -210,8 +210,6 @@ GeanyDocument* document_open_file(const gchar *locale_filename, gboolean readonl
gboolean document_close_all(void);
-GeanyDocument *document_clone(GeanyDocument *old_doc, const gchar *utf8_filename);
-
GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename, gint pos,
gboolean readonly, GeanyFiletype *ft, const gchar *forced_enc);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Commits
mailing list