SF.net SVN: geany: [787] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Sep 4 11:16:15 UTC 2006


Revision: 787
          http://svn.sourceforge.net/geany/?rev=787&view=rev
Author:   ntrel
Date:     2006-09-04 04:16:07 -0700 (Mon, 04 Sep 2006)

Log Message:
-----------
   Rename --no-socket, -s command-line option to --new-instance, -i.
   Add --no-session, -s command-line option to not load session files.
   Only save session when session files were loaded at startup.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/keyfile.c
    trunk/src/main.c
    trunk/src/main.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-09-03 22:25:24 UTC (rev 786)
+++ trunk/ChangeLog	2006-09-04 11:16:07 UTC (rev 787)
@@ -1,3 +1,11 @@
+2006-09-04  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/keyfile.c, src/main.c, src/main.h:
+   Rename --no-socket, -s command-line option to --new-instance, -i.
+   Add --no-session, -s command-line option to not load session files.
+   Only save session when session files were loaded at startup.
+
+
 2006-09-03  Nick Treleaven  <nick.treleaven at btinternet.com>
 
  * src/main.c: Open a new instance without loading session files if

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2006-09-03 22:25:24 UTC (rev 786)
+++ trunk/src/keyfile.c	2006-09-04 11:16:07 UTC (rev 787)
@@ -38,6 +38,7 @@
 #include "sciwrappers.h"
 #include "encodings.h"
 #include "vte.h"
+#include "main.h"
 
 
 static gchar *scribble_text = NULL;
@@ -201,26 +202,29 @@
 				(const gchar**)recent_files, app->mru_length);
 	g_strfreev(recent_files);
 
-	// store the last 15(or what ever GEANY_SESSION_FILES is set to) filenames, to reopen the next time
-	max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
-	for(i = 0; (i < max) && (j < GEANY_SESSION_FILES); i++)
+	if (cl_options.load_session)
 	{
-		idx = document_get_n_idx(i);
-		if (idx >= 0 && doc_list[idx].file_name)
+		// store the last 15(or what ever GEANY_SESSION_FILES is set to) filenames, to reopen the next time
+		max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
+		for(i = 0; (i < max) && (j < GEANY_SESSION_FILES); i++)
 		{
-			g_snprintf(entry, 13, "FILE_NAME_%d", j);
-			g_snprintf(fname, 255, "%d:%d:%s", sci_get_current_position(doc_list[idx].sci),
-				doc_list[idx].file_type->uid, doc_list[idx].file_name);
-			g_key_file_set_string(config, "files", entry, fname);
-			j++;
+			idx = document_get_n_idx(i);
+			if (idx >= 0 && doc_list[idx].file_name)
+			{
+				g_snprintf(entry, 13, "FILE_NAME_%d", j);
+				g_snprintf(fname, 255, "%d:%d:%s", sci_get_current_position(doc_list[idx].sci),
+					doc_list[idx].file_type->uid, doc_list[idx].file_name);
+				g_key_file_set_string(config, "files", entry, fname);
+				j++;
+			}
 		}
+		// if open filenames less than GEANY_SESSION_FILES, delete existing saved entries in the list
+		for(i = j; i < GEANY_SESSION_FILES; i++)
+		{
+			g_snprintf(entry, 13, "FILE_NAME_%d", i);
+			g_key_file_set_string(config, "files", entry, "");
+		}
 	}
-	// if open filenames less than GEANY_SESSION_FILES, delete existing saved entries in the list
-	for(i = j; i < GEANY_SESSION_FILES; i++)
-	{
-		g_snprintf(entry, 13, "FILE_NAME_%d", i);
-		g_key_file_set_string(config, "files", entry, "");
-	}
 
 	// write the file
 	data = g_key_file_to_data(config, NULL, NULL);

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2006-09-03 22:25:24 UTC (rev 786)
+++ trunk/src/main.c	2006-09-04 11:16:07 UTC (rev 787)
@@ -39,6 +39,7 @@
 #include <netinet/in.h>
 #endif
 
+#include "main.h"
 #include "interface.h"
 #include "support.h"
 #include "callbacks.h"
@@ -95,8 +96,9 @@
 static gint socket_fd_close			(gint sock);
 #endif
 
+CommandLineOptions cl_options;	// fields initialised in parse_command_line_options
+
 static gboolean debug_mode = FALSE;
-static gboolean load_session = TRUE;
 static gboolean ignore_global_tags = FALSE;
 static gboolean no_msgwin = FALSE;
 static gboolean show_version = FALSE;
@@ -110,9 +112,10 @@
 static GOptionEntry entries[] =
 {
 	{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode, N_("runs in debug mode (means being verbose)"), NULL },
+	{ "no-session", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &cl_options.load_session, N_("don't load the previous session's files"), NULL },
 	{ "no-ctags", 'n', 0, G_OPTION_ARG_NONE, &ignore_global_tags, N_("don't load auto completion data (see documentation)"), NULL },
 #ifdef HAVE_SOCKET
-	{ "no-socket", 's', 0, G_OPTION_ARG_NONE, &ignore_socket, N_("don't open files in a running instance, force opening a new instance"), NULL },
+	{ "new-instance", 'i', 0, G_OPTION_ARG_NONE, &ignore_socket, N_("don't open files in a running instance, force opening a new instance"), NULL },
 #endif
 	{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &alternate_config, N_("use an alternate configuration directory"), NULL },
 	{ "no-msgwin", 'm', 0, G_OPTION_ARG_NONE, &no_msgwin, N_("don't show message window at startup"), NULL },
@@ -408,6 +411,9 @@
 	GOptionContext *context;
 	GError *error = NULL;
 
+	// first initialise cl_options fields with default values
+	cl_options.load_session = TRUE;
+
 	context = g_option_context_new(_(" - A fast and lightweight IDE"));
 	g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
 	g_option_group_set_translation_domain(g_option_context_get_main_group(context), GETTEXT_PACKAGE);
@@ -520,7 +526,7 @@
 			}
 			// Start a new instance if no command line strings were passed
 			socket_info.ignore_socket = TRUE;
-			load_session = FALSE;
+			cl_options.load_session = FALSE;
 		}
 	}
 #endif
@@ -610,7 +616,7 @@
 			}
 		}
 	}
-	else if (app->pref_main_load_session && load_session)
+	else if (app->pref_main_load_session && cl_options.load_session)
 	{
 		if (! configuration_open_files())
 		{

Modified: trunk/src/main.h
===================================================================
--- trunk/src/main.h	2006-09-03 22:25:24 UTC (rev 786)
+++ trunk/src/main.h	2006-09-04 11:16:07 UTC (rev 787)
@@ -25,6 +25,14 @@
 #ifndef GEANY_MAIN_H
 #define GEANY_MAIN_H
 
+typedef struct
+{
+	gboolean load_session;
+} CommandLineOptions;
+
+extern CommandLineOptions cl_options;
+
+
 #ifdef HAVE_SOCKET
 gint socket_finalize();
 #endif


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