[atomato] Add main window and fix build



commit f684348ed968ea7a6701b7d836832bc6739d1238
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Sun Nov 15 04:01:15 2015 +0100

    Add main window and fix build

 .gitignore           |   23 ++++++++++++++
 src/Makefile.am      |   24 +++++++++++++--
 src/config.vapi      |    6 ++++
 src/main-window.vala |   36 ++++++++++++++++++++++
 src/main.vala        |   79 +++++++++++++++++++++++++++++++++++++++++--------
 5 files changed, 152 insertions(+), 16 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 282522d..259df3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,25 @@
 Makefile
 Makefile.in
+aclocal.m4
+autom4te.cache
+compile
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libtool
+ltmain.sh
+missing
+po/Makefile.in.in
+po/POTFILES
+po/stamp-it
+stamp-h1
+.deps
+.libs
+*.o
+src/atomato
diff --git a/src/Makefile.am b/src/Makefile.am
index 604584d..c1bca5c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,8 +1,26 @@
+AM_CPPFLAGS = \
+       -DGETTEXT_PACKAGE=\""$(GETTEXT_PACKAGE)"\"  \
+       -DGNOMELOCALEDIR=\""$(localedir)"\"         \
+       $(NULL)
+
 bin_PROGRAMS = atomato
 
-atomato_SOURCES =              \
-       main.vala
+atomato_VALAFLAGS = \
+       $(ATOMATO_VALAFLAGS)            \
+       --target-glib=2.38                      \
+       --pkg gtk+-3.0                          \
+       --pkg gio-2.0                           \
+       --pkg gio-unix-2.0
+
+atomato_SOURCES =      \
+       config.vapi             \
+       main.vala               \
+       main-window.vala
 
 atomato_LDADD =                                \
        $(ATOMATO_LIBS)                         \
-       $(ATOMATO_GUI_VALAFLAGS)
+       $(ATOMATO_GUI_LIBS)
+
+AM_CFLAGS =                            \
+       $(ATOMATO_CFLAGS)               \
+       $(ATOMATO_GUI_CFLAGS)
diff --git a/src/config.vapi b/src/config.vapi
new file mode 100644
index 0000000..c08f03c
--- /dev/null
+++ b/src/config.vapi
@@ -0,0 +1,6 @@
+[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
+namespace Config {
+    public const string VERSION;
+    public const string GETTEXT_PACKAGE;
+    public const string GNOMELOCALEDIR;
+}
diff --git a/src/main-window.vala b/src/main-window.vala
new file mode 100644
index 0000000..c50fa92
--- /dev/null
+++ b/src/main-window.vala
@@ -0,0 +1,36 @@
+/* GNOME Automation Engine
+ * Copyright (C) 2006-2015 The GNOME Foundation
+ *
+ * Authors:
+ *      Rodrigo Moya (rodrigo gnome org)
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using Gtk;
+
+namespace Atomato
+{
+    public class MainWindow : Gtk.ApplicationWindow
+    {
+        public MainWindow (Atomato.Application app)
+        {
+            Object (application: app);
+
+            show ();
+        }
+    }
+}
diff --git a/src/main.vala b/src/main.vala
index 16f9eba..03061ca 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -1,8 +1,8 @@
-/* GNOME Automator
- * Copyright (C) 2006 The GNOME Foundation
+/* GNOME Automation Engine
+ * Copyright (C) 2006-2015 The GNOME Foundation
  *
  * Authors:
- *      Rodrigo Moya (rodrigo gnome-db org)
+ *      Rodrigo Moya (rodrigo gnome org)
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -20,19 +20,72 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <gtk/gtkmain.h>
-#include "atomato-gui.h"
+using Gtk;
 
-MainWindow *main_window = NULL;
-
-int
-main (int argc, char *argv[])
+namespace Atomato
 {
-       gtk_init (&argc, &argv);
+       public class Application : Gtk.Application
+       {
+               const OptionEntry[] option_entries = {
+            { "version", 'v', 0, OptionArg.NONE, null, N_("Print version information and exit"), null },
+            { null }
+        };
+
+        const GLib.ActionEntry[] action_entries = {
+            { "quit", on_quit_activate }
+        };
+
+               protected override void activate ()
+               {
+            new MainWindow (this);
+        }
+
+               public static new Application get_default ()
+               {
+            return (Application) GLib.Application.get_default ();
+        }
+
+               protected override void startup ()
+               {
+                       base.startup ();
+               }
+
+               protected override int handle_local_options (GLib.VariantDict options)
+               {
+            if (options.contains("version")) {
+                print ("%s %s\n", Environment.get_application_name (), Config.VERSION);
+                return 0;
+            }
+
+            return -1;
+        }
+
+               protected override void shutdown ()
+               {
+                       base.shutdown ();
+               }
+
+               public Application ()
+               {
+            Object (application_id: "org.gnome.atomato", flags: ApplicationFlags.HANDLES_OPEN);
+
+            add_main_option_entries (option_entries);
+            add_action_entries (action_entries, this);
+        }
 
-       main_window = main_window_new ();
+               void on_quit_activate ()
+               {
+                       quit ();
+               }
+       }
 
-       gtk_main ();
+       public static int main (string[] args)
+       {
+               Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR);
+               Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
+               Intl.textdomain (Config.GETTEXT_PACKAGE);
 
-       return 0;
+               var app = new Atomato.Application ();
+               return app.run ();
+       }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]