nemiver r817 - in branches/0.5: . src src/common src/workbench tests



Author: dodji
Date: Sun May 18 13:36:54 2008
New Revision: 817
URL: http://svn.gnome.org/viewvc/nemiver?rev=817&view=rev

Log:
Merge patch #814 from trunk.

it is to remove libgnome dep.
the merge command line was:
svn merge -r813:814 svn+ssh://svn.gnome.org/svn/nemiver/trunk


Added:
   branches/0.5/tests/test-env.cc
      - copied unchanged from r814, /trunk/tests/test-env.cc
Modified:
   branches/0.5/ChangeLog
   branches/0.5/configure.ac
   branches/0.5/src/common/nmv-env.cc
   branches/0.5/src/common/nmv-env.h
   branches/0.5/src/main.cc
   branches/0.5/src/workbench/nmv-workbench.cc
   branches/0.5/tests/Makefile.am

Modified: branches/0.5/configure.ac
==============================================================================
--- branches/0.5/configure.ac	(original)
+++ branches/0.5/configure.ac	Sun May 18 13:36:54 2008
@@ -28,8 +28,6 @@
 AC_SUBST([LIBGTHREAD_VERSION])
 LIBGLIBMM_VERSION=2.14
 AC_SUBST([LIBGLIBMM_VERSION])
-LIBGNOME_VERSION=2.0
-AC_SUBST([LIBGNOME_VERSION])
 LIBGNOMEVFS_VERSION=2.14
 AC_SUBST([LIBGNOMEVFS_VERSION])
 LIBXML2_VERSION=2.6.22
@@ -237,7 +235,6 @@
 PKG_CHECK_MODULES(LIBXML2, [libxml-2.0 >= $LIBXML2_VERSION])
 PKG_CHECK_MODULES(LIBGMODULE, [gmodule-2.0 >= $LIBGMODULE_VERSION])
 PKG_CHECK_MODULES(LIBGTHREAD, [gthread-2.0 >= $LIBGTHREAD_VERSION])
-PKG_CHECK_MODULES(LIBGNOME, [libgnome-2.0 >= $LIBGNOME_VERSION])
 PKG_CHECK_MODULES(LIBVFS, [$VFS_PKG >= $VFS_VERSION])
 PKG_CHECK_MODULES(LIBGTOP, [libgtop-2.0 >= $LIBGTOP_VERSION])
 PKG_CHECK_MODULES(GCONF,[gconf-2.0 >= $GCONF_VERSION])
@@ -302,11 +299,9 @@
 
 dnl library dependencies for the nemiver workbench module
 NEMIVERWORKBENCH_LIBS="$NEMIVERCOMMON_LIBS $LIBGTKMM_LIBS $LIBGLADEMM_LIBS"
-NEMIVERWORKBENCH_LIBS="$NEMIVERWORKBENCH_LIBS $LIBGNOME_LIBS"
 NEMIVERWORKBENCH_LIBS="$NEMIVERWORKBENCH_LIBS $LIBVFS_LIBS"
 NEMIVERWORKBENCH_CFLAGS="$NEMIVERCOMMON_CFLAGS $LIBGTKMM_CFLAGS "
 NEMIVERWORKBENCH_CFLAGS="$NEMIVERWORKBENCH_CFLAGS $LIBGLADEMM_CFLAGS"
-NEMIVERWORKBENCH_CFLAGS="$NEMIVERWORKBENCH_CFLAGS $LIBGNOME_CFLAGS"
 NEMIVERWORKBENCH_CFLAGS="$NEMIVERWORKBENCH_CFLAGS $LIBVFS_CFLAGS"
 
 AC_SUBST(NEMIVERWORKBENCH_LIBS)
@@ -325,8 +320,8 @@
 AC_SUBST(NEMIVERDBGPERSP_LIBS)
 AC_SUBST(NEMIVERDBGPERSP_CFLAGS)
 
-NEMIVER_LIBS="$NEMIVERUICOMMON_LIBS $LIBGNOME_LIBS"
-NEMIVER_CFLAGS="$NEMIVERUICOMMON_CFLAGS $LIBGNOME_CFLAGS"
+NEMIVER_LIBS="$NEMIVERUICOMMON_LIBS"
+NEMIVER_CFLAGS="$NEMIVERUICOMMON_CFLAGS"
 
 AC_SUBST(NEMIVER_LIBS)
 AC_SUBST(NEMIVER_CFLAGS)

