[libchamplainmm] Add Champlain::init() and GtkChamplain::init()



commit dc0702ce4a0bafb6da9c99890dd065c598c7e7b3
Author: Juan R. García Blanco <juanrgar gmail com>
Date:   Sat May 31 20:37:35 2014 +0200

    Add Champlain::init() and GtkChamplain::init()

 champlain-gtk/champlainmm-gtk.h           |    7 +++--
 champlain-gtk/champlainmm-gtk/filelist.am |    5 ++-
 champlain-gtk/champlainmm-gtk/init.cc     |   41 +++++++++++++++++++++++++++++
 champlain-gtk/champlainmm-gtk/init.h      |   31 ++++++++++++++++++++++
 champlain-gtk/champlainmm-gtk/wrap_init.h |    2 +-
 champlain/champlainmm.h                   |    1 +
 champlain/champlainmm/filelist.am         |    5 ++-
 champlain/champlainmm/init.cc             |   41 +++++++++++++++++++++++++++++
 champlain/champlainmm/init.h              |   31 ++++++++++++++++++++++
 demos/embed-demo.cc                       |    6 ++--
 10 files changed, 159 insertions(+), 11 deletions(-)
---
diff --git a/champlain-gtk/champlainmm-gtk.h b/champlain-gtk/champlainmm-gtk.h
index c67ae12..893aeb6 100644
--- a/champlain-gtk/champlainmm-gtk.h
+++ b/champlain-gtk/champlainmm-gtk.h
@@ -16,11 +16,12 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef CHAMPLAINMMGTK_H_INCLUDED
-#define CHAMPLAINMMGTK_H_INCLUDED
+#ifndef CHAMPLAINMM_GTK_H_INCLUDED
+#define CHAMPLAINMM_GTK_H_INCLUDED
 
 #include <champlainmmgtkconfig.h>
 
+#include <champlainmm-gtk/init.h>
 #include <champlainmm-gtk/embed.h>
 
-#endif /* !CHAMPLAINMMGTK_H_INCLUDED */
+#endif /* !CHAMPLAINMM_GTK_H_INCLUDED */
diff --git a/champlain-gtk/champlainmm-gtk/filelist.am b/champlain-gtk/champlainmm-gtk/filelist.am
index c0e5b33..44bca67 100644
--- a/champlain-gtk/champlainmm-gtk/filelist.am
+++ b/champlain-gtk/champlainmm-gtk/filelist.am
@@ -3,6 +3,7 @@
 files_built_cc = $(files_hg:.hg=.cc) wrap_init.cc
 files_built_h  = $(files_hg:.hg=.h)
 files_built_ph = $(patsubst %.hg,private/%_p.h,$(files_hg))
-files_extra_cc =
-files_extra_h  = wrap_init.h
+
+files_extra_cc = init.cc
+files_extra_h  = init.h wrap_init.h
 files_extra_ph =
diff --git a/champlain-gtk/champlainmm-gtk/init.cc b/champlain-gtk/champlainmm-gtk/init.cc
new file mode 100644
index 0000000..bd5c7db
--- /dev/null
+++ b/champlain-gtk/champlainmm-gtk/init.cc
@@ -0,0 +1,41 @@
+/* Copyright (c) 2014  Juan R. García Blanco <juanrgar gmail com>
+ *
+ * This file is part of libchamplainmm.
+ *
+ * libchamplainmm is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * libchamplainmm 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "init.h"
+#include "wrap_init.h"
+#include <glibmm/init.h>
+#include <champlainmm/init.h>
+
+namespace GtkChamplain
+{
+
+void init(int *argc, char **argv[])
+{
+  static bool is_initialized = false;
+
+  if (!is_initialized)
+  {
+    Glib::init();
+    Champlain::init(argc, argv);
+    wrap_init();
+
+    is_initialized = true;
+  }
+}
+
+} // namespace GtkChamplain
diff --git a/champlain-gtk/champlainmm-gtk/init.h b/champlain-gtk/champlainmm-gtk/init.h
new file mode 100644
index 0000000..01266cc
--- /dev/null
+++ b/champlain-gtk/champlainmm-gtk/init.h
@@ -0,0 +1,31 @@
+/* Copyright (c) 2014  Juan R. García Blanco <juanrgar gmail com>
+ *
+ * This file is part of libchamplainmm.
+ *
+ * libchamplainmm is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * libchamplainmm 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _CHAMPLAINMM_GTK_INIT_H
+#define _CHAMPLAINMM_GTK_INIT_H
+
+namespace GtkChamplain
+{
+
+/** Initialize champlainmm.
+ */
+void init(int *argc, char **argv[]);
+
+} // namespace GtkChamplain
+
+#endif /* _CHAMPLAINMM_GTK_INIT_H */
diff --git a/champlain-gtk/champlainmm-gtk/wrap_init.h b/champlain-gtk/champlainmm-gtk/wrap_init.h
index d715425..694498f 100644
--- a/champlain-gtk/champlainmm-gtk/wrap_init.h
+++ b/champlain-gtk/champlainmm-gtk/wrap_init.h
@@ -19,6 +19,6 @@
 #ifndef LIBCHAMPLAINMMGTK_WRAP_INIT_H_INCLUDED
 #define LIBCHAMPLAINMMGTK_WRAP_INIT_H_INCLUDED
 
