SF.net SVN: geany:[5265] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Thu Sep 30 14:49:55 UTC 2010
Revision: 5265
http://geany.svn.sourceforge.net/geany/?rev=5265&view=rev
Author: ntrel
Date: 2010-09-30 14:49:54 +0000 (Thu, 30 Sep 2010)
Log Message:
-----------
Avoid delay and redrawing when automatically opening a new document
after closing one.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-30 14:14:54 UTC (rev 5264)
+++ trunk/ChangeLog 2010-09-30 14:49:54 UTC (rev 5265)
@@ -11,6 +11,9 @@
Move GeanyFiletypePrivate to filetypesprivate.h.
* src/Makefile.am, src/ui_utils.c, configure.ac, wscript:
Link with X11 if found to fix linking with a recent GNU ld.
+ * src/document.c:
+ Avoid delay and redrawing when automatically opening a new document
+ after closing one.
2010-09-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2010-09-30 14:14:54 UTC (rev 5264)
+++ trunk/src/document.c 2010-09-30 14:49:54 UTC (rev 5265)
@@ -541,6 +541,8 @@
}
+static gboolean remove_page(guint page_num);
+
/* Creates a new document and editor, adding a tab in the notebook.
* @return The created document */
static GeanyDocument *document_create(const gchar *utf8_filename)
@@ -552,9 +554,11 @@
if (cur_pages == 1)
{
GeanyDocument *cur = document_get_current();
- /* remove the empty document and open a new one */
+ /* remove the empty document first */
if (cur != NULL && cur->file_name == NULL && ! cur->changed)
- document_remove_page(0);
+ /* prevent immediately opening another new doc with
+ * new_document_after_close pref */
+ remove_page(0);
}
new_idx = document_get_new_idx();
@@ -609,25 +613,9 @@
}
-static gboolean on_idle_new_doc(gpointer user_data)
+/* Call document_remove_page() instead, this is only needed for document_create(). */
+static gboolean remove_page(guint page_num)
{
- /* Idle may be after Geany has quit */
- if (!main_status.quitting)
- document_new_file_if_non_open();
- return FALSE;
-}
-
-
-/**
- * Removes the given notebook tab at @a page_num and clears all related information
- * in the document list.
- *
- * @param page_num The notebook page number to remove.
- *
- * @return @c TRUE if the document was actually removed or @c FALSE otherwise.
- **/
-gboolean document_remove_page(guint page_num)
-{
GeanyDocument *doc = document_get_from_page(page_num);
if (G_UNLIKELY(doc == NULL))
@@ -686,16 +674,30 @@
ui_update_popup_reundo_items(NULL);
ui_document_buttons_update();
build_menu_update(NULL);
-
- /* we use an idle callback to prevent opening a new document if other documents
- * are about to be opened. */
- if (ui_prefs.new_document_after_close)
- g_idle_add(on_idle_new_doc, NULL);
}
return TRUE;
}
+/**
+ * Removes the given notebook tab at @a page_num and clears all related information
+ * in the document list.
+ *
+ * @param page_num The notebook page number to remove.
+ *
+ * @return @c TRUE if the document was actually removed or @c FALSE otherwise.
+ **/
+gboolean document_remove_page(guint page_num)
+{
+ gboolean done = remove_page(page_num);
+
+ if (done && ui_prefs.new_document_after_close)
+ document_new_file_if_non_open();
+
+ return done;
+}
+
+
/* used to keep a record of the unchanged document state encoding */
static void store_saved_encoding(GeanyDocument *doc)
{
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