Kaydet (Commit) 59690a16 authored tarafından Nick Treleaven's avatar Nick Treleaven

Avoid delay and redrawing when automatically opening a new document

after closing one.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5265 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 95c4f604
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
Move GeanyFiletypePrivate to filetypesprivate.h. Move GeanyFiletypePrivate to filetypesprivate.h.
* src/Makefile.am, src/ui_utils.c, configure.ac, wscript: * src/Makefile.am, src/ui_utils.c, configure.ac, wscript:
Link with X11 if found to fix linking with a recent GNU ld. 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> 2010-09-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
......
...@@ -541,6 +541,8 @@ static gboolean on_idle_focus(gpointer doc) ...@@ -541,6 +541,8 @@ static gboolean on_idle_focus(gpointer doc)
} }
static gboolean remove_page(guint page_num);
/* Creates a new document and editor, adding a tab in the notebook. /* Creates a new document and editor, adding a tab in the notebook.
* @return The created document */ * @return The created document */
static GeanyDocument *document_create(const gchar *utf8_filename) static GeanyDocument *document_create(const gchar *utf8_filename)
...@@ -552,9 +554,11 @@ static GeanyDocument *document_create(const gchar *utf8_filename) ...@@ -552,9 +554,11 @@ static GeanyDocument *document_create(const gchar *utf8_filename)
if (cur_pages == 1) if (cur_pages == 1)
{ {
GeanyDocument *cur = document_get_current(); 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) 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(); new_idx = document_get_new_idx();
...@@ -609,24 +613,8 @@ gboolean document_close(GeanyDocument *doc) ...@@ -609,24 +613,8 @@ gboolean document_close(GeanyDocument *doc)
} }
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); GeanyDocument *doc = document_get_from_page(page_num);
...@@ -686,16 +674,30 @@ gboolean document_remove_page(guint page_num) ...@@ -686,16 +674,30 @@ gboolean document_remove_page(guint page_num)
ui_update_popup_reundo_items(NULL); ui_update_popup_reundo_items(NULL);
ui_document_buttons_update(); ui_document_buttons_update();
build_menu_update(NULL); 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; 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 */ /* used to keep a record of the unchanged document state encoding */
static void store_saved_encoding(GeanyDocument *doc) static void store_saved_encoding(GeanyDocument *doc)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment