SF.net SVN: geany:[5039] branches/sm/src
statc at users.sourceforge.net
statc at xxxxx
Thu Jun 17 14:54:23 UTC 2010
Revision: 5039
http://geany.svn.sourceforge.net/geany/?rev=5039&view=rev
Author: statc
Date: 2010-06-17 14:54:23 +0000 (Thu, 17 Jun 2010)
Log Message:
-----------
SM: do not rely on Geany session management and always specify required file names in restore command
Modified Paths:
--------------
branches/sm/src/main.c
branches/sm/src/main.h
branches/sm/src/sm.c
branches/sm/src/socket.c
Modified: branches/sm/src/main.c
===================================================================
--- branches/sm/src/main.c 2010-06-17 14:53:59 UTC (rev 5038)
+++ branches/sm/src/main.c 2010-06-17 14:54:23 UTC (rev 5039)
@@ -888,7 +888,7 @@
}
-void main_load_project_from_command_line(const gchar *locale_filename)
+void main_load_project_from_command_line(const gchar *locale_filename, gboolean use_session)
{
gchar *pfile = NULL;
@@ -898,13 +898,18 @@
pfile = g_strdup(locale_filename);
if (pfile != NULL)
- project_load_file_with_session(pfile);
+ {
+ if (use_session)
+ project_load_file_with_session(pfile);
+ else
+ project_load_file(pfile);
+ }
g_free(pfile);
}
-static void load_startup_files(gint argc, gchar **argv)
+static void load_startup_files(gint argc, gchar **argv, gboolean restoring)
{
gboolean load_default_session = TRUE;
@@ -915,7 +920,9 @@
if (cl_options.project)
{
- main_load_project_from_command_line(cl_options.project);
+ /* when being restored by session manager, do not open file names from project session file,
+ * because required file names are passed via command-line and handled by open_cl_files() */
+ main_load_project_from_command_line(cl_options.project, !restoring);
load_default_session = FALSE;
}
@@ -924,7 +931,8 @@
/* load filenames from the default session into global session_files variable */
load_session_project_file();
/* load files into tabs, as they are found in the session_files variable */
- configuration_open_files();
+ if (!restoring)
+ configuration_open_files();
}
open_cl_files(argc, argv);
@@ -1101,7 +1109,7 @@
/* load any command line files or session files */
main_status.opening_session_files = TRUE;
- load_startup_files(argc, argv);
+ load_startup_files(argc, argv, libsm_client_id != NULL);
main_status.opening_session_files = FALSE;
/* open a new file if no other file was opened */
Modified: branches/sm/src/main.h
===================================================================
--- branches/sm/src/main.h 2010-06-17 14:53:59 UTC (rev 5038)
+++ branches/sm/src/main.h 2010-06-17 14:54:23 UTC (rev 5039)
@@ -84,6 +84,6 @@
gboolean main_is_realized(void);
-void main_load_project_from_command_line(const gchar *locale_filename);
+void main_load_project_from_command_line(const gchar *locale_filename, gboolean use_session);
#endif
Modified: branches/sm/src/sm.c
===================================================================
--- branches/sm/src/sm.c 2010-06-17 14:53:59 UTC (rev 5038)
+++ branches/sm/src/sm.c 2010-06-17 14:54:23 UTC (rev 5039)
@@ -469,48 +469,42 @@
*/
static void sm_files_props(GArray * arr)
{
- gboolean store_project = TRUE, store_files = TRUE;
SmPropValue val;
- gint i;
+ gint i, page_count;
- if (cl_options.load_session)
- /* Files will be restored by Geany session management facilities. */
- store_project = store_files = FALSE;
+ /* Unfortunately, we can't rely entirely on Geany session management facilities and have to pass
+ * active project and opened files even if they are probably, for example, stored in geany.conf */
- if (store_project && app->project)
+ /* Specify active project */
+
+ if (app->project)
{
gchar * locale_filename = utils_get_locale_from_utf8(app->project->file_name);
val.value = g_strconcat("--project=", locale_filename, NULL);
val.length = strlen(val.value);
g_free(locale_filename);
g_array_append_val(arr, val);
-
- if (project_prefs.project_session)
- /* Files will be restored when the project is reopened. */
- store_files = FALSE;
}
- if (store_files)
- {
- /* Specify file names in the command line */
- const gint page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
+ /* Specify opened files */
- val.length = 2;
- val.value = g_strdup("--");
- g_array_append_val(arr, val);
+ val.length = 2;
+ val.value = g_strdup("--");
+ g_array_append_val(arr, val);
- /* NOTE: compare this cycle with the one inside
- * configuration_save_session_files() function in keyfile.c. */
- for (i = 0; i < page_count; i++)
+ page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
+
+ /* NOTE: compare this cycle with the one inside
+ * configuration_save_session_files() function in keyfile.c. */
+ for (i = 0; i < page_count; i++)
+ {
+ GeanyDocument * doc = document_get_from_page(i);
+ if (doc && doc->real_path)
{
- GeanyDocument * doc = document_get_from_page(i);
- if (doc && doc->real_path)
- {
- gchar * locale_filename = utils_get_locale_from_utf8(doc->file_name);
- val.value = locale_filename;
- val.length = strlen(val.value);
- g_array_append_val(arr, val);
- }
+ gchar * locale_filename = utils_get_locale_from_utf8(doc->file_name);
+ val.value = locale_filename;
+ val.length = strlen(val.value);
+ g_array_append_val(arr, val);
}
}
}
Modified: branches/sm/src/socket.c
===================================================================
--- branches/sm/src/socket.c 2010-06-17 14:53:59 UTC (rev 5038)
+++ branches/sm/src/socket.c 2010-06-17 14:54:23 UTC (rev 5039)
@@ -573,7 +573,7 @@
if (project)
{
if (project_ask_close())
- main_load_project_from_command_line(locale_filename);
+ main_load_project_from_command_line(locale_filename, TRUE);
}
else
main_handle_filename(locale_filename);
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