Open files from command line.
This commit is contained in:
parent
7fa6efbaec
commit
781273c236
|
@ -174,13 +174,20 @@ static GtkActionEntry wm_action_entries[] =
|
|||
|
||||
/**
|
||||
* ld_window_main_new:
|
||||
* @filename: (allow-none): a file to open.
|
||||
*
|
||||
* Create an instance.
|
||||
*/
|
||||
GtkWidget *
|
||||
ld_window_main_new (void)
|
||||
ld_window_main_new (const gchar *filename)
|
||||
{
|
||||
return g_object_new (LD_TYPE_WINDOW_MAIN, NULL);
|
||||
GtkWidget *self;
|
||||
self = g_object_new (LD_TYPE_WINDOW_MAIN, NULL);
|
||||
|
||||
if (filename)
|
||||
diagram_open (LD_WINDOW_MAIN (self), filename);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE (LdWindowMain, ld_window_main, GTK_TYPE_WINDOW);
|
||||
|
|
|
@ -47,7 +47,7 @@ struct _LdWindowMainClass
|
|||
|
||||
GType ld_window_main_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *ld_window_main_new (void);
|
||||
GtkWidget *ld_window_main_new (const gchar *filename);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GError *error;
|
||||
#ifdef _WIN32
|
||||
gchar *install_dir;
|
||||
|
@ -48,11 +47,15 @@ main (int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* TODO: Open the file in the parameter, if present. */
|
||||
gtk_window_set_default_icon_name (PROJECT_NAME);
|
||||
window = ld_window_main_new ();
|
||||
gtk_main ();
|
||||
|
||||
/* TODO: Accept multiple files. */
|
||||
if (argc < 2)
|
||||
ld_window_main_new (NULL);
|
||||
else
|
||||
ld_window_main_new (argv[1]);
|
||||
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue