now utilizing LiveSupport::Core::LocalizedObject and GtkLocalizedObject

added -pthread to build parameters
This commit is contained in:
maroy 2004-11-23 12:07:17 +00:00
parent 723e0459fa
commit 1e833bc16b
13 changed files with 336 additions and 40 deletions

View File

@ -21,7 +21,7 @@
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.3 $
# Version : $Revision: 1.4 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
#
# @configure_input@
@ -38,6 +38,8 @@ DOXYGEN = doxygen
#-------------------------------------------------------------------------------
# Basic directory and file definitions
#-------------------------------------------------------------------------------
PACKAGE_NAME = @PACKAGE_NAME@
BASE_DIR = @builddir@
DOC_DIR = ${BASE_DIR}/doc
DOXYGEN_DIR = ${DOC_DIR}/doxygen
@ -45,13 +47,21 @@ COVERAGE_DIR = ${DOC_DIR}/coverage
ETC_DIR = ${BASE_DIR}/etc
SRC_DIR = ${BASE_DIR}/src
TMP_DIR = ${BASE_DIR}/tmp
VAR_DIR = ${BASE_DIR}/var
USR_DIR = ${BASE_DIR}/../../usr
USR_INCLUDE_DIR = ${USR_DIR}/include
USR_LIB_DIR = ${USR_DIR}/lib
USR_BIN_DIR = ${USR_DIR}/bin
BOOST_INCLUDE_DIR = ${USR_INCLUDE_DIR}/boost-1_31
LIBXMLPP_INCLUDE_DIR = ${USR_INCLUDE_DIR}/libxml++-1.0
GENRB = ${USR_BIN_DIR}/genrb
GENRBOPTS = --destdir ${TMP_DIR} \
--encoding utf-8 \
--package-name ${PACKAGE_NAME} \
--strict
VPATH = ${SRC_DIR}
MODULES_DIR = ${BASE_DIR}/../../modules
@ -71,6 +81,9 @@ STORAGE_LIB_FILE = ${STORAGE_LIB_DIR}/lib${STORAGE_LIB}.a
GTKMM_CFLAGS=@GTKMM_CFLAGS@
GTKMM_LIBS=@GTKMM_LIBS@
ICU_CFLAGS=
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags-toolutil --ldflags-icuio`
TEST_RESULTS = ${DOC_DIR}/testResults.xml
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
TEST_XSLT = ../etc/testResultToHtml.xsl
@ -81,13 +94,16 @@ TEST_RUNNER = ${TMP_DIR}/testRunner
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
export LD_LIBRARY_PATH=${USR_LIB_DIR}
#-------------------------------------------------------------------------------
# Configuration parameters
#-------------------------------------------------------------------------------
CPPFLAGS = @CPPFLAGS@
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
-pedantic -Wall -Wno-long-long \
${ICU_CFLAGS} \
${GTKMM_CFLAGS} \
-I${USR_INCLUDE_DIR} \
-I${BOOST_INCLUDE_DIR} \
@ -95,7 +111,10 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \
-I${CORE_INCLUDE_DIR} \
-I${STORAGE_INCLUDE_DIR} \
-I${TMP_DIR}
LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} \
LDFLAGS = @LDFLAGS@ -pthread \
${ICU_LIBS} \
${GTKMM_LIBS} \
-L${USR_LIB_DIR} \
-L${CORE_LIB_DIR} \
-L${STORAGE_LIB_DIR}
@ -104,13 +123,18 @@ LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} \
# Dependencies
#-------------------------------------------------------------------------------
G_LIVESUPPORT_OBJS = ${TMP_DIR}/UiTestMainWindow.o \
${TMP_DIR}/GtkLocalizedObject.o \
${TMP_DIR}/LoginWindow.o
G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
${TMP_DIR}/${PACKAGE_NAME}_en.res \
${TMP_DIR}/${PACKAGE_NAME}_hu.res
G_LIVESUPPORT_EXE_OBJS = ${G_LIVESUPPORT_OBJS} \
G_LIVESUPPORT_EXE_OBJS = ${TMP_DIR}/main.o
FSDF = ${G_LIVESUPPORT_OBJS} \
${TMP_DIR}/main.o
G_LIVESUPPORT_EXE_LIBS = -l${STORAGE_LIB} -l${CORE_LIB} \
${GTKMM_LIBS} \
G_LIVESUPPORT_EXE_LIBS = -l${CORE_LIB} \
-lboost_date_time-gcc \
-lxmlrpc++ -lssl -lxml++-1.0
@ -125,7 +149,7 @@ TEST_RUNNER_LIBS = ${G_LIVESUPPORT_EXE_LIBS} -lcppunit -ldl
.PHONY: all dir_setup doc clean docclean depclean distclean
.PHONY: install start run_tests stop uninstall
all: dir_setup ${G_LIVESUPPORT_EXE}
all: dir_setup ${G_LIVESUPPORT_EXE} ${G_LIVESUPPORT_RES}
dir_setup: ${TMP_DIR} ${DOXYGEN_DIR}
@ -133,7 +157,7 @@ doc:
${DOXYGEN} ${DOXYGEN_CONFIG}
clean:
${RM} ${G_LIVESUPPORT_EXE_OBJS} ${G_LIVESUPPORT_EXE}
${RM} ${G_LIVESUPPORT_EXE_OBJS} ${G_LIVESUPPORT_RES} ${G_LIVESUPPORT_EXE}
${RM} ${TEST_RUNNER_OBJS} ${TEST_RUNNER}
${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info
@ -152,18 +176,17 @@ distclean: clean docclean
check: all ${TEST_RUNNER} run_tests
run_tests: ${TEST_RUNNER}
LD_LIBRARY_PATH=${USR_LIB_DIR} ${TEST_RUNNER} \
-o ${TEST_RESULTS} -s ${TEST_XSLT}
${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
run: ${G_LIVESUPPORT_EXE}
LD_LIBRARY_PATH=${USR_LIB_DIR} ${G_LIVESUPPORT_EXE}
run: all
${G_LIVESUPPORT_EXE}
#-------------------------------------------------------------------------------
# Specific targets
#-------------------------------------------------------------------------------
${G_LIVESUPPORT_EXE}: ${CORE_LIB_FILE} ${STORAGE_LIB_FILE} \
${G_LIVESUPPORT_EXE_OBJS}
${G_LIVESUPPORT_OBJS} ${G_LIVESUPPORT_EXE_OBJS}
${CXX} ${LDFLAGS} -o $@ $^ ${G_LIVESUPPORT_EXE_LIBS}
${TMP_DIR}:
@ -189,3 +212,6 @@ ${STORAGE_LIB_FILE}:
${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<
${TMP_DIR}/${PACKAGE_NAME}_%.res : ${VAR_DIR}/%.txt
${GENRB} ${GENRBOPTS} $^

View File

@ -21,7 +21,7 @@ dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
dnl
dnl Author : $Author: maroy $
dnl Version : $Revision: 1.3 $
dnl Version : $Revision: 1.4 $
dnl Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/configure.ac,v $
dnl-----------------------------------------------------------------------------
@ -35,7 +35,7 @@ dnl-----------------------------------------------------------------------------
AC_INIT(gLiveSupport, 0.1, bugs@campware.org)
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2004 Media Development Loan Fund under the GNU GPL])
AC_REVISION($Revision: 1.3 $)
AC_REVISION($Revision: 1.4 $)
AC_CONFIG_SRCDIR(../src/main.cxx)
@ -43,7 +43,7 @@ AC_CONFIG_HEADERS(configure.h)
AC_PROG_CXX()
AC_CHECK_HEADERS(sys/types.h unistd.h getopt.h signal.h sys/stat.h time.h)
AC_CHECK_HEADERS(stdio.h fcntl.h pthread.h sys/time.h)
AC_CHECK_HEADERS(stdio.h fcntl.h sys/time.h)
PKG_CHECK_MODULES(GTKMM,[gtkmm-2.4 >= 2.4.0])
AC_SUBST(GTKMM_CFLAGS)

View File

@ -0,0 +1,72 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/GtkLocalizedObject.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "GtkLocalizedObject.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Create a Glib ustring from an ICU UnicodeString
*----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref
GtkLocalizedObject :: unicodeStringToUstring(
Ptr<const UnicodeString>::Ref unicodeString)
throw ()
{
const UChar * uchars = unicodeString->getBuffer();
int32_t length = unicodeString->length();
Ptr<Glib::ustring>::Ref ustr(new Glib::ustring());
ustr->reserve(length);
while (length--) {
ustr->push_back((gunichar) (*(uchars++)));
}
return ustr;
}

View File

@ -0,0 +1,125 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/GtkLocalizedObject.h,v $
------------------------------------------------------------------------------*/
#ifndef GtkLocalizedObject_h
#define GtkLocalizedObject_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <glibmm/ustring.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Base class for localized objects, using GTK+ strings.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class GtkLocalizedObject : public LocalizedObject
{
public:
/**
* Constructor.
*
* @param bundle the resource bundle holding the localized
* resources for this window
*/
GtkLocalizedObject(Ptr<ResourceBundle>::Ref bundle) throw ()
: LocalizedObject(bundle)
{
}
/**
* Virtual destructor.
*/
virtual
~GtkLocalizedObject(void) throw ()
{
}
/**
* Convert an ICU unicode string to a Glib ustring.
*
* @param unicodeString the ICU unicode string to conver.
* @return the same string as supplied, in Glib ustring form.
*/
static Ptr<Glib::ustring>::Ref
unicodeStringToUstring(Ptr<const UnicodeString>::Ref unicodeString)
throw ();
/**
* Get a string from the resource bundle, as a Glib ustring.
*
* @param key the key identifying the requested string.
* @return the requested string
* @exception std::invalid_argument if there is no string for the
* specified key.
*/
Ptr<Glib::ustring>::Ref
getResourceUstring(const char * key)
throw (std::invalid_argument)
{
return unicodeStringToUstring(getResourceString(key));
}
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Core
} // namespace LiveSupport
#endif // GtkLocalizedObject_h

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LoginWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -34,10 +34,13 @@
#endif
#include <iostream>
#include <stdexcept>
#include "LoginWindow.h"
using namespace Glib;
using namespace LiveSupport::Core;
using namespace LiveSupport::GLiveSupport;
@ -55,14 +58,21 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
LoginWindow :: LoginWindow (void) throw ()
LoginWindow :: LoginWindow (Ptr<ResourceBundle>::Ref bundle)
throw ()
: GtkLocalizedObject(bundle)
{
table.reset(new Gtk::Table(2, 2, false));
loginLabel.reset(new Gtk::Label("login:"));
passwordLabel.reset(new Gtk::Label("password:"));
loginEntry.reset(new Gtk::Entry());
passwordEntry.reset(new Gtk::Entry());
okButton.reset(new Gtk::Button("OK"));
try {
table.reset(new Gtk::Table(2, 2, false));
loginLabel.reset(new Gtk::Label(*getResourceUstring("loginLabel")));
passwordLabel.reset(new Gtk::Label(
*getResourceUstring("passwordLabel")));
loginEntry.reset(new Gtk::Entry());
passwordEntry.reset(new Gtk::Entry());
okButton.reset(new Gtk::Button(*getResourceUstring("okButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
// set up the login label
loginLabel->set_name("loginLabel");

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LoginWindow.h,v $
------------------------------------------------------------------------------*/
@ -42,6 +42,8 @@
#include <string>
#include <unicode/resbund.h>
#include <gtkmm/window.h>
#include <gtkmm/button.h>
#include <gtkmm/label.h>
@ -49,6 +51,7 @@
#include <gtkmm/table.h>
#include "LiveSupport/Core/Ptr.h"
#include "GtkLocalizedObject.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -67,9 +70,9 @@ using namespace LiveSupport::Core;
* A window, handling user login.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class LoginWindow : public Gtk::Window
class LoginWindow : public Gtk::Window, public GtkLocalizedObject
{
protected:
@ -123,8 +126,11 @@ class LoginWindow : public Gtk::Window
public:
/**
* Constructor.
*
* @param bundle the resource bundle holding the localized
* resources for this window
*/
LoginWindow(void) throw ();
LoginWindow(Ptr<ResourceBundle>::Ref bundle) throw ();
/**
* Virtual destructor.

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -34,7 +34,6 @@
#endif
#include <iostream>
#include <gtkmm/main.h>
#include "LoginWindow.h"
@ -57,7 +56,9 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
UiTestMainWindow :: UiTestMainWindow (void) throw ()
UiTestMainWindow :: UiTestMainWindow (Ptr<ResourceBundle>::Ref bundle)
throw ()
: GtkLocalizedObject(bundle)
{
// set up the quit button
quitButton.reset(new Gtk::Button("quit"));
@ -110,9 +111,15 @@ UiTestMainWindow :: onQuitButtonClicked (void) throw ()
void
UiTestMainWindow :: onLoginButtonClicked (void) throw ()
{
std::cout << "invoking loginWindow" << std::endl;
Ptr<ResourceBundle>::Ref loginBundle;
try {
loginBundle = getBundle("loginWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
Ptr<LoginWindow>::Ref loginWindow(new LoginWindow());
Ptr<LoginWindow>::Ref loginWindow(new LoginWindow(loginBundle));
Gtk::Main::run(*loginWindow);

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.h,v $
------------------------------------------------------------------------------*/
@ -46,6 +46,8 @@
#include "LiveSupport/Core/Ptr.h"
#include "GtkLocalizedObject.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -63,9 +65,9 @@ using namespace LiveSupport::Core;
* A window, enabling interactive testing of UI components.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class UiTestMainWindow : public Gtk::Window
class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
{
protected:
/**
@ -99,8 +101,11 @@ class UiTestMainWindow : public Gtk::Window
public:
/**
* Constructor.
*
* @param bundle the resource bundle holding localized resources
*/
UiTestMainWindow(void) throw ();
UiTestMainWindow(Ptr<ResourceBundle>::Ref bundle)
throw ();
/**
* Virtual destructor.

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/main.cxx,v $
------------------------------------------------------------------------------*/
@ -37,9 +37,13 @@
#include "configure.h"
#endif
#include <iostream>
#include <unicode/resbund.h>
#include <gtkmm/main.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "UiTestMainWindow.h"
@ -68,11 +72,28 @@ int main ( int argc,
{
Gtk::Main kit(argc, argv);
Ptr<UiTestMainWindow>::Ref mainWindow(new UiTestMainWindow());
UErrorCode status = U_ZERO_ERROR;
Ptr<ResourceBundle>::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME,
"en",
status));
if (!U_SUCCESS(status)) {
std::cerr << "opening resource bundle a failure" << std::endl;
exit(EXIT_FAILURE);
}
Ptr<UiTestMainWindow>::Ref mainWindow(new UiTestMainWindow(bundle));
Ptr<ResourceBundle>::Ref loginBundle;
try {
loginBundle = mainWindow->getBundle("loginWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
}
// Shows the window and returns when it is closed.
Gtk::Main::run(*mainWindow);
return 0;
exit(EXIT_SUCCESS);
}

View File

@ -0,0 +1 @@
keep me

View File

@ -0,0 +1,3 @@
en:table
{
}

View File

@ -0,0 +1,10 @@
hu:table
{
loginWindow:table
{
loginLabel:string { "azonositó:" }
passwordLabel:string { "jelszó:" }
okButtonLabel:string { "Belépés" }
}
}

View File

@ -0,0 +1,10 @@
root:table
{
loginWindow:table
{
loginLabel:string { "login:" }
passwordLabel:string { "password:" }
okButtonLabel:string { "OK" }
}
}