From 781273c236c9a17d13d813e5689f72bac6053818 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 19 Feb 2011 13:22:06 +0100
Subject: Open files from command line.
---
src/ld-window-main.c | 11 +++++++++--
src/ld-window-main.h | 2 +-
src/logdiag.c | 11 +++++++----
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index 6191bc2..3599da6 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -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);
diff --git a/src/ld-window-main.h b/src/ld-window-main.h
index 8d28150..2eccc12 100644
--- a/src/ld-window-main.h
+++ b/src/ld-window-main.h
@@ -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
diff --git a/src/logdiag.c b/src/logdiag.c
index 99aa8de..fd871f2 100644
--- a/src/logdiag.c
+++ b/src/logdiag.c
@@ -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;
}
--
cgit v1.2.3-70-g09d2