summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2011-02-19 13:22:06 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2011-02-19 22:49:20 +0100
commit781273c236c9a17d13d813e5689f72bac6053818 (patch)
treee0d67d95b620445170143b2537e13c771549a81c
parent7fa6efbaec6ee743a9ddfbab81b3e8079448e107 (diff)
downloadlogdiag-781273c236c9a17d13d813e5689f72bac6053818.tar.gz
logdiag-781273c236c9a17d13d813e5689f72bac6053818.tar.xz
logdiag-781273c236c9a17d13d813e5689f72bac6053818.zip
Open files from command line.
-rw-r--r--src/ld-window-main.c11
-rw-r--r--src/ld-window-main.h2
-rw-r--r--src/logdiag.c11
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;
}