SF.net SVN: geany:[4693] branches/sm
statc at users.sourceforge.net
statc at xxxxx
Mon Feb 22 22:11:54 UTC 2010
Revision: 4693
http://geany.svn.sourceforge.net/geany/?rev=4693&view=rev
Author: statc
Date: 2010-02-22 22:11:54 +0000 (Mon, 22 Feb 2010)
Log Message:
-----------
Remember opened project across restarts.
Modified Paths:
--------------
branches/sm/ChangeLog
branches/sm/src/sm.c
Modified: branches/sm/ChangeLog
===================================================================
--- branches/sm/ChangeLog 2010-02-22 22:11:21 UTC (rev 4692)
+++ branches/sm/ChangeLog 2010-02-22 22:11:54 UTC (rev 4693)
@@ -2,6 +2,8 @@
* src/main.c, src/main.h, src/socket.c:
Use a separate command-line option to specify a project to be opened.
+ * src/sm.c:
+ Remember opened project across restarts.
2010-02-15 Eugene Arshinov <earshinov(at)gmail(dot)com>
Modified: branches/sm/src/sm.c
===================================================================
--- branches/sm/src/sm.c 2010-02-22 22:11:21 UTC (rev 4692)
+++ branches/sm/src/sm.c 2010-02-22 22:11:54 UTC (rev 4693)
@@ -60,6 +60,7 @@
#include "ui_utils.h" /* access main_widgets.notebook to iterate over opened docs */
#include "document.h"
#include "utils.h"
+#include "project.h"
static void ice_connection_watch(IceConn icecon, IcePointer client_data, Bool opening,
@@ -387,19 +388,16 @@
static void sm_set_runtime_props(SmcConn smcon)
{
GArray * arr = g_array_new(FALSE, FALSE, sizeof(SmPropValue));
- gint arr_filenames_begin = -1;
-
GOptionEntry * optentry;
SmPropValue val;
SmProp * prop;
SmProp restart_command_prop, clone_command_prop;
gint i;
-
g_array_append_val(arr, sm_program_val);
- /* "libsm-client-id" option requires special handling */
g_array_append_val(arr, sm_client_id_arg_val);
- /* handle other command-line options */
+
+ /* Handle command-line options */
for (i = 0, optentry = optentries; optentry->long_name; i++, optentry++)
{
if (optentries_aux[i].persist_upon_restart)
@@ -408,8 +406,8 @@
gchar ** ss = (gchar **)arr2->data;
for (; *ss; ss++)
{
- val.length = strlen(*ss);
val.value = *ss;
+ val.length = strlen(val.value);
g_array_append_val(arr, val);
}
/* elements are freed after `arr' is used */
@@ -417,44 +415,44 @@
}
}
-
+ /* Handle opened files */
if (cl_options.load_session)
{
- /*
- * Files will be restored by Geany session management facilities.
- * NOTE: the condition matches the one inside configuration_save() function in keyfile.c.
- */
+ /* Files will be restored by Geany session management facilities. */
}
+ else if (app->project)
+ {
+ /* Files will be restored when the project is reopened. */
+ 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);
+ }
else
{
/* Specify file names in the command line */
const gint page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
val.length = 2;
- val.value = "--";
+ val.value = g_strdup("--");
g_array_append_val(arr, val);
- arr_filenames_begin = arr->len;
- /*
- * NOTE: compare this cycle with the one inside
- * configuration_save_session_files() function in keyfile.c.
- */
+ /* 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)
{
- /* freed after `arr' is used */
gchar * locale_filename = utils_get_locale_from_utf8(doc->file_name);
-
- val.length = strlen(locale_filename);
val.value = locale_filename;
+ val.length = strlen(val.value);
g_array_append_val(arr, val);
}
}
}
-
restart_command_prop.name = SmRestartCommand;
restart_command_prop.type = SmLISTofARRAY8;
restart_command_prop.num_vals = arr->len;
@@ -462,10 +460,8 @@
prop = &restart_command_prop;
SmcSetProperties(smcon, 1, &prop);
- /*
- * We should not specify client ID in SmCloneCommand,
- * so "remove" the corresponding element from `arr'.
- */
+ /* We should not specify client ID in SmCloneCommand,
+ * so "remove" the corresponding element from `arr'. */
((SmPropValue *)arr->data)[1] = sm_program_val;
clone_command_prop.name = SmCloneCommand;
clone_command_prop.type = SmLISTofARRAY8;
@@ -474,11 +470,8 @@
prop = &clone_command_prop;
SmcSetProperties(smcon, 1, &prop);
-
- /* free allocated strings storing command-line options and file names */
for (i = 2; i < (gint)arr->len; i++)
- if (i != (arr_filenames_begin - 1))
- g_free(((SmPropValue *)arr->data)[i].value);
+ g_free(((SmPropValue *)arr->data)[i].value);
g_array_free(arr, TRUE);
}
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