[ekiga/ds-gtk-application] EkigaApp: Moved all of the initialization stuff to GtkApplication.



commit 41a8d03d54cec3fdef7869c23adca20c14963e58
Author: Damien Sandras <dsandras beip be>
Date:   Sun Feb 9 14:19:08 2014 +0100

    EkigaApp: Moved all of the initialization stuff to GtkApplication.

 .gitignore                                |    2 +-
 Makefile.am                               |   17 ++++++-
 configure.ac                              |    2 +-
 lib/engine/gui/gtk-frontend/ekiga-app.cpp |   67 ++++++++++++++++++++++++--
 src/Makefile.am                           |   20 +--------
 src/main.cpp                              |   73 -----------------------------
 6 files changed, 81 insertions(+), 100 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 85b10b3..ec99551 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,7 +56,7 @@ src/dbus-helper/org.ekiga.Helper.service
 src/ekiga
 src/ekiga-config-tool
 src/ekiga-helper
-src/revision.h
+revision.h
 lib/engine/components/hal-dbus/hal-marshal.*
 stamp-h1
 help/*/*.mo
diff --git a/Makefile.am b/Makefile.am
index f845904..bebb853 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,9 +71,24 @@ EXTRA_DIST = \
 Applicationsdir = $(datadir)/applications
 Applications_DATA = $(DESKTOP_FILE)
 
+BUILT_SOURCES = revision.h
+
+GIT_REVISION=\"$$(git describe)\"
+CACHED_REVISION=$$(cat revision.h 2>/dev/null | cut -c24-)
+
+revision.h:
+       @if test -d ".git" -a -n "$$(which git)"; then \
+          if test "x$(GIT_REVISION)" != "x$(CACHED_REVISION)"; then \
+            echo "#define EKIGA_REVISION $(GIT_REVISION)" > revision.h; \
+          fi \
+        else \
+          if !(test -e "./revision.h"); then\
+            echo "#define EKIGA_REVISION \"unknown\"" > revision.h; \
+          fi \
+        fi
 
 ### Dist Clear
-DISTCLEANFILES=gnome-doc-utils.make ekiga.desktop org.gnome.ekiga.gschema
+DISTCLEANFILES=gnome-doc-utils.make ekiga.desktop org.gnome.ekiga.gschema revision.h
 
 MAINTAINERCLEANFILES= \
        Makefile.in aclocal.m4 compile config.guess config.sub \
diff --git a/configure.ac b/configure.ac
index 3775f9f..a0667ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_INIT([ekiga],[4.1.0],[http://bugzilla.gnome.org/enter_bug.cgi?product=ekiga])
 AC_CANONICAL_TARGET
 AC_PREREQ([2.53])
 AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_SRCDIR(src/ekiga.cpp)
+AC_CONFIG_SRCDIR(src/main.cpp)
 AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz tar-ustar subdir-objects])
 
 AM_MAINTAINER_MODE([enable])
diff --git a/lib/engine/gui/gtk-frontend/ekiga-app.cpp b/lib/engine/gui/gtk-frontend/ekiga-app.cpp
index f328ee2..55eedfd 100644
--- a/lib/engine/gui/gtk-frontend/ekiga-app.cpp
+++ b/lib/engine/gui/gtk-frontend/ekiga-app.cpp
@@ -39,6 +39,7 @@
 
 #include "config.h"
 #include "ekiga-settings.h"
+#include "revision.h"
 
 #include "trigger.h"
 #include "ekiga-app.h"
@@ -68,6 +69,7 @@
 #include "call-core.h"
 #include "engine.h"
 #include "runtime.h"
+#include "platform/platform.h"
 
 #include "gmwindow.h"
 
@@ -75,16 +77,23 @@
 #include "platform/winpaths.h"
 #include <windows.h>
 #include <shellapi.h>
+#include <gdk/gdkwin32.h>
+#include <cstdio>
 #define WIN32_HELP_DIR "help"
 #define WIN32_HELP_FILE "index.html"
+#else
+#include <signal.h>
+#include <gdk/gdkx.h>
 #endif
 
 #ifdef HAVE_DBUS
 #include "../../../../src/dbus-helper/dbus.h"
 #endif
 
-
 #include <glib/gi18n.h>
+#include <ptlib.h>
+#include <opal/buildopts.h>
+
 
 /*
  * The GmApplication
@@ -257,11 +266,46 @@ gm_application_startup (GApplication *app)
 {
   GmApplication *self = GM_APPLICATION (app);
 
+  gchar *path = NULL;
   GtkBuilder *builder = NULL;
   GMenuModel *app_menu = NULL;
 
   G_APPLICATION_CLASS (gm_application_parent_class)->startup (app);
 
+  /* Globals */
+#if !GLIB_CHECK_VERSION(2,36,0)
+  g_type_init ();
+#endif
+#if !GLIB_CHECK_VERSION(2,32,0)
+  g_thread_init();
+#endif
+
+#ifndef WIN32
+  signal (SIGPIPE, SIG_IGN);
+#endif
+
+  /* initialize platform-specific code */
+  gm_platform_init ();
+#ifdef WIN32
+  // plugins (i.e. the audio/video ptlib/opal codecs) are searched in ./plugins
+  chdir (win32_datadir ());
+#endif
+
+
+  /* Gettext initialization */
+  path = g_build_filename (DATA_DIR, "locale", NULL);
+  textdomain (GETTEXT_PACKAGE);
+  bindtextdomain (GETTEXT_PACKAGE, path);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  g_free (path);
+
+  /* Application name */
+  g_set_application_name (_("Ekiga Softphone"));
+#ifndef WIN32
+  setenv ("PULSE_PROP_application.name", _("Ekiga Softphone"), true);
+  setenv ("PA_PROP_MEDIA_ROLE", "phone", true);
+#endif
+
   const gchar *menu =
     "<?xml version=\"1.0\"?>"
     "<interface>"