-namespace Gtk { void wrap_init(); }
+namespace GtkChamplain { void wrap_init(); }
 
 #endif /* !LIBCHAMPLAINMMGTK_WRAP_INIT_H_INCLUDED */
diff --git a/champlain/champlainmm.h b/champlain/champlainmm.h
index 64f62eb..9d14d5d 100644
--- a/champlain/champlainmm.h
+++ b/champlain/champlainmm.h
@@ -21,6 +21,7 @@
 
 #include <champlainmmconfig.h>
 
+#include <champlainmm/init.h>
 #include <champlainmm/base-marker.h>
 #include <champlainmm/cache.h>
 #include <champlainmm/debug.h>
diff --git a/champlain/champlainmm/filelist.am b/champlain/champlainmm/filelist.am
index c0e5b33..44bca67 100644
--- a/champlain/champlainmm/filelist.am
+++ b/champlain/champlainmm/filelist.am
@@ -3,6 +3,7 @@
 files_built_cc = $(files_hg:.hg=.cc) wrap_init.cc
 files_built_h  = $(files_hg:.hg=.h)
 files_built_ph = $(patsubst %.hg,private/%_p.h,$(files_hg))
-files_extra_cc =
-files_extra_h  = wrap_init.h
+
+files_extra_cc = init.cc
+files_extra_h  = init.h wrap_init.h
 files_extra_ph =
diff --git a/champlain/champlainmm/init.cc b/champlain/champlainmm/init.cc
new file mode 100644
index 0000000..b698423
--- /dev/null
+++ b/champlain/champlainmm/init.cc
@@ -0,0 +1,41 @@
+/* Copyright (c) 2014  Juan R. García Blanco <juanrgar gmail com>
+ *
+ * This file is part of libchamplainmm.
+ *
+ * libchamplainmm is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * libchamplainmm 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "init.h"
+#include "wrap_init.h"
+#include <glibmm/init.h>
+#include <cluttermm/init.h>
+
+namespace Champlain
+{
+
+void init(int *argc, char **argv[])
+{
+  static bool is_initialized = false;
+
+  if (!is_initialized)
+  {
+    Glib::init();
+    Clutter::init(argc, argv);
+    wrap_init();
+
+    is_initialized = true;
+  }
+}
+
+} // namespace Champlain
diff --git a/champlain/champlainmm/init.h b/champlain/champlainmm/init.h
new file mode 100644
index 0000000..8fbaf89
--- /dev/null
+++ b/champlain/champlainmm/init.h
@@ -0,0 +1,31 @@
+/* Copyright (c) 2014  Juan R. García Blanco <juanrgar gmail com>
+ *
+ * This file is part of libchamplainmm.
+ *
+ * libchamplainmm is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * libchamplainmm 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _CHAMPLAINMM_INIT_H
+#define _CHAMPLAINMM_INIT_H
+
+namespace Champlain
+{
+
+/** Initialize champlainmm.
+ */
+void init(int *argc, char **argv[]);
+
+} // namespace Champlain
+
+#endif /* _CHAMPLAINMM_INIT_H */
diff --git a/demos/embed-demo.cc b/demos/embed-demo.cc
index 3d78a66..4f493f3 100644
--- a/demos/embed-demo.cc
+++ b/demos/embed-demo.cc
@@ -38,7 +38,7 @@ EmbedDemoWindow::EmbedDemoWindow()
 {
   // Window properties
   set_title("ChamplainEmbed demo");
-  set_default_size(600, 400);
+  set_default_size(800, 600);
   set_border_width(6);
 
   // Header bar
@@ -63,9 +63,9 @@ EmbedDemoWindow::~EmbedDemoWindow()
 
 int main(int argc, char *argv[])
 {
-  Clutter::init(&argc, &argv);
+  GtkChamplain::init(&argc, &argv);
 
-  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.libchamplainmm.embed-demo");
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.libchamplainmm.demo");
 
   EmbedDemoWindow window;
 


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