Modified: branches/0.5/src/common/nmv-env.cc
==============================================================================
--- branches/0.5/src/common/nmv-env.cc	(original)
+++ branches/0.5/src/common/nmv-env.cc	Sun May 18 13:36:54 2008
@@ -39,9 +39,9 @@
 
 using namespace std ;
 
-namespace nemiver {
-namespace common {
-namespace env {
+NEMIVER_BEGIN_NAMESPACE (nemiver)
+NEMIVER_BEGIN_NAMESPACE (common)
+NEMIVER_BEGIN_NAMESPACE (env)
 
 class Initializer
 {
@@ -279,6 +279,86 @@
     return result ;
 }
 
-}//end namespace env
-}//end namespace common
-}//end namespace nemiver
+UString
+build_path_to_help_file (const UString &a_file_name)
+{
+    //So, before all, don't forget that a locale name has the general form:
+    //language[_territory][ codeset][ modifier]
+    //
+    //Once that is said, let's not forget either that
+    //the help file is located under the directory:
+    //$prefix/share/gnome/help/nemiver/language[_territory]
+    //So the goal of this function is to go look in that directory
+    //to see if a_file_name exists there. If so, return the path to it.
+    //Otherwise, return an empty string.
+    UString result;
+    UString prefix (get_install_prefix ());
+    vector<string> path_elems;
+    path_elems.push_back (prefix.c_str ());
+    path_elems.push_back ("share");
+    path_elems.push_back ("gnome");
+    path_elems.push_back ("help");
+    path_elems.push_back ("nemiver");
+
+    string help_dir = Glib::build_filename (path_elems);
+
+    if (!Glib::file_test (help_dir, Glib::FILE_TEST_IS_DIR)) {
+        LOG_ERROR ("help dir " << help_dir << " does not exist");
+        return "";
+    }
+
+    locale loc ("");
+    UString loc_name (loc.name ());
+    LOG_DD ("locale name: " << loc_name);
+    string lang_dir = Glib::build_filename (help_dir, loc_name.c_str ());
+    if (!Glib::file_test (lang_dir, Glib::FILE_TEST_IS_DIR)) {
+        LOG_DD ("lang dir '" << lang_dir << "' does not exist");
+        //let's try now to extract the <language>_<territory> part of the
+        //locale, that can be of the more general form:
+        //language[_territory][ codeset][ modifier]
+        vector<UString> tmp;
+        tmp = loc_name.split (".");
+        if (tmp.empty ()) {
+            goto locale_language;
+        }
+        loc_name = tmp[0];
+        lang_dir = Glib::build_filename (help_dir, loc_name.c_str ());
+        LOG_DD ("trying locale name: " << lang_dir);
+        if (!Glib::file_test (lang_dir, Glib::FILE_TEST_IS_DIR)) {
+            LOG_DD ("lang dir '" << lang_dir << "' does not exist");
+            //let's try to extract the <language> part of the locale now.
+locale_language:
+            tmp.clear ();
+            tmp = loc_name.split ("_");
+            if (tmp.empty ()) {
+                goto c_locale;
+            }
+            loc_name = tmp[0];
+            lang_dir = Glib::build_filename (help_dir, loc_name.c_str ());
+            LOG_DD ("trying locale name: " << lang_dir);
+            if (!Glib::file_test (lang_dir, Glib::FILE_TEST_IS_DIR)) {
+                LOG_DD ("lang dir '" << lang_dir << "' does not exist");
+                //okay so let's fall back to the C locale then.
+c_locale:
+                loc_name = "C";
+                lang_dir = Glib::build_filename (help_dir, loc_name.c_str ());
+                LOG_DD ("trying locale name: " << lang_dir);
+                if (!Glib::file_test (lang_dir, Glib::FILE_TEST_IS_DIR)) {
+                    LOG_ERROR ("could not find a proper help dir");
+                    return result;
+                }
+            }
+        }
+    }
+    result = Glib::build_filename (lang_dir, a_file_name);
+    if (!Glib::file_test (result, Glib::FILE_TEST_IS_REGULAR)) {
+        LOG_ERROR ("file " << result << " does not exist!");
+        result.clear ();
+    }
+    return result;
+}
+
+NEMIVER_END_NAMESPACE (env)
+NEMIVER_END_NAMESPACE (common)
+NEMIVER_END_NAMESPACE (nemiver)
+

