glom r1555 - in trunk: . glom glom/libglom
- From: arminb svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1555 - in trunk: . glom glom/libglom
- Date: Fri, 11 Apr 2008 14:27:26 +0100 (BST)
Author: arminb
Date: Fri Apr 11 14:27:26 2008
New Revision: 1555
URL: http://svn.gnome.org/viewvc/glom?rev=1555&view=rev
Log:
2008-04-11 Armin Burgmeier <armin openismus com>
* glom/libglom/utils.cc (Utils::show_help): Replace gnome_help_display
by constructing a path to the help file, making a ghelp: URI out of it
and passing it to g_app_info_launch_default_for_uri().
* glom/xsl_utils.cc (GlomXslUtils::transform_and_open): Replace
gnome_url_show by g_app_info_launch_default_for_uri().
* glom/main.cc (main): Don't call gnome_program_init().
* configure.in: Remove the libgnome dependency.
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/glom/libglom/utils.cc
trunk/glom/main.cc
trunk/glom/xsl_utils.cc
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Fri Apr 11 14:27:26 2008
@@ -86,7 +86,7 @@
fi
# Do not require, goocanvas and gtksourceviewmm in client only mode
-REQUIRED_LIBS="bakery-2.6 >= 2.4.2 gtkmm-2.4 >= 2.10 gthread-2.0 libxslt >= 1.1.10 pygda-3.0 pygtk-2.0 >= 2.6.0 libgnome-2.0 >= 2.6.0 libgdamm-3.0 >= 2.9.82 libgda-3.0 >= 3.0.1 libgda-postgres-3.0 goocanvasmm-1.0 >= 0.2.0"
+REQUIRED_LIBS="bakery-2.6 >= 2.4.2 gtkmm-2.4 >= 2.10 gthread-2.0 libxslt >= 1.1.10 pygda-3.0 pygtk-2.0 >= 2.6.0 libgdamm-3.0 >= 2.9.82 libgda-3.0 >= 3.0.1 libgda-postgres-3.0 goocanvasmm-1.0 >= 0.2.0"
if test $enable_client_only != yes; then
REQUIRED_LIBS="$REQUIRED_LIBS gtksourceviewmm-2.0"
fi
@@ -95,13 +95,12 @@
if test "$enable_maemo" = "yes"; then
REQUIRED_LIBS="$REQUIRED_LIBS hildonmm libepc-1.0 >= 0.3.1 avahi-ui";
elif test "$win32" = "true"; then
- REQUIRED_LIBS="$REQUIRED_LIBS gtkmm-2.4 >= 2.10 libgnome-2.0 >= 2.6.0";
+ REQUIRED_LIBS="$REQUIRED_LIBS gtkmm-2.4 >= 2.10";
else
- REQUIRED_LIBS="$REQUIRED_LIBS libgnome-2.0 >= 2.6.0 iso-codes libepc-1.0 >= 0.3.1 avahi-ui";
+ REQUIRED_LIBS="$REQUIRED_LIBS iso-codes libepc-1.0 >= 0.3.1 avahi-ui";
fi
# Checks for libraries
-# We need libgnome only for gnome_help_display().:
PKG_CHECK_MODULES(GLOM, $REQUIRED_LIBS)
GLOM_LIBS="$GLOM_LIBS --no-undefined"
Modified: trunk/glom/libglom/utils.cc
==============================================================================
--- trunk/glom/libglom/utils.cc (original)
+++ trunk/glom/libglom/utils.cc Fri Apr 11 14:27:26 2008
@@ -28,10 +28,7 @@
#include <glibmm/i18n.h>
#include <gtkmm/messagedialog.h>
-#ifndef GLOM_ENABLE_MAEMO
-#include <libgnome/gnome-url.h>
-#include <libgnome/gnome-help.h>
-#endif
+#include <gio/gio.h> // For g_app_info_launch_default_for_uri
#ifdef GLOM_ENABLE_MAEMO
#include <hildonmm/note.h>
@@ -58,6 +55,42 @@
const unsigned int Glom::Utils::DEFAULT_SPACING_SMALL = 6;
#endif //GLOM_ENABLE_MAEMO
+namespace
+{
+
+// Basically copied from libgnome (gnome-help.c, Copyright (C) 2001 Sid Vicious
+// Copyright (C) 2001 Jonathan Blandford <jrb alum mit edu>), but C++ified
+std::string locate_help_file(const std::string& path, const std::string& doc_name)
+{
+ // g_get_language_names seems not to be wrapped by glibmm
+ const char* const* lang_list = g_get_language_names ();
+
+ for(unsigned int j = 0; lang_list[j] != NULL; ++j)
+ {
+ const char* lang = lang_list[j];
+
+ /* This has to be a valid language AND a language with
+ * no encoding postfix. The language will come up without
+ * encoding next. */
+ if (lang == NULL || strchr(lang, '.') != NULL)
+ continue;
+
+ const char* exts[] = { "", ".xml", ".docbook", ".sgml", ".html", NULL };
+ for(unsigned i = 0; exts[i] != NULL; ++i)
+ {
+ std::string name = doc_name + exts[i];
+ std::string full = Glib::build_filename(path, Glib::build_filename(lang, name));
+
+ if(Glib::file_test(full, Glib::FILE_TEST_EXISTS))
+ return full;
+ }
+ }
+
+ return std::string();
+}
+
+}
+
namespace Glom
{
@@ -804,6 +837,8 @@
void Utils::show_help(const Glib::ustring& id)
{
+ // TODO_maemo: Show help on maemo by some other means
+#ifndef GLOM_ENABLE_MAEMO
GError* err = 0;
const gchar* pId;
if (id.length())
@@ -813,18 +848,36 @@
else
{
pId = 0;
- }
+ }
- // TODO_maemo: Show help on maemo by some other means
-#ifndef GLOM_ENABLE_MAEMO
- if (!gnome_help_display("glom.xml", pId, &err))
+ try
{
- std::string message = std::string(_("Could not display help: ")) + err->message;
- Gtk::MessageDialog* dialog = new Gtk::MessageDialog(message, false, Gtk::MESSAGE_ERROR);
- dialog->run();
- delete dialog;
- g_error_free(err);
- }
+ const char* path = DATADIR "/gnome/help/glom";
+ std::string help_file = locate_help_file(path, "glom.xml");
+ if(help_file.empty())
+ {
+ throw std::runtime_error(_("No help file available"));
+ }
+ else
+ {
+ std::string uri = "ghelp:" + help_file;
+ if(pId) { uri += "?"; uri += pId; }
+
+ // g_app_info_launch_default_for_uri seems not to be wrapped by giomm
+ if(!g_app_info_launch_default_for_uri(uri.c_str(), NULL, &err))
+ {
+ std::string message(err->message);
+ g_error_free(err);
+ throw std::runtime_error(message);
+ }
+ }
+ }
+ catch(const std::exception& ex)
+ {
+ std::string message(std::string(_("Could not display help: ")) + ex.what());
+ Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_ERROR);
+ dialog.run();
+ }
#endif
}
Modified: trunk/glom/main.cc
==============================================================================
--- trunk/glom/main.cc (original)
+++ trunk/glom/main.cc Fri Apr 11 14:27:26 2008
@@ -25,9 +25,6 @@
//#include <gnome.h>
#include <gtkmm/main.h>
-#ifndef GLOM_ENABLE_MAEMO
-#include <libgnome/gnome-init.h> // For gnome_program_init().
-#endif
#include <giomm.h>
#ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -200,14 +197,6 @@
try
#endif
{
-#ifndef GLOM_ENABLE_MAEMO
- //Initialize gnome_program, so that we can use gnome_help_display().
- gnome_program_init(PACKAGE, VERSION, LIBGNOME_MODULE, argc, argv,
- GNOME_PARAM_HUMAN_READABLE_NAME, _("Glom"),
- GNOME_PROGRAM_STANDARD_PROPERTIES, NULL);
-#endif
-
-
Gtk::Main mainInstance(argc, argv, context);
Bakery::init();
Modified: trunk/glom/xsl_utils.cc
==============================================================================
--- trunk/glom/xsl_utils.cc (original)
+++ trunk/glom/xsl_utils.cc Fri Apr 11 14:27:26 2008
@@ -31,10 +31,6 @@
#include <giomm.h>
#include <glibmm/i18n.h>
-#ifndef GLOM_ENABLE_MAEMO
-#include <libgnome/gnome-url.h>
-#endif
-
#include <sstream> //For stringstream
#include <iostream>
@@ -119,20 +115,14 @@
if(parent_window)
Frame_Glom::show_ok_dialog(_("Report Finished"), _("The report will now be opened in your web browser."), *parent_window, Gtk::MESSAGE_INFO);
-#ifdef GLOM_ENABLE_MAEMO
- // TODO_maemo: We don't have libgnome available. A quick search did not yield
- // a similar method in the hildon API. Perhaps we can just use
- // gnome_vfs_url_show()?
-#else
//Use the GNOME browser:
GError* gerror = 0;
- gnome_url_show(temp_uri.c_str(), &gerror); //This is in libgnome.
- if(gerror)
+ // g_app_info_launch_default_for_uri seems not to be wrapped by giomm
+ if(!g_app_info_launch_default_for_uri(temp_uri.c_str(), NULL, &gerror))
{
- std::cerr << "Error while calling gnome_url_show(): " << gerror->message << std::endl;
- g_clear_error(&gerror);
+ std::cerr << "Error while calling g_app_info_launch_default_for_uri(): " << gerror->message << std::endl;
+ g_error_free(gerror);
}
-#endif
}
Glib::ustring GlomXslUtils::xslt_process(const xmlpp::Document& xml_document, const std::string& filepath_xslt)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]