@@ -350,6 +394,8 @@ gm_application_shutdown (GApplication *app)
   self->priv->core.reset ();
   Ekiga::Runtime::quit ();
 
+  gm_platform_shutdown ();
+
   G_APPLICATION_CLASS (gm_application_parent_class)->shutdown (app);
 }
 
@@ -467,10 +513,21 @@ gm_application_command_line (GApplication *app,
 #endif
 
 #if PTRACING
-    if (debug_level != 0)
-      PTrace::Initialise (PMAX (PMIN (8, debug_level), 0), NULL,
-                          PTrace::Timestamp | PTrace::Thread
-                          | PTrace::Blocks | PTrace::DateAndTime);
+    PTrace::Initialise (PMAX (PMIN (8, debug_level), 0), NULL,
+                        PTrace::Timestamp | PTrace::Thread
+                        | PTrace::Blocks | PTrace::DateAndTime);
+    PTRACE (1, "Ekiga version "
+            << MAJOR_VERSION << "." << MINOR_VERSION << "." << BUILD_NUMBER);
+#ifdef EKIGA_REVISION
+    PTRACE (1, "Ekiga git revision: " << EKIGA_REVISION);
+#endif
+    PTRACE (1, "PTLIB version " << PTLIB_VERSION);
+    PTRACE (1, "OPAL version " << OPAL_VERSION);
+#ifdef HAVE_DBUS
+    PTRACE (1, "DBUS support enabled");
+#else
+    PTRACE (1, "DBUS support disabled");
+#endif
 #endif
   }
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 523c32a..e225ec7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,8 +27,6 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)/src/dbus-helper/                \
        -I$(top_builddir)/src/dbus-helper/
 
-BUILT_SOURCES = src/revision.h
-
 bin_PROGRAMS = ekiga
 
 EXTRA_PROGRAMS =
@@ -71,7 +69,7 @@ nodist_ekiga_helper_SOURCES =         \
 
 ekiga_helper_LDADD = $(DBUS_LIBS)
 
-BUILT_SOURCES += dbus-helper/dbus-helper-stub.h dbus-helper/dbus-stub.h
+BUILT_SOURCES = dbus-helper/dbus-helper-stub.h dbus-helper/dbus-stub.h
 
 dbus-helper/dbus-helper-stub.h: dbus-helper/dbus-helper-stub.xml build-subdir-stamp
        $(LIBTOOL) --mode=execute dbus-binding-tool --prefix=helper --mode=glib-server --output=$@ $<
@@ -99,20 +97,6 @@ endif
 .rc.o:
        $(RC) $< -o $@ -I $(top_srcdir)
 
