Use sockets instead of named pipes when pipes are not needed; added --app-name thing

master
Yevgen Muntyan 2007-07-10 10:32:29 -05:00
parent 7023717cb2
commit d1cfccd4e5
10 changed files with 1496 additions and 569 deletions

View File

@ -79,6 +79,10 @@ int _medit_parse_options (const char *const program_name,
#define STR_HELP_PID "\ #define STR_HELP_PID "\
--pid=PID Use existing instance with process id PID\n" --pid=PID Use existing instance with process id PID\n"
#define STR_HELP_APP_NAME "\
--app-name=NAME Set instance name to NAME if it's not already\n\
running\n"
#define STR_HELP_MODE "\ #define STR_HELP_MODE "\
-m, --mode=[simple|project] Use specified mode\n" -m, --mode=[simple|project] Use specified mode\n"
@ -110,6 +114,8 @@ int _medit_parse_options (const char *const program_name,
-n, --new-app Run new instance of application\n\ -n, --new-app Run new instance of application\n\
-s, --use-session Load and save session\n\ -s, --use-session Load and save session\n\
--pid=PID Use existing instance with process id PID\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\
-m, --mode=[simple|project] Use specified mode\n\ -m, --mode=[simple|project] Use specified mode\n\
-p, --project=PROJECT Open project file PROJECT\n\ -p, --project=PROJECT Open project file PROJECT\n\
-l, --line=LINE Open file and position cursor on line LINE\n\ -l, --line=LINE Open file and position cursor on line LINE\n\
@ -129,6 +135,9 @@ char _medit_opt_use_session;
/* Set to 1 if option --pid has been specified. */ /* Set to 1 if option --pid has been specified. */
char _medit_opt_pid; char _medit_opt_pid;
/* Set to 1 if option --app-name has been specified. */
char _medit_opt_app_name;
/* Set to 1 if option --mode (-m) has been specified. */ /* Set to 1 if option --mode (-m) has been specified. */
char _medit_opt_mode; char _medit_opt_mode;
@ -159,6 +168,9 @@ char _medit_opt_help;
/* Argument to option --pid. */ /* Argument to option --pid. */
const char *_medit_arg_pid; const char *_medit_arg_pid;
/* Argument to option --app-name. */
const char *_medit_arg_app_name;
/* Argument to option --mode (-m). */ /* Argument to option --mode (-m). */
const char *_medit_arg_mode; const char *_medit_arg_mode;
@ -184,6 +196,7 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
static const char *const optstr__new_app = "new-app"; static const char *const optstr__new_app = "new-app";
static const char *const optstr__use_session = "use-session"; static const char *const optstr__use_session = "use-session";
static const char *const optstr__pid = "pid"; static const char *const optstr__pid = "pid";
static const char *const optstr__app_name = "app-name";
static const char *const optstr__mode = "mode"; static const char *const optstr__mode = "mode";
static const char *const optstr__project = "project"; static const char *const optstr__project = "project";
static const char *const optstr__line = "line"; static const char *const optstr__line = "line";
@ -196,6 +209,7 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
_medit_opt_new_app = 0; _medit_opt_new_app = 0;
_medit_opt_use_session = 0; _medit_opt_use_session = 0;
_medit_opt_pid = 0; _medit_opt_pid = 0;
_medit_opt_app_name = 0;
_medit_opt_mode = 0; _medit_opt_mode = 0;
_medit_opt_project = 0; _medit_opt_project = 0;
_medit_opt_line = 0; _medit_opt_line = 0;
@ -206,6 +220,7 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
_medit_opt_version = 0; _medit_opt_version = 0;
_medit_opt_help = 0; _medit_opt_help = 0;
_medit_arg_pid = 0; _medit_arg_pid = 0;
_medit_arg_app_name = 0;
_medit_arg_mode = 0; _medit_arg_mode = 0;
_medit_arg_project = 0; _medit_arg_project = 0;
_medit_arg_line = 0; _medit_arg_line = 0;
@ -234,6 +249,22 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
{ {
case '\0': case '\0':
return i + 1; return i + 1;
case 'a':
if (strncmp (option + 1, optstr__app_name + 1, option_len - 1) == 0)
{
if (argument != 0)
_medit_arg_app_name = argument;
else if (++i < argc)
_medit_arg_app_name = argv [i];
else
{
option = optstr__app_name;
goto error_missing_arg_long;
}
_medit_opt_app_name = 1;
break;
}
goto error_unknown_long_opt;
case 'd': case 'd':
if (strncmp (option + 1, optstr__debug + 1, option_len - 1) == 0) if (strncmp (option + 1, optstr__debug + 1, option_len - 1) == 0)
{ {
@ -473,12 +504,13 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
} }
return i; return i;
} }
#line 63 "../../../medit/medit-app.opag" #line 64 "../../../medit/medit-app.opag"
#undef STR_HELP #undef STR_HELP
#define STR_HELP \ #define STR_HELP \
STR_HELP_NEW_APP \ STR_HELP_NEW_APP \
STR_HELP_PID \ STR_HELP_PID \
STR_HELP_APP_NAME \
STR_HELP_LINE \ STR_HELP_LINE \
STR_HELP_LOG \ STR_HELP_LOG \
STR_HELP_DEBUG \ STR_HELP_DEBUG \
@ -489,13 +521,23 @@ int _medit_parse_options (const char *const program_name, const int argc, char *
********************************************************/ ********************************************************/
static void G_GNUC_NORETURN static void
usage (void) usage (int status)
{
if (status)
{
g_printerr ("Usage: %s [OPTIONS] [FILES]\n", g_get_prgname ());
g_printerr ("Options:\n%s", STR_HELP);
}
else
{ {
g_print ("Usage: %s [OPTIONS] [FILES]\n", g_get_prgname ()); g_print ("Usage: %s [OPTIONS] [FILES]\n", g_get_prgname ());
g_print ("Options:\n%s", STR_HELP); g_print ("Options:\n%s", STR_HELP);
} }
exit (status);
}
static void static void
version (void) version (void)
{ {
@ -507,10 +549,7 @@ static void
check_args (int opt_remain) check_args (int opt_remain)
{ {
if (_medit_opt_help) if (_medit_opt_help)
{ usage (0);
usage ();
exit (0);
}
if (_medit_opt_version) if (_medit_opt_version)
{ {
@ -519,8 +558,11 @@ check_args (int opt_remain)
} }
if (opt_remain < 0) if (opt_remain < 0)
usage (1);
if (_medit_opt_pid && _medit_opt_app_name)
{ {
usage (); g_printerr ("--pid may not be used together with --app-name\n");
exit (1); exit (1);
} }
@ -528,16 +570,16 @@ check_args (int opt_remain)
{ {
if (_medit_opt_new_app) if (_medit_opt_new_app)
{ {
g_print ("--new-app can't be used together with --pid\n"); g_printerr ("--new-app can't be used together with --pid\n");
exit (1); exit (1);
} }
if (!_medit_arg_pid || !_medit_arg_pid[0]) if (!_medit_arg_pid || !_medit_arg_pid[0])
{ usage (1);
usage ();
exit (1);
}
} }
if (_medit_opt_app_name && (!_medit_arg_app_name || !_medit_arg_app_name[0]))
usage (1);
} }
@ -602,8 +644,8 @@ main (int argc, char *argv[])
AppMode mode = MODE_SIMPLE; AppMode mode = MODE_SIMPLE;
guint32 stamp; guint32 stamp;
guint32 line = 0; guint32 line = 0;
const char *pid_string = NULL;
gboolean use_session = FALSE; gboolean use_session = FALSE;
const char *name = NULL;
init_mem_stuff (); init_mem_stuff ();
@ -649,8 +691,8 @@ main (int argc, char *argv[])
if (_medit_opt_new_app || mode == MODE_PROJECT) if (_medit_opt_new_app || mode == MODE_PROJECT)
new_instance = TRUE; new_instance = TRUE;
run_input = !_medit_opt_new_app || _medit_opt_use_session || _medit_opt_project; 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; use_session = !_medit_opt_new_app || _medit_opt_use_session || _medit_opt_app_name;
app = g_object_new (MOO_TYPE_APP, app = g_object_new (MOO_TYPE_APP,
"argv", argv, "argv", argv,
@ -663,37 +705,46 @@ main (int argc, char *argv[])
"quit-on-editor-close", TRUE, "quit-on-editor-close", TRUE,
"logo", "medit", "logo", "medit",
"credits", THANKS, "credits", THANKS,
"instance-name", _medit_opt_app_name ? _medit_arg_app_name : NULL,
NULL); NULL);
if (_medit_arg_line) if (_medit_arg_line)
line = strtol (_medit_arg_line, NULL, 10); line = strtol (_medit_arg_line, NULL, 10);
if (_medit_opt_pid) if (_medit_opt_pid)
pid_string = _medit_arg_pid; name = _medit_arg_pid;
else if (_medit_opt_app_name)
name = _medit_arg_app_name;
else if (!_medit_opt_new_app) else if (!_medit_opt_new_app)
pid_string = g_getenv ("MEDIT_PID"); name = g_getenv ("MEDIT_PID");
if (name && !name[0])
name = NULL;
if (_medit_opt_exec || _medit_opt_exec_file) if (_medit_opt_exec || _medit_opt_exec_file)
{ {
GString *msg; GString *msg;
msg = g_string_new (_medit_opt_exec ? "p" : "P"); msg = g_string_new (_medit_opt_exec ? "p" : "P");
g_string_append (msg, _medit_opt_exec ? _medit_arg_exec : _medit_arg_exec_file); g_string_append (msg, _medit_opt_exec ? _medit_arg_exec : _medit_arg_exec_file);
moo_app_send_msg (app, pid_string, msg->str, msg->len + 1); moo_app_send_msg (app, name, msg->str, msg->len + 1);
exit (0); exit (0);
} }
files = moo_filenames_from_locale (argv + opt_remain); files = moo_filenames_from_locale (argv + opt_remain);
if (pid_string) if (name)
{ {
if (moo_app_send_files (app, files, line, stamp, pid_string)) if (moo_app_send_files (app, files, line, stamp, name))
exit (0); exit (0);
g_print ("Could not send files to pid %s\n", pid_string); if (!_medit_opt_app_name)
{
g_printerr ("Could not send files to instance '%s'\n", name);
exit (1); exit (1);
} }
}
if ((!new_instance && moo_app_send_files (app, files, line, stamp, NULL)) || if ((!new_instance && !_medit_opt_app_name && moo_app_send_files (app, files, line, stamp, NULL)) ||
!moo_app_init (app)) !moo_app_init (app))
{ {
gdk_notify_startup_complete (); gdk_notify_startup_complete ();

View File

@ -49,6 +49,7 @@ int _medit_parse_options (const char *const program_name,
n new-app "Run new instance of application" n new-app "Run new instance of application"
s use-session "Load and save session" s use-session "Load and save session"
pid "=PID Use existing instance with process id PID" reqarg 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 m mode "=[simple|project] Use specified mode" reqarg
p project "=PROJECT Open project file PROJECT" reqarg p project "=PROJECT Open project file PROJECT" reqarg
l line "=LINE Open file and position cursor on line LINE" reqarg l line "=LINE Open file and position cursor on line LINE" reqarg
@ -59,12 +60,13 @@ l line "=LINE Open file and position cursor on line LINE" reqarg
version "Display version information and exit" return version "Display version information and exit" return
h help "Display this help text and exit" return h help "Display this help text and exit" return
%% %%
#line 63 "../../../medit/medit-app.opag" #line 64 "../../../medit/medit-app.opag"
#undef STR_HELP #undef STR_HELP
#define STR_HELP \ #define STR_HELP \
STR_HELP_NEW_APP \ STR_HELP_NEW_APP \
STR_HELP_PID \ STR_HELP_PID \
STR_HELP_APP_NAME \
STR_HELP_LINE \ STR_HELP_LINE \
STR_HELP_LOG \ STR_HELP_LOG \
STR_HELP_DEBUG \ STR_HELP_DEBUG \
@ -75,13 +77,23 @@ h help "Display this help text and exit" return
********************************************************/ ********************************************************/
static void G_GNUC_NORETURN static void
usage (void) usage (int status)
{
if (status)
{
g_printerr ("Usage: %s [OPTIONS] [FILES]\n", g_get_prgname ());
g_printerr ("Options:\n%s", STR_HELP);
}
else
{ {
g_print ("Usage: %s [OPTIONS] [FILES]\n", g_get_prgname ()); g_print ("Usage: %s [OPTIONS] [FILES]\n", g_get_prgname ());
g_print ("Options:\n%s", STR_HELP); g_print ("Options:\n%s", STR_HELP);
} }
exit (status);
}
static void static void
version (void) version (void)
{ {
@ -93,10 +105,7 @@ static void
check_args (int opt_remain) check_args (int opt_remain)
{ {
if (_medit_opt_help) if (_medit_opt_help)
{ usage (0);
usage ();
exit (0);
}
if (_medit_opt_version) if (_medit_opt_version)
{ {
@ -105,8 +114,11 @@ check_args (int opt_remain)
} }
if (opt_remain < 0) if (opt_remain < 0)
usage (1);
if (_medit_opt_pid && _medit_opt_app_name)
{ {
usage (); g_printerr ("--pid may not be used together with --app-name\n");
exit (1); exit (1);
} }
@ -114,16 +126,16 @@ check_args (int opt_remain)
{ {
if (_medit_opt_new_app) if (_medit_opt_new_app)
{ {
g_print ("--new-app can't be used together with --pid\n"); g_printerr ("--new-app can't be used together with --pid\n");
exit (1); exit (1);
} }
if (!_medit_arg_pid || !_medit_arg_pid[0]) if (!_medit_arg_pid || !_medit_arg_pid[0])
{ usage (1);
usage ();
exit (1);
}
} }
if (_medit_opt_app_name && (!_medit_arg_app_name || !_medit_arg_app_name[0]))
usage (1);
} }
@ -188,8 +200,8 @@ main (int argc, char *argv[])
AppMode mode = MODE_SIMPLE; AppMode mode = MODE_SIMPLE;
guint32 stamp; guint32 stamp;
guint32 line = 0; guint32 line = 0;
const char *pid_string = NULL;
gboolean use_session = FALSE; gboolean use_session = FALSE;
const char *name = NULL;
init_mem_stuff (); init_mem_stuff ();
@ -235,8 +247,8 @@ main (int argc, char *argv[])
if (_medit_opt_new_app || mode == MODE_PROJECT) if (_medit_opt_new_app || mode == MODE_PROJECT)
new_instance = TRUE; new_instance = TRUE;
run_input = !_medit_opt_new_app || _medit_opt_use_session || _medit_opt_project; 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; use_session = !_medit_opt_new_app || _medit_opt_use_session || _medit_opt_app_name;
app = g_object_new (MOO_TYPE_APP, app = g_object_new (MOO_TYPE_APP,
"argv", argv, "argv", argv,
@ -249,37 +261,46 @@ main (int argc, char *argv[])
"quit-on-editor-close", TRUE, "quit-on-editor-close", TRUE,
"logo", "medit", "logo", "medit",
"credits", THANKS, "credits", THANKS,
"instance-name", _medit_opt_app_name ? _medit_arg_app_name : NULL,
NULL); NULL);
if (_medit_arg_line) if (_medit_arg_line)
line = strtol (_medit_arg_line, NULL, 10); line = strtol (_medit_arg_line, NULL, 10);
if (_medit_opt_pid) if (_medit_opt_pid)
pid_string = _medit_arg_pid; name = _medit_arg_pid;
else if (_medit_opt_app_name)
name = _medit_arg_app_name;
else if (!_medit_opt_new_app) else if (!_medit_opt_new_app)
pid_string = g_getenv ("MEDIT_PID"); name = g_getenv ("MEDIT_PID");
if (name && !name[0])
name = NULL;
if (_medit_opt_exec || _medit_opt_exec_file) if (_medit_opt_exec || _medit_opt_exec_file)
{ {
GString *msg; GString *msg;
msg = g_string_new (_medit_opt_exec ? "p" : "P"); msg = g_string_new (_medit_opt_exec ? "p" : "P");
g_string_append (msg, _medit_opt_exec ? _medit_arg_exec : _medit_arg_exec_file); g_string_append (msg, _medit_opt_exec ? _medit_arg_exec : _medit_arg_exec_file);
moo_app_send_msg (app, pid_string, msg->str, msg->len + 1); moo_app_send_msg (app, name, msg->str, msg->len + 1);
exit (0); exit (0);
} }
files = moo_filenames_from_locale (argv + opt_remain); files = moo_filenames_from_locale (argv + opt_remain);
if (pid_string) if (name)
{ {
if (moo_app_send_files (app, files, line, stamp, pid_string)) if (moo_app_send_files (app, files, line, stamp, name))
exit (0); exit (0);
g_print ("Could not send files to pid %s\n", pid_string); if (!_medit_opt_app_name)
{
g_printerr ("Could not send files to instance '%s'\n", name);
exit (1); exit (1);
} }
}
if ((!new_instance && moo_app_send_files (app, files, line, stamp, NULL)) || if ((!new_instance && !_medit_opt_app_name && moo_app_send_files (app, files, line, stamp, NULL)) ||
!moo_app_init (app)) !moo_app_init (app))
{ {
gdk_notify_startup_complete (); gdk_notify_startup_complete ();

View File

@ -41,6 +41,10 @@ Load and save session. By default \fBmedit\fP does it when \-n is not used.
.B \-\-pid PID .B \-\-pid PID
Use existing instance with process id \fBPID\fP. Use existing instance with process id \fBPID\fP.
.TP .TP
.B \-\-app-name NAME
Use instance name \fBNAME\fP. If an instance with this name is already running,
then it will send files given on the command line to that instance and exit.
.TP
.B \-l, \-\-line LINE .B \-l, \-\-line LINE
Open file and position cursor on line \fBLINE\fP. Open file and position cursor on line \fBLINE\fP.
.TP .TP
@ -58,6 +62,7 @@ Execute python file in an existing instance.
.TP .TP
.B files .B files
List of files to open. Filenames may include line numbers after colon, e.g. /tmp/file.txt:200. List of files to open. Filenames may include line numbers after colon, e.g. /tmp/file.txt:200.
Trailing colon is also fine.
.SH ENVIRONMENT .SH ENVIRONMENT
.TP .TP
.B MEDIT_PID .B MEDIT_PID

View File

@ -8,4 +8,4 @@ Type=Application
StartupNotify=true StartupNotify=true
MimeType=text/plain; MimeType=text/plain;
Icon=medit.png Icon=medit.png
Categories=Application;Utility;TextEditor; Categories=Utility;TextEditor;

View File

@ -13,8 +13,8 @@
<configure> <configure>
<args>--enable-debug=full --enable-all-warnings --enable-project</args> <args>--enable-debug=full --enable-all-warnings --enable-project</args>
<vars> <vars>
<var name="OBJCFLAGS">-g</var>
<var name="CFLAGS">-g</var> <var name="CFLAGS">-g</var>
<var name="OBJCFLAGS">-g</var>
</vars> </vars>
</configure> </configure>
</debug> </debug>
@ -37,8 +37,8 @@
<build_dir>build/optimized</build_dir> <build_dir>build/optimized</build_dir>
<configure> <configure>
<vars> <vars>
<var name="OBJCFLAGS">-O2 -g</var>
<var name="CFLAGS">-O2 -g</var> <var name="CFLAGS">-O2 -g</var>
<var name="OBJCFLAGS">-O2 -g</var>
</vars> </vars>
</configure> </configure>
</optimized> </optimized>
@ -47,8 +47,8 @@
<configure> <configure>
<args>--enable-debug=full --enable-all-warnings --enable-project --prefix=/usr/local/test</args> <args>--enable-debug=full --enable-all-warnings --enable-project --prefix=/usr/local/test</args>
<vars> <vars>
<var name="OBJCFLAGS">-g</var>
<var name="CFLAGS">-g</var> <var name="CFLAGS">-g</var>
<var name="OBJCFLAGS">-g</var>
</vars> </vars>
</configure> </configure>
</test> </test>

View File

@ -71,7 +71,9 @@ struct _MooAppPrivate {
MooEditor *editor; MooEditor *editor;
MooAppInfo *info; MooAppInfo *info;
char *rc_files[2]; char *rc_files[2];
gboolean run_input; gboolean run_input;
char *instance_name;
gboolean running; gboolean running;
gboolean in_try_quit; gboolean in_try_quit;
@ -191,7 +193,8 @@ enum {
PROP_LOGO, PROP_LOGO,
PROP_WEBSITE, PROP_WEBSITE,
PROP_WEBSITE_LABEL, PROP_WEBSITE_LABEL,
PROP_CREDITS PROP_CREDITS,
PROP_INSTANCE_NAME
}; };
enum { enum {
@ -303,6 +306,14 @@ moo_app_class_init (MooAppClass *klass)
TRUE, TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class,
PROP_INSTANCE_NAME,
g_param_spec_string ("instance-name",
"instance-name",
"instance-name",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_USE_EDITOR, PROP_USE_EDITOR,
g_param_spec_boolean ("use-editor", g_param_spec_boolean ("use-editor",
@ -510,6 +521,7 @@ moo_app_finalize (GObject *object)
if (app->priv->ui_xml) if (app->priv->ui_xml)
g_object_unref (app->priv->ui_xml); g_object_unref (app->priv->ui_xml);
g_free (app->priv->instance_name);
g_free (app->priv); g_free (app->priv);
G_OBJECT_CLASS (moo_app_parent_class)->finalize (object); G_OBJECT_CLASS (moo_app_parent_class)->finalize (object);
@ -561,6 +573,11 @@ moo_app_set_property (GObject *object,
app->priv->run_input = g_value_get_boolean (value); app->priv->run_input = g_value_get_boolean (value);
break; break;
case PROP_INSTANCE_NAME:
g_free (app->priv->instance_name);
app->priv->instance_name = g_value_dup_string (value);
break;
case PROP_USE_EDITOR: case PROP_USE_EDITOR:
app->priv->use_editor = g_value_get_boolean (value); app->priv->use_editor = g_value_get_boolean (value);
break; break;
@ -625,6 +642,9 @@ moo_app_get_property (GObject *object,
case PROP_RUN_INPUT: case PROP_RUN_INPUT:
g_value_set_boolean (value, app->priv->run_input); g_value_set_boolean (value, app->priv->run_input);
break; break;
case PROP_INSTANCE_NAME:
g_value_set_string (value, app->priv->instance_name);
break;
case PROP_USE_EDITOR: case PROP_USE_EDITOR:
g_value_set_boolean (value, app->priv->use_editor); g_value_set_boolean (value, app->priv->use_editor);
@ -666,13 +686,6 @@ moo_app_set_exit_code (MooApp *app,
} }
const char *
moo_app_get_input_pipe_name (G_GNUC_UNUSED MooApp *app)
{
return moo_app_input ? _moo_app_input_get_name (moo_app_input) : NULL;
}
char * char *
moo_app_create_user_data_dir (MooApp *app) moo_app_create_user_data_dir (MooApp *app)
{ {
@ -891,16 +904,9 @@ static void
start_input (MooApp *app) start_input (MooApp *app)
{ {
if (app->priv->run_input) if (app->priv->run_input)
{ moo_app_input = _moo_app_input_new (app->priv->info->short_name,
moo_app_input = _moo_app_input_new (app->priv->info->short_name); app->priv->instance_name,
TRUE);
if (!_moo_app_input_start (moo_app_input))
{
g_critical ("%s: oops", G_STRLOC);
_moo_app_input_free (moo_app_input);
moo_app_input = NULL;
}
}
} }
@ -1097,7 +1103,6 @@ moo_app_quit_real (MooApp *app)
if (moo_app_input) if (moo_app_input)
{ {
_moo_app_input_shutdown (moo_app_input);
_moo_app_input_free (moo_app_input); _moo_app_input_free (moo_app_input);
moo_app_input = NULL; moo_app_input = NULL;
} }
@ -1541,7 +1546,15 @@ moo_app_load_session (MooApp *app)
g_return_if_fail (MOO_IS_APP (app)); g_return_if_fail (MOO_IS_APP (app));
if (!app->priv->session_file) if (!app->priv->session_file)
app->priv->session_file = g_strdup_printf ("%s.session", g_get_prgname ()); {
if (app->priv->instance_name)
app->priv->session_file = g_strdup_printf ("%s.session.%s",
g_get_prgname (),
app->priv->instance_name);
else
app->priv->session_file = g_strdup_printf ("%s.session",
g_get_prgname ());
}
session_file = moo_get_user_cache_file (app->priv->session_file); session_file = moo_get_user_cache_file (app->priv->session_file);
@ -1877,8 +1890,18 @@ move_rc_files (MooApp *app)
const char *new_file; const char *new_file;
char *old_file = g_strdup_printf ("%s/.%s.state", g_get_home_dir (), g_get_prgname ()); char *old_file = g_strdup_printf ("%s/.%s.state", g_get_home_dir (), g_get_prgname ());
if (app->priv->instance_name)
app->priv->rc_files[MOO_PREFS_STATE] = app->priv->rc_files[MOO_PREFS_STATE] =
g_strdup_printf ("%s/%s.state", cache_dir, g_get_prgname ()); g_strdup_printf ("%s/%s.state.%s",
cache_dir,
g_get_prgname (),
app->priv->instance_name);
else
app->priv->rc_files[MOO_PREFS_STATE] =
g_strdup_printf ("%s/%s.state",
cache_dir,
g_get_prgname ());
new_file = app->priv->rc_files[MOO_PREFS_STATE]; new_file = app->priv->rc_files[MOO_PREFS_STATE];
if (!g_file_test (new_file, G_FILE_TEST_EXISTS) && if (!g_file_test (new_file, G_FILE_TEST_EXISTS) &&

View File

@ -92,7 +92,6 @@ void moo_app_set_exit_code (MooApp *app,
const MooAppInfo*moo_app_get_info (MooApp *app); const MooAppInfo*moo_app_get_info (MooApp *app);
char *moo_app_create_user_data_dir (MooApp *app); char *moo_app_create_user_data_dir (MooApp *app);
const char *moo_app_get_input_pipe_name (MooApp *app);
MooEditor *moo_app_get_editor (MooApp *app); MooEditor *moo_app_get_editor (MooApp *app);

File diff suppressed because it is too large Load Diff

View File

@ -65,21 +65,18 @@ static const char *moo_app_cmd_chars =
#endif /* WANT_MOO_APP_CMD_CHARS */ #endif /* WANT_MOO_APP_CMD_CHARS */
#define MOO_APP_INPUT_NAME_DEFAULT "main"
typedef struct _MooAppInput MooAppInput; typedef struct _MooAppInput MooAppInput;
MooAppInput *_moo_app_input_new (const char *pipe_basename); MooAppInput *_moo_app_input_new (const char *appname,
const char *name,
gboolean bind_default);
void _moo_app_input_free (MooAppInput *ch); void _moo_app_input_free (MooAppInput *ch);
gboolean _moo_app_input_start (MooAppInput *ch); gboolean _moo_app_input_send_msg (const char *appname,
void _moo_app_input_shutdown (MooAppInput *ch); const char *name,
const char *_moo_app_input_get_name (MooAppInput *ch);
gboolean _moo_app_input_send_msg (const char *pipe_basename,
const char *pid,
const char *data, const char *data,
gssize len); gssize len);

View File

@ -64,12 +64,6 @@
;; (return-type "const-MooAppInfo*") ;; (return-type "const-MooAppInfo*")
;; ) ;; )
(define-method get_input_pipe_name
(of-object "MooApp")
(c-name "moo_app_get_input_pipe_name")
(return-type "const-char*")
)
(define-method get_editor (define-method get_editor
(of-object "MooApp") (of-object "MooApp")
(c-name "moo_app_get_editor") (c-name "moo_app_get_editor")