Revision: 5041 http://geany.svn.sourceforge.net/geany/?rev=5041&view=rev Author: statc Date: 2010-06-17 14:55:15 +0000 (Thu, 17 Jun 2010)
Log Message: ----------- Update for r4974: add some checks to prevent unnecessary writes to geany.conf; do not touch recent lists while being restored by session manager
Modified Paths: -------------- branches/sm/src/keyfile.c branches/sm/src/main.c branches/sm/src/main.h branches/sm/src/ui_utils.c
Modified: branches/sm/src/keyfile.c =================================================================== --- branches/sm/src/keyfile.c 2010-06-17 14:54:46 UTC (rev 5040) +++ branches/sm/src/keyfile.c 2010-06-17 14:55:15 UTC (rev 5041) @@ -575,6 +575,16 @@ { GKeyFile *config; gchar *configfile; + gboolean write_recent_files, write_recent_projects, write_other; + + write_recent_files = ((flags & GEANY_SETTINGS_RECENT_FILES) && + ui_prefs.recent_queue->length > 0); + write_recent_projects = ((flags & GEANY_SETTINGS_RECENT_PROJECTS) && + ui_prefs.recent_projects_queue->length > 0); + write_other = (flags & ~(GEANY_SETTINGS_RECENT_FILES | GEANY_SETTINGS_RECENT_PROJECTS)); + if (!write_recent_files && !write_recent_projects && !write_other) + return; /* nothing to do */ + open_config(&config, &configfile);
/* this signal can be used e.g. to prepare any settings before Stash code reads them below */ @@ -592,13 +602,13 @@ configuration_save_session_files(config); }
- if (flags & GEANY_SETTINGS_RECENT_FILES) + if (write_recent_files) { load_recent_files(config, ui_prefs.recent_queue, "recent_files"); save_recent_files(config, ui_prefs.recent_queue, "recent_files"); }
- if (flags & GEANY_SETTINGS_RECENT_PROJECTS) + if (write_recent_projects) { load_recent_files(config, ui_prefs.recent_projects_queue, "recent_projects"); save_recent_files(config, ui_prefs.recent_projects_queue, "recent_projects");
Modified: branches/sm/src/main.c =================================================================== --- branches/sm/src/main.c 2010-06-17 14:54:46 UTC (rev 5040) +++ branches/sm/src/main.c 2010-06-17 14:55:15 UTC (rev 5041) @@ -279,6 +279,7 @@ ui_prefs.recent_projects_queue = g_queue_new(); ui_prefs.closed_queue = g_queue_new(); main_status.opening_session_files = FALSE; + main_status.restoring = FALSE;
ui_init_stock_items();
@@ -909,7 +910,7 @@ }
-static void load_startup_files(gint argc, gchar **argv, gboolean restoring) +static void load_startup_files(gint argc, gchar **argv) { gboolean load_default_session = TRUE;
@@ -922,7 +923,7 @@ { /* Do not load project session files if we are being restored by session manager: * corresponding file names are passed via command-line and will be handled by open_cl_files() */ - main_load_project_from_command_line(cl_options.project, !restoring); + main_load_project_from_command_line(cl_options.project, !main_status.restoring); load_default_session = FALSE; }
@@ -931,9 +932,9 @@ /* Load project session file (if any) writing its filenames into global session_files variable. * Don't load filenames when being restored by session manager: in that case file names are * passed via command line and will be opened by open_cl_files() */ - load_session_project_file(!restoring); + load_session_project_file(!main_status.restoring); /* load files into tabs, as they are found in the session_files variable */ - if (!restoring) + if (!main_status.restoring) configuration_open_files(); }
@@ -1111,8 +1112,11 @@
/* load any command line files or session files */ main_status.opening_session_files = TRUE; - load_startup_files(argc, argv, libsm_client_id != NULL); + if (libsm_client_id != NULL) + main_status.restoring = TRUE; + load_startup_files(argc, argv); main_status.opening_session_files = FALSE; + main_status.restoring = FALSE;
/* open a new file if no other file was opened */ document_new_file_if_non_open();
Modified: branches/sm/src/main.h =================================================================== --- branches/sm/src/main.h 2010-06-17 14:54:46 UTC (rev 5040) +++ branches/sm/src/main.h 2010-06-17 14:55:15 UTC (rev 5041) @@ -62,6 +62,7 @@ * (used to prevent notebook switch page signals) */ gboolean quitting; /* state when Geany is quitting completely */ gboolean main_window_realized; + gboolean restoring; /* being restored by session manager */ } GeanyStatus;
Modified: branches/sm/src/ui_utils.c =================================================================== --- branches/sm/src/ui_utils.c 2010-06-17 14:54:46 UTC (rev 5040) +++ branches/sm/src/ui_utils.c 2010-06-17 14:55:15 UTC (rev 5041) @@ -52,6 +52,7 @@ #include "toolbar.h" #include "geanymenubuttonaction.h" #include "keyfile.h" +#include "main.h"
GeanyInterfacePrefs interface_prefs; GeanyMainWidgets main_widgets; @@ -1078,11 +1079,15 @@ } } #endif - g_queue_push_head(grf->recent_queue, g_strdup(utf8_filename)); - if (g_queue_get_length(grf->recent_queue) > file_prefs.mru_length) + + /* do not touch recent lists while being restored by session manager */ + if (!main_status.restoring) { - g_free(g_queue_pop_tail(grf->recent_queue)); + g_queue_push_head(grf->recent_queue, g_strdup(utf8_filename)); + if (g_queue_get_length(grf->recent_queue) > file_prefs.mru_length) + g_free(g_queue_pop_tail(grf->recent_queue)); } + update_recent_menu(grf); } /* filename already in recent list */ @@ -1093,6 +1098,10 @@
void ui_add_recent_file(const gchar *utf8_filename, gboolean update_config) { + /* do not touch recent lists while being restored by session manager */ + if (main_status.restoring) + return; + add_recent_file(utf8_filename, recent_get_recent_files()); if (update_config) configuration_save(GEANY_SETTINGS_RECENT_FILES); @@ -1101,6 +1110,10 @@
void ui_add_recent_project_file(const gchar *utf8_filename) { + /* do not touch recent lists while being restored by session manager */ + if (main_status.restoring) + return; + add_recent_file(utf8_filename, recent_get_recent_projects()); configuration_save(GEANY_SETTINGS_RECENT_PROJECTS); } @@ -1137,16 +1150,20 @@ void *data; GtkWidget *tmp;
- /* first reorder the queue */ - item = g_queue_find_custom(grf->recent_queue, utf8_filename, (GCompareFunc) strcmp); - if (item != NULL) + /* first reorder the queue. + * if we are being restored by session manager, we shouldn't touch it */ + if (!main_status.restoring) { - data = item->data; - g_queue_remove(grf->recent_queue, data); + item = g_queue_find_custom(grf->recent_queue, utf8_filename, (GCompareFunc) strcmp); + if (item != NULL) + { + data = item->data; + g_queue_remove(grf->recent_queue, data); + } + else + data = g_strdup(utf8_filename); + g_queue_push_head(grf->recent_queue, data); } - else - data = g_strdup(utf8_filename); - g_queue_push_head(grf->recent_queue, data);
/* remove the old menuitem for the filename */ children = gtk_container_get_children(GTK_CONTAINER(grf->menubar));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.