Added use-session setting
This commit is contained in:
parent
90169df51a
commit
009ffddb0a
@ -30,3 +30,4 @@ Makefile(\.in)?$
|
||||
^moo/moopython/pygtk/goocanvas/.cvsignore
|
||||
^patches/
|
||||
^po(-gsv)?/(dist|pot)$
|
||||
^ppc-configure$
|
||||
|
@ -74,7 +74,7 @@ int _medit_parse_options (const char *const program_name,
|
||||
-n, --new-app Run new instance of application\n"
|
||||
|
||||
#define STR_HELP_USE_SESSION "\
|
||||
-s, --use-session Load and save session\n"
|
||||
-s, --use-session[=yes|no] Load and save session\n"
|
||||
|
||||
#define STR_HELP_PID "\
|
||||
--pid=PID Use existing instance with process id PID\n"
|
||||
@ -112,7 +112,7 @@ int _medit_parse_options (const char *const program_name,
|
||||
|
||||
#define STR_HELP "\
|
||||
-n, --new-app Run new instance of application\n\
|
||||
-s, --use-session Load and save session\n\
|
||||
-s, --use-session[=yes|no] Load and save session\n\
|
||||
--pid=PID Use existing instance with process id PID\n\
|
||||
--app-name=NAME Set instance name to NAME if it's not already\n\
|
||||
running\n\
|
||||
@ -165,6 +165,9 @@ char _medit_opt_version;
|
||||
/* Set to 1 if option --help (-h) has been specified. */
|
||||
char _medit_opt_help;
|
||||
|
||||
/* Argument to option --use-session (-s), or a null pointer if no argument. */
|
||||
const char *_medit_arg_use_session;
|
||||
|
||||
/* Argument to option --pid. */
|
||||
const char *_medit_arg_pid;
|
||||
|
||||
@ -194,7 +197,6 @@ const char *_medit_arg_exec_file;
|
||||
int _medit_parse_options (const char *const program_name, const int argc, char **const argv)
|
||||
{
|
||||
static const char *const optstr__new_app = "new-app";
|
||||
static const char *const optstr__use_session = "use-session";
|
||||
static const char *const optstr__pid = "pid";
|
||||
static const char *const optstr__app_name = "app-name";
|
||||
static const char *const optstr__mode = "mode";
|
||||
@ -219,6 +221,7 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
|
||||
_medit_opt_exec_file = 0;
|
||||
_medit_opt_version = 0;
|
||||
_medit_opt_help = 0;
|
||||
_medit_arg_use_session = 0;
|
||||
_medit_arg_pid = 0;
|
||||
_medit_arg_app_name = 0;
|
||||
_medit_arg_mode = 0;
|
||||
@ -412,13 +415,9 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
|
||||
}
|
||||
goto error_unknown_long_opt;
|
||||
case 'u':
|
||||
if (strncmp (option + 1, optstr__use_session + 1, option_len - 1) == 0)
|
||||
if (strncmp (option + 1, "se-session", option_len - 1) == 0)
|
||||
{
|
||||
if (argument != 0)
|
||||
{
|
||||
option = optstr__use_session;
|
||||
goto error_unexpec_arg_long;
|
||||
}
|
||||
_medit_arg_use_session = argument;
|
||||
_medit_opt_use_session = 1;
|
||||
break;
|
||||
}
|
||||
@ -491,6 +490,13 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
|
||||
_medit_opt_project = 1;
|
||||
break;
|
||||
case 's':
|
||||
if (option [1] != '\0')
|
||||
{
|
||||
_medit_arg_use_session = option + 1;
|
||||
option = "\0";
|
||||
}
|
||||
else
|
||||
_medit_arg_use_session = 0;
|
||||
_medit_opt_use_session = 1;
|
||||
break;
|
||||
default:
|
||||
@ -641,10 +647,10 @@ main (int argc, char *argv[])
|
||||
int retval;
|
||||
gboolean new_instance = FALSE;
|
||||
gboolean run_input = TRUE;
|
||||
int use_session = -1;
|
||||
AppMode mode = MODE_SIMPLE;
|
||||
guint32 stamp;
|
||||
guint32 line = 0;
|
||||
gboolean use_session = FALSE;
|
||||
const char *name = NULL;
|
||||
|
||||
init_mem_stuff ();
|
||||
@ -691,12 +697,20 @@ main (int argc, char *argv[])
|
||||
if (_medit_opt_new_app || mode == MODE_PROJECT)
|
||||
new_instance = TRUE;
|
||||
|
||||
run_input = !_medit_opt_new_app || _medit_opt_app_name || _medit_opt_use_session || _medit_opt_project;
|
||||
use_session = !_medit_opt_new_app || _medit_opt_use_session || _medit_opt_app_name;
|
||||
if (_medit_opt_use_session)
|
||||
{
|
||||
if (!_medit_arg_use_session || !strcmp (_medit_arg_use_session, "yes"))
|
||||
use_session = 1;
|
||||
else
|
||||
use_session = 0;
|
||||
}
|
||||
|
||||
run_input = !_medit_opt_new_app || _medit_opt_app_name || use_session == 1 || _medit_opt_project;
|
||||
|
||||
app = g_object_new (MOO_TYPE_APP,
|
||||
"argv", argv,
|
||||
"run-input", run_input,
|
||||
"use-session", use_session,
|
||||
"short-name", "medit",
|
||||
"full-name", "medit",
|
||||
"description", _("medit is a text editor"),
|
||||
@ -755,7 +769,7 @@ main (int argc, char *argv[])
|
||||
|
||||
if (mode == MODE_PROJECT)
|
||||
project_mode ();
|
||||
else if (use_session)
|
||||
else
|
||||
moo_app_load_session (app);
|
||||
|
||||
editor = moo_app_get_editor (app);
|
||||
|
@ -47,7 +47,7 @@ int _medit_parse_options (const char *const program_name,
|
||||
#line 122 "medit-app.c"
|
||||
%%
|
||||
n new-app "Run new instance of application"
|
||||
s use-session "Load and save session"
|
||||
s use-session "[=yes|no] Load and save session" optarg
|
||||
pid "=PID Use existing instance with process id PID" reqarg
|
||||
app-name "=NAME Set instance name to NAME if it's not already running" reqarg
|
||||
m mode "=[simple|project] Use specified mode" reqarg
|
||||
@ -197,10 +197,10 @@ main (int argc, char *argv[])
|
||||
int retval;
|
||||
gboolean new_instance = FALSE;
|
||||
gboolean run_input = TRUE;
|
||||
int use_session = -1;
|
||||
AppMode mode = MODE_SIMPLE;
|
||||
guint32 stamp;
|
||||
guint32 line = 0;
|
||||
gboolean use_session = FALSE;
|
||||
const char *name = NULL;
|
||||
|
||||
init_mem_stuff ();
|
||||
@ -247,12 +247,20 @@ main (int argc, char *argv[])
|
||||
if (_medit_opt_new_app || mode == MODE_PROJECT)
|
||||
new_instance = TRUE;
|
||||
|
||||
run_input = !_medit_opt_new_app || _medit_opt_app_name || _medit_opt_use_session || _medit_opt_project;
|
||||
use_session = !_medit_opt_new_app || _medit_opt_use_session || _medit_opt_app_name;
|
||||
if (_medit_opt_use_session)
|
||||
{
|
||||
if (!_medit_arg_use_session || !strcmp (_medit_arg_use_session, "yes"))
|
||||
use_session = 1;
|
||||
else
|
||||
use_session = 0;
|
||||
}
|
||||
|
||||
run_input = !_medit_opt_new_app || _medit_opt_app_name || use_session == 1 || _medit_opt_project;
|
||||
|
||||
app = g_object_new (MOO_TYPE_APP,
|
||||
"argv", argv,
|
||||
"run-input", run_input,
|
||||
"use-session", use_session,
|
||||
"short-name", "medit",
|
||||
"full-name", "medit",
|
||||
"description", _("medit is a text editor"),
|
||||
@ -311,7 +319,7 @@ main (int argc, char *argv[])
|
||||
|
||||
if (mode == MODE_PROJECT)
|
||||
project_mode ();
|
||||
else if (use_session)
|
||||
else
|
||||
moo_app_load_session (app);
|
||||
|
||||
editor = moo_app_get_editor (app);
|
||||
|
@ -35,8 +35,10 @@ Show version of the program.
|
||||
Run new instance of \fBmedit\fP. By default \fBmedit\fP opens \fBfiles\fP
|
||||
in an existing instance of application.
|
||||
.TP
|
||||
.B \-s, \-\-use\-session
|
||||
.B \-s, \-\-use\-session[=yes|no]
|
||||
Load and save session. By default \fBmedit\fP does it when \-n is not used.
|
||||
If this option is not given on command line then medit uses the corresponding
|
||||
preferences setting.
|
||||
.TP
|
||||
.B \-\-pid PID
|
||||
Use existing instance with process id \fBPID\fP.
|
||||
|
@ -78,6 +78,7 @@ struct _MooAppPrivate {
|
||||
gboolean running;
|
||||
gboolean in_try_quit;
|
||||
|
||||
int use_session;
|
||||
EggSMClient *sm_client;
|
||||
char *session_file;
|
||||
MooMarkupDoc *session;
|
||||
@ -187,6 +188,7 @@ enum {
|
||||
PROP_VERSION,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_RUN_INPUT,
|
||||
PROP_USE_SESSION,
|
||||
PROP_USE_EDITOR,
|
||||
PROP_QUIT_ON_EDITOR_CLOSE,
|
||||
PROP_DEFAULT_UI,
|
||||
@ -306,6 +308,14 @@ moo_app_class_init (MooAppClass *klass)
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_USE_SESSION,
|
||||
g_param_spec_int ("use-session",
|
||||
"use-session",
|
||||
"use-session",
|
||||
-1, 1, -1,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_INSTANCE_NAME,
|
||||
g_param_spec_string ("instance-name",
|
||||
@ -435,8 +445,9 @@ moo_app_instance_init (MooApp *app)
|
||||
moo_app_instance = app;
|
||||
|
||||
app->priv = g_new0 (MooAppPrivate, 1);
|
||||
app->priv->info = moo_app_info_new ();
|
||||
app->priv->use_session = -1;
|
||||
|
||||
app->priv->info = moo_app_info_new ();
|
||||
app->priv->info->version = g_strdup (APP_VERSION);
|
||||
app->priv->info->website = g_strdup ("http://ggap.sourceforge.net/");
|
||||
app->priv->info->website_label = g_strdup ("http://ggap.sourceforge.net");
|
||||
@ -573,6 +584,10 @@ moo_app_set_property (GObject *object,
|
||||
app->priv->run_input = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_USE_SESSION:
|
||||
app->priv->use_session = g_value_get_int (value);
|
||||
break;
|
||||
|
||||
case PROP_INSTANCE_NAME:
|
||||
g_free (app->priv->instance_name);
|
||||
app->priv->instance_name = g_value_dup_string (value);
|
||||
@ -642,6 +657,9 @@ moo_app_get_property (GObject *object,
|
||||
case PROP_RUN_INPUT:
|
||||
g_value_set_boolean (value, app->priv->run_input);
|
||||
break;
|
||||
case PROP_USE_SESSION:
|
||||
g_value_set_int (value, app->priv->use_session);
|
||||
break;
|
||||
case PROP_INSTANCE_NAME:
|
||||
g_value_set_string (value, app->priv->instance_name);
|
||||
break;
|
||||
@ -892,8 +910,13 @@ moo_app_init_real (MooApp *app)
|
||||
#ifdef MOO_BUILD_EDIT
|
||||
if (app->priv->use_editor)
|
||||
moo_app_init_editor (app);
|
||||
|
||||
if (app->priv->use_session == -1)
|
||||
app->priv->use_session = moo_prefs_get_bool (moo_edit_setting (MOO_EDIT_PREFS_SAVE_SESSION));
|
||||
#endif
|
||||
|
||||
if (app->priv->use_session)
|
||||
app->priv->run_input = TRUE;
|
||||
start_input (app);
|
||||
|
||||
return TRUE;
|
||||
@ -1551,6 +1574,9 @@ moo_app_load_session (MooApp *app)
|
||||
|
||||
g_return_if_fail (MOO_IS_APP (app));
|
||||
|
||||
if (!app->priv->use_session)
|
||||
return;
|
||||
|
||||
if (!app->priv->session_file)
|
||||
{
|
||||
if (app->priv->instance_name)
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.0.3 on Wed Jul 4 20:05:48 2007 by muntyan@munt10
|
||||
<!--Generated with glade3 3.0.3 on Fri Jul 20 12:54:00 2007 by muntyan@munt10
|
||||
Version: 3.0.0
|
||||
Date: Fri Dec 8 17:47:39 2006
|
||||
User: muntyan
|
||||
@ -27,18 +27,6 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">1</property>
|
||||
<property name="n_columns">2</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label12">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Encodings to autodetect:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
<property name="x_padding">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="entry1">
|
||||
<property name="visible">True</property>
|
||||
@ -51,6 +39,18 @@
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label12">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Encodings to autodetect:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
<property name="x_padding">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
@ -87,17 +87,30 @@
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="checkbutton21">
|
||||
<widget class="GtkComboBoxEntry" id="encoding_save">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Remove trailing spaces</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="moo_prefs_key">strip</property>
|
||||
<child internal-child="entry">
|
||||
<widget class="GtkEntry" id="comboboxentry-entry2">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label14">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Encoding for new files:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
<property name="x_padding">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -114,30 +127,17 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label14">
|
||||
<widget class="GtkCheckButton" id="checkbutton21">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Encoding for new files:</property>
|
||||
<property name="label" translatable="yes">Remove trailing spaces</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="moo_prefs_key">strip</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
<property name="x_padding">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBoxEntry" id="encoding_save">
|
||||
<property name="visible">True</property>
|
||||
<child internal-child="entry">
|
||||
<widget class="GtkEntry" id="comboboxentry-entry2">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
@ -161,7 +161,41 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<widget class="GtkFrame" id="frame1">
|
||||
<property name="visible">True</property>
|
||||
<property name="border_width">3</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="bottom_padding">3</property>
|
||||
<property name="left_padding">3</property>
|
||||
<property name="right_padding">3</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="checkbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Enable session support</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="moo_prefs_key">save_session</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Sessions</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
@ -92,6 +92,7 @@ _moo_edit_init_prefs (void)
|
||||
NEW_KEY_BOOL (MOO_EDIT_PREFS_AUTO_INDENT, TRUE);
|
||||
NEW_KEY_BOOL (MOO_EDIT_PREFS_BACKSPACE_INDENTS, FALSE);
|
||||
|
||||
NEW_KEY_BOOL (MOO_EDIT_PREFS_SAVE_SESSION, TRUE);
|
||||
NEW_KEY_BOOL (MOO_EDIT_PREFS_AUTO_SAVE, FALSE);
|
||||
NEW_KEY_INT (MOO_EDIT_PREFS_AUTO_SAVE_INTERVAL, 5);
|
||||
NEW_KEY_BOOL (MOO_EDIT_PREFS_MAKE_BACKUPS, FALSE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user