124 lines
3.1 KiB
Plaintext
124 lines
3.1 KiB
Plaintext
/*
|
|
* medit-app.c
|
|
*
|
|
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* See COPYING file that comes with this distribution.
|
|
*/
|
|
|
|
#include "medit-ui.h"
|
|
#include <mooapp/mooapp.h>
|
|
#include <mooutils/mooutils-fs.h>
|
|
#include <mooutils/mooutils-misc.h>
|
|
#include <mooutils/moostock.h>
|
|
#include <moo-version.h>
|
|
#include <gtk/gtk.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
int _medit_parse_options (const char *const program_name,
|
|
const int argc,
|
|
char **const argv);
|
|
|
|
/********************************************************
|
|
* command line parsing code generated by Opag
|
|
* http://www.zero-based.org/software/opag/
|
|
*/
|
|
%%
|
|
n new-app "Run new instance of application"
|
|
l log "[=FILE] Show debug output or write it to FILE" optarg
|
|
version "Display version information and exit" return
|
|
h help "Display this help text and exit" return
|
|
%%
|
|
/* end of generated code
|
|
********************************************************/
|
|
|
|
|
|
static void usage (void)
|
|
{
|
|
g_print ("Usage: %s [OPTIONS] [FILES]\n", g_get_prgname ());
|
|
g_print ("Options:\n");
|
|
|
|
g_print ("%s", STR_HELP_NEW_APP);
|
|
g_print ("%s", STR_HELP_LOG);
|
|
g_print ("%s", STR_HELP_VERSION);
|
|
g_print ("%s", STR_HELP_HELP);
|
|
}
|
|
|
|
static void version (void)
|
|
{
|
|
g_print ("medit %s\n", MOO_VERSION);
|
|
}
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
{
|
|
MooApp *app;
|
|
int opt_remain;
|
|
MooEditor *editor;
|
|
char **files;
|
|
|
|
gtk_init (&argc, &argv);
|
|
// gdk_window_set_debug_updates (TRUE);
|
|
|
|
opt_remain = _medit_parse_options (g_get_prgname (), argc, argv);
|
|
|
|
if (opt_remain < 0)
|
|
{
|
|
usage ();
|
|
return 1;
|
|
}
|
|
|
|
if (_medit_opt_help)
|
|
{
|
|
usage ();
|
|
return 0;
|
|
}
|
|
else if (_medit_opt_version)
|
|
{
|
|
version ();
|
|
return 0;
|
|
}
|
|
|
|
if (_medit_opt_log)
|
|
{
|
|
if (_medit_arg_log)
|
|
moo_set_log_func_file (_medit_arg_log);
|
|
else
|
|
moo_set_log_func_window (TRUE);
|
|
}
|
|
|
|
files = moo_filenames_from_locale (argv + opt_remain);
|
|
|
|
app = g_object_new (MOO_TYPE_APP,
|
|
"argv", argv,
|
|
"short-name", "medit",
|
|
"full-name", "medit",
|
|
"description", "medit is a text editor",
|
|
"open-files", files && *files ? files : NULL,
|
|
"new-app", (gboolean) _medit_opt_new_app,
|
|
"default-ui", MEDIT_UI,
|
|
"logo", MOO_STOCK_MEDIT,
|
|
NULL);
|
|
|
|
g_free (files);
|
|
|
|
if (!moo_app_init (app))
|
|
return 0;
|
|
|
|
editor = moo_app_get_editor (app);
|
|
moo_editor_new_window (editor);
|
|
|
|
g_signal_connect_swapped (editor, "all-windows-closed",
|
|
G_CALLBACK (moo_app_quit), app);
|
|
|
|
return moo_app_run (app);
|
|
}
|