Kaydet (Commit) 6a5a3d1d authored tarafından Nick Treleaven's avatar Nick Treleaven

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.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@787 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 9f77222d
2006-09-04 Nick Treleaven <nick.treleaven@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@btinternet.com>
* src/main.c: Open a new instance without loading session files if
......
......@@ -38,6 +38,7 @@
#include "sciwrappers.h"
#include "encodings.h"
#include "vte.h"
#include "main.h"
static gchar *scribble_text = NULL;
......@@ -201,25 +202,28 @@ void configuration_save()
(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
......
......@@ -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_recv (gint fd, gchar *buf, gint len, gint flags);
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 gboolean generate_datafiles = FALSE;
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 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
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 @@ gint main(gint argc, gchar **argv)
}
// 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 @@ gint main(gint argc, gchar **argv)
}
}
}
else if (app->pref_main_load_session && load_session)
else if (app->pref_main_load_session && cl_options.load_session)
{
if (! configuration_open_files())
{
......
......@@ -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
......
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