-GIT_REVISION=\"$$(cd ../.git; git describe )\"
-CACHED_REVISION=$$(cat revision.h 2>/dev/null | cut -c24-)
-
-src/revision.h:
-       @if test -d "../.git" -a -n "$$(which git)"; then \
-          if test "x$(GIT_REVISION)" != "x$(CACHED_REVISION)"; then \
-            echo "#define EKIGA_REVISION $(GIT_REVISION)" > revision.h; \
-          fi \
-        else \
-          if !(test -e "./revision.h"); then\
-            echo "#define EKIGA_REVISION \"unknown\"" > revision.h; \
-          fi \
-        fi
-
 AM_CXXFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) $(DBUS_CFLAGS) $(OPAL_CFLAGS) $(PTLIB_CFLAGS) $(BOOST_CPPFLAGS) 
$(XML_CFLAGS)
 AM_LIBS = $(GTK_LIBS) $(GLIB_LIBS) $(DBUS_LIBS) $(OPAL_LIBS) $(PTLIB_LIBS) $(BOOST_LDFLAGS) $(XML_LIBS)
 
@@ -133,5 +117,3 @@ CLEANFILES = \
        $(service_DATA)         \
        build-subdir-stamp      \
        $(BUILT_SOURCES)
-
-DISTCLEANFILES = revision.h
diff --git a/src/main.cpp b/src/main.cpp
index fd7e672..8975fd5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,33 +34,11 @@
  *   description          : This file contains the main method.
  */
 
-#include "revision.h"
 #include "config.h"
 
-#include "platform/platform.h"
 
 #include <glib/gi18n.h>
 
-#include <ptlib.h>
-#include <opal/buildopts.h> // only for OPAL_VERSION!
-
-
-#ifndef WIN32
-#include <signal.h>
-#include <gdk/gdkx.h>
-#else
-#include "platform/winpaths.h"
-#include <gdk/gdkwin32.h>
-#include <cstdio>
-#endif
-
-#include "ekiga-settings.h"
-
-#include "engine.h"
-#include "runtime.h"
-
-#include "call-core.h"
-
 #include "ekiga-app.h"
 
 #ifdef WIN32
@@ -74,59 +52,8 @@ main (int argc,
       char ** argv,
       char ** /*envp*/)
 {
-  gchar *path = NULL;
-
-  /* Globals */
-#if !GLIB_CHECK_VERSION(2,36,0)
-  g_type_init ();
-#endif
-#if !GLIB_CHECK_VERSION(2,32,0)
-  g_thread_init();
-#endif
-
-#ifndef WIN32
-  signal (SIGPIPE, SIG_IGN);
-#endif
-
-  /* initialize platform-specific code */
-  gm_platform_init ();
-#ifdef WIN32
-  // plugins (i.e. the audio/video ptlib/opal codecs) are searched in ./plugins
-  chdir (win32_datadir ());
-#endif
-
-  /* Gettext initialization */
-  path = g_build_filename (DATA_DIR, "locale", NULL);
-  textdomain (GETTEXT_PACKAGE);
-  bindtextdomain (GETTEXT_PACKAGE, path);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-  g_free (path);
-
-  /* Application name */
-  g_set_application_name (_("Ekiga Softphone"));
-#ifndef WIN32
-  setenv ("PULSE_PROP_application.name", _("Ekiga Softphone"), true);
-  setenv ("PA_PROP_MEDIA_ROLE", "phone", true);
-#endif
-
-  PTRACE (1, "Ekiga version "
-          << MAJOR_VERSION << "." << MINOR_VERSION << "." << BUILD_NUMBER);
-#ifdef EKIGA_REVISION
-  PTRACE (1, "Ekiga git revision: " << EKIGA_REVISION);
-#endif
-  PTRACE (1, "PTLIB version " << PTLIB_VERSION);
-  PTRACE (1, "OPAL version " << OPAL_VERSION);
-#ifdef HAVE_DBUS
-  PTRACE (1, "DBUS support enabled");
-#else
-  PTRACE (1, "DBUS support disabled");
-#endif
-
   ekiga_main (argc, argv);
 
-  /* deinitialize platform-specific code */
-  gm_platform_shutdown ();
-
   return 0;
 }
 


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