Modified: branches/0.5/src/common/nmv-env.h
==============================================================================
--- branches/0.5/src/common/nmv-env.h	(original)
+++ branches/0.5/src/common/nmv-env.h	Sun May 18 13:36:54 2008
@@ -34,9 +34,9 @@
 #include "nmv-ustring.h"
 #include "nmv-exception.h"
 
-namespace nemiver {
-namespace common {
-namespace env {
+NEMIVER_BEGIN_NAMESPACE (nemiver)
+NEMIVER_BEGIN_NAMESPACE (common)
+NEMIVER_BEGIN_NAMESPACE (env)
 
 void do_init () ;
 
@@ -76,10 +76,11 @@
 
 NEMIVER_API UString build_path_to_image_file (const UString &a_image_file_name) ;
 
-}//end namespace env
-}//end namespace common
-}//end namespace nemiver
+NEMIVER_API UString build_path_to_help_file (const UString &a_file_name);
 
+NEMIVER_END_NAMESPACE (env)
+NEMIVER_END_NAMESPACE (common)
+NEMIVER_END_NAMESPACE (nemiver)
 
 #endif //__NEMIVER_ENV_H__
 

Modified: branches/0.5/src/main.cc
==============================================================================
--- branches/0.5/src/main.cc	(original)
+++ branches/0.5/src/main.cc	Sun May 18 13:36:54 2008
@@ -27,7 +27,6 @@
 #include <gtkmm/window.h>
 #include <libglademm.h>
 #include <glib/gi18n.h>
-#include <libgnome/gnome-init.h>
 #include "nmv-exception.h"
 #include "nmv-initializer.h"
 #include "nmv-i-workbench.h"
@@ -439,11 +438,6 @@
 
     parse_command_line (a_argc, a_argv);
 
-    //intialize gnome libraries
-    gnome_program_init (PACKAGE, PACKAGE_VERSION,
-                        LIBGNOME_MODULE, a_argc, a_argv,
-                        GNOME_PROGRAM_STANDARD_PROPERTIES, NULL);
-
 
     //**********************************
     //load the workbench dynamic module

Modified: branches/0.5/src/workbench/nmv-workbench.cc
==============================================================================
--- branches/0.5/src/workbench/nmv-workbench.cc	(original)
+++ branches/0.5/src/workbench/nmv-workbench.cc	Sun May 18 13:36:54 2008
@@ -27,7 +27,6 @@
 #include <vector>
 #include <iostream>
 #include <glib/gi18n.h>
-#include <libgnome/gnome-help.h>
 #ifdef WITH_GIO
 #include <giomm/init.h>
 #else
@@ -227,9 +226,20 @@
 void
 Workbench::on_contents_menu_item_action ()
 {
-    gnome_help_display("nemiver.xml",
-                       NULL, /*link id*/
-                       NULL /*GError*/);
+    NEMIVER_TRY
+
+    UString help_url = "ghelp:nemiver";
+    LOG_DD ("launching help url: " << help_url);
+    UString path_to_help =
+        nemiver::common::env::build_path_to_help_file ("nemiver.xml");
+    THROW_IF_FAIL (!path_to_help.empty ());
+    UString cmd_line ("yelp " + path_to_help);
+    LOG_DD ("going to spawn: " << cmd_line);
+    bool is_ok = g_spawn_command_line_async (cmd_line.c_str (), NULL);
+    if (!is_ok) {
+        LOG_ERROR ("failed to spawn " << is_ok);
+    }
+    NEMIVER_CATCH
 }
 
 void

Modified: branches/0.5/tests/Makefile.am
==============================================================================
--- branches/0.5/tests/Makefile.am	(original)
+++ branches/0.5/tests/Makefile.am	Sun May 18 13:36:54 2008
@@ -11,7 +11,8 @@
 runtestderef \
 runtestlocalvarslist runtestcpplexer \
 runtestcppparser  \
-runtestlibtoolwrapperdetection
+runtestlibtoolwrapperdetection \
+runtestenv
 
 
 else
@@ -104,6 +105,11 @@
 $(top_builddir)/src/langs/libnemivercparser.la \
 $(top_builddir)/src/common/libnemivercommon.la
 
+runtestenv_SOURCES=test-env.cc
+runtestenv_LDADD= NEMIVERCOMMON_LIBS@ \
+ BOOST_UNIT_TEST_FRAMEWORK_STATIC_LIB@ \
+$(top_builddir)/src/common/libnemivercommon.la
+
 docore_SOURCES=do-core.cc
 docore_LDADD= NEMIVERCOMMON_LIBS@ \
 $(top_builddir)/src/common/libnemivercommon.la



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