+2004-04-27 Angus Leeming <leeming@lyx.org>
+
+ * ghelpers.[Ch]: new files.
+ (findGladeFile): search the top_srcdir() as welll as LibFileSearch
+ when looking for glade files.
+
+ * Makefile.am: add new files.
+
+ * GAboutlyx.C (doBuild):
+ * GMathDelim.C (doBuild):
+ * GMathPanel.C (doBuild):
+ * GPrint.C (doBuild):
+ * GTableCreate.C (doBuild):
+ * GText.C (doBuild):
+ * GUrl.C (doBuild): use findGladeFile in preference to LibFileSearch.
+ Prevents crash when using a not-installed lyx executable.
+
2004-04-20 Angus Leeming <leeming@lyx.org>
* Makefile.am (SUBDIRS): add gimages.
#include "ControlAboutlyx.h"
#include "GAboutlyx.h"
-#include "support/filetools.h"
+#include "ghelpers.h"
#include "version.h"
using std::ostringstream;
void GAboutlyx::doBuild()
{
- string const gladeName =
- lyx::support::LibFileSearch("glade", "aboutlyx", "glade");
+ string const gladeName = findGladeFile("aboutlyx");
xml_ = Gnome::Glade::Xml::create(gladeName);
Gtk::Label * version;
Gtk::Label * credits;
#include "ControlMath.h"
#include "GMathDelim.h"
-#include "support/filetools.h"
+#include "ghelpers.h"
+
#include "support/lstrings.h"
+
#include "delim.xbm"
#include "delim0.xpm"
void GMathDelim::doBuild()
{
- string const gladeName =
- lyx::support::LibFileSearch("glade", "mathDelim", "glade");
+ string const gladeName = findGladeFile("mathDelim");
xml_ = Gnome::Glade::Xml::create(gladeName);
Gtk::Button * ok;
Gtk::Button * apply;
#include "ControlMath.h"
#include "GMathPanel.h"
-#include "support/filetools.h"
+#include "ghelpers.h"
+
#include "support/lstrings.h"
#include "deco.xpm"
void GMathPanel::doBuild()
{
- string const gladeName =
- lyx::support::LibFileSearch("glade", "mathPanel", "glade");
+ string const gladeName = findGladeFile("mathPanel");
xml_ = Gnome::Glade::Xml::create(gladeName);
Gtk::Button * close;
Gtk::VBox * vbox;
#include "GPrint.h"
#include "ControlPrint.h"
-#include "support/filetools.h"
+#include "ghelpers.h"
+
#include "PrinterParams.h"
#include "support/lstrings.h"
void GPrint::doBuild()
{
- string const gladeName = LibFileSearch("glade", "print", "glade");
+ string const gladeName = findGladeFile("print");
xml_ = Gnome::Glade::Xml::create(gladeName);
xml_->get_widget("Printer", printer_);
xml_->get_widget("File", file_);
#include "ControlTabularCreate.h"
#include "GTableCreate.h"
-#include "support/filetools.h"
+#include "ghelpers.h"
#include "support/lstrings.h"
using std::string;
void GTableCreate::doBuild()
{
- string const gladeName =
- lyx::support::LibFileSearch("glade", "tableCreate", "glade");
+ string const gladeName = findGladeFile("tableCreate");
xml_ = Gnome::Glade::Xml::create(gladeName);
Gtk::Button * ok;
Gtk::Button * apply;
#include <libglademm.h>
#include "support/lstrings.h"
-#include "support/filetools.h"
#include "ControlCommand.h"
#include "GText.h"
+#include "ghelpers.h"
#include "IdSc.h"
using std::string;
void GText::doBuild()
{
- string const gladeName =
- lyx::support::LibFileSearch("glade", "text", "glade");
+ string const gladeName = findGladeFile("text");
xml_ = Gnome::Glade::Xml::create(gladeName);
Gtk::Label * label;
Gtk::Button * restore;
#include "ControlCommand.h"
#include "GUrl.h"
-#include "support/filetools.h"
+#include "ghelpers.h"
#include "support/lstrings.h"
using std::string;
void GUrl::doBuild()
{
- string const gladeName =
- lyx::support::LibFileSearch("glade", "url", "glade");
+ string const gladeName = findGladeFile("url");
xml_ = Gnome::Glade::Xml::create(gladeName);
Gtk::Button * restore;
Gtk::Button * ok;
# Alphabetical order please. It makes it easier to figure out what's missing.
libgtk_la_SOURCES = \
+ ghelpers.C \
+ ghelpers.h \
lyx_gui.C \
GtkmmX.h \
xftFontLoader.C \
--- /dev/null
+/**
+ * \file ghelpers.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ghelpers.h"
+
+#include "debug.h"
+
+#include "support/filetools.h"
+#include "support/path_defines.h"
+
+using std::string;
+
+string const findGladeFile(string const & name)
+{
+ // First, search in the installation directories.
+
+ string filename =
+ lyx::support::LibFileSearch("glade", name, "glade");
+
+ if (!filename.empty())
+ return filename;
+
+ // Second, search in the src tree.
+ string const dir =
+ lyx::support::AddPath(lyx::support::top_srcdir(),
+ "src/frontends/gtk/glade");
+
+ filename = lyx::support::ChangeExtension(name, ".glade");
+ filename = lyx::support::AddName(dir, filename);
+
+ if (!lyx::support::IsFileReadable(filename)) {
+ lyxerr << "Unable to find glade file \"" << name
+ << "\". libglade is going to crash..." << std::endl;
+ }
+
+ return filename;
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file ghelpers.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GHELPERS_H
+#define GHELPERS_H
+
+#include <string>
+
+/** name is the name of the glade file, without path or extension.
+ * Eg, "aboutlyx", "tableCreate".
+ */
+std::string const findGladeFile(std::string const & name);
+
+#endif // NOT GHELPERS_H
+2004-04-27 Angus Leeming <leeming@lyx.org>
+
+ * path_defines.{h,C.in}: expose top_srcdir, renamed from
+ lyx_top_srcdir.
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* filetools.C:
return ld;
}
+} // namespace anon
+
+
+namespace lyx {
+namespace support {
+
/* The absolute path to the top of the lyx build tree.
* (Make-time value.)
*/
-string const & lyx_top_srcdir()
+string const & top_srcdir()
{
static string const lts = "%TOP_SRCDIR%";
return lts;
}
-} // namespace anon
-
-
-namespace lyx {
-namespace support {
-
/* The absolute path to the system-level lyx locale directory.
* (Make-time value.)
string const buildlyxdir = MakeAbsPath("../lib", binpath);
if (!FileSearch(buildlyxdir, "lyxrc.defaults").empty()) {
- searchpath += AddPath(lyx_top_srcdir(), "lib") + ';';
+ searchpath += AddPath(top_srcdir(), "lib") + ';';
build_lyxdir(buildlyxdir);
lyxerr[Debug::INIT] << "Checking whether LyX is run in "
"place... yes" << endl;
} while (followlink);
// <absolute top srcdir>/lib
- searchpath += AddPath(lyx_top_srcdir(), "lib") + ';';
+ searchpath += AddPath(top_srcdir(), "lib") + ';';
// Hardcoded dir
searchpath += lyx_dir();
std::string const & lyx_localedir();
+/* The absolute path to the top of the lyx build tree.
+ * (Make-time value.)
+ */
+std::string const & top_srcdir();
+
/// The absolute path to the lyx support files we're actually going to use.
std::string const & system_lyxdir();