mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Search the src tree for glade files, so preventing an unnecessary crash
in the gtk frontend. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8699 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5dfeef80ef
commit
f439fef46d
@ -1,3 +1,20 @@
|
||||
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.
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "ControlAboutlyx.h"
|
||||
#include "GAboutlyx.h"
|
||||
#include "support/filetools.h"
|
||||
#include "ghelpers.h"
|
||||
#include "version.h"
|
||||
|
||||
using std::ostringstream;
|
||||
@ -145,8 +145,7 @@ GAboutlyx::GAboutlyx(Dialog & parent)
|
||||
|
||||
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;
|
||||
|
@ -15,8 +15,10 @@
|
||||
|
||||
#include "ControlMath.h"
|
||||
#include "GMathDelim.h"
|
||||
#include "support/filetools.h"
|
||||
#include "ghelpers.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "delim.xbm"
|
||||
#include "delim0.xpm"
|
||||
|
||||
@ -88,8 +90,7 @@ GMathDelim::GMathDelim(Dialog & parent) :
|
||||
|
||||
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;
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
#include "ControlMath.h"
|
||||
#include "GMathPanel.h"
|
||||
#include "support/filetools.h"
|
||||
#include "ghelpers.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "deco.xpm"
|
||||
@ -98,8 +99,7 @@ GMathPanel::GMathPanel(Dialog & parent)
|
||||
|
||||
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;
|
||||
|
@ -14,7 +14,8 @@
|
||||
|
||||
#include "GPrint.h"
|
||||
#include "ControlPrint.h"
|
||||
#include "support/filetools.h"
|
||||
#include "ghelpers.h"
|
||||
|
||||
#include "PrinterParams.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -122,7 +123,7 @@ void GPrint::onFromToEdit()
|
||||
|
||||
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_);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "ControlTabularCreate.h"
|
||||
#include "GTableCreate.h"
|
||||
#include "support/filetools.h"
|
||||
#include "ghelpers.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::string;
|
||||
@ -27,8 +27,7 @@ GTableCreate::GTableCreate(Dialog & parent)
|
||||
|
||||
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;
|
||||
|
@ -13,9 +13,9 @@
|
||||
#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;
|
||||
@ -42,8 +42,7 @@ void GText::update()
|
||||
|
||||
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;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "ControlCommand.h"
|
||||
#include "GUrl.h"
|
||||
#include "support/filetools.h"
|
||||
#include "ghelpers.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::string;
|
||||
@ -28,8 +28,7 @@ GUrl::GUrl(Dialog & parent)
|
||||
|
||||
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;
|
||||
|
@ -15,6 +15,8 @@ libgtk_la_LIBADD = xforms.lo @GTK_FRONTEND_LIBS@ @XFORMS_LIBS@
|
||||
|
||||
# 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 \
|
||||
|
46
src/frontends/gtk/ghelpers.C
Normal file
46
src/frontends/gtk/ghelpers.C
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* \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;
|
||||
}
|
22
src/frontends/gtk/ghelpers.h
Normal file
22
src/frontends/gtk/ghelpers.h
Normal file
@ -0,0 +1,22 @@
|
||||
// -*- 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
|
@ -1,3 +1,8 @@
|
||||
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:
|
||||
|
@ -50,16 +50,6 @@ string const & lyx_dir()
|
||||
return ld;
|
||||
}
|
||||
|
||||
|
||||
/* The absolute path to the top of the lyx build tree.
|
||||
* (Make-time value.)
|
||||
*/
|
||||
string const & lyx_top_srcdir()
|
||||
{
|
||||
static string const lts = "%TOP_SRCDIR%";
|
||||
return lts;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
@ -67,6 +57,16 @@ namespace lyx {
|
||||
namespace support {
|
||||
|
||||
|
||||
/* The absolute path to the top of the lyx build tree.
|
||||
* (Make-time value.)
|
||||
*/
|
||||
string const & top_srcdir()
|
||||
{
|
||||
static string const lts = "%TOP_SRCDIR%";
|
||||
return lts;
|
||||
}
|
||||
|
||||
|
||||
/* The absolute path to the system-level lyx locale directory.
|
||||
* (Make-time value.)
|
||||
*/
|
||||
@ -149,7 +149,7 @@ bool setLyxPaths()
|
||||
|
||||
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;
|
||||
@ -233,7 +233,7 @@ bool setLyxPaths()
|
||||
} while (followlink);
|
||||
|
||||
// <absolute top srcdir>/lib
|
||||
searchpath += AddPath(lyx_top_srcdir(), "lib") + ';';
|
||||
searchpath += AddPath(top_srcdir(), "lib") + ';';
|
||||
// Hardcoded dir
|
||||
searchpath += lyx_dir();
|
||||
|
||||
|
@ -20,6 +20,11 @@ namespace support {
|
||||
|
||||
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user