merged the libglade branch (3104:3183) back to the trunk

This commit is contained in:
fgerlits 2007-08-03 11:13:44 +00:00
parent e6b5b273c4
commit 6d9cf9f3db
122 changed files with 10646 additions and 5791 deletions

View file

@ -66,6 +66,7 @@ using namespace LiveSupport::Core;
class Bar class Bar
{ {
private: private:
/** /**
* A static member variable. * A static member variable.
*/ */
@ -76,25 +77,38 @@ class Bar
*/ */
int barInt; int barInt;
public: public:
/** /**
* Default constructor. * Default constructor.
*/ */
Bar (void) throw () Bar (void) throw ()
{ {
} }
/** /**
* Say something. * Say something.
* *
* @param parameter a parameter we don't care about.
* @return the bar string. * @return the bar string.
* @exception std::exception on some problems. * @exception std::exception on some problems.
*/ */
const std::string const std::string
sayBar (void) throw (std::exception) sayBar(void) throw (std::exception);
/**
* Say something else.
*
* @param firstParam the first parameter (a pointer).
* @param secondParam the second parameter (a smart pointer).
* @return the bar string.
*/
void
sayFoo(ClassOne * firstParam,
Ptr<ClassTwo>::Ref secondParam)
throw ()
{ {
return barStr; // TODO: implement this important function.
} }
}; };

View file

@ -97,6 +97,7 @@ system:<br>
<li><a href="http://curl.haxx.se/">curl</a> &gt;= 7.12.3</li> <li><a href="http://curl.haxx.se/">curl</a> &gt;= 7.12.3</li>
<li><a href="http://www.gtk.org/">gtk+</a> &gt;= 2.6.10</li> <li><a href="http://www.gtk.org/">gtk+</a> &gt;= 2.6.10</li>
<li><a href="http://www.gtkmm.org/">gtkmm</a> &gt;= 2.6.5</li> <li><a href="http://www.gtkmm.org/">gtkmm</a> &gt;= 2.6.5</li>
<li><a href="http://www.gtkmm.org/">libglademm</a> &gt;= 2.6.2</li>
<li><a href="http://www.ibm.com/software/globalization/icu/">icu</a> <li><a href="http://www.ibm.com/software/globalization/icu/">icu</a>
&gt;= 3.0</li> &gt;= 3.0</li>
<li><a href="http://libxmlplusplus.sourceforge.net/">libxml++</a> <li><a href="http://libxmlplusplus.sourceforge.net/">libxml++</a>

View file

@ -0,0 +1,99 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8"
http-equiv="content-type">
<title>File Conventions</title>
<meta content="$Author$" name="author">
</head>
<body>
<h1>Preface</h1>
This document is part of the <a href="http://campcaster.campware.org/">Campcaster</a>
project, Copyright &#169; 2007 <a href="http://www.mdlf.org/">Media
Development Loan Fund</a>, under the GNU <a
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
<ul>
<li>Author: $Author$</li>
<li>Version: $Revision$</li>
<li>Location: $URL$</li>
</ul>
<h1>Scope</h1>
This document describes the conventions used for the Glade window design files.<br>
<h1>Introduction</h1>
The following are spacing and other conventions observed in the Glade files
<code>src/products/gLiveSupport/var/glade/*.glade</code>. They are loosely
based on the design documentation <code>styleguide.pdf</code>.
<h1>Structural conventions</h1>
<p>Each toplevel has its own file, named the same as the C++ class which
controls it, with the extension <code>.glade</code>. For example:
<code>ScratchpadWindow.glade</code>, <code>LiveModeWindow.glade</code>.
Pop-up dialogs go into the Glade file of the toplevel which pops them up.
<p>Each toplevel should be a GtkWindow, except for pop-ups like the Login
window, confirmation dialogs etc., which are GtkDialogs or subclasses of it.</p>
<p>Always use boxes, because this assures that the widgets get positioned
and resized properly when the window is resized. Each toplevel should
contain a single GtkVBox, which contains some number of GtkHBoxes and
GtkHButtonBoxes, which in turn contain the widgets.</p>
<p>If a group of widgets belong logically together, put them in their own
GtkHBox or GtkVBox.</p>
<h1>Naming conventions</h1>
<p>Widgets which need to be referred to from the controlling class should
have a camelCased name followed by "1", with the function of the widget first
and the kind of the widget second: e.g., <code>playButton1</code>,
<code>fileNameEntry1</code>, <code>scratchpadTreeView1</code>. Such names
must be unique in their own Glade file. If there is a group of
widgets with same function, they should be numbered starting with 1,
like this: <code>myGroupButton1</code>, <code>myGroupButton2</code>,
<code>myGroupButton3</code> etc.</p>
<p><em>The reason for the "1" at the end of names, and for the unusual
1-based numbering for groups of widgets is that this is how Glade does it.
If you follow these guidelines, and copy or move part of the window using
copy-paste, the widget names will stay correct. If a widget had a name
without a number, and you cut and then repasted it, its name would get an
extra "1" at the end.</em></p>
<p>Widgets which do not need to be referred can keep their Glade-assigned
names like <code>treeview3</code>; these do not need to be unique.</p>
<h1>Sizing conventions</h1>
<p>Each toplevel should have a border width of <strong>8 pixels</strong>.</p>
<p>Use spacing, not padding. For example, if some widgets are packed into
<code>hbox1</code>, and we want 8 pixels between each widget, set the spacing
of <code>hbox1</code> to 8 pixels; leave the padding of the widgets at 0.
To put some space before the first and after the last widget, set the spacing
of the outer box which contains <code>hbox1</code>.
For finetuning, if spacing can not be used, you can add padding to boxes,
but not to widgets.</p>
<p>Normal spacing between widgets is <strong>8 pixels</strong>. Spacing
between related widgets (e.g., an input field and its label) is
<strong>3 pixels</strong>.</p>
<h1>Other conventions</h1>
<p>Use stock buttons whenever possible. This makes the application behave
much nicer with themes.</p>
<br><br><br>
</body>
</html>

View file

@ -45,6 +45,7 @@ Build-Depends: debhelper (>= 4.0.0),
libboost-date-time-dev (>= 1.33.1), libboost-date-time-dev (>= 1.33.1),
libgtk2.0-dev (>= 2.6.10), libgtk2.0-dev (>= 2.6.10),
libgtkmm-2.4-dev (>= 2.6.5), libgtkmm-2.4-dev (>= 2.6.5),
libglademm-2.4-dev (>= 2.6.2),
libxml++2.6-dev (>= 2.8.1), libxml++2.6-dev (>= 2.8.1),
libicu34-dev, libicu34-dev,
apache2, apache2,
@ -164,6 +165,7 @@ Depends: ${shlibs:Depends},
libicu34, libicu34,
libgtk2.0-0 (>= 2.6.10), libgtk2.0-0 (>= 2.6.10),
libgtkmm-2.4-1c2a (>= 2.6.5) libgtkmm-2.4-1c2a (>= 2.6.5)
libglademm-2.4-1c2a (>= 2.6.2)
Description: A radio program automation and support tool. Description: A radio program automation and support tool.
Campcaster is the first free and open radio management software that Campcaster is the first free and open radio management software that
provides live studio broadcast capabilities as well as remote automation provides live studio broadcast capabilities as well as remote automation

View file

@ -149,7 +149,8 @@ CORE_LIB_OBJS = ${TMP_DIR}/UniqueId.o \
${TMP_DIR}/NumericRangeConstraint.o \ ${TMP_DIR}/NumericRangeConstraint.o \
${TMP_DIR}/EnumerationConstraint.o \ ${TMP_DIR}/EnumerationConstraint.o \
${TMP_DIR}/RdsItem.o \ ${TMP_DIR}/RdsItem.o \
${TMP_DIR}/RdsContainer.o ${TMP_DIR}/RdsContainer.o \
${TMP_DIR}/NumericTools.o
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
${TMP_DIR}/FileToolsTest.o \ ${TMP_DIR}/FileToolsTest.o \
@ -170,7 +171,8 @@ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
${TMP_DIR}/SearchCriteriaTest.o \ ${TMP_DIR}/SearchCriteriaTest.o \
${TMP_DIR}/MetadataTypeContainerTest.o \ ${TMP_DIR}/MetadataTypeContainerTest.o \
${TMP_DIR}/AsyncStateTest.o \ ${TMP_DIR}/AsyncStateTest.o \
${TMP_DIR}/RdsContainerTest.o ${TMP_DIR}/RdsContainerTest.o \
${TMP_DIR}/NumericToolsTest.o
TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \ TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
${TMP_DIR}/${PACKAGE_NAME}_en.res \ ${TMP_DIR}/${PACKAGE_NAME}_en.res \

View file

@ -281,6 +281,7 @@ class AudioClip : public Configurable,
* use the constructor with (title, playlength, uri) arguments. * use the constructor with (title, playlength, uri) arguments.
* *
* @param id the id of the audio clip. * @param id the id of the audio clip.
* @param title the title of the audio clip.
* @param playlength the playing length of the audio clip. * @param playlength the playing length of the audio clip.
* @param uri the location of the sound file corresponding to * @param uri the location of the sound file corresponding to
* this audio clip object (optional) * this audio clip object (optional)
@ -397,7 +398,7 @@ class AudioClip : public Configurable,
* Set the ID of the object. This is only allowed if the ID was * Set the ID of the object. This is only allowed if the ID was
* a null pointer; once the ID is set, it can not be changed. * a null pointer; once the ID is set, it can not be changed.
* *
* @param the new unique id of the audio clip. * @param id the new unique id of the audio clip.
*/ */
void void
setId(Ptr<UniqueId>::Ref id) throw (std::invalid_argument) setId(Ptr<UniqueId>::Ref id) throw (std::invalid_argument)

View file

@ -172,7 +172,7 @@ class LocalizedObject
/** /**
* Change the resource bundle for this object. * Change the resource bundle for this object.
* *
* @param the new resource bundle used by the object. * @param bundle the new resource bundle used by the object.
*/ */
virtual void virtual void
setBundle(Ptr<ResourceBundle>::Ref bundle) throw () setBundle(Ptr<ResourceBundle>::Ref bundle) throw ()

View file

@ -146,7 +146,7 @@ class MetadataConstraint : public Configurable
/** /**
* Configure the metadata object based on an XML configuration element. * Configure the metadata object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument of the supplied XML element * @exception std::invalid_argument of the supplied XML element
* contains bad configuration information * contains bad configuration information
*/ */

View file

@ -69,15 +69,15 @@ class MetadataTypeContainer;
* called metadataType. This may look like the following: * called metadataType. This may look like the following:
* *
* <pre><code> * <pre><code>
* <metadataType dcName = "dc:creator" * &lt;metadataType dcName = "dc:creator"
* id3Tag = "TPE2" * id3Tag = "TPE2"
* localizationKey = "dc_creator" * localizationKey = "dc_creator"
* tab = "main" > * tab = "main" &gt;
* <constraint type = "numericRange" > * &lt;constraint type = "numericRange" &gt;
* <value>1</value> * &lt;value&gt;1&lt;/value&gt;
* <value>12</value> * &lt;value&gt;12&lt;/value&gt;
* </constraint> * &lt;/constraint&gt;
* </metadataType> * &lt;/metadataType&gt;
* </code></pre> * </code></pre>
* *
* The tab attribute (if present) must be one of "main", "music" or "voice" * The tab attribute (if present) must be one of "main", "music" or "voice"
@ -88,7 +88,9 @@ class MetadataTypeContainer;
* *
* The optional constraint sub-element can give restrictions on the acceptable * The optional constraint sub-element can give restrictions on the acceptable
* values for this type of metadata. See the MetadataConstraint class for * values for this type of metadata. See the MetadataConstraint class for
* more information, including the DTD of the "constraint" element. * more information, including the DTD of the &lt;constraint&gt; element.
*
* See the Studio config files for a list of all metadata types.
* *
* The DTD for the expected XML element looks like the following: * The DTD for the expected XML element looks like the following:
* *
@ -173,6 +175,8 @@ class MetadataType : public Configurable
* @param id3Tag the ID3v2 tag assciated with the metadata. * @param id3Tag the ID3v2 tag assciated with the metadata.
* @param localizationKey the key to get the localized name for * @param localizationKey the key to get the localized name for
* the metadata * the metadata
* @param tab in which tab to show this kind of metadata in the
* Upload File window (default: none of them).
*/ */
MetadataType(Ptr<MetadataTypeContainer>::Ref container, MetadataType(Ptr<MetadataTypeContainer>::Ref container,
Glib::ustring dcName, Glib::ustring dcName,
@ -196,7 +200,7 @@ class MetadataType : public Configurable
/** /**
* Configure the metadata object based on an XML configuration element. * Configure the metadata object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument of the supplied XML element * @exception std::invalid_argument of the supplied XML element
* contains bad configuration information * contains bad configuration information
*/ */

View file

@ -86,6 +86,8 @@ namespace Core {
* For a description of the metadataType XML element, see the documentation * For a description of the metadataType XML element, see the documentation
* for the MetadataType class. * for the MetadataType class.
* *
* See the Studio config files for a list of all metadata types.
*
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
* @see MetadataType * @see MetadataType
@ -164,7 +166,7 @@ class MetadataTypeContainer : public Configurable,
/** /**
* Configure the metadata object based on an XML configuration element. * Configure the metadata object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument of the supplied XML element * @exception std::invalid_argument of the supplied XML element
* contains bad configuration information * contains bad configuration information
*/ */
@ -242,6 +244,17 @@ class MetadataTypeContainer : public Configurable,
getById3Tag(const Glib::ustring id3Tag) getById3Tag(const Glib::ustring id3Tag)
throw (std::invalid_argument); throw (std::invalid_argument);
/**
* Return a MetadataType object, by index.
*
* @param index the index of the item in the metadata container.
* @return the MetadataType object at the supplied index.
* @exception std::invalid_argument if the index is out of range.
*/
Ptr<const MetadataType>::Ref
getByIndex(unsigned int index) const
throw (std::invalid_argument);
/** /**
* Check that the given value satisfies the constraint of a metadata * Check that the given value satisfies the constraint of a metadata
* type. * type.

View file

@ -0,0 +1,109 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
#ifndef LiveSupport_Core_NumericTools_h
#define LiveSupport_Core_NumericTools_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <sstream>
#include <glibmm/ustring.h>
namespace LiveSupport {
namespace Core {
using namespace LiveSupport;
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* A toolbox for various small numeric functions.
*
* @author $Author$
* @version $Revision$
*/
class NumericTools
{
public:
/**
* Convert an integer to a string.
*
* @param number the number to be converted.
* @return the string value of the number (in base 10).
*/
static Glib::ustring
itoa(int number) throw ();
/**
* Add a number to the end of a string.
* This is used in various GUI classes, to generate Glade widget
* names like "itemLabel1", "itemLabel2" etc.
*
* NOTE: the <code>index</code> parameter is 0-based (because this
* is normal in C++, for containers etc), but the return value is
* 1-based (because this is what Glade expects)!
* Thus <code>addIndex("itemLabel", 0)</code> returns "itemLabel1".
*
* @param baseString the string without the index.
* @param index the index to be added to the string (0-based).
* @return the new string, with the index added at the end (1-based).
*/
static Glib::ustring
addIndex(const Glib::ustring & baseString,
int index) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Core
} // namespace LiveSupport
#endif // LiveSupport_Core_NumericTools_h

View file

@ -216,6 +216,7 @@ class OptionsContainer
/** /**
* Set a string type option. * Set a string type option.
* *
* @param optionItem which option to set
* @param value the new value of the option * @param value the new value of the option
* @exception std::invalid_argument if the option name is not found * @exception std::invalid_argument if the option name is not found
*/ */

View file

@ -398,6 +398,7 @@ class Playlist : public Configurable,
* see the note at the default constructor. * see the note at the default constructor.
* *
* @param id the id of the playlist. * @param id the id of the playlist.
* @param title the title of the playlist.
* @param playlength the playing length of the playlist. * @param playlength the playing length of the playlist.
* @param uri the location of the SMIL file representing this * @param uri the location of the SMIL file representing this
* playlist (optional) * playlist (optional)

View file

@ -155,7 +155,7 @@ class RdsContainer : public Configurable
/** /**
* Configure the object based on an XML configuration element. * Configure the object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument if the supplied XML element * @exception std::invalid_argument if the supplied XML element
* contains bad configuration information. * contains bad configuration information.
*/ */
@ -171,6 +171,7 @@ class RdsContainer : public Configurable
* *
* @param key which setting to modify. * @param key which setting to modify.
* @param value the new value of the RDS setting. * @param value the new value of the RDS setting.
* @param enabled whether this value will be broadcast.
*/ */
void void
setRdsOptions(Ptr<const Glib::ustring>::Ref key, setRdsOptions(Ptr<const Glib::ustring>::Ref key,

View file

@ -172,7 +172,7 @@ class RdsItem : public Configurable
/** /**
* Configure the object based on an XML configuration element. * Configure the object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument if the supplied XML element * @exception std::invalid_argument if the supplied XML element
* contains bad configuration information * contains bad configuration information
*/ */

View file

@ -164,10 +164,10 @@ class ScheduleEntry
* A constructor based on a DOM element * A constructor based on a DOM element
* *
* @param element a DOM element returned earlier by a * @param element a DOM element returned earlier by a
* getDom() call from another schedule entry. * toDom() call from another schedule entry.
* @throws std::invalid_argument in case of a bad DOM element * @throws std::invalid_argument in case of a bad DOM element
* @see #getElementName * @see #getElementName
* @see #getDom * @see #toDom
*/ */
ScheduleEntry(xmlpp::Element * element) ScheduleEntry(xmlpp::Element * element)
throw (std::invalid_argument); throw (std::invalid_argument);

View file

@ -132,7 +132,7 @@ class UniqueId
* 2^31-1 (inclusive), the value of the UniqueId will be * 2^31-1 (inclusive), the value of the UniqueId will be
* bogus. * bogus.
* *
* @param strValue the id in base 10, in string from. * @param idStr the id in base 10, in string from.
* @return a new UniqueId with the specified ID value. * @return a new UniqueId with the specified ID value.
*/ */
static Ptr<UniqueId>::Ref static Ptr<UniqueId>::Ref

View file

@ -357,7 +357,7 @@ class XmlRpcTools
static void static void
fromTimeToXmlRpcValue( fromTimeToXmlRpcValue(
Ptr<const boost::posix_time::ptime>::Ref from, Ptr<const boost::posix_time::ptime>::Ref from,
XmlRpc::XmlRpcValue & xmlRpcValue) XmlRpc::XmlRpcValue & returnValue)
throw (); throw ();
/** /**
@ -370,7 +370,7 @@ class XmlRpcTools
static void static void
toTimeToXmlRpcValue( toTimeToXmlRpcValue(
Ptr<const boost::posix_time::ptime>::Ref to, Ptr<const boost::posix_time::ptime>::Ref to,
XmlRpc::XmlRpcValue & xmlRpcValue) XmlRpc::XmlRpcValue & returnValue)
throw (); throw ();
/** /**
@ -575,7 +575,7 @@ class XmlRpcTools
* Convert a SearchCriteria to an XmlRpcValue. * Convert a SearchCriteria to an XmlRpcValue.
* *
* @param criteria the SearchCriteria to convert. * @param criteria the SearchCriteria to convert.
* @param xmlRpcValue the output parameter holding the result of * @param returnValue the output parameter holding the result of
* the conversion. * the conversion.
*/ */
static void static void
@ -599,8 +599,8 @@ class XmlRpcTools
/** /**
* Convert a string token to an XmlRpcValue. * Convert a string token to an XmlRpcValue.
* *
* @param criteria the string token to convert. * @param token the string token to convert.
* @param xmlRpcValue the output parameter holding the result of * @param returnValue the output parameter holding the result of
* the conversion. * the conversion.
*/ */
static void static void
@ -625,7 +625,7 @@ class XmlRpcTools
* of the backup methods to an XmlRpcValue. * of the backup methods to an XmlRpcValue.
* *
* @param status the AsyncState to convert. * @param status the AsyncState to convert.
* @param xmlRpcValue the output parameter holding the result of * @param returnValue the output parameter holding the result of
* the conversion. * the conversion.
*/ */
static void static void
@ -649,7 +649,7 @@ class XmlRpcTools
* Convert a URL string to an XmlRpcValue. * Convert a URL string to an XmlRpcValue.
* *
* @param url the URL string to convert. * @param url the URL string to convert.
* @param xmlRpcValue the output parameter holding the result of * @param returnValue the output parameter holding the result of
* the conversion. * the conversion.
*/ */
static void static void
@ -673,7 +673,7 @@ class XmlRpcTools
* Convert a path string to an XmlRpcValue. * Convert a path string to an XmlRpcValue.
* *
* @param path the path string to convert. * @param path the path string to convert.
* @param xmlRpcValue the output parameter holding the result of * @param returnValue the output parameter holding the result of
* the conversion. * the conversion.
*/ */
static void static void
@ -696,7 +696,7 @@ class XmlRpcTools
/** /**
* Convert a fault string to an XmlRpcValue. * Convert a fault string to an XmlRpcValue.
* *
* @param path the fault string to convert. * @param faultString the fault string to convert.
* @param xmlRpcValue the output parameter holding the result of * @param xmlRpcValue the output parameter holding the result of
* the conversion. * the conversion.
*/ */

View file

@ -426,7 +426,7 @@ AudioClip :: configure(const xmlpp::Element & element)
* Return the value of a metadata field. * Return the value of a metadata field.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref Ptr<Glib::ustring>::Ref
AudioClip :: getMetadata(const string &key) const AudioClip :: getMetadata(const std::string & key) const
throw () throw ()
{ {
std::string name, prefix; std::string name, prefix;

View file

@ -140,7 +140,7 @@ class EnumerationConstraint : public MetadataConstraint
/** /**
* Configure the metadata object based on an XML configuration element. * Configure the metadata object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument of the supplied XML element * @exception std::invalid_argument of the supplied XML element
* contains bad configuration information * contains bad configuration information
*/ */

View file

@ -157,6 +157,22 @@ MetadataTypeContainer :: getById3Tag(const Glib::ustring id3Tag)
} }
/*------------------------------------------------------------------------------
* Look for a metadata type object by the ID3v2 tag name.
*----------------------------------------------------------------------------*/
Ptr<const MetadataType>::Ref
MetadataTypeContainer :: getByIndex(unsigned int index) const
throw (std::invalid_argument)
{
if (index < 0 || index >= vector.size()) {
throw std::invalid_argument("index out of range in "
"MetadataTypeContainer::getByIndex()");
}
return vector.at(index);
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Check that the given value satisfies the constraint of a metadata type. * Check that the given value satisfies the constraint of a metadata type.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View file

@ -112,7 +112,7 @@ class NumericConstraint : public MetadataConstraint
/** /**
* Configure the metadata object based on an XML configuration element. * Configure the metadata object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument of the supplied XML element * @exception std::invalid_argument of the supplied XML element
* contains bad configuration information * contains bad configuration information
*/ */

View file

@ -160,7 +160,7 @@ class NumericRangeConstraint : public MetadataConstraint
/** /**
* Configure the metadata object based on an XML configuration element. * Configure the metadata object based on an XML configuration element.
* *
* @param elemen the XML configuration element. * @param element the XML configuration element.
* @exception std::invalid_argument of the supplied XML element * @exception std::invalid_argument of the supplied XML element
* contains bad configuration information * contains bad configuration information
*/ */

View file

@ -0,0 +1,78 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "LiveSupport/Core/NumericTools.h"
using namespace LiveSupport;
using namespace LiveSupport::Core;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Convert an integer to a string.
*----------------------------------------------------------------------------*/
Glib::ustring
NumericTools :: itoa(int number) throw ()
{
std::ostringstream stream;
stream << number;
Glib::ustring string = stream.str();
return string;
}
/*------------------------------------------------------------------------------
* Add a number to the end of a string.
*----------------------------------------------------------------------------*/
Glib::ustring
NumericTools :: addIndex(const Glib::ustring & baseString,
int index) throw ()
{
std::ostringstream stream;
stream << baseString
<< (index + 1);
return stream.str();
}

View file

@ -0,0 +1,101 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "LiveSupport/Core/NumericTools.h"
#include "NumericToolsTest.h"
using namespace LiveSupport::Core;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
CPPUNIT_TEST_SUITE_REGISTRATION(NumericToolsTest);
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
NumericToolsTest :: setUp(void) throw ()
{
}
/*------------------------------------------------------------------------------
* Clean up the test environment
*----------------------------------------------------------------------------*/
void
NumericToolsTest :: tearDown(void) throw ()
{
}
/*------------------------------------------------------------------------------
* Test the itoa() function.
*----------------------------------------------------------------------------*/
void
NumericToolsTest :: itoaTest(void)
throw (CPPUNIT_NS::Exception)
{
int i = 3142874;
Glib::ustring a = NumericTools::itoa(i);
CPPUNIT_ASSERT(a == "3142874");
}
/*------------------------------------------------------------------------------
* Test the addIndex() function.
*----------------------------------------------------------------------------*/
void
NumericToolsTest :: addIndexTest(void)
throw (CPPUNIT_NS::Exception)
{
Glib::ustring base = "itemLabel";
int index = 123;
Glib::ustring result = NumericTools::addIndex(base, index);
CPPUNIT_ASSERT(result == "itemLabel124");
Glib::ustring second = NumericTools::addIndex("second", 0);
CPPUNIT_ASSERT(second == "second1");
}

View file

@ -0,0 +1,119 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
#ifndef NumericToolsTest_h
#define NumericToolsTest_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <cppunit/extensions/HelperMacros.h>
namespace LiveSupport {
namespace Core {
using namespace LiveSupport;
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Unit test for the NumericTools class.
*
* @author $Author$
* @version $Revision$
* @see NumericTools
*/
class NumericToolsTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(NumericToolsTest);
CPPUNIT_TEST(itoaTest);
CPPUNIT_TEST(addIndexTest);
CPPUNIT_TEST_SUITE_END();
protected:
/**
* Test the itoa() function.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
itoaTest(void) throw (CPPUNIT_NS::Exception);
/**
* Test the addIndex() function.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
addIndexTest(void) throw (CPPUNIT_NS::Exception);
public:
/**
* Set up the environment for the test case.
*/
void
setUp(void) throw ();
/**
* Clean up the environment after the test case.
*/
void
tearDown(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Core
} // namespace LiveSupport
#endif // NumericToolsTest_h

View file

@ -639,7 +639,7 @@ Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
* Return the value of a metadata field. * Return the value of a metadata field.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref Ptr<Glib::ustring>::Ref
Playlist :: getMetadata(const string &key) const Playlist :: getMetadata(const std::string & key) const
throw () throw ()
{ {
std::string name, prefix; std::string name, prefix;

View file

@ -90,9 +90,11 @@ class Conversion
roundNearest } RoundingType; roundNearest } RoundingType;
/** /**
* Convert a boost::ptime to a odbc::Timestamp, rounding down. * Convert a boost::ptime to a odbc::Timestamp.
* *
* @param ptime the boost ptime to convert. * @param ptime the boost ptime to convert.
* @param round specify how to round the fractional part
* (default: down).
* @return an odbc::Timestamp, holding the same time. * @return an odbc::Timestamp, holding the same time.
*/ */
static Ptr<odbc::Timestamp>::Ref static Ptr<odbc::Timestamp>::Ref

View file

@ -214,7 +214,7 @@ class SchedulerThread : public virtual RunnableInterface
* </ul> * </ul>
* *
* @param signalId a value from SignalTypes. * @param signalId a value from SignalTypes.
* @see #signalTypes * @see #SignalTypes
*/ */
virtual void virtual void
signal(int signalId) throw (); signal(int signalId) throw ();

View file

@ -91,6 +91,9 @@ ICU_LIBS=@ICU_LIBS@
GTKMM_CFLAGS=@GTKMM_CFLAGS@ GTKMM_CFLAGS=@GTKMM_CFLAGS@
GTKMM_LIBS=@GTKMM_LIBS@ GTKMM_LIBS=@GTKMM_LIBS@
LIBGLADEMM_CFLAGS=@LIBGLADEMM_CFLAGS@
LIBGLADEMM_LIBS=@LIBGLADEMM_LIBS@
TEST_RESULTS = ${DOC_DIR}/testResults.xml TEST_RESULTS = ${DOC_DIR}/testResults.xml
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR # the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
TEST_XSLT = ../etc/testResultToHtml.xsl TEST_XSLT = ../etc/testResultToHtml.xsl
@ -115,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
${LIBXMLPP_CFLAGS} \ ${LIBXMLPP_CFLAGS} \
${ICU_CFLAGS} \ ${ICU_CFLAGS} \
${GTKMM_CFLAGS} \ ${GTKMM_CFLAGS} \
${LIBGLADEMM_CFLAGS} \
-I${USR_INCLUDE_DIR} \ -I${USR_INCLUDE_DIR} \
-I${CORE_INCLUDE_DIR} \ -I${CORE_INCLUDE_DIR} \
-I${INCLUDE_DIR} -I${TMP_DIR} -I${INCLUDE_DIR} -I${TMP_DIR}
@ -123,6 +127,7 @@ LDFLAGS = @LDFLAGS@ -pthread \
${LIBXMLPP_LIBS} \ ${LIBXMLPP_LIBS} \
${ICU_LIBS} \ ${ICU_LIBS} \
${GTKMM_LIBS} \ ${GTKMM_LIBS} \
${LIBGLADEMM_LIBS} \
-L${USR_LIB_DIR} \ -L${USR_LIB_DIR} \
-L${CORE_LIB_DIR} \ -L${CORE_LIB_DIR} \
-L${LIB_DIR} -L${LIB_DIR}

View file

@ -108,6 +108,10 @@ PKG_CHECK_MODULES(GTKMM,[gtkmm-2.4 >= 2.5.5])
AC_SUBST(GTKMM_CFLAGS) AC_SUBST(GTKMM_CFLAGS)
AC_SUBST(GTKMM_LIBS) AC_SUBST(GTKMM_LIBS)
PKG_CHECK_MODULES(LIBGLADEMM,[libglademm-2.4 >= 2.6.2])
AC_SUBST(LIBGLADEMM_CFLAGS)
AC_SUBST(LIBGLADEMM_LIBS)
dnl----------------------------------------------------------------------------- dnl-----------------------------------------------------------------------------
dnl enable compilaton for code coverage data dnl enable compilaton for code coverage data

View file

@ -40,21 +40,12 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <map>
#include <exception>
#include <gtkmm/label.h>
#include <gtkmm/menu.h>
#include <gtkmm/comboboxtext.h> #include <gtkmm/comboboxtext.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
namespace LiveSupport { namespace LiveSupport {
namespace Widgets { namespace Widgets {
using namespace LiveSupport::Core;
/* ================================================================ constants */ /* ================================================================ constants */
@ -65,296 +56,31 @@ using namespace LiveSupport::Core;
/** /**
* A combo box holding text entries. * A combo box holding text entries.
* This just adds another constructor to its parent class, so that it can
* be used with Libglade.
* *
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class ComboBoxText : public Gtk::ComboBoxText class ComboBoxText : public Gtk::ComboBoxText
{ {
private:
/**
* The Gdk::Window object, used to draw inside this button.
*/
Glib::RefPtr<Gdk::Window> gdkWindow;
/**
* The Graphics Context, used to draw.
*/
Glib::RefPtr<Gdk::GC> gc;
/**
* The text displayed inside the button.
*/
Gtk::Label * label;
/**
* The X coordinate of the label.
*/
int labelX;
/**
* The Y coordinate of the label.
*/
int labelY;
/**
* The drop-down menu for the combo box.
*/
Ptr<Gtk::Menu>::Ref menu;
/**
* The left image of the widget.
*/
Glib::RefPtr<Gdk::Pixbuf> leftImage;
/**
* The image behind the text display.
*/
Glib::RefPtr<Gdk::Pixbuf> centerImage;
/**
* The right image for the widget.
*/
Glib::RefPtr<Gdk::Pixbuf> rightImage;
/**
* A map type for storing { text, key } pairs.
*/
typedef std::map<const Glib::ustring, Ptr<const Glib::ustring>::Ref>
KeyMapType;
/**
* A map containing { text, key } pairs.
*/
KeyMapType keyMap;
/**
* Default constructor.
*/
ComboBoxText(void) throw ()
{
}
/**
* Return the popup menu position.
*
* @param x the X coordinate for the menu.
* @param y the Y coordinate for the menu.
* @param pushIn don't know what this does.
*/
void
onMenuPosition(int & x,
int & y,
bool & pushIn) throw ();
/**
* Event handler for the combo box being clicked.
*
* @param event the button click event.
* @return true if the the event was handled, false otherwise.
*/
bool
onBoxClicked(GdkEventButton * event) throw ();
/**
* Event handler for the menu item selected.
*/
void
onMenuItemSelected(void) throw ();
protected:
/**
* Handle the size request event.
*
* @param requisition the size request, also being the ouptut
* parameter.
*/
virtual void
on_size_request(Gtk::Requisition* requisition)
throw ();
/**
* Handle the size allocate event.
*
* @param allocation the allocated size.
*/
virtual void
on_size_allocate(Gtk::Allocation& allocation)
throw ();
/**
* Handle the map event.
*/
virtual void
on_map() throw ();
/**
* Handle the unmap event.
*/
virtual void
on_unmap() throw ();
/**
* Handle the realize event.
*/
virtual void
on_realize() throw ();
/**
* Handle the unrealize event.
*/
virtual void
on_unrealize() throw ();
/**
* Handle the expose event.
*
* @param event the actual expose event recieved.
* @return true if something was drawn (?)
*/
virtual bool
on_expose_event(GdkEventExpose* event) throw ();
/**
* Execute a function on all children of this container.
*
* @param includeInternals true if the callback function should
* also be called on the internals, false otherwise.
* @param callback the callback function to execute on the children.
* @param callbackData the data passed to the callback function.
*/
virtual void
forall_vfunc(gboolean includeInternals,
GtkCallback callback,
gpointer callbackData)
throw ();
/**
* Handle the add event.
*
* @param child the child being added to the widget.
*/
virtual void
on_add(Gtk::Widget* child) throw ();
/**
* Handle the remove event.
*
* @param child the child to remove from the widget.
*/
virtual void
on_remove(Gtk::Widget* child) throw ();
/**
* Tell what kind of children this container accepts.
*
* @return the type of children this container accepts.
*/
virtual GtkType
child_type_vfunc() const throw ();
/**
* A signal object to notify people that the selection has changed.
*/
sigc::signal<void> signalSelectionChangedObject;
public: public:
/** /**
* Constructor. * Constructor to be used with Glade::Xml::get_widget_derived().
* *
* @param leftImage the left image of the widget. * @param baseClass widget of the parent class, created by Glade.
* @param centerImage the image under the text display. * @param glade the Glade object.
* @param rightImage the right image for the widget.
*/ */
ComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage, ComboBoxText(GtkComboBox * baseClass,
Glib::RefPtr<Gdk::Pixbuf> centerImage, const Glib::RefPtr<Gnome::Glade::Xml> & glade)
Glib::RefPtr<Gdk::Pixbuf> rightImage) throw (); throw ();
/** /**
* A virtual destructor. * A virtual destructor.
*/ */
virtual virtual
~ComboBoxText(void) throw (); ~ComboBoxText(void) throw ();
/**
* Append a new text entry to the combo box menu.
*
* @param text the text entry to append.
*/
void
append_text(const Glib::ustring &text) throw ();
/**
* Return the active text.
*
* @return the active text of the combo box.
*/
Glib::ustring
get_active_text(void) const throw ();
/**
* Insert a new text entry at a given position.
*
* @param position the position where to insert the text.
* @param text the text to insert.
*/
void
insert_text(int position,
const Glib::ustring & text) throw ();
/**
* Set the active text.
*
* @param text the text to select as active.
*/
void
set_active_text(const Glib::ustring & text) throw ();
/**
* Set the active text.
*
* @param index the number of the menu item to select as active.
*/
void
set_active(int index) throw ();
/**
* Add a new entry, together with an (invisible) key.
*
* @param text the text to be displayed
* @param key the key corresponding to this text
* @see getActiveKey()
*/
void
appendPair(Ptr<const Glib::ustring>::Ref text,
Ptr<const Glib::ustring>::Ref key)
throw ();
/**
* Get the key corresponding to the selected item.
*
* @return the key corresponding to the currently active (selected)
* text
*/
Ptr<const Glib::ustring>::Ref
getActiveKey(void) throw (std::logic_error);
/**
* Accessor for the selectionChanged signal.
* This signal is emitted by onMenuItemSelected() when the active
* text of the ComboBoxText has changed.
* It has the same function as Gtk::ComboBoxText::signal_changed().
*
* TODO: it would be nicer to override signal_changed();
* need to figure out how.
*
* @return the signal object (a protected member of this class)
*/
sigc::signal<void>
signalSelectionChanged(void) throw ();
}; };

View file

@ -40,6 +40,8 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <libglademm.h>
#include "LiveSupport/Core/MetadataTypeContainer.h" #include "LiveSupport/Core/MetadataTypeContainer.h"
#include "LiveSupport/Widgets/ComboBoxText.h" #include "LiveSupport/Widgets/ComboBoxText.h"
@ -65,22 +67,53 @@ using namespace LiveSupport::Core;
*/ */
class MetadataComboBoxText : public ComboBoxText class MetadataComboBoxText : public ComboBoxText
{ {
public: private:
/**
* Constructor.
*
*/
MetadataComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage,
Glib::RefPtr<Gdk::Pixbuf> centerImage,
Glib::RefPtr<Gdk::Pixbuf> rightImage,
Ptr<MetadataTypeContainer>::Ref metadataTypes)
throw ();
/**
* The list of metadata types.
*/
Ptr<const MetadataTypeContainer>::Ref metadataTypes;
public:
/**
* Constructor to be used with Glade::Xml::get_widget_derived().
*
* @param baseClass widget of the parent class, created by Glade.
* @param glade the Glade object.
*/
MetadataComboBoxText(
GtkComboBox * baseClass,
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
throw ();
/** /**
* A virtual destructor. * A virtual destructor.
*/ */
virtual virtual
~MetadataComboBoxText(void) throw (); ~MetadataComboBoxText(void) throw ();
/**
* Set up the contents of the combo box.
*
* @param metadataTypes contains the metadata keys and values.
*/
void
setContents(Ptr<const MetadataTypeContainer>::Ref metadataTypes)
throw ();
/**
* Get the DC name for the currently selected metadata type.
* This is either a standard Dublin Core metadata type like
* "dc:title" or "dc:creator", or one of the Campcaster
* (née LiveSupport) extensions like "ls:year" or "ls:bpm".
* See the Studio config files for a list of all metadata types.
*
* @return the DC name for the current selection.
*/
Ptr<const Glib::ustring>::Ref
getActiveKey(void)
throw ();
}; };

View file

@ -67,14 +67,16 @@ class OperatorComboBoxText : public ComboBoxText,
public LocalizedObject public LocalizedObject
{ {
public: public:
/** /**
* Constructor. * Constructor to be used with Glade::Xml::get_widget_derived().
* *
* @param baseClass widget of the parent class, created by Glade.
* @param glade the Glade object.
*/ */
OperatorComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage, OperatorComboBoxText(
Glib::RefPtr<Gdk::Pixbuf> centerImage, GtkComboBox * baseClass,
Glib::RefPtr<Gdk::Pixbuf> rightImage, const Glib::RefPtr<Gnome::Glade::Xml> & glade)
Ptr<ResourceBundle>::Ref bundle)
throw (); throw ();
/** /**
@ -82,6 +84,24 @@ class OperatorComboBoxText : public ComboBoxText,
*/ */
virtual virtual
~OperatorComboBoxText(void) throw (); ~OperatorComboBoxText(void) throw ();
/**
* Set up the contents of the combo box.
*
* @param bundle the resource bundle which holds the localized
* operator names.
*/
void
setContents(Ptr<ResourceBundle>::Ref bundle)
throw ();
/**
* Get the currently selected operator.
* This is one of "partial", "prefix", "=", "<=" or ">=".
*
* @return the current selection.
*/
Ptr<const Glib::ustring>::Ref
getActiveKey(void) throw ();
}; };

View file

@ -40,12 +40,17 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playable.h" #include "LiveSupport/Core/Playable.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include <LiveSupport/Widgets/ZebraTreeModelColumnRecord.h>
namespace LiveSupport { namespace LiveSupport {
namespace Widgets { namespace Widgets {
using namespace LiveSupport::Core;
/* ================================================================ constants */ /* ================================================================ constants */

View file

@ -42,18 +42,11 @@
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
#include <gtkmm/treeview.h> #include <gtkmm/treeview.h>
#include <gtkmm/label.h> #include <libglademm.h>
#include <gtkmm/table.h>
#include <gtkmm/alignment.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/image.h>
#include <gtkmm/window.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Widgets/WidgetConstants.h" #include "LiveSupport/Widgets/WidgetConstants.h"
#include "LiveSupport/Widgets/CornerImages.h"
#include "LiveSupport/Widgets/ImageButton.h" #include "LiveSupport/Widgets/ImageButton.h"
#include "LiveSupport/Widgets/BlueBin.h"
namespace LiveSupport { namespace LiveSupport {
@ -182,7 +175,6 @@ class ZebraTreeView : public Gtk::TreeView
protected: protected:
/** /**
* A signal object to notify people that a cell has been edited. * A signal object to notify people that a cell has been edited.
*/ */
@ -262,6 +254,16 @@ class ZebraTreeView : public Gtk::TreeView
ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel) ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
throw (); throw ();
/**
* Constructor to be used with Glade::Xml::get_widget_derived().
*
* @param baseClass widget of the parent class, created by Glade.
* @param glade the Glade object.
*/
ZebraTreeView(_GtkTreeView * baseClass,
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
throw ();
/** /**
* A virtual destructor. * A virtual destructor.
*/ */

View file

@ -33,11 +33,9 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include "LiveSupport/Widgets/Colors.h"
#include "LiveSupport/Widgets/ComboBoxText.h" #include "LiveSupport/Widgets/ComboBoxText.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets; using namespace LiveSupport::Widgets;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -54,30 +52,12 @@ using namespace LiveSupport::Widgets;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
ComboBoxText :: ComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage, ComboBoxText :: ComboBoxText(
Glib::RefPtr<Gdk::Pixbuf> centerImage, GtkComboBox * baseClass,
Glib::RefPtr<Gdk::Pixbuf> rightImage) const Glib::RefPtr<Gnome::Glade::Xml> & glade)
throw () throw ()
: Gtk::ComboBoxText(baseClass)
{ {
set_flags(Gtk::NO_WINDOW);
this->leftImage = leftImage;
this->centerImage = centerImage;
this->rightImage = rightImage;
label = Gtk::manage(new Gtk::Label(""));
label->set_parent(*this);
// specify a white background
Gdk::Color bgColor = Colors::getColor(Colors::White);
menu.reset(new Gtk::Menu());
menu->modify_bg(Gtk::STATE_NORMAL, bgColor);
// register the event handler for the mouse click
add_events(Gdk::BUTTON_PRESS_MASK);
signal_button_press_event().connect(sigc::mem_fun(*this,
&ComboBoxText::onBoxClicked));
} }
@ -88,412 +68,3 @@ ComboBoxText :: ~ComboBoxText(void) throw ()
{ {
} }
/*------------------------------------------------------------------------------
* Handle the size request event.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_size_request(Gtk::Requisition* requisition) throw ()
{
*requisition = Gtk::Requisition();
// get the required size from the label
Gtk::Requisition childRequisition = label->size_request();;
// iterate through the menu elements, and get the biggest size
Gtk::Menu::MenuList & list = menu->items();
Gtk::Menu::MenuList::iterator it = list.begin();
Gtk::Menu::MenuList::iterator end = list.end();
while (it != end) {
Gtk::MenuItem & item = *it;
Gtk::Requisition itemRequisition = item.size_request();
if (childRequisition.width < itemRequisition.width) {
childRequisition.width = itemRequisition.width;
}
if (childRequisition.height < itemRequisition.height) {
childRequisition.height = itemRequisition.height;
}
++it;
}
requisition->width = leftImage->get_width()
+ childRequisition.width
+ rightImage->get_width();
requisition->height = centerImage->get_height();
}
/*------------------------------------------------------------------------------
* Handle the size allocate event.
* We will not be given heights or widths less than we have requested,
* though we might get more.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_size_allocate(Gtk::Allocation& allocation) throw ()
{
allocation.set_height(centerImage->get_height());
set_allocation(allocation);
if (gdkWindow) {
gdkWindow->move_resize( allocation.get_x(),
allocation.get_y(),
allocation.get_width(),
allocation.get_height() );
}
Gtk::Allocation labelAlloc;
labelX = leftImage->get_width();
// put it 1 pixel lower, so that it looks good
labelY = 1 + ((allocation.get_height() - centerImage->get_height()) / 2);
labelAlloc.set_x(labelX);
labelAlloc.set_y(labelY);
labelAlloc.set_width(allocation.get_width()
- leftImage->get_width()
- rightImage->get_width());
labelAlloc.set_height(centerImage->get_height());
label->size_allocate(labelAlloc);
Gtk::ComboBoxText::on_size_allocate(allocation);
}
/*------------------------------------------------------------------------------
* Execute a function on all the children.
* As this widget has no children, don't do anything.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: forall_vfunc(gboolean includeInternals,
GtkCallback callback,
gpointer callbackData) throw ()
{
callback((GtkWidget*) label->gobj(), callbackData);
}
/*------------------------------------------------------------------------------
* Handle the add child widget event.
* As this widget has no children, don't do anything.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_add(Gtk::Widget* child) throw ()
{
}
/*------------------------------------------------------------------------------
* Handle the remove child widget event.
* As this widget has no children, don't do anything.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_remove(Gtk::Widget* child) throw ()
{
}
/*------------------------------------------------------------------------------
* Return what kind of widgets can be added to this container.
* As this widget has no children, return G_TYPE_NONE always.
*----------------------------------------------------------------------------*/
GtkType
ComboBoxText :: child_type_vfunc() const throw ()
{
return G_TYPE_NONE;
}
/*------------------------------------------------------------------------------
* Handle the map event.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_map() throw ()
{
Gtk::ComboBoxText::on_map();
}
/*------------------------------------------------------------------------------
* Handle the unmap event.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_unmap() throw ()
{
Gtk::ComboBoxText::on_unmap();
}
/*------------------------------------------------------------------------------
* Handle the realize event.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_realize() throw ()
{
// trick to make GTK-- allocate a window for the later get_window() call
set_flags(Gtk::NO_WINDOW);
Gtk::ComboBoxText::on_realize();
if (!gdkWindow) {
// create the Gdk::Window, if it didn't exist before
GdkWindowAttr attributes;
memset(&attributes, 0, sizeof(attributes));
Gtk::Allocation allocation = get_allocation();
// set initial position and size of the Gdk::Window
attributes.x = allocation.get_x();
attributes.y = allocation.get_y();
attributes.width = allocation.get_width();
attributes.height = allocation.get_height();
attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
gdkWindow = Gdk::Window::create(get_window(),
&attributes,
GDK_WA_X | GDK_WA_Y);
unset_flags(Gtk::NO_WINDOW);
set_window(gdkWindow);
// make the widget receive expose events
gdkWindow->set_user_data(gobj());
// allocate a GC for use in on_expose_event()
gc = Gdk::GC::create(gdkWindow);
}
}
/*------------------------------------------------------------------------------
* Handle the unrealize event.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: on_unrealize() throw ()
{
gdkWindow.clear();
gc.clear();
Gtk::ComboBoxText::on_unrealize();
}
/*------------------------------------------------------------------------------
* Handle the expose event.
*----------------------------------------------------------------------------*/
bool
ComboBoxText :: on_expose_event(GdkEventExpose* event) throw ()
{
if (event->count > 0) {
return false;
}
if (gdkWindow) {
gdkWindow->clear();
// draw everything vertically centered, but horizontally stretched
// out
int x = 0;
int y = (get_height() - centerImage->get_height()) / 2;
int maxX = get_width() - rightImage->get_width();
// draw the left image
leftImage->render_to_drawable(gdkWindow,
get_style()->get_black_gc(),
0, 0,
x,
y,
leftImage->get_width(),
leftImage->get_height(),
Gdk::RGB_DITHER_NONE,
0, 0);
// draw as many center images, as necessary
for (x = leftImage->get_width();
x < maxX;
x += centerImage->get_width()) {
centerImage->render_to_drawable(gdkWindow,
get_style()->get_black_gc(),
0, 0,
x,
y,
centerImage->get_width(),
centerImage->get_height(),
Gdk::RGB_DITHER_NONE,
0, 0);
}
// draw the right image
rightImage->render_to_drawable(gdkWindow,
get_style()->get_black_gc(),
0, 0,
maxX,
y,
rightImage->get_width(),
rightImage->get_height(),
Gdk::RGB_DITHER_NONE,
0, 0);
// draw the label itself
gdkWindow->draw_layout(gc, labelX, labelY, label->get_layout());
}
Gtk::ComboBoxText::on_expose_event(event);
return false;
}
/*------------------------------------------------------------------------------
* Return the menu position.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: onMenuPosition(int & x,
int & y,
bool & pushIn) throw ()
{
int windowX;
int windowY;
gdkWindow->get_origin(windowX, windowY);
x = windowX + labelX;
y = windowY + labelY;
pushIn = false;
}
/*------------------------------------------------------------------------------
* Return the menu position.
*----------------------------------------------------------------------------*/
bool
ComboBoxText :: onBoxClicked(GdkEventButton * event) throw ()
{
if (event->button == 1) {
// display the menu
menu->popup(sigc::mem_fun(*this, &ComboBoxText::onMenuPosition),
0, 0);
}
return false;
}
/*------------------------------------------------------------------------------
* Event handler for the menu item selected.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: onMenuItemSelected(void) throw ()
{
Gtk::MenuItem * item = menu->get_active();
Gtk::Label * selected = (Gtk::Label*) item->get_child();
set_active_text(selected->get_text());
signalSelectionChanged().emit();
}
/*------------------------------------------------------------------------------
* Append a new text entry to the combo box menu.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: append_text(const Glib::ustring &text) throw ()
{
Gtk::Menu::MenuList& list = menu->items();
list.push_back(Gtk::Menu_Helpers::MenuElem(text,
sigc::mem_fun(*this,
&ComboBoxText::onMenuItemSelected)));
}
/*------------------------------------------------------------------------------
* Return the active text.
*----------------------------------------------------------------------------*/
Glib::ustring
ComboBoxText :: get_active_text(void) const throw ()
{
// TODO: this may actually be bogus data
return label->get_text();
}
/*------------------------------------------------------------------------------
* Insert a new text entry at a given position.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: insert_text(int position,
const Glib::ustring & text) throw ()
{
// TODO: this probably doesn't work, the menu->insert() function seems
// to be broken
Gtk::MenuItem item(text);
menu->insert(item, position);
}
/*------------------------------------------------------------------------------
* Set the active text.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: set_active_text(const Glib::ustring & text) throw ()
{
// TODO: the activate function probably doesn't work, it seems to be broken
Gtk::MenuItem item(text);
menu->activate_item(item);
label->set_text(text);
}
/*------------------------------------------------------------------------------
* Set the first item in the combo box to be the active text.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: set_active(int index) throw ()
{
menu->set_active(index);
onMenuItemSelected();
}
/*------------------------------------------------------------------------------
* Add a new entry, together with an (invisible) key.
*----------------------------------------------------------------------------*/
void
ComboBoxText :: appendPair(Ptr<const Glib::ustring>::Ref text,
Ptr<const Glib::ustring>::Ref key) throw ()
{
append_text(*text);
keyMap[*text] = key;
}
/*------------------------------------------------------------------------------
* Get the key corresponding to the selected item.
*----------------------------------------------------------------------------*/
Ptr<const Glib::ustring>::Ref
ComboBoxText :: getActiveKey(void) throw (std::logic_error)
{
KeyMapType::const_iterator it = keyMap.find(get_active_text());
if (it != keyMap.end()) {
return it->second;
} else {
throw std::logic_error("no active key found in OperatorComboBoxText");
}
}
/*------------------------------------------------------------------------------
* Accessor for the selectionChanged signal.
*----------------------------------------------------------------------------*/
sigc::signal<void>
ComboBoxText :: signalSelectionChanged(void) throw ()
{
return signalSelectionChangedObject;
}

View file

@ -54,26 +54,50 @@ using namespace LiveSupport::Widgets;
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
MetadataComboBoxText :: MetadataComboBoxText( MetadataComboBoxText :: MetadataComboBoxText(
Glib::RefPtr<Gdk::Pixbuf> leftImage, GtkComboBox * baseClass,
Glib::RefPtr<Gdk::Pixbuf> centerImage, const Glib::RefPtr<Gnome::Glade::Xml> & glade)
Glib::RefPtr<Gdk::Pixbuf> rightImage,
Ptr<MetadataTypeContainer>::Ref metadataTypes)
throw () throw ()
: ComboBoxText(leftImage, centerImage, rightImage) : ComboBoxText(baseClass, glade)
{ {
MetadataTypeContainer::Vector::const_iterator it;
for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) {
Ptr<const MetadataType>::Ref metadata = *it;
appendPair(metadata->getLocalizedName(), metadata->getDcName());
}
set_active(0); // select the first item
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Destructor. * Destructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
MetadataComboBoxText :: ~MetadataComboBoxText(void) throw () MetadataComboBoxText :: ~MetadataComboBoxText(void) throw ()
{ {
} }
/*------------------------------------------------------------------------------
* Set up the contents of the combo box.
*----------------------------------------------------------------------------*/
void
MetadataComboBoxText :: setContents(
Ptr<const MetadataTypeContainer>::Ref metadataTypes)
throw ()
{
this->metadataTypes = metadataTypes;
MetadataTypeContainer::Vector::const_iterator it;
for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) {
Ptr<const MetadataType>::Ref metadata = *it;
append_text(*metadata->getLocalizedName());
}
set_active(0); // select the first item
}
/*------------------------------------------------------------------------------
* Set up the contents of the combo box.
*----------------------------------------------------------------------------*/
Ptr<const Glib::ustring>::Ref
MetadataComboBoxText :: getActiveKey(void)
throw ()
{
Ptr<const MetadataType>::Ref metadata = metadataTypes->getByIndex(
get_active_row_number());
return metadata->getDcName();
}

View file

@ -33,6 +33,9 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <iostream>
#include <libglademm.h>
#include "LiveSupport/Widgets/OperatorComboBoxText.h" #include "LiveSupport/Widgets/OperatorComboBoxText.h"
@ -54,37 +57,72 @@ using namespace LiveSupport::Widgets;
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
OperatorComboBoxText :: OperatorComboBoxText( OperatorComboBoxText :: OperatorComboBoxText(
Glib::RefPtr<Gdk::Pixbuf> leftImage, GtkComboBox * baseClass,
Glib::RefPtr<Gdk::Pixbuf> centerImage, const Glib::RefPtr<Gnome::Glade::Xml> & glade)
Glib::RefPtr<Gdk::Pixbuf> rightImage,
Ptr<ResourceBundle>::Ref bundle)
throw () throw ()
: ComboBoxText(leftImage, centerImage, rightImage), : ComboBoxText(baseClass, glade)
LocalizedObject(bundle)
{ {
Ptr<Glib::ustring>::Ref partialOperator(new Glib::ustring("partial"));
appendPair(getResourceUstring("partialOperatorDisplay"), partialOperator);
Ptr<Glib::ustring>::Ref prefixOperator(new Glib::ustring("prefix"));
appendPair(getResourceUstring("prefixOperatorDisplay"), prefixOperator);
Ptr<Glib::ustring>::Ref equalsOperator(new Glib::ustring("="));
appendPair(getResourceUstring("=OperatorDisplay"), equalsOperator);
Ptr<Glib::ustring>::Ref lessOrEqualOperator(new Glib::ustring("<="));
appendPair(getResourceUstring("<=OperatorDisplay"), lessOrEqualOperator);
Ptr<Glib::ustring>::Ref greaterOrEqualOperator(new Glib::ustring(">="));
appendPair(getResourceUstring(">=OperatorDisplay"), greaterOrEqualOperator);
set_active(0); // select the first item
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Destructor. * Destructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
OperatorComboBoxText :: ~OperatorComboBoxText(void) throw () OperatorComboBoxText :: ~OperatorComboBoxText(void) throw ()
{ {
} }
/*------------------------------------------------------------------------------
* Set up the contents of the combo box.
*----------------------------------------------------------------------------*/
void
OperatorComboBoxText :: setContents(Ptr<ResourceBundle>::Ref bundle)
throw ()
{
setBundle(bundle);
append_text(*getResourceUstring("partialOperatorDisplay"));
append_text(*getResourceUstring("prefixOperatorDisplay"));
append_text(*getResourceUstring("=OperatorDisplay"));
append_text(*getResourceUstring("<=OperatorDisplay"));
append_text(*getResourceUstring(">=OperatorDisplay"));
set_active(0);
}
/*------------------------------------------------------------------------------
* Set up the contents of the combo box.
*----------------------------------------------------------------------------*/
Ptr<const Glib::ustring>::Ref
OperatorComboBoxText :: getActiveKey(void) throw ()
{
Ptr<Glib::ustring>::Ref selectedOperator(new Glib::ustring);
int selectedRow = get_active_row_number();
switch (selectedRow) {
case 0: selectedOperator->assign("partial");
break;
case 1: selectedOperator->assign("prefix");
break;
case 2: selectedOperator->assign("=");
break;
case 3: selectedOperator->assign("<=");
break;
case 4: selectedOperator->assign(">=");
break;
default: std::cerr << "impossible value '"
<< selectedRow
<< "' in OperatorComboBoxText::getActiveKey"
<< std::endl;
std::exit(1);
break;
}
return selectedOperator;
}

View file

@ -470,9 +470,10 @@ WidgetFactory :: createButton(const Glib::ustring & label,
ComboBoxText * ComboBoxText *
WidgetFactory :: createComboBoxText(void) throw () WidgetFactory :: createComboBoxText(void) throw ()
{ {
return new ComboBoxText(comboBoxLeftImage, return 0;
comboBoxCenterImage, // return new ComboBoxText(comboBoxLeftImage,
comboBoxRightImage); // comboBoxCenterImage,
// comboBoxRightImage);
} }
@ -484,10 +485,11 @@ WidgetFactory :: createMetadataComboBoxText(
Ptr<MetadataTypeContainer>::Ref metadataTypes) Ptr<MetadataTypeContainer>::Ref metadataTypes)
throw () throw ()
{ {
return new MetadataComboBoxText(comboBoxLeftImage, return 0;
comboBoxCenterImage, // return new MetadataComboBoxText(comboBoxLeftImage,
comboBoxRightImage, // comboBoxCenterImage,
metadataTypes); // comboBoxRightImage,
// metadataTypes);
} }
@ -499,10 +501,11 @@ WidgetFactory :: createOperatorComboBoxText(
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle)
throw () throw ()
{ {
return new OperatorComboBoxText(comboBoxLeftImage, return 0;
comboBoxCenterImage, // return new OperatorComboBoxText(comboBoxLeftImage,
comboBoxRightImage, // comboBoxCenterImage,
bundle); // comboBoxRightImage,
// bundle);
} }
@ -515,13 +518,14 @@ WidgetFactory :: createNumericComboBoxText(int lowerLimit,
int minLength) int minLength)
throw () throw ()
{ {
ComboBoxText * comboBox = new ComboBoxText(comboBoxLeftImage, return 0;
comboBoxCenterImage, // ComboBoxText * comboBox = new ComboBoxText(comboBoxLeftImage,
comboBoxRightImage); // comboBoxCenterImage,
for (int i = lowerLimit; i <= upperLimit; ++i) { // comboBoxRightImage);
comboBox->append_text(itoa(i, minLength)); // for (int i = lowerLimit; i <= upperLimit; ++i) {
} // comboBox->append_text(itoa(i, minLength));
return comboBox; // }
// return comboBox;
} }

View file

@ -71,6 +71,22 @@ ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
} }
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
ZebraTreeView :: ZebraTreeView(
_GtkTreeView * baseClass,
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
throw ()
: Gtk::TreeView(baseClass)
{
this->signal_row_expanded().connect(sigc::mem_fun(*this,
&ZebraTreeView::onRowExpanded));
this->signal_row_collapsed().connect(sigc::mem_fun(*this,
&ZebraTreeView::onRowCollapsed));
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Destructor. * Destructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View file

@ -184,6 +184,9 @@ CURL_LIBS=@CURL_LIBS@
GTKMM_CFLAGS=@GTKMM_CFLAGS@ GTKMM_CFLAGS=@GTKMM_CFLAGS@
GTKMM_LIBS=@GTKMM_LIBS@ GTKMM_LIBS=@GTKMM_LIBS@
LIBGLADEMM_CFLAGS=@LIBGLADEMM_CFLAGS@
LIBGLADEMM_LIBS=@LIBGLADEMM_LIBS@
GSTREAMER_CFLAGS=@GSTREAMER_CFLAGS@ GSTREAMER_CFLAGS=@GSTREAMER_CFLAGS@
GSTREAMER_LIBS=@GSTREAMER_LIBS@ GSTREAMER_LIBS=@GSTREAMER_LIBS@
@ -219,6 +222,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
${TAGLIB_CFLAGS} \ ${TAGLIB_CFLAGS} \
${LIBXMLPP_CFLAGS} \ ${LIBXMLPP_CFLAGS} \
${GTKMM_CFLAGS} \ ${GTKMM_CFLAGS} \
${LIBGLADEMM_CFLAGS} \
${GSTREAMER_CFLAGS} \ ${GSTREAMER_CFLAGS} \
-I${USR_INCLUDE_DIR} \ -I${USR_INCLUDE_DIR} \
-I${CORE_INCLUDE_DIR} \ -I${CORE_INCLUDE_DIR} \
@ -235,6 +239,7 @@ LDFLAGS = @LDFLAGS@ -pthread \
${LIBXMLPP_LIBS} \ ${LIBXMLPP_LIBS} \
${CURL_LIBS} \ ${CURL_LIBS} \
${GTKMM_LIBS} \ ${GTKMM_LIBS} \
${LIBGLADEMM_LIBS} \
${GSTREAMER_LIBS} \ ${GSTREAMER_LIBS} \
${TAGLIB_LIBS} \ ${TAGLIB_LIBS} \
-L${USR_LIB_DIR} \ -L${USR_LIB_DIR} \
@ -253,12 +258,12 @@ LDFLAGS = @LDFLAGS@ -pthread \
G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/MasterPanelWindow.o \ ${TMP_DIR}/MasterPanelWindow.o \
${TMP_DIR}/NowPlaying.o \ ${TMP_DIR}/NowPlaying.o \
${TMP_DIR}/MasterPanelUserInfoWidget.o \
${TMP_DIR}/GuiWindow.o \ ${TMP_DIR}/GuiWindow.o \
${TMP_DIR}/BasicWindow.o \
${TMP_DIR}/LoginWindow.o \ ${TMP_DIR}/LoginWindow.o \
${TMP_DIR}/UploadFileWindow.o \ ${TMP_DIR}/UploadFileWindow.o \
${TMP_DIR}/ScratchpadWindow.o \ ${TMP_DIR}/ScratchpadWindow.o \
${TMP_DIR}/SimplePlaylistManagementWindow.o \ ${TMP_DIR}/PlaylistWindow.o \
${TMP_DIR}/SchedulerWindow.o \ ${TMP_DIR}/SchedulerWindow.o \
${TMP_DIR}/SchedulePlaylistWindow.o \ ${TMP_DIR}/SchedulePlaylistWindow.o \
${TMP_DIR}/SearchWindow.o \ ${TMP_DIR}/SearchWindow.o \

View file

@ -3,6 +3,7 @@
<!ELEMENT gLiveSupport (resourceBundle, <!ELEMENT gLiveSupport (resourceBundle,
supportedLanguages, supportedLanguages,
gladeDirectory,
widgetFactory, widgetFactory,
authenticationClientFactory, authenticationClientFactory,
storageClientFactory, storageClientFactory,
@ -25,8 +26,11 @@
<!ELEMENT supportedLanguages (language+) > <!ELEMENT supportedLanguages (language+) >
<!ELEMENT language EMPTY > <!ELEMENT language EMPTY >
<!ATTLIST language locale CDATA #REQUIRED > <!ATTLIST language locale CDATA #REQUIRED >
<!ATTLIST language name CDATA #REQUIRED > <!ATTLIST language name CDATA #REQUIRED >
<!ELEMENT gladeDirectory EMPTY >
<!ATTLIST gladeDirectory path CDATA #REQUIRED >
<!ELEMENT widgetFactory EMPTY > <!ELEMENT widgetFactory EMPTY >
<!ATTLIST widgetFactory path CDATA #REQUIRED > <!ATTLIST widgetFactory path CDATA #REQUIRED >
@ -150,6 +154,8 @@
<language locale="sr_CS_CYRILLIC" name="Српски"/> <language locale="sr_CS_CYRILLIC" name="Српски"/>
</supportedLanguages> </supportedLanguages>
<gladeDirectory path = "./var/glade/" />
<widgetFactory path = "var/widgets/" /> <widgetFactory path = "var/widgets/" />
<authenticationClientFactory> <authenticationClientFactory>
@ -430,7 +436,7 @@
</keyboardShortcutContainer> </keyboardShortcutContainer>
<keyboardShortcutContainer <keyboardShortcutContainer
windowName ="simplePlaylistManagementWindow"> windowName ="playlistWindow">
<keyboardShortcut action = "moveItemUp" <keyboardShortcut action = "moveItemUp"
key = "&lt;Alt&gt;Up" /> key = "&lt;Alt&gt;Up" />
<keyboardShortcut action = "moveItemDown" <keyboardShortcut action = "moveItemDown"

View file

@ -3,6 +3,7 @@
<!ELEMENT gLiveSupport (resourceBundle, <!ELEMENT gLiveSupport (resourceBundle,
supportedLanguages, supportedLanguages,
gladeDirectory,
widgetFactory, widgetFactory,
authenticationClientFactory, authenticationClientFactory,
storageClientFactory, storageClientFactory,
@ -25,8 +26,11 @@
<!ELEMENT supportedLanguages (language+) > <!ELEMENT supportedLanguages (language+) >
<!ELEMENT language EMPTY > <!ELEMENT language EMPTY >
<!ATTLIST language locale CDATA #REQUIRED > <!ATTLIST language locale CDATA #REQUIRED >
<!ATTLIST language name CDATA #REQUIRED > <!ATTLIST language name CDATA #REQUIRED >
<!ELEMENT gladeDirectory EMPTY >
<!ATTLIST gladeDirectory path CDATA #REQUIRED >
<!ELEMENT widgetFactory EMPTY > <!ELEMENT widgetFactory EMPTY >
<!ATTLIST widgetFactory path CDATA #REQUIRED > <!ATTLIST widgetFactory path CDATA #REQUIRED >
@ -150,6 +154,8 @@
<language locale="sr_CS_CYRILLIC" name="Српски"/> <language locale="sr_CS_CYRILLIC" name="Српски"/>
</supportedLanguages> </supportedLanguages>
<gladeDirectory path = "ls_var_dir/Campcaster/glade/" />
<widgetFactory path = "ls_var_dir/Campcaster/Widgets/" /> <widgetFactory path = "ls_var_dir/Campcaster/Widgets/" />
<authenticationClientFactory> <authenticationClientFactory>
@ -429,7 +435,7 @@
</keyboardShortcutContainer> </keyboardShortcutContainer>
<keyboardShortcutContainer <keyboardShortcutContainer
windowName ="simplePlaylistManagementWindow"> windowName ="playlistWindow">
<keyboardShortcut action = "moveItemUp" <keyboardShortcut action = "moveItemUp"
key = "&lt;Alt&gt;Up" /> key = "&lt;Alt&gt;Up" />
<keyboardShortcut action = "moveItemDown" <keyboardShortcut action = "moveItemDown"

View file

@ -3,6 +3,7 @@
<!ELEMENT gLiveSupport (resourceBundle, <!ELEMENT gLiveSupport (resourceBundle,
supportedLanguages, supportedLanguages,
gladeDirectory,
widgetFactory, widgetFactory,
authenticationClientFactory, authenticationClientFactory,
storageClientFactory, storageClientFactory,
@ -25,8 +26,11 @@
<!ELEMENT supportedLanguages (language+) > <!ELEMENT supportedLanguages (language+) >
<!ELEMENT language EMPTY > <!ELEMENT language EMPTY >
<!ATTLIST language locale CDATA #REQUIRED > <!ATTLIST language locale CDATA #REQUIRED >
<!ATTLIST language name CDATA #REQUIRED > <!ATTLIST language name CDATA #REQUIRED >
<!ELEMENT gladeDirectory EMPTY >
<!ATTLIST gladeDirectory path CDATA #REQUIRED >
<!ELEMENT widgetFactory EMPTY > <!ELEMENT widgetFactory EMPTY >
<!ATTLIST widgetFactory path CDATA #REQUIRED > <!ATTLIST widgetFactory path CDATA #REQUIRED >
@ -150,6 +154,8 @@
<language locale="sr_CS_CYRILLIC" name="Српски"/> <language locale="sr_CS_CYRILLIC" name="Српски"/>
</supportedLanguages> </supportedLanguages>
<gladeDirectory path = "./var/glade/" />
<widgetFactory path = "var/widgets/" /> <widgetFactory path = "var/widgets/" />
<authenticationClientFactory> <authenticationClientFactory>
@ -429,7 +435,7 @@
</keyboardShortcutContainer> </keyboardShortcutContainer>
<keyboardShortcutContainer <keyboardShortcutContainer
windowName ="simplePlaylistManagementWindow"> windowName ="playlistWindow">
<keyboardShortcut action = "moveItemUp" <keyboardShortcut action = "moveItemUp"
key = "&lt;Alt&gt;Up" /> key = "&lt;Alt&gt;Up" />
<keyboardShortcut action = "moveItemDown" <keyboardShortcut action = "moveItemDown"

View file

@ -101,6 +101,10 @@ PKG_CHECK_MODULES(GTKMM,[gtkmm-2.4 >= 2.5.5])
AC_SUBST(GTKMM_CFLAGS) AC_SUBST(GTKMM_CFLAGS)
AC_SUBST(GTKMM_LIBS) AC_SUBST(GTKMM_LIBS)
PKG_CHECK_MODULES(LIBGLADEMM,[libglademm-2.4 >= 2.6.2])
AC_SUBST(LIBGLADEMM_CFLAGS)
AC_SUBST(LIBGLADEMM_LIBS)
PKG_CHECK_MODULES(GSTREAMER,[gstreamer-0.8 >= 0.8]) PKG_CHECK_MODULES(GSTREAMER,[gstreamer-0.8 >= 0.8])
AC_SUBST(GSTREAMER_CFLAGS) AC_SUBST(GSTREAMER_CFLAGS)
AC_SUBST(GSTREAMER_LIBS) AC_SUBST(GSTREAMER_LIBS)

View file

@ -35,12 +35,10 @@
#include <iostream> #include <iostream>
#include "AdvancedSearchItem.h"
#include "AdvancedSearchEntry.h" #include "AdvancedSearchEntry.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -51,39 +49,9 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The localization key for "File type: " before the file type selector box. * The maximum number of AdvancedSearchItem children.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
const std::string fileTypeLabelKey = "fileTypeTextLabel"; const int maxChildren = 5;
/*------------------------------------------------------------------------------
* The localization key for "all" in the file type selector box.
*----------------------------------------------------------------------------*/
const std::string allLocalizationKey = "allFileType";
/*------------------------------------------------------------------------------
* The localization key for "playlist" in the file type selector box.
*----------------------------------------------------------------------------*/
const std::string playlistLocalizationKey = "playlistFileType";
/*------------------------------------------------------------------------------
* The localization key for "audioClip" in the file type selector box.
*----------------------------------------------------------------------------*/
const std::string audioClipLocalizationKey = "audioClipFileType";
/*------------------------------------------------------------------------------
* The search key for "all" in the file type selector box.
*----------------------------------------------------------------------------*/
const std::string allSearchKey = "all";
/*------------------------------------------------------------------------------
* The search key for "playlist" in the file type selector box.
*----------------------------------------------------------------------------*/
const std::string playlistSearchKey = "playlist";
/*------------------------------------------------------------------------------
* The search key for "audioClip" in the file type selector box.
*----------------------------------------------------------------------------*/
const std::string audioClipSearchKey = "audioClip";
} }
@ -95,61 +63,39 @@ const std::string audioClipSearchKey = "audioClip";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
AdvancedSearchEntry :: AdvancedSearchEntry(Ptr<GLiveSupport>::Ref gLiveSupport) AdvancedSearchEntry :: AdvancedSearchEntry(
Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: gLiveSupport(gLiveSupport) : gLiveSupport(gLiveSupport)
{ {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
try { "advancedSearchEntry");
bundle = gLiveSupport->getBundle("advancedSearchEntry");
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
setBundle(bundle); setBundle(bundle);
metadataTypes = gLiveSupport->getMetadataTypeContainer(); metadataTypes = gLiveSupport->getMetadataTypeContainer();
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
Gtk::Label * fileTypeLabel; Gtk::Label * fileTypeLabel;
try { glade->get_widget("advancedFileTypeLabel1", fileTypeLabel);
fileTypeLabel = Gtk::manage(new Gtk::Label( fileTypeLabel->set_label(*getResourceUstring("fileTypeTextLabel"));
*getResourceUstring(fileTypeLabelKey) ));
glade->get_widget_derived("advancedFileTypeEntry1", fileTypeEntry);
} catch (std::invalid_argument &e) { fileTypeEntry->append_text(*getResourceUstring("allFileType"));
std::cerr << e.what() << std::endl; fileTypeEntry->append_text(*getResourceUstring("audioClipFileType"));
std::exit(1); fileTypeEntry->append_text(*getResourceUstring("playlistFileType"));
fileTypeEntry->set_active(0);
for (int i = 0; i < maxChildren; ++i) {
Ptr<AdvancedSearchItem>::Ref searchItem(new AdvancedSearchItem(
i,
metadataTypes,
getBundle(),
glade));
children.push_back(searchItem);
} }
fileTypeEntry = Gtk::manage(wf->createComboBoxText()); children.at(0)->signalAddNew().connect(sigc::mem_fun(*this,
Ptr<Glib::ustring>::Ref allKey(new Glib::ustring(allSearchKey));
Ptr<Glib::ustring>::Ref audioClipKey(new Glib::ustring(audioClipSearchKey));
Ptr<Glib::ustring>::Ref playlistKey( new Glib::ustring(playlistSearchKey));
fileTypeEntry->appendPair(getResourceUstring(allLocalizationKey),
allKey);
fileTypeEntry->appendPair(getResourceUstring(audioClipLocalizationKey),
audioClipKey);
fileTypeEntry->appendPair(getResourceUstring(playlistLocalizationKey),
playlistKey);
fileTypeEntry->set_active(0);
AdvancedSearchItem * searchItem = Gtk::manage(new AdvancedSearchItem(
true,
metadataTypes,
getBundle() ));
searchItem->signalAddNew().connect(sigc::mem_fun(*this,
&AdvancedSearchEntry::onAddNewCondition )); &AdvancedSearchEntry::onAddNewCondition ));
Gtk::HBox * fileTypeBox = Gtk::manage(new Gtk::HBox);
fileTypeBox->pack_start(*fileTypeLabel, Gtk::PACK_SHRINK, 5);
fileTypeBox->pack_start(*fileTypeEntry, Gtk::PACK_SHRINK, 5);
searchItemsBox = Gtk::manage(new Gtk::VBox);
searchItemsBox->pack_start(*searchItem, Gtk::PACK_SHRINK, 0);
pack_start(*fileTypeBox, Gtk::PACK_SHRINK, 5);
pack_start(*searchItemsBox, Gtk::PACK_SHRINK, 5);
} }
@ -159,14 +105,20 @@ AdvancedSearchEntry :: AdvancedSearchEntry(Ptr<GLiveSupport>::Ref gLiveSupport)
void void
AdvancedSearchEntry :: onAddNewCondition(void) throw () AdvancedSearchEntry :: onAddNewCondition(void) throw ()
{ {
AdvancedSearchItem * searchItem = Gtk::manage(new AdvancedSearchItem( bool foundAvailableChild = false;
false, Ptr<AdvancedSearchItem>::Ref child;
metadataTypes,
getBundle() )); for (int i = 1; i < maxChildren; ++i) {
searchItemsBox->pack_start(*searchItem, Gtk::PACK_SHRINK, 5); child = children.at(i);
if (!child->is_visible()) {
searchItem->show_all_children(); foundAvailableChild = true;
searchItem->show(); break;
}
}
if (foundAvailableChild) {
child->show();
}
} }
@ -176,16 +128,26 @@ AdvancedSearchEntry :: onAddNewCondition(void) throw ()
Ptr<SearchCriteria>::Ref Ptr<SearchCriteria>::Ref
AdvancedSearchEntry :: getSearchCriteria(void) throw () AdvancedSearchEntry :: getSearchCriteria(void) throw ()
{ {
Ptr<const Glib::ustring>::Ref fileType = fileTypeEntry->getActiveKey(); Glib::ustring fileType;
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria(*fileType)); switch (fileTypeEntry->get_active_row_number()) {
case 0: fileType = "all";
break;
case 1: fileType = "audioClip";
break;
case 2: fileType = "playlist";
break;
default: std::cerr << "impossible value in AdvancedSearchEntry::"
<< "getSearchCriteria()" << std::endl;
break;
}
Gtk::Box_Helpers::BoxList children = searchItemsBox->children(); Ptr<SearchCriteria>::Ref criteria(new SearchCriteria(fileType));
Gtk::Box_Helpers::BoxList::type_base::iterator it;
for (int i = 0; i < maxChildren; ++i) {
for (it = children.begin(); it != children.end(); ++it) { Ptr<AdvancedSearchItem>::Ref child = children.at(i);
AdvancedSearchItem * child = dynamic_cast<AdvancedSearchItem *>( if (child->is_visible()) {
it->get_widget() ); criteria->addCondition(child->getSearchCondition());
criteria->addCondition(child->getSearchCondition()); }
} }
return criteria; return criteria;
@ -199,12 +161,8 @@ void
AdvancedSearchEntry :: connectCallback(const sigc::slot<void> & callback) AdvancedSearchEntry :: connectCallback(const sigc::slot<void> & callback)
throw () throw ()
{ {
Gtk::Box_Helpers::BoxList children = searchItemsBox->children(); for (int i = 0; i < maxChildren; ++i) {
Gtk::Box_Helpers::BoxList::type_base::iterator it; Ptr<AdvancedSearchItem>::Ref child = children.at(i);
for (it = children.begin(); it != children.end(); ++it) {
AdvancedSearchItem * child = dynamic_cast<AdvancedSearchItem *>(
it->get_widget() );
child->signal_activate().connect(callback); child->signal_activate().connect(callback);
} }
} }

View file

@ -40,18 +40,23 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/box.h> #include <vector>
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/MetadataTypeContainer.h" #include "LiveSupport/Core/MetadataTypeContainer.h"
#include "LiveSupport/Core/SearchCriteria.h" #include "LiveSupport/Core/SearchCriteria.h"
#include "LiveSupport/Widgets/ComboBoxText.h"
#include "AdvancedSearchItem.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -62,15 +67,15 @@ using namespace LiveSupport::Core;
/* =============================================================== data types */ /* =============================================================== data types */
/** /**
* A Gtk::VBox with one or more search input fields in it. * A sub-window with one or more search input fields in it.
* *
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class AdvancedSearchEntry : public Gtk::VBox, class AdvancedSearchEntry : public LocalizedObject
public LocalizedObject
{ {
private: private:
/** /**
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
*/ */
@ -85,21 +90,25 @@ class AdvancedSearchEntry : public Gtk::VBox,
* The combo box for selecting the file types to search for. * The combo box for selecting the file types to search for.
*/ */
ComboBoxText * fileTypeEntry; ComboBoxText * fileTypeEntry;
/** /**
* The box containing the AdvancedSearchItem widgets. * The AdvancedSearchItem children of the widget.
*/ */
Gtk::VBox * searchItemsBox; std::vector<Ptr<AdvancedSearchItem>::Ref> children;
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param gLiveSupport the gLiveSupport object, containing * @param gLiveSupport the GLiveSupport object, containing
* all the vital info. * all the vital info.
* @param glade the Glade file which specifies the visual
* components for this class.
*/ */
AdvancedSearchEntry(Ptr<GLiveSupport>::Ref gLiveSupport) AdvancedSearchEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**

View file

@ -35,13 +35,10 @@
#include <iostream> #include <iostream>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "AdvancedSearchItem.h" #include "AdvancedSearchItem.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -59,46 +56,39 @@ using namespace LiveSupport::GLiveSupport;
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
AdvancedSearchItem :: AdvancedSearchItem( AdvancedSearchItem :: AdvancedSearchItem(
bool isFirst, int index,
Ptr<MetadataTypeContainer>::Ref metadataTypes, Ptr<MetadataTypeContainer>::Ref metadataTypes,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: LocalizedObject(bundle) : LocalizedObject(bundle)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); glade->get_widget(addIndex("advancedSearchItem", index), enclosingBox);
Gtk::Label * searchByLabel; Gtk::Label * searchByLabel;
try { glade->get_widget(addIndex("advancedSearchByLabel", index), searchByLabel);
searchByLabel = Gtk::manage(new Gtk::Label( searchByLabel->set_label(*getResourceUstring("searchByTextLabel"));
*getResourceUstring("searchByTextLabel") ));
} catch (std::invalid_argument &e) { glade->get_widget_derived(addIndex("advancedMetadataEntry", index),
std::cerr << e.what() << std::endl; metadataEntry);
std::exit(1); metadataEntry->setContents(metadataTypes);
}
glade->get_widget_derived(addIndex("advancedOperatorEntry", index),
operatorEntry);
operatorEntry->setContents(bundle);
glade->get_widget(addIndex("advancedValueEntry", index), valueEntry);
pack_start(*searchByLabel, Gtk::PACK_SHRINK, 5); if (index == 0) {
glade->get_widget(addIndex("advancedPlusMinusButton", index),
metadataEntry = Gtk::manage(wf->createMetadataComboBoxText(metadataTypes)); plusButton);
pack_start(*metadataEntry, Gtk::PACK_SHRINK, 5);
operatorEntry = Gtk::manage(wf->createOperatorComboBoxText(bundle));
pack_start(*operatorEntry, Gtk::PACK_SHRINK, 5);
valueEntry = Gtk::manage(wf->createEntryBin());
pack_start(*valueEntry, Gtk::PACK_EXPAND_WIDGET, 5);
if (isFirst) {
plusButton = Gtk::manage(wf->createButton(WidgetConstants::plusButton));
pack_start(*plusButton, Gtk::PACK_SHRINK, 5);
plusButton->signal_clicked().connect(sigc::mem_fun(*this, plusButton->signal_clicked().connect(sigc::mem_fun(*this,
&AdvancedSearchItem::onPlusButtonClicked )); &AdvancedSearchItem::onPlusButtonClicked));
} else { } else {
closeButton = Gtk::manage(wf->createButton( glade->get_widget(addIndex("advancedPlusMinusButton", index),
WidgetConstants::minusButton)); closeButton);
closeButton->signal_clicked().connect(sigc::mem_fun(*this, closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&AdvancedSearchItem::destroy_ )); &AdvancedSearchItem::onCloseButtonClicked));
pack_start(*closeButton, Gtk::PACK_SHRINK, 5);
} }
} }
@ -107,7 +97,7 @@ AdvancedSearchItem :: AdvancedSearchItem(
* Return the current state of the search fields. * Return the current state of the search fields.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Ptr<SearchCriteria::SearchConditionType>::Ref Ptr<SearchCriteria::SearchConditionType>::Ref
AdvancedSearchItem :: getSearchCondition(void) throw () AdvancedSearchItem :: getSearchCondition(void) throw ()
{ {
Ptr<const Glib::ustring>::Ref metadataKey = metadataEntry->getActiveKey(); Ptr<const Glib::ustring>::Ref metadataKey = metadataEntry->getActiveKey();
Ptr<const Glib::ustring>::Ref operatorKey = operatorEntry->getActiveKey(); Ptr<const Glib::ustring>::Ref operatorKey = operatorEntry->getActiveKey();

View file

@ -42,17 +42,16 @@
#include <vector> #include <vector>
#include <utility> #include <utility>
#include <gtkmm.h>
#include <gtkmm/box.h> #include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/NumericTools.h"
#include "LiveSupport/Core/MetadataTypeContainer.h" #include "LiveSupport/Core/MetadataTypeContainer.h"
#include "LiveSupport/Core/SearchCriteria.h" #include "LiveSupport/Core/SearchCriteria.h"
#include "LiveSupport/Widgets/MetadataComboBoxText.h" #include "LiveSupport/Widgets/MetadataComboBoxText.h"
#include "LiveSupport/Widgets/OperatorComboBoxText.h" #include "LiveSupport/Widgets/OperatorComboBoxText.h"
#include "LiveSupport/Widgets/EntryBin.h"
#include "LiveSupport/Widgets/ImageButton.h"
namespace LiveSupport { namespace LiveSupport {
@ -75,47 +74,45 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class AdvancedSearchItem : public Gtk::HBox, class AdvancedSearchItem : public LocalizedObject,
public LocalizedObject private NumericTools
{ {
private: private:
/**
* The type for storing both the metadata and the comparison operator
* localizations.
*/
typedef std::vector<std::pair<Glib::ustring, Glib::ustring> >
MapVector;
/**
* The enclosing box.
*/
Gtk::Box * enclosingBox;
/** /**
* The metadata field. * The metadata field.
*/ */
MetadataComboBoxText * metadataEntry; MetadataComboBoxText * metadataEntry;
/** /**
* The operator field. * The operator field.
*/ */
OperatorComboBoxText * operatorEntry; OperatorComboBoxText * operatorEntry;
/** /**
* The "search for this value" field. * The "search for this value" field.
*/ */
EntryBin * valueEntry; Gtk::Entry * valueEntry;
/** /**
* The "add new search item" button. * The "add new search item" button.
*/ */
ImageButton * plusButton; Gtk::Button * plusButton;
/** /**
* The "remove this item" button. * The "remove this item" button.
*/ */
ImageButton * closeButton; Gtk::Button * closeButton;
/** /**
* A signal object emitted when the plus button is pressed. * A signal object emitted when the plus button is pressed.
*/ */
sigc::signal<void> signalAddNewObject; sigc::signal<void> signalAddNewObject;
/** /**
* Event handler for the Plus button getting clicked. * Event handler for the Plus button getting clicked.
@ -126,19 +123,33 @@ class AdvancedSearchItem : public Gtk::HBox,
signalAddNew().emit(); signalAddNew().emit();
} }
/**
* Event handler for the Close button getting clicked.
*/
void
onCloseButtonClicked() throw ()
{
hide();
}
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param isFirst true if this is the first search condition * @param index the position of this item in the list of
* (so it does not need a Close button) * advanced search items.
* @param metadataTypes container holding all known metadata types * @param metadataTypes container holding all known metadata types
* @param bundle the resource bundle holding the localized
* resources for this widget.
* @param glade the Glade file which specifies the visual
* components for this class.
*/ */
AdvancedSearchItem(bool isFirst, AdvancedSearchItem(int index,
Ptr<MetadataTypeContainer>::Ref metadataTypes, Ptr<MetadataTypeContainer>::Ref metadataTypes,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**
@ -179,6 +190,35 @@ class AdvancedSearchItem : public Gtk::HBox,
{ {
return signalAddNewObject; return signalAddNewObject;
} }
/**
* Is the widget visible?
*
* return true if visible, false if not.
*/
bool
is_visible(void) throw ()
{
return enclosingBox->is_visible();
}
/**
* Show the widget.
*/
void
show(void) throw ()
{
enclosingBox->show();
}
/**
* Hide the widget.
*/
void
hide(void) throw ()
{
enclosingBox->hide();
}
}; };

View file

@ -38,7 +38,6 @@
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -78,34 +77,26 @@ const Glib::ustring userPreferencesKeyName = "activeBackups";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
BackupList :: BackupList (Ptr<GLiveSupport>::Ref gLiveSupport, BackupList :: BackupList (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: LocalizedObject(bundle), : LocalizedObject(bundle),
gLiveSupport(gLiveSupport) gLiveSupport(gLiveSupport)
{ {
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
// create the tree view // create the tree view
treeModel = Gtk::ListStore::create(modelColumns); treeModel = Gtk::ListStore::create(modelColumns);
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel)); glade->get_widget_derived("backupListTreeView1", treeView);
treeView->set_enable_search(false); treeView->set_model(treeModel);
treeView->connectModelSignals(treeModel);
// Add the TreeView's view columns: // Add the TreeView's view columns:
try { treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
treeView->appendColumn(*getResourceUstring("titleColumnLabel"), modelColumns.titleColumn, 300);
modelColumns.titleColumn, 300); treeView->appendColumn(*getResourceUstring("dateColumnLabel"),
treeView->appendColumn(*getResourceUstring("dateColumnLabel"), modelColumns.dateColumn, 180);
modelColumns.dateColumn, 180); treeView->appendColumn(*getResourceUstring("statusColumnLabel"),
treeView->appendColumn(*getResourceUstring("statusColumnLabel"), modelColumns.statusDisplayColumn, 50);
modelColumns.statusDisplayColumn, 50);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// add the tree view to this widget
Gtk::VBox::add(*treeView);
userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName)); userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName));
} }
@ -342,7 +333,7 @@ BackupList :: setStatus(Gtk::TreeIter iter,
} else { } else {
std::cerr << "Impossible status: '" << status std::cerr << "Impossible status: '" << status
<< "' in BackupList::setStatus()." << std::endl; << "' in BackupList::setStatus()." << std::endl;
} }
return false; return false;

View file

@ -40,13 +40,12 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/box.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/XmlRpcException.h" #include "LiveSupport/Core/XmlRpcException.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ScrolledWindow.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ZebraTreeView.h" #include "LiveSupport/Widgets/ZebraTreeView.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -89,11 +88,11 @@ using namespace LiveSupport::Widgets;
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision$ * @version $Revision$
*/ */
class BackupList : public Gtk::VBox, class BackupList : public LocalizedObject,
public LocalizedObject,
public ContentsStorable public ContentsStorable
{ {
private: private:
/** /**
* The user preferences key. * The user preferences key.
*/ */
@ -144,6 +143,7 @@ class BackupList : public Gtk::VBox,
protected: protected:
/** /**
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
*/ */
@ -220,6 +220,7 @@ class BackupList : public Gtk::VBox,
public: public:
/** /**
* Constructor. * Constructor.
* *
@ -227,9 +228,12 @@ class BackupList : public Gtk::VBox,
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
* @param glade the Glade file which specifies the visual
* components for this class.
*/ */
BackupList(Ptr<GLiveSupport>::Ref gLiveSupport, BackupList(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**

View file

@ -49,7 +49,6 @@
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
using namespace boost::posix_time; using namespace boost::posix_time;
@ -67,71 +66,42 @@ using namespace boost::posix_time;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport, BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: LocalizedObject(bundle), : gLiveSupport(gLiveSupport),
gLiveSupport(gLiveSupport) glade(glade)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle("backupView");
setBundle(bundle);
Gtk::Label * backupTitleLabel; Gtk::Label * backupTitleLabel;
Gtk::Label * mtimeLabel; Gtk::Label * mtimeLabel;
Gtk::Button * chooseTimeButton; Gtk::Button * chooseTimeButton;
Gtk::Button * resetTimeButton; Gtk::Button * resetTimeButton;
try { glade->get_widget("backupTitleLabel1", backupTitleLabel);
backupTitleLabel = Gtk::manage(new Gtk::Label( glade->get_widget("backupMtimeLabel1", mtimeLabel);
*getResourceUstring("backupTitleLabel"))); glade->get_widget("backupMtimeChooseButton1", chooseTimeButton);
mtimeLabel = Gtk::manage(new Gtk::Label( glade->get_widget("backupMtimeResetButton1", resetTimeButton);
*getResourceUstring("mtimeTextLabel"))); backupTitleLabel->set_label(*getResourceUstring("backupTitleLabel"));
chooseTimeButton = Gtk::manage(wf->createButton( mtimeLabel->set_label(*getResourceUstring("mtimeTextLabel"));
*getResourceUstring("chooseTimeButtonLabel"))); chooseTimeButton->set_label(*getResourceUstring("chooseTimeButtonLabel"));
resetTimeButton = Gtk::manage(wf->createButton( resetTimeButton->set_label(*getResourceUstring("resetTimeButtonLabel"));
*getResourceUstring("resetTimeButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
chooseTimeButton->signal_clicked().connect(sigc::mem_fun( chooseTimeButton->signal_clicked().connect(sigc::mem_fun(*this,
*this, &BackupView::onChooseTimeButtonClicked )); &BackupView::onChooseTimeButtonClicked));
resetTimeButton->signal_clicked().connect(sigc::mem_fun( resetTimeButton->signal_clicked().connect(sigc::mem_fun(*this,
*this, &BackupView::onResetTimeButtonClicked )); &BackupView::onResetTimeButtonClicked));
backupTitleEntry = Gtk::manage(wf->createEntryBin()); glade->get_widget("backupTitleEntry1", backupTitleEntry);
mtimeEntry = Gtk::manage(wf->createEntryBin()); glade->get_widget("backupMtimeEntry1", mtimeEntry);
mtimeEntry->getEntry()->set_editable(false);
mtimeEntry->getEntry()->set_alignment(0.5);
mtimeEntry->getEntry()->set_width_chars(20);
writeMtimeEntry(); writeMtimeEntry();
constructCriteriaView();
constructBackupListView();
Gtk::Box * backupTitleBox = Gtk::manage(new Gtk::HBox); dateTimeChooserWindow.reset(new DateTimeChooserWindow(
backupTitleBox->pack_start(*backupTitleLabel, Gtk::PACK_SHRINK, 5);
backupTitleBox->pack_start(*backupTitleEntry, Gtk::PACK_SHRINK, 5);
Gtk::Box * mtimeBox = Gtk::manage(new Gtk::HBox);
mtimeBox->pack_start(*mtimeLabel, Gtk::PACK_SHRINK, 5);
mtimeBox->pack_start(*mtimeEntry, Gtk::PACK_SHRINK, 5);
mtimeBox->pack_start(*chooseTimeButton, Gtk::PACK_SHRINK, 5);
mtimeBox->pack_start(*resetTimeButton, Gtk::PACK_SHRINK, 5);
Gtk::Box * criteriaView = constructCriteriaView();
Gtk::Box * topPane = Gtk::manage(new Gtk::VBox);
topPane->pack_start(*backupTitleBox, Gtk::PACK_SHRINK, 5);
topPane->pack_start(*mtimeBox, Gtk::PACK_SHRINK, 5);
topPane->pack_start(*criteriaView, Gtk::PACK_EXPAND_WIDGET, 5);
Gtk::Box * bottomPane = constructBackupListView();
Gtk::VPaned * twoPanedView = Gtk::manage(new Gtk::VPaned);
twoPanedView->pack1(*topPane, Gtk::PACK_EXPAND_WIDGET, 5);
twoPanedView->pack2(*bottomPane, Gtk::PACK_EXPAND_WIDGET, 5);
add(*twoPanedView);
dateTimeChooserWindow.reset(wf->createDateTimeChooserWindow(
gLiveSupport->getBundle("dateTimeChooserWindow") )); gLiveSupport->getBundle("dateTimeChooserWindow") ));
} }
@ -139,86 +109,33 @@ BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport,
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the box for entering the backup criteria. * Construct the box for entering the backup criteria.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Box * void
BackupView :: constructCriteriaView(void) throw () BackupView :: constructCriteriaView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); criteriaEntry.reset(new AdvancedSearchEntry(gLiveSupport, glade));
criteriaEntry->connectCallback(sigc::mem_fun(*this,
criteriaEntry = Gtk::manage(new AdvancedSearchEntry(gLiveSupport)); &BackupView::onCreateBackup));
criteriaEntry->connectCallback(sigc::mem_fun(
*this, &BackupView::onCreateBackup ));
Button * backupButton; Gtk::Button * backupButton;
try { glade->get_widget("backupButton1", backupButton);
backupButton = Gtk::manage(wf->createButton( backupButton->set_label(*getResourceUstring("backupButtonLabel"));
*getResourceUstring("backupButtonLabel") )); backupButton->signal_clicked().connect(sigc::mem_fun(*this,
} catch (std::invalid_argument &e) { &BackupView::onCreateBackup));
std::cerr << e.what() << std::endl;
std::exit(1);
}
backupButton->signal_clicked().connect(sigc::mem_fun(
*this, &BackupView::onCreateBackup ));
Gtk::Box * criteriaButtonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_END ));
criteriaButtonBox->pack_start(*backupButton, Gtk::PACK_SHRINK, 5);
ScrolledWindow * criteriaWindow = Gtk::manage(new ScrolledWindow);
criteriaWindow->add(*criteriaEntry);
// NOTE: criteriaWindow->setShadowType() causes Gtk warnings here
// TODO: find out why and fix it
criteriaWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
Gtk::Box * criteriaView = Gtk::manage(new Gtk::VBox);
criteriaView->pack_start(*criteriaWindow, Gtk::PACK_EXPAND_WIDGET, 0);
criteriaView->pack_start(*criteriaButtonBox, Gtk::PACK_SHRINK, 5);
return criteriaView;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the box for listing the pending backups. * Construct the box for listing the pending backups.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Box * void
BackupView :: constructBackupListView(void) throw () BackupView :: constructBackupListView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); backupList.reset(new BackupList(gLiveSupport, getBundle(), glade));
backupList = Gtk::manage(new BackupList(gLiveSupport, getBundle())); glade->connect_clicked("backupDeleteButton1", sigc::mem_fun(*this,
// TODO: connect callbacks &BackupView::onDeleteButtonClicked));
glade->connect_clicked("backupSaveButton1", sigc::mem_fun(*this,
Button * deleteButton; &BackupView::onSaveButtonClicked));
Button * saveButton;
try {
deleteButton = Gtk::manage(wf->createButton(
*getResourceUstring("deleteButtonLabel") ));
saveButton = Gtk::manage(wf->createButton(
*getResourceUstring("saveButtonLabel") ));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
deleteButton->signal_clicked().connect(sigc::mem_fun(
*this, &BackupView::onDeleteButtonClicked));
saveButton->signal_clicked().connect(sigc::mem_fun(
*this, &BackupView::onSaveButtonClicked));
Gtk::Box * backupListButtonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_END ));
backupListButtonBox->pack_start(*deleteButton, Gtk::PACK_SHRINK, 5);
backupListButtonBox->pack_start(*saveButton, Gtk::PACK_SHRINK, 5);
ScrolledWindow * backupListWindow = Gtk::manage(new ScrolledWindow);
backupListWindow->add(*backupList);
backupListWindow->setShadowType(Gtk::SHADOW_NONE);
backupListWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
Gtk::Box * backupListView = Gtk::manage(new Gtk::VBox);
backupListView->pack_start(*backupListWindow, Gtk::PACK_EXPAND_WIDGET, 5);
backupListView->pack_start(*backupListButtonBox, Gtk::PACK_SHRINK, 5);
return backupListView;
} }
@ -268,7 +185,7 @@ BackupView :: onCreateBackup(void) throw ()
Ptr<Glib::ustring>::Ref errorMsg Ptr<Glib::ustring>::Ref errorMsg
= getResourceUstring("backupErrorMsg"); = getResourceUstring("backupErrorMsg");
errorMsg->append(e.what()); errorMsg->append(e.what());
gLiveSupport->displayMessageWindow(errorMsg); gLiveSupport->displayMessageWindow(*errorMsg);
} }
} }
@ -286,7 +203,7 @@ BackupView :: onDeleteButtonClicked(void) throw ()
Ptr<Glib::ustring>::Ref errorMsg Ptr<Glib::ustring>::Ref errorMsg
= getResourceUstring("backupErrorMsg"); = getResourceUstring("backupErrorMsg");
errorMsg->append(e.what()); errorMsg->append(e.what());
gLiveSupport->displayMessageWindow(errorMsg); gLiveSupport->displayMessageWindow(*errorMsg);
} }
} }
@ -305,7 +222,7 @@ BackupView :: onSaveButtonClicked(void) throw ()
Ptr<Glib::ustring>::Ref errorMsg Ptr<Glib::ustring>::Ref errorMsg
= getResourceUstring("backupErrorMsg"); = getResourceUstring("backupErrorMsg");
errorMsg->append(e.what()); errorMsg->append(e.what());
gLiveSupport->displayMessageWindow(errorMsg); gLiveSupport->displayMessageWindow(*errorMsg);
} }
if (!url) { if (!url) {
@ -358,16 +275,8 @@ BackupView :: readTitle(void) throw ()
{ {
Ptr<Glib::ustring>::Ref title(new Glib::ustring( Ptr<Glib::ustring>::Ref title(new Glib::ustring(
backupTitleEntry->get_text() )); backupTitleEntry->get_text() ));
if (*title != "") { if (*title == "") {
return title;
}
try {
title = getResourceUstring("defaultBackupTitle"); title = getResourceUstring("defaultBackupTitle");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
} }
return title; return title;

View file

@ -40,14 +40,13 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/box.h> #include <gtkmm.h>
#include <libglademm.h>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ScrolledWindow.h"
#include "LiveSupport/Widgets/DateTimeChooserWindow.h" #include "LiveSupport/Widgets/DateTimeChooserWindow.h"
#include "AdvancedSearchEntry.h" #include "AdvancedSearchEntry.h"
#include "BackupList.h" #include "BackupList.h"
@ -89,24 +88,24 @@ using namespace boost::posix_time;
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision$ * @version $Revision$
*/ */
class BackupView : public Gtk::VBox, class BackupView : public LocalizedObject
public LocalizedObject
{ {
private: private:
/** /**
* The text entry field for entering the title of the backup. * The text entry field for entering the title of the backup.
*/ */
EntryBin * backupTitleEntry; Gtk::Entry * backupTitleEntry;
/** /**
* The "modified since" time for the backup. * The "modified since" time for the backup.
*/ */
Ptr<const ptime>::Ref mtime; Ptr<const ptime>::Ref mtime;
/** /**
* The entry field holding the "modified since" time for the backup. * The entry field holding the "modified since" time for the backup.
*/ */
EntryBin * mtimeEntry; Gtk::Entry * mtimeEntry;
/** /**
* The window for entering the "modified since" time. * The window for entering the "modified since" time.
@ -116,19 +115,19 @@ class BackupView : public Gtk::VBox,
/** /**
* The object for entering the backup criteria. * The object for entering the backup criteria.
*/ */
AdvancedSearchEntry * criteriaEntry; Ptr<AdvancedSearchEntry>::Ref criteriaEntry;
/** /**
* The list of pending backups. * The list of pending backups.
*/ */
BackupList * backupList; Ptr<BackupList>::Ref backupList;
/** /**
* Construct the box for entering the backup criteria. * Construct the box for entering the backup criteria.
* *
* @return the constructed box, already Gtk::manage()'ed. * @return the constructed box, already Gtk::manage()'ed.
*/ */
Gtk::Box * void
constructCriteriaView(void) throw (); constructCriteriaView(void) throw ();
/** /**
@ -136,7 +135,7 @@ class BackupView : public Gtk::VBox,
* *
* @return the constructed box, already Gtk::manage()'ed. * @return the constructed box, already Gtk::manage()'ed.
*/ */
Gtk::Box * void
constructBackupListView(void) throw (); constructBackupListView(void) throw ();
/** /**
@ -156,11 +155,17 @@ class BackupView : public Gtk::VBox,
protected: protected:
/** /**
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
*/ */
Ptr<GLiveSupport>::Ref gLiveSupport; Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The Glade object, which specifies the visual components.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/** /**
* Event handler for the time chooser button being clicked. * Event handler for the time chooser button being clicked.
*/ */
@ -193,16 +198,17 @@ class BackupView : public Gtk::VBox,
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param gLiveSupport the gLiveSupport object, containing * @param gLiveSupport the gLiveSupport object, containing
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param glade the Glade file which specifies the visual
* resources for this window. * components for this class.
*/ */
BackupView(Ptr<GLiveSupport>::Ref gLiveSupport, BackupView(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**
@ -216,7 +222,7 @@ class BackupView : public Gtk::VBox,
/** /**
* Return the BackupList object shown by the widget. * Return the BackupList object shown by the widget.
*/ */
BackupList * Ptr<BackupList>::Ref
getBackupList(void) throw () getBackupList(void) throw ()
{ {
return backupList; return backupList;

View file

@ -0,0 +1,157 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 3105 $
Location : $URL: svn+ssh://fgerlits@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/products/gLiveSupport/src/BasicWindow.cxx $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "GLiveSupport.h"
#include "BasicWindow.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
namespace {
/**
* The name of the application, shown on the task bar.
*/
const Glib::ustring applicationTitle = "Campcaster";
}
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
BasicWindow :: BasicWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeFileName)
throw ()
: LocalizedObject(bundle),
gLiveSupport(gLiveSupport),
windowOpenerButton(windowOpenerButton)
{
glade = Gnome::Glade::Xml::create(gladeFileName);
glade->get_widget("mainWindow1", mainWindow);
setTitle(getResourceUstring("windowTitle"));
mainWindow->signal_delete_event().connect(sigc::mem_fun(*this,
&BasicWindow::onDeleteEvent));
}
/*------------------------------------------------------------------------------
* Restore the window position and show the window.
*----------------------------------------------------------------------------*/
void
BasicWindow :: show (void) throw ()
{
preShow();
mainWindow->show();
}
/*------------------------------------------------------------------------------
* Stuff to do before showing the window.
*----------------------------------------------------------------------------*/
void
BasicWindow :: preShow (void) throw ()
{
gLiveSupport->getWindowPosition(this);
if (windowOpenerButton) {
windowOpenerButton->set_active(true);
}
}
/*------------------------------------------------------------------------------
* Save the window position and hide the window.
*----------------------------------------------------------------------------*/
void
BasicWindow :: hide (void) throw ()
{
preHide();
mainWindow->hide();
}
/*------------------------------------------------------------------------------
* Signal handler for the close button getting clicked.
*----------------------------------------------------------------------------*/
bool
BasicWindow :: onDeleteEvent (GdkEventAny * event) throw ()
{
preHide();
return false;
}
/*------------------------------------------------------------------------------
* Stuff to do before hiding the window.
*----------------------------------------------------------------------------*/
void
BasicWindow :: preHide (void) throw ()
{
gLiveSupport->putWindowPosition(this);
if (windowOpenerButton) {
windowOpenerButton->set_active(false);
}
}
/*------------------------------------------------------------------------------
* Set the title of the window.
*----------------------------------------------------------------------------*/
void
BasicWindow :: setTitle (Ptr<const Glib::ustring>::Ref title)
throw ()
{
windowTitle = title;
Glib::ustring fullTitle = applicationTitle;
fullTitle += " - ";
fullTitle += *title;
mainWindow->set_title(fullTitle);
}

View file

@ -0,0 +1,210 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
#ifndef BasicWindow_h
#define BasicWindow_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <unicode/resbund.h>
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/LocalizedObject.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport::Core;
class GLiveSupport;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* The common ancestor of all openable and closable windows in the GUI.
*
* @author $Author$
* @version $Revision$
*/
class BasicWindow : public LocalizedObject
{
private:
/**
* The title of the window.
*/
Ptr<const Glib::ustring>::Ref windowTitle;
/**
* Stuff to do before showing the window.
*/
void
preShow(void) throw ();
/**
* Stuff to do before hiding the window.
*/
void
preHide(void) throw ();
protected:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The button which was used to open this window.
*/
Gtk::ToggleButton * windowOpenerButton;
/**
* The window itself.
*/
Gtk::Window * mainWindow;
/**
* The Glade object, containing the visual design.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* Signal handler for the close button getting clicked.
*/
virtual bool
onDeleteEvent(GdkEventAny * event) throw ();
public:
/**
* Constructor.
*
* @param gLiveSupport the GLiveSupport application object.
* @param bundle the resource bundle holding the localized
* resources for this window.
* @param windowOpenerButton the button which was pressed to open
* this window.
* @param gladeFileName the Glade file for this window.
*/
BasicWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeFileName)
throw ();
/**
* Virtual destructor.
*/
virtual
~BasicWindow(void) throw ()
{
}
/**
* Restore the window position and show the window.
*/
virtual void
show(void) throw ();
/**
* Save the window position and hide the window.
*/
virtual void
hide(void) throw ();
/**
* Set the title of the window.
*
* Adds the application's title to the title of the window shown
* on the task bar.
*
* @param title the title of the window.
*/
virtual void
setTitle(Ptr<const Glib::ustring>::Ref title) throw ();
/**
* A replacement for Gtk::Window::get_name().
*
* @return the (localized) title of the window.
*/
virtual Ptr<const Glib::ustring>::Ref
getTitle(void) const throw ()
{
return windowTitle;
}
/**
* Get the underlying Gtk::Window.
*/
virtual Gtk::Window *
getWindow(void) throw ()
{
return mainWindow;
}
/**
* Get the underlying Gtk::Window.
*/
virtual const Gtk::Window *
getWindow(void) const throw ()
{
return mainWindow;
}
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace GLiveSupport
} // namespace LiveSupport
#endif // BasicWindow_h

View file

@ -39,7 +39,6 @@
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -56,34 +55,36 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
BrowseEntry :: BrowseEntry( BrowseEntry :: BrowseEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport, Ptr<ResourceBundle>::Ref bundle,
Ptr<ResourceBundle>::Ref bundle) Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: LocalizedObject(bundle) : LocalizedObject(bundle)
{ {
browseItemOne = Gtk::manage(new BrowseItem(gLiveSupport, browseItemOne.reset(new BrowseItem(0,
bundle, gLiveSupport,
4 /* Genre */)); bundle,
browseItemTwo = Gtk::manage(new BrowseItem(gLiveSupport, glade,
bundle, 4 /* Genre */));
1 /* Creator */)); browseItemTwo.reset(new BrowseItem(1,
browseItemThree = Gtk::manage(new BrowseItem(gLiveSupport, gLiveSupport,
bundle, bundle,
2 /* Album */)); glade,
1 /* Creator */));
browseItemThree.reset(new BrowseItem(2,
gLiveSupport,
bundle,
glade,
2 /* Album */));
// TODO: change hard-coded indices to stuff read from config // TODO: change hard-coded indices to stuff read from config
browseItemOne->signalSelectionChanged().connect( browseItemOne->signalChanged().connect(
sigc::bind<BrowseItem*>( sigc::bind<Ptr<BrowseItem>::Ref>(
sigc::mem_fun(*browseItemTwo, &BrowseItem::onParentChangedShow), sigc::mem_fun(*browseItemTwo, &BrowseItem::onParentChangedShow),
browseItemOne )); browseItemOne ));
browseItemTwo->signalSelectionChanged().connect( browseItemTwo->signalChanged().connect(
sigc::bind<BrowseItem*>( sigc::bind<Ptr<BrowseItem>::Ref>(
sigc::mem_fun(*browseItemThree, &BrowseItem::onParentChangedShow), sigc::mem_fun(*browseItemThree, &BrowseItem::onParentChangedShow),
browseItemTwo )); browseItemTwo ));
pack_start(*browseItemOne, Gtk::PACK_EXPAND_WIDGET, 5);
pack_start(*browseItemTwo, Gtk::PACK_EXPAND_WIDGET, 5);
pack_start(*browseItemThree, Gtk::PACK_EXPAND_WIDGET, 5);
} }

View file

@ -40,7 +40,8 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/box.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
@ -68,8 +69,7 @@ using namespace LiveSupport::Core;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class BrowseEntry : public Gtk::HBox, class BrowseEntry : public LocalizedObject
public LocalizedObject
{ {
private: private:
@ -81,34 +81,40 @@ class BrowseEntry : public Gtk::HBox,
/** /**
* The first BrowseItem entry field. * The first BrowseItem entry field.
*/ */
BrowseItem * browseItemOne; Ptr<BrowseItem>::Ref browseItemOne;
/** /**
* The second BrowseItem entry field. * The second BrowseItem entry field.
*/ */
BrowseItem * browseItemTwo; Ptr<BrowseItem>::Ref browseItemTwo;
/** /**
* The third BrowseItem entry field. * The third BrowseItem entry field.
*/ */
BrowseItem * browseItemThree; Ptr<BrowseItem>::Ref browseItemThree;
public: public:
/** /**
* Constructor with localization parameter. * Constructor with localization parameter.
*
* @param gLiveSupport the GLiveSupport object, containing
* all the vital info.
* @param bundle the resource bundle for localization.
* @param glade the Glade file which specifies the visual
* components for this class.
*/ */
BrowseEntry( BrowseEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport, Ptr<ResourceBundle>::Ref bundle,
Ptr<ResourceBundle>::Ref bundle) Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**
* A virtual destructor. * A virtual destructor.
*/ */
virtual virtual
~BrowseEntry(void) throw () ~BrowseEntry(void) throw ()
{ {
} }
@ -129,12 +135,12 @@ class BrowseEntry : public Gtk::HBox,
* The signal raised when either the combo box or the tree view * The signal raised when either the combo box or the tree view
* selection has changed. * selection has changed.
* *
* @return the signalSelectionChanged() of the last browse item * @return the signalChanged() of the last browse item
*/ */
sigc::signal<void> sigc::signal<void>
signalSelectionChanged(void) throw () signalChanged(void) throw ()
{ {
return browseItemThree->signalSelectionChanged(); return browseItemThree->signalChanged();
} }
}; };
@ -145,7 +151,7 @@ class BrowseEntry : public Gtk::HBox,
/* ====================================================== function prototypes */ /* ====================================================== function prototypes */
} // namespace Widgets } // namespace GLiveSupport
} // namespace LiveSupport } // namespace LiveSupport
#endif // BrowseEntry_h #endif // BrowseEntry_h

View file

@ -36,13 +36,10 @@
#include <iostream> #include <iostream>
#include <glibmm.h> #include <glibmm.h>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "BrowseItem.h" #include "BrowseItem.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -59,46 +56,36 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
BrowseItem :: BrowseItem( BrowseItem :: BrowseItem(int index,
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
int defaultIndex) Glib::RefPtr<Gnome::Glade::Xml> glade,
int defaultIndex)
throw () throw ()
: LocalizedObject(bundle), : LocalizedObject(bundle),
gLiveSupport(gLiveSupport) gLiveSupport(gLiveSupport)
{ {
parentCriteria.reset(new SearchCriteria); parentCriteria.reset(new SearchCriteria);
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); glade->get_widget_derived(addIndex("browseMetadataEntry", index),
metadataEntry);
metadataEntry = Gtk::manage(wf->createMetadataComboBoxText( metadataEntry->setContents(gLiveSupport->getMetadataTypeContainer());
gLiveSupport->getMetadataTypeContainer()));
metadataEntry->set_active(defaultIndex); metadataEntry->set_active(defaultIndex);
metadataEntry->signalSelectionChanged().connect(sigc::mem_fun(*this, metadataEntry->signal_changed().connect(sigc::mem_fun(*this,
&BrowseItem::onShow )); &BrowseItem::onShow ));
pack_start(*metadataEntry, Gtk::PACK_SHRINK, 5);
treeModel = Gtk::ListStore::create(modelColumns); treeModel = Gtk::ListStore::create(modelColumns);
metadataValues = Gtk::manage(wf->createTreeView(treeModel)); glade->get_widget_derived(addIndex("browseMetadataValues", index),
metadataValues);
metadataValues->set_model(treeModel);
metadataValues->connectModelSignals(treeModel);
metadataValues->appendColumn("", modelColumns.displayedColumn, 200); metadataValues->appendColumn("", modelColumns.displayedColumn, 200);
metadataValues->set_size_request(230, 150);
metadataValues->set_headers_visible(false);
metadataValues->signal_cursor_changed().connect(sigc::mem_fun(*this, metadataValues->signal_cursor_changed().connect(sigc::mem_fun(*this,
&BrowseItem::emitSignalSelectionChanged )); &BrowseItem::emitSignalChanged ));
Gtk::ScrolledWindow * scrolledWindow = Gtk::manage(new Gtk::ScrolledWindow); allString = Glib::Markup::escape_text(
scrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrolledWindow->add(*metadataValues);
pack_start(*scrolledWindow, Gtk::PACK_SHRINK, 5);
try {
allString = Glib::Markup::escape_text(
*getResourceUstring("allStringForBrowse")); *getResourceUstring("allStringForBrowse"));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
onShow(); onShow();
} }
@ -174,6 +161,6 @@ BrowseItem :: onShow(void) throw ()
*valuesIt); *valuesIt);
} }
emitSignalSelectionChanged(); emitSignalChanged();
} }

View file

@ -42,11 +42,12 @@
#include <vector> #include <vector>
#include <utility> #include <utility>
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/NumericTools.h"
#include "LiveSupport/Core/SearchCriteria.h" #include "LiveSupport/Core/SearchCriteria.h"
#include "LiveSupport/Widgets/ComboBoxText.h" #include "LiveSupport/Widgets/ComboBoxText.h"
#include "LiveSupport/Widgets/ZebraTreeView.h" #include "LiveSupport/Widgets/ZebraTreeView.h"
@ -73,17 +74,17 @@ using namespace LiveSupport::Widgets;
* A single browse input field. * A single browse input field.
* *
* It consists of a Widgets::ComboBoxText and a Widgets::ZebraTreeView * It consists of a Widgets::ComboBoxText and a Widgets::ZebraTreeView
* (without header). It stores a "parent search criteria", and shows all * (without headers). It stores a "parent search criteria", and shows all
* possible metadata values of the type selected in the ComboBoxText which * possible metadata values of the type selected in the ComboBoxText which
* match this condition. The parent search criteria should be conjunction * match this condition. The parent search criteria should be the conjunction
* of all search conditions selected in BrowseItem objects to the left of * of all search conditions selected in BrowseItem objects to the left of
* this one. * this one.
* *
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class BrowseItem : public Gtk::VBox, class BrowseItem : public LocalizedObject,
public LocalizedObject private NumericTools
{ {
private: private:
@ -152,7 +153,7 @@ class BrowseItem : public Gtk::VBox,
/** /**
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
*/ */
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport; Ptr<GLiveSupport>::Ref gLiveSupport;
/** /**
* The criteria from the browse items to the left of this one. * The criteria from the browse items to the left of this one.
@ -162,15 +163,15 @@ class BrowseItem : public Gtk::VBox,
/** /**
* Default constructor. * Default constructor.
*/ */
BrowseItem(void) throw (); BrowseItem(void) throw ();
/** /**
* Emit the "selection changed" signal. * Emit the "selection changed" signal.
*/ */
void void
emitSignalSelectionChanged(void) throw () emitSignalChanged(void) throw ()
{ {
signalSelectionChanged().emit(); signalChanged().emit();
} }
@ -179,7 +180,7 @@ class BrowseItem : public Gtk::VBox,
/** /**
* A signal object to notify people that the selection has changed. * A signal object to notify people that the selection has changed.
*/ */
sigc::signal<void> signalSelectionChangedObject; sigc::signal<void> signalChangedObject;
public: public:
@ -187,22 +188,27 @@ class BrowseItem : public Gtk::VBox,
/** /**
* Constructor with parent and localization parameter. * Constructor with parent and localization parameter.
* *
* @param index the position of this item in the list of
* browse items.
* @param gLiveSupport the main program object * @param gLiveSupport the main program object
* @param bundle the resource bundle for localization * @param bundle the resource bundle for localization
* @param glade the Glade file which specifies the visual
* components for this class.
* @param defaultIndex the index of the metadata entry to display * @param defaultIndex the index of the metadata entry to display
* initially * initially
*/ */
BrowseItem( BrowseItem(int index,
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
int defaultIndex) Glib::RefPtr<Gnome::Glade::Xml> glade,
throw (); int defaultIndex)
throw ();
/** /**
* A virtual destructor. * A virtual destructor.
*/ */
virtual virtual
~BrowseItem(void) throw () ~BrowseItem(void) throw ()
{ {
} }
@ -223,18 +229,19 @@ class BrowseItem : public Gtk::VBox,
* parent criteria), and set the selection to "all". * parent criteria), and set the selection to "all".
*/ */
void void
onShow(void) throw (); onShow(void) throw ();
/** /**
* The signal handler for refreshing the treeview of metadata values, * The signal handler for refreshing the treeview of metadata values,
* if we also need to change the parent criteria. Same as onShow(), * if we also need to change the parent criteria. Same as onShow(),
* plus changing the parent criteria. * plus changing the parent criteria.
* *
* @param criteria the new parent search criteria * @param leftNeighbor the neighbor where the parent criteria
* are coming from.
*/ */
void void
onParentChangedShow(BrowseItem * leftNeighbor) onParentChangedShow(Ptr<BrowseItem>::Ref leftNeighbor)
throw () throw ()
{ {
parentCriteria = leftNeighbor->getSearchCriteria(); parentCriteria = leftNeighbor->getSearchCriteria();
onShow(); onShow();
@ -247,9 +254,9 @@ class BrowseItem : public Gtk::VBox,
* @return the signal object (a protected member of this class) * @return the signal object (a protected member of this class)
*/ */
sigc::signal<void> sigc::signal<void>
signalSelectionChanged(void) throw () signalChanged(void) throw ()
{ {
return signalSelectionChangedObject; return signalChangedObject;
} }
}; };

View file

@ -44,7 +44,6 @@ namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -64,6 +63,7 @@ using namespace LiveSupport::Widgets;
class ContentsStorable class ContentsStorable
{ {
public: public:
/** /**
* Virtual destructor. * Virtual destructor.
*/ */

View file

@ -35,13 +35,10 @@
#include <iostream> #include <iostream>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "CuePlayer.h" #include "CuePlayer.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -49,6 +46,19 @@ using namespace LiveSupport::GLiveSupport;
/* ================================================ local constants & macros */ /* ================================================ local constants & macros */
namespace {
/**
* The string which identifies the Play stock image.
*/
const Glib::ustring playStockImageName = "gtk-media-play";
/**
* The string which identifies the Pause stock image.
*/
const Glib::ustring pauseStockImageName = "gtk-media-pause";
}
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -60,31 +70,21 @@ using namespace LiveSupport::GLiveSupport;
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
CuePlayer :: CuePlayer(Ptr<GLiveSupport>::Ref gLiveSupport, CuePlayer :: CuePlayer(Ptr<GLiveSupport>::Ref gLiveSupport,
Gtk::TreeView * treeView, Gtk::TreeView * treeView,
const PlayableTreeModelColumnRecord & modelColumns) const PlayableTreeModelColumnRecord & modelColumns,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: gLiveSupport(gLiveSupport), : gLiveSupport(gLiveSupport),
treeView(treeView), treeView(treeView),
modelColumns(modelColumns) modelColumns(modelColumns)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); glade->get_widget("cuePlayButton1", playButton);
glade->get_widget("cueStopButton1", stopButton);
playButton = Gtk::manage(wf->createButton(
WidgetConstants::smallPlayButton ));
pauseButton = Gtk::manage(wf->createButton(
WidgetConstants::smallPauseButton ));
stopButton = Gtk::manage(wf->createButton(
WidgetConstants::smallStopButton ));
playButton->signal_clicked().connect(sigc::mem_fun(*this, playButton->signal_clicked().connect(sigc::mem_fun(*this,
&CuePlayer::onPlayButtonClicked )); &CuePlayer::onPlayButtonClicked ));
pauseButton->signal_clicked().connect(sigc::mem_fun(*this,
&CuePlayer::onPauseButtonClicked ));
stopButton->signal_clicked().connect(sigc::mem_fun(*this, stopButton->signal_clicked().connect(sigc::mem_fun(*this,
&CuePlayer::onStopButtonClicked )); &CuePlayer::onStopButtonClicked ));
pack_end(*stopButton, Gtk::PACK_SHRINK, 3);
pack_end(*playButton, Gtk::PACK_SHRINK, 3);
audioState = waitingState; audioState = waitingState;
gLiveSupport->attachCueAudioListener(this); gLiveSupport->attachCueAudioListener(this);
@ -137,6 +137,22 @@ CuePlayer :: onPlayItem(void) throw ()
} }
/*------------------------------------------------------------------------------
* Pause the song.
*----------------------------------------------------------------------------*/
void
CuePlayer :: onPauseItem(void) throw ()
{
try {
gLiveSupport->pauseCueAudio();
setAudioState(pausedState);
} catch (std::logic_error &e) {
std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl
<< e.what() << std::endl;
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler for the Play button getting clicked * Event handler for the Play button getting clicked
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -148,10 +164,8 @@ CuePlayer :: onPlayButtonClicked(void) throw ()
onPlayItem(); onPlayItem();
break; break;
case playingState: // should never happen case playingState:
std::cerr << "Assertion failed in CuePlayer:" << std::endl onPauseItem();
<< "play button clicked when it should not be visible."
<< std::endl;
break; break;
case pausedState: case pausedState:
@ -167,22 +181,6 @@ CuePlayer :: onPlayButtonClicked(void) throw ()
} }
/*------------------------------------------------------------------------------
* Event handler for the Pause button getting clicked
*----------------------------------------------------------------------------*/
void
CuePlayer :: onPauseButtonClicked(void) throw ()
{
try {
gLiveSupport->pauseCueAudio();
setAudioState(pausedState);
} catch (std::logic_error &e) {
std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl
<< e.what() << std::endl;
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler for the Stop button getting clicked * Event handler for the Stop button getting clicked
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -210,7 +208,7 @@ CuePlayer :: onStop(Ptr<const Glib::ustring>::Ref errorMessage) throw ()
setAudioState(waitingState); setAudioState(waitingState);
if (errorMessage) { if (errorMessage) {
gLiveSupport->displayMessageWindow(errorMessage); gLiveSupport->displayMessageWindow(*errorMessage);
} }
} }
@ -223,17 +221,11 @@ CuePlayer :: setAudioState(AudioState newState) throw ()
{ {
if ((audioState == waitingState || audioState == pausedState) if ((audioState == waitingState || audioState == pausedState)
&& newState == playingState) { && newState == playingState) {
remove(*playButton); playButton->set_label(pauseStockImageName);
pack_end(*pauseButton, Gtk::PACK_SHRINK, 3);
pauseButton->show();
gLiveSupport->runMainLoop();
} else if (audioState == playingState } else if (audioState == playingState
&& (newState == waitingState || newState == pausedState)) { && (newState == waitingState || newState == pausedState)) {
remove(*pauseButton); playButton->set_label(playStockImageName);
pack_end(*playButton, Gtk::PACK_SHRINK, 3);
playButton->show();
gLiveSupport->runMainLoop();
} }
audioState = newState; audioState = newState;

View file

@ -41,10 +41,10 @@
#endif #endif
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/PlaylistExecutor/AudioPlayerEventListener.h" #include "LiveSupport/PlaylistExecutor/AudioPlayerEventListener.h"
#include "LiveSupport/Widgets/ImageButton.h"
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" #include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -71,11 +71,9 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class CuePlayer : public Gtk::HBox, class CuePlayer : public PlaylistExecutor::AudioPlayerEventListener
public PlaylistExecutor::AudioPlayerEventListener
{ {
private: private:
/** /**
* The possible states of the (cue) audio player. * The possible states of the (cue) audio player.
*/ */
@ -89,17 +87,12 @@ class CuePlayer : public Gtk::HBox,
/** /**
* The play button. * The play button.
*/ */
ImageButton * playButton; Gtk::Button * playButton;
/**
* The pause button.
*/
ImageButton * pauseButton;
/** /**
* The stop button. * The stop button.
*/ */
ImageButton * stopButton; Gtk::Button * stopButton;
/** /**
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
@ -109,7 +102,7 @@ class CuePlayer : public Gtk::HBox,
/** /**
* The Gtk::TreeView of the parent. * The Gtk::TreeView of the parent.
*/ */
Gtk::TreeView * treeView; Gtk::TreeView * treeView;
/** /**
* The Gtk::TreeModelColumnRecord of the parent. * The Gtk::TreeModelColumnRecord of the parent.
@ -122,18 +115,18 @@ class CuePlayer : public Gtk::HBox,
*/ */
CuePlayer(void) throw (); CuePlayer(void) throw ();
/**
* Pause the song.
*/
void
onPauseItem(void) throw ();
/** /**
* Event handler for the Play button being clicked. * Event handler for the Play button being clicked.
*/ */
void void
onPlayButtonClicked(void) throw (); onPlayButtonClicked(void) throw ();
/**
* Event handler for the Pause button being clicked.
*/
void
onPauseButtonClicked(void) throw ();
/** /**
* Event handler for the Stop button being clicked. * Event handler for the Stop button being clicked.
*/ */
@ -152,17 +145,19 @@ class CuePlayer : public Gtk::HBox,
public: public:
/** /**
* Constructor with parent parameters. * Constructor with parent parameters.
* *
* @param gLiveSupport the GLiveSupport, application object. * @param gLiveSupport the GLiveSupport, application object.
* @param treeView the TreeView object showing the selection. * @param treeView the TreeView object showing the selection.
* @param modelColumns the object holding the types of the columns. * @param modelColumns the object holding the types of the columns.
* @param glade the Glade file which specifies the visual
* components for this class.
*/ */
CuePlayer(Ptr<GLiveSupport>::Ref gLiveSupport, CuePlayer(Ptr<GLiveSupport>::Ref gLiveSupport,
Gtk::TreeView * treeView, Gtk::TreeView * treeView,
const PlayableTreeModelColumnRecord & modelColumns) const PlayableTreeModelColumnRecord & modelColumns,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**

View file

@ -38,7 +38,6 @@
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::StorageClient; using namespace LiveSupport::StorageClient;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -56,18 +55,17 @@ using namespace LiveSupport::GLiveSupport;
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
ExportFormatRadioButtons :: ExportFormatRadioButtons( ExportFormatRadioButtons :: ExportFormatRadioButtons(
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: RadioButtons(), : LocalizedObject(bundle)
LocalizedObject(bundle)
{ {
try { glade->get_widget("internalFormatRadioButton1", internalFormatRadioButton);
add(getResourceUstring("internalFormatName")); glade->get_widget("smilFormatRadioButton1", smilFormatRadioButton);
add(getResourceUstring("smilFormatName")); internalFormatRadioButton->set_label(*getResourceUstring(
} catch (std::invalid_argument &e) { "internalFormatName"));
std::cerr << e.what() << std::endl; smilFormatRadioButton->set_label(*getResourceUstring(
std::exit(1); "smilFormatName"));
}
} }
@ -77,7 +75,16 @@ ExportFormatRadioButtons :: ExportFormatRadioButtons(
StorageClientInterface::ExportFormatType StorageClientInterface::ExportFormatType
ExportFormatRadioButtons :: getFormat(void) throw () ExportFormatRadioButtons :: getFormat(void) throw ()
{ {
int button = getActiveButton(); if (internalFormatRadioButton->get_active()) {
return StorageClientInterface::ExportFormatType(button); return StorageClientInterface::internalFormat;
} else if (smilFormatRadioButton->get_active()) {
return StorageClientInterface::smilFormat;
} else {
std::cerr << "impossible value in ExportFormatRadioButtons::getFormat()"
<< std::endl;
std::exit(1);
}
} }

View file

@ -36,9 +36,11 @@
/* ============================================================ include files */ /* ============================================================ include files */
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/StorageClient/StorageClientInterface.h" #include "LiveSupport/StorageClient/StorageClientInterface.h"
#include "LiveSupport/Widgets/RadioButtons.h"
namespace LiveSupport { namespace LiveSupport {
@ -46,7 +48,6 @@ namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::StorageClient; using namespace LiveSupport::StorageClient;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -63,17 +64,31 @@ using namespace LiveSupport::Widgets;
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision$ * @version $Revision$
*/ */
class ExportFormatRadioButtons : public RadioButtons, class ExportFormatRadioButtons : public LocalizedObject
public LocalizedObject
{ {
private:
/**
* The radio button for the internal Campcaster format.
*/
Gtk::RadioButton * internalFormatRadioButton;
/**
* The radio button for the SMIL format.
*/
Gtk::RadioButton * smilFormatRadioButton;
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
*/ */
ExportFormatRadioButtons(Ptr<ResourceBundle>::Ref bundle) ExportFormatRadioButtons(Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**

View file

@ -39,19 +39,12 @@
#error need pwd.h #error need pwd.h
#endif #endif
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/stock.h>
#include "LiveSupport/Core/FileTools.h" #include "LiveSupport/Core/FileTools.h"
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "ExportPlaylistWindow.h" #include "ExportPlaylistWindow.h"
using namespace Glib;
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -62,9 +55,9 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc). * The name of the glade file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
const Glib::ustring windowName = "exportPlaylistWindow"; const Glib::ustring gladeFileName = "ExportPlaylistWindow.glade";
} }
@ -78,71 +71,41 @@ const Glib::ustring windowName = "exportPlaylistWindow";
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
ExportPlaylistWindow :: ExportPlaylistWindow( ExportPlaylistWindow :: ExportPlaylistWindow(
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, const Glib::ustring & gladeDir,
Ptr<Playlist>::Ref playlist) Ptr<Playlist>::Ref playlist)
throw () throw ()
: GuiWindow(gLiveSupport, : gLiveSupport(gLiveSupport),
bundle),
playlist(playlist) playlist(playlist)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
"exportPlaylistWindow");
setBundle(bundle);
Gtk::Label * playlistTitleLabel; glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
Gtk::Label * formatLabel;
Button * cancelButton;
Button * saveButton;
try {
set_title(*getResourceUstring("windowTitle"));
playlistTitleLabel = Gtk::manage(new Gtk::Label(
*getResourceUstring("playlistTitleLabel")));
formatLabel = Gtk::manage(new Gtk::Label(
*getResourceUstring("formatLabel")));
cancelButton = Gtk::manage(wf->createButton(
*getResourceUstring("cancelButtonLabel")));
saveButton = Gtk::manage(wf->createButton(
*getResourceUstring("saveButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
cancelButton->signal_clicked().connect(sigc::mem_fun(
*this, &ExportPlaylistWindow::onCancelButtonClicked ));
saveButton->signal_clicked().connect(sigc::mem_fun(
*this, &ExportPlaylistWindow::onSaveButtonClicked ));
Gtk::Box * playlistTitleBox = Gtk::manage(new Gtk::HBox);
Gtk::Label * playlistTitle = Gtk::manage(new Gtk::Label(
*playlist->getTitle() ));
playlistTitleBox->pack_start(*playlistTitleLabel, Gtk::PACK_SHRINK, 5);
playlistTitleBox->pack_start(*playlistTitle, Gtk::PACK_SHRINK, 5);
formatButtons = Gtk::manage(new ExportFormatRadioButtons(bundle));
Gtk::Box * formatBox = Gtk::manage(new Gtk::HBox);
formatBox->pack_start(*formatLabel, Gtk::PACK_SHRINK, 5);
formatBox->pack_start(*formatButtons, Gtk::PACK_SHRINK, 5);
Gtk::Box * buttonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_END, 5));
buttonBox->pack_start(*cancelButton);
buttonBox->pack_start(*saveButton);
Gtk::Box * extraSpace = Gtk::manage(new Gtk::HBox);
Gtk::Label * statusBar = Gtk::manage(new Gtk::Label(""));
Gtk::Box * layout = Gtk::manage(new Gtk::VBox);
layout->pack_start(*extraSpace, Gtk::PACK_SHRINK, 5);
layout->pack_start(*playlistTitleBox, Gtk::PACK_SHRINK, 5);
layout->pack_start(*formatBox, Gtk::PACK_SHRINK, 0);
layout->pack_start(*statusBar, Gtk::PACK_SHRINK, 10);
layout->pack_start(*buttonBox, Gtk::PACK_SHRINK, 0);
add(*layout); glade->get_widget("mainWindow1", mainWindow);
mainWindow->set_title(*getResourceUstring("windowTitle"));
mainWindow->signal_delete_event().connect(sigc::mem_fun(*this,
&ExportPlaylistWindow::onDeleteEvent));
Gtk::Label * playlistTitleTextLabel;
Gtk::Label * formatLabel;
glade->get_widget("playlistTitleTextLabel1", playlistTitleTextLabel);
glade->get_widget("formatLabel1", formatLabel);
playlistTitleTextLabel->set_label(*getResourceUstring(
"playlistTitleLabel"));
formatLabel->set_label(*getResourceUstring("formatLabel"));
Gtk::Label * playlistTitleValueLabel;
glade->get_widget("playlistTitleValueLabel1", playlistTitleValueLabel);
playlistTitleValueLabel->set_label(*playlist->getTitle());
glade->connect_clicked("cancelButton1", sigc::mem_fun(*this,
&ExportPlaylistWindow::onCancelButtonClicked));
glade->connect_clicked("saveButton1", sigc::mem_fun(*this,
&ExportPlaylistWindow::onSaveButtonClicked));
set_name(windowName); formatButtons.reset(new ExportFormatRadioButtons(bundle, glade));
show_all_children();
} }
@ -152,7 +115,7 @@ ExportPlaylistWindow :: ExportPlaylistWindow(
void void
ExportPlaylistWindow :: onCancelButtonClicked(void) throw () ExportPlaylistWindow :: onCancelButtonClicked(void) throw ()
{ {
hide(); mainWindow->hide();
} }
@ -181,7 +144,7 @@ ExportPlaylistWindow :: onSaveButtonClicked(void) throw ()
Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring( Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring(
"createExportErrorMsg"); "createExportErrorMsg");
errorMsg->append(e.what()); errorMsg->append(e.what());
gLiveSupport->displayMessageWindow(errorMsg); gLiveSupport->displayMessageWindow(*errorMsg);
return; return;
} }
@ -220,19 +183,19 @@ ExportPlaylistWindow :: onSaveButtonClicked(void) throw ()
} catch (std::runtime_error &e) { } catch (std::runtime_error &e) {
Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring( Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring(
"saveExportErrorMsg"); "saveExportErrorMsg");
gLiveSupport->displayMessageWindow(errorMsg); gLiveSupport->displayMessageWindow(*errorMsg);
} }
} }
// close the exporting operation // close the exporting operation
resetToken(); resetToken();
hide(); mainWindow->hide();
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler called when the the window gets hidden. * Cancel the current operation.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ExportPlaylistWindow :: resetToken(void) throw () ExportPlaylistWindow :: resetToken(void) throw ()
@ -247,7 +210,7 @@ ExportPlaylistWindow :: resetToken(void) throw ()
Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring( Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring(
"createExportErrorMsg"); "createExportErrorMsg");
errorMsg->append(e.what()); errorMsg->append(e.what());
gLiveSupport->displayMessageWindow(errorMsg); gLiveSupport->displayMessageWindow(*errorMsg);
} }
} }
@ -255,13 +218,14 @@ ExportPlaylistWindow :: resetToken(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler called when the the window gets hidden. * Event handler called when the the window gets hidden.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void bool
ExportPlaylistWindow :: on_hide(void) throw () ExportPlaylistWindow :: onDeleteEvent(GdkEventAny * event) throw ()
{ {
std::cerr << "ExportPlaylistWindow :: onDeleteEvent called\n";
if (token) { if (token) {
resetToken(); resetToken();
} }
GuiWindow::on_hide(); return false;
} }

View file

@ -40,16 +40,19 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include "LiveSupport/Core/Playlist.h" #include <gtkmm.h>
#include "ExportFormatRadioButtons.h" #include <libglademm.h>
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "ExportFormatRadioButtons.h"
#include "GLiveSupport.h"
#include "GuiWindow.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -60,7 +63,7 @@ using namespace LiveSupport::Widgets;
/* =============================================================== data types */ /* =============================================================== data types */
/** /**
* The ExportPlaylist window. This is a pop-up window accessible from the * The Export Playlist window. This is a pop-up window accessible from the
* right-click menus of the Scratchpad, Live Mode and Search/Browse windows. * right-click menus of the Scratchpad, Live Mode and Search/Browse windows.
* It lets the user select the format of the exported playlist, and the * It lets the user select the format of the exported playlist, and the
* location where it will be saved. * location where it will be saved.
@ -68,23 +71,39 @@ using namespace LiveSupport::Widgets;
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision$ * @version $Revision$
*/ */
class ExportPlaylistWindow : public GuiWindow class ExportPlaylistWindow : public LocalizedObject
{ {
private: private:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The Glade object, containing the visual design.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* The main window for this class.
*/
Gtk::Window * mainWindow;
/** /**
* The playlist to be exported. * The playlist to be exported.
*/ */
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
/** /**
* The playlist to be exported. * The playlist to be exported.
*/ */
Ptr<const Glib::ustring>::Ref token; Ptr<const Glib::ustring>::Ref token;
/** /**
* The radio buttons for selecting the export format. * The radio buttons for selecting the export format.
*/ */
ExportFormatRadioButtons * formatButtons; Ptr<ExportFormatRadioButtons>::Ref formatButtons;
/** /**
* Cancel the current operation. * Cancel the current operation.
@ -95,6 +114,7 @@ class ExportPlaylistWindow : public GuiWindow
protected: protected:
/** /**
* Event handler for the Cancel button being clicked. * Event handler for the Cancel button being clicked.
*/ */
@ -110,26 +130,25 @@ class ExportPlaylistWindow : public GuiWindow
/** /**
* Event handler called when the the window gets hidden. * Event handler called when the the window gets hidden.
* *
* This overrides GuiWindow::on_hide(), and closes the exporting * It closes the exporting operations, if there is one in progress.
* operations, if there is one in progress.
*/ */
virtual void virtual bool
on_hide(void) throw (); onDeleteEvent(GdkEventAny * event) throw ();
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param gLiveSupport the gLiveSupport object, containing * @param gLiveSupport the gLiveSupport object, containing
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param gladeDir the directory where the Glade files are.
* resources for this window.
* @param playlist the playlist to be exported. * @param playlist the playlist to be exported.
*/ */
ExportPlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport, ExportPlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, const Glib::ustring & gladeDir,
Ptr<Playlist>::Ref playlist) Ptr<Playlist>::Ref playlist)
throw (); throw ();
/** /**
@ -139,6 +158,15 @@ class ExportPlaylistWindow : public GuiWindow
~ExportPlaylistWindow(void) throw () ~ExportPlaylistWindow(void) throw ()
{ {
} }
/**
* Get the underlying Gtk::Window.
*/
virtual Gtk::Window *
getWindow(void) throw ()
{
return mainWindow;
}
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -120,6 +120,16 @@ const std::string localeAttrName = "locale";
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
const std::string nameAttrName = "name"; const std::string nameAttrName = "name";
/*------------------------------------------------------------------------------
* The name of the config element for the directory where the Glade files are
*----------------------------------------------------------------------------*/
const std::string gladeDirConfigElementName = "gladeDirectory";
/*------------------------------------------------------------------------------
* The name of the glade file.
*----------------------------------------------------------------------------*/
const std::string gladeFileName = "GLiveSupport.glade";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the config element for the scheduler daemon start command * The name of the config element for the scheduler daemon start command
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -191,6 +201,7 @@ const std::string serialPortConfigElementName = "serialPort";
* The default serial device * The default serial device
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
const std::string serialPortDefaultDevice = "/dev/ttyS0"; const std::string serialPortDefaultDevice = "/dev/ttyS0";
} }
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -253,6 +264,17 @@ GLiveSupport :: configure(const xmlpp::Element & element)
storage = stcf->getStorageClient(); storage = stcf->getStorageClient();
// configure the directory where the Glade files are
nodes = element.get_children(gladeDirConfigElementName);
if (nodes.size() < 1) {
throw std::invalid_argument("no gladeDirectory element");
}
const xmlpp::Element* gladeDirElement
= dynamic_cast<const xmlpp::Element*>(nodes.front());
gladeDir = gladeDirElement->get_attribute("path")
->get_value();
glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
// configure the WidgetFactory // configure the WidgetFactory
nodes = element.get_children(WidgetFactory::getConfigElementName()); nodes = element.get_children(WidgetFactory::getConfigElementName());
if (nodes.size() < 1) { if (nodes.size() < 1) {
@ -474,7 +496,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
Ptr<UnicodeString>::Ref uLanguage = ustringToUnicodeString(language); Ptr<UnicodeString>::Ref uLanguage = ustringToUnicodeString(language);
Ptr<Glib::ustring>::Ref msg = formatMessage(localeNotAvailableKey, Ptr<Glib::ustring>::Ref msg = formatMessage(localeNotAvailableKey,
(*it).first); (*it).first);
displayMessageWindow(msg); displayMessageWindow(*msg);
changeLocale(""); changeLocale("");
return false; return false;
@ -496,7 +518,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
storageAvailable = true; storageAvailable = true;
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
storageAvailable = false; storageAvailable = false;
displayMessageWindow(getResourceUstring(storageNotReachableKey)); displayMessageWindow(*getResourceUstring(storageNotReachableKey));
} }
// no need to check the widget factory // no need to check the widget factory
@ -504,7 +526,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
// check the scheduler client // check the scheduler client
checkSchedulerClient(); checkSchedulerClient();
if (!isSchedulerAvailable()) { if (!isSchedulerAvailable()) {
displayMessageWindow(getResourceUstring(schedulerNotReachableKey)); displayMessageWindow(*getResourceUstring(schedulerNotReachableKey));
} }
// TODO: check the audio player? // TODO: check the audio player?
@ -516,17 +538,62 @@ GLiveSupport :: checkConfiguration(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Display a message window. * Display a message window.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void inline void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: displayMessageWindow(Ptr<const Glib::ustring>::Ref message) GLiveSupport :: displayMessageWindow(const Glib::ustring & message)
throw () throw ()
{ {
std::cerr << "gLiveSupport: " << *message << std::endl; runOkDialog(message);
}
/*------------------------------------------------------------------------------
* Run a dialog window with No and Yes buttons.
*----------------------------------------------------------------------------*/
inline Gtk::ResponseType
LiveSupport :: GLiveSupport ::
GLiveSupport :: runNoYesDialog(const Glib::ustring & message)
throw ()
{
return runDialog("noYesDialog", message);
}
/*------------------------------------------------------------------------------
* Run a dialog window with just an OK button.
*----------------------------------------------------------------------------*/
inline Gtk::ResponseType
LiveSupport :: GLiveSupport ::
GLiveSupport :: runOkDialog(const Glib::ustring & message)
throw ()
{
return runDialog("okDialog", message);
}
/*------------------------------------------------------------------------------
* Run a dialog window.
*----------------------------------------------------------------------------*/
Gtk::ResponseType
LiveSupport :: GLiveSupport ::
GLiveSupport :: runDialog(const Glib::ustring & dialogName,
const Glib::ustring & message)
throw ()
{
Gtk::Dialog * dialog;
Gtk::Label * dialogLabel;
glade->get_widget(dialogName + "1", dialog);
glade->get_widget(dialogName + "Label1", dialogLabel);
Ptr<DialogWindow>::Ref window(widgetFactory->createDialogWindow( Glib::ustring formattedMessage = "<span weight=\"bold\" ";
message, formattedMessage += " size=\"larger\">";
getBundle())); formattedMessage += message;
window->run(); formattedMessage += "</span>";
dialogLabel->set_label(formattedMessage);
Gtk::ResponseType response = Gtk::ResponseType(dialog->run());
dialog->hide();
return response;
} }
@ -537,13 +604,16 @@ void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: show(void) throw () GLiveSupport :: show(void) throw ()
{ {
masterPanel.reset(new MasterPanelWindow(shared_from_this(), getBundle())); masterPanel.reset(new MasterPanelWindow(shared_from_this(),
getBundle(),
gladeDir));
masterPanel->set_icon_list(taskbarIcons->getIconList()); masterPanel->getWindow()->set_icon_list(taskbarIcons->getIconList());
masterPanel->set_default_icon_list(taskbarIcons->getIconList()); masterPanel->getWindow()->set_default_icon_list(
taskbarIcons->getIconList());
// Shows the window and returns when it is closed. // Shows the window and returns when it is closed.
Gtk::Main::run(*masterPanel); Gtk::Main::run(*masterPanel->getWindow());
masterPanel.reset(); masterPanel.reset();
} }
@ -635,12 +705,12 @@ GLiveSupport :: logout(void) throw ()
return false; return false;
} }
if (masterPanel && !masterPanel->cancelEditedPlaylist()) { if (!masterPanel->cancelEditedPlaylist()) {
return false; // do nothing if the user presses the cancel button return false; // do nothing if the user presses the cancel button
} }
stopCueAudio(); stopCueAudio();
showAnonymousUI(); masterPanel->showAnonymousUI();
storeWindowPositions(); storeWindowPositions();
windowPositions.clear(); windowPositions.clear();
@ -713,32 +783,6 @@ GLiveSupport :: loadWindowContents(ContentsStorable * window)
} }
/*------------------------------------------------------------------------------
* Show the anonymous UI
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: showAnonymousUI(void) throw ()
{
if (masterPanel.get()) {
masterPanel->showAnonymousUI();
}
}
/*------------------------------------------------------------------------------
* Show the UI when someone is logged in
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: showLoggedInUI(void) throw ()
{
if (masterPanel.get()) {
masterPanel->showLoggedInUI();
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Open an audio clip, and put it into the internal cache of the GLiveSupport * Open an audio clip, and put it into the internal cache of the GLiveSupport
* object. * object.
@ -1028,7 +1072,10 @@ LiveSupport :: GLiveSupport ::
GLiveSupport :: setNowPlaying(Ptr<Playable>::Ref playable) GLiveSupport :: setNowPlaying(Ptr<Playable>::Ref playable)
throw () throw ()
{ {
masterPanel->setNowPlaying(playable); // test needed: this gets called indirectly from ~MasterPanelWindow
if (masterPanel) {
masterPanel->setNowPlaying(playable);
}
} }
@ -1068,7 +1115,7 @@ GLiveSupport :: openPlaylistForEditing(Ptr<const UniqueId>::Ref playlistId)
editedPlaylist->createSavedCopy(); editedPlaylist->createSavedCopy();
masterPanel->updateSimplePlaylistMgmtWindow(); masterPanel->updatePlaylistWindow();
} }
@ -1121,7 +1168,7 @@ GLiveSupport :: addToPlaylist(Ptr<const UniqueId>::Ref id)
editedPlaylist->addAudioClip(clip, editedPlaylist->getPlaylength()); editedPlaylist->addAudioClip(clip, editedPlaylist->getPlaylength());
} }
masterPanel->updateSimplePlaylistMgmtWindow(); masterPanel->updatePlaylistWindow();
emitSignalEditedPlaylistModified(); emitSignalEditedPlaylistModified();
} }
@ -1252,21 +1299,21 @@ GLiveSupport :: playOutputAudio(Ptr<Playable>::Ref playable)
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append("\n"); eMsg->append("\n");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(*eMsg);
throw std::runtime_error(e.what()); throw std::runtime_error(e.what());
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
Ptr<Glib::ustring>::Ref eMsg Ptr<Glib::ustring>::Ref eMsg
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append("\n"); eMsg->append("\n");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(*eMsg);
throw std::runtime_error(e.what()); throw std::runtime_error(e.what());
} catch (std::runtime_error &e) { } catch (std::runtime_error &e) {
Ptr<Glib::ustring>::Ref eMsg Ptr<Glib::ustring>::Ref eMsg
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append("\n"); eMsg->append("\n");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(*eMsg);
throw std::runtime_error(e.what()); throw std::runtime_error(e.what());
} }
@ -1336,7 +1383,7 @@ GLiveSupport :: onStop(Ptr<const Glib::ustring>::Ref errorMessage)
} }
if (errorMessage) { if (errorMessage) {
displayMessageWindow(errorMessage); displayMessageWindow(*errorMessage);
} }
} }
@ -1382,21 +1429,21 @@ GLiveSupport :: playCueAudio(Ptr<Playable>::Ref playable)
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append("\n"); eMsg->append("\n");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(*eMsg);
throw std::runtime_error(e.what()); throw std::runtime_error(e.what());
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
Ptr<Glib::ustring>::Ref eMsg Ptr<Glib::ustring>::Ref eMsg
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append("\n"); eMsg->append("\n");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(*eMsg);
throw std::runtime_error(e.what()); throw std::runtime_error(e.what());
} catch (std::runtime_error &e) { } catch (std::runtime_error &e) {
Ptr<Glib::ustring>::Ref eMsg Ptr<Glib::ustring>::Ref eMsg
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append("\n"); eMsg->append("\n");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(*eMsg);
throw std::runtime_error(e.what()); throw std::runtime_error(e.what());
} }
@ -1436,7 +1483,10 @@ GLiveSupport :: stopCueAudio(void)
cuePlayerIsPaused = false; cuePlayerIsPaused = false;
cueItemPlayingNow.reset(); cueItemPlayingNow.reset();
masterPanel->showCuePlayerStopped(); // test needed: this gets called indirectly from ~MasterPanelWindow
if (masterPanel) {
masterPanel->showCuePlayerStopped();
}
} }
} }
@ -1468,11 +1518,11 @@ GLiveSupport :: detachCueAudioListener(AudioPlayerEventListener * listener)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Return an image containing the radio station logo. * Return an image containing the radio station logo.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Image * Glib::RefPtr<Gdk::Pixbuf>
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: getStationLogoImage(void) throw() GLiveSupport :: getStationLogoPixbuf(void) throw()
{ {
return new Gtk::Image(stationLogoPixbuf); return stationLogoPixbuf;
} }
@ -1536,6 +1586,60 @@ GLiveSupport :: getWindowPosition(Ptr<Gtk::Window>::Ref window)
} }
/*------------------------------------------------------------------------------
* Save the position and size of the window.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: putWindowPosition(const BasicWindow * window)
throw ()
{
WindowPositionType pos;
window->getWindow()->get_position(pos.x, pos.y);
window->getWindow()->get_size(pos.width, pos.height);
windowPositions[replaceSpaces(window->getTitle())] = pos;
}
/*------------------------------------------------------------------------------
* Apply saved position and size data to the window.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: getWindowPosition(BasicWindow * window)
throw ()
{
WindowPositionsListType::const_iterator it = windowPositions.find(
replaceSpaces(window->getTitle()));
if (it != windowPositions.end()) {
WindowPositionType pos = it->second;
window->getWindow()->move(pos.x, pos.y);
window->getWindow()->resize(pos.width, pos.height);
}
}
/*------------------------------------------------------------------------------
* Replace spaces with underscore characters.
*----------------------------------------------------------------------------*/
Glib::ustring
LiveSupport :: GLiveSupport ::
GLiveSupport :: replaceSpaces(Ptr<const Glib::ustring>::Ref string)
throw ()
{
Glib::ustring copy = *string;
for (unsigned int i = 0; i < copy.size(); ++i) {
if (copy[i] == ' ') {
copy.replace(i, 1, 1, '_');
}
}
return copy;
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Store the saved window positions. * Store the saved window positions.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -1741,40 +1845,23 @@ void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: displayAuthenticationServerMissingMessage(void) throw () GLiveSupport :: displayAuthenticationServerMissingMessage(void) throw ()
{ {
Ptr<Glib::ustring>::Ref message;
try {
message = getResourceUstring("authenticationNotReachableMsg");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// "authentication not available -- would you like to edit the options?" // "authentication not available -- would you like to edit the options?"
Ptr<DialogWindow>::Ref question(widgetFactory->createDialogWindow( Gtk::ResponseType answer = runNoYesDialog(*getResourceUstring(
message, "authenticationNotReachableMsg"));
getBundle(),
DialogWindow::noButton
| DialogWindow::yesButton ));
DialogWindow::ButtonType answer = question->run();
if (answer == DialogWindow::yesButton) { if (answer == Gtk::RESPONSE_YES) {
Ptr<ResourceBundle>::Ref bundle; /* DISABLED TEMPORARILY
try {
bundle = getBundle("optionsWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
Ptr<OptionsWindow>::Ref optionsWindow(new OptionsWindow( Ptr<OptionsWindow>::Ref optionsWindow(new OptionsWindow(
shared_from_this(), shared_from_this(),
bundle, getBundle("optionsWindow"),
0)); 0,
gladeDir));
optionsWindow->run(); optionsWindow->run();
if (optionsContainer->isTouched()) { if (optionsContainer->isTouched()) {
optionsContainer->writeToFile(); optionsContainer->writeToFile();
} }
*/
} }
} }

View file

@ -59,6 +59,7 @@
#include "KeyboardShortcutList.h" #include "KeyboardShortcutList.h"
#include "TaskbarIcons.h" #include "TaskbarIcons.h"
#include "ContentsStorable.h" #include "ContentsStorable.h"
#include "BasicWindow.h"
namespace LiveSupport { namespace LiveSupport {
@ -122,6 +123,7 @@ class GLiveSupport : public LocalizedConfigurable,
public AudioPlayerEventListener public AudioPlayerEventListener
{ {
public: public:
/** /**
* A type for the map of supported languages. * A type for the map of supported languages.
* This is an STL map, containing const Glib::ustring as keys, which * This is an STL map, containing const Glib::ustring as keys, which
@ -147,8 +149,9 @@ class GLiveSupport : public LocalizedConfigurable,
private: private:
/** /**
* The name of the configuration XML elmenent used by Playlist. * The name of the configuration XML elmenent used by this class.
*/ */
static const std::string configElementNameStr; static const std::string configElementNameStr;
@ -162,6 +165,17 @@ class GLiveSupport : public LocalizedConfigurable,
*/ */
Ptr<StorageClientInterface>::Ref storage; Ptr<StorageClientInterface>::Ref storage;
/**
* The directory where the Glade files are.
*/
Glib::ustring gladeDir;
/**
* The Glade object, containing the visual design.
* For this class, it only contains some pop-up windows.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/** /**
* The widget factory, containing our own widgets. * The widget factory, containing our own widgets.
*/ */
@ -398,8 +412,30 @@ class GLiveSupport : public LocalizedConfigurable,
void void
writeToSerial(Ptr<const Glib::ustring>::Ref message) throw (); writeToSerial(Ptr<const Glib::ustring>::Ref message) throw ();
/**
* Replace spaces with underscore characters.
*
* @param string the original string, eg: "one two three".
* @return the new string, eg: "one_two_three".
*/
Glib::ustring
replaceSpaces(Ptr<const Glib::ustring>::Ref string) throw ();
/**
* Run a dialog window.
*
* @param dialogName the type of the dialog; can be "noYesDialog"
* or "okDialog".
* @param message the text to be displayed by the dialog.
* @return the response ID returned by the dialog.
*/
Gtk::ResponseType
runDialog(const Glib::ustring & dialogName,
const Glib::ustring & message) throw ();
protected: protected:
/** /**
* A signal object to notify people that the edited playlist changed. * A signal object to notify people that the edited playlist changed.
*/ */
@ -407,6 +443,7 @@ class GLiveSupport : public LocalizedConfigurable,
public: public:
/** /**
* Constructor. * Constructor.
*/ */
@ -486,9 +523,27 @@ class GLiveSupport : public LocalizedConfigurable,
* @param message the message to display * @param message the message to display
*/ */
void void
displayMessageWindow(Ptr<const Glib::ustring>::Ref message) displayMessageWindow(const Glib::ustring & message)
throw (); throw ();
/**
* Run a dialog window with No and Yes buttons.
*
* @param message the text to be displayed by the dialog.
* @return the response ID returned by the dialog.
*/
Gtk::ResponseType
runNoYesDialog(const Glib::ustring & message) throw ();
/**
* Run a dialog window with just an OK button.
*
* @param message the text to be displayed by the dialog.
* @return the response ID returned by the dialog.
*/
Gtk::ResponseType
runOkDialog(const Glib::ustring & message) throw ();
/** /**
* Show the main window, and run the application. * Show the main window, and run the application.
* This call will only return after the main window has been closed. * This call will only return after the main window has been closed.
@ -583,18 +638,6 @@ class GLiveSupport : public LocalizedConfigurable,
return metadataTypeContainer; return metadataTypeContainer;
} }
/**
* Show the UI components that are visible when no one is logged in.
*/
void
showAnonymousUI(void) throw ();
/**
* Show the UI components that are visible when someone is logged in.
*/
void
showLoggedInUI(void) throw ();
/** /**
* Upload an audio clip to the storage. * Upload an audio clip to the storage.
* *
@ -816,7 +859,7 @@ class GLiveSupport : public LocalizedConfigurable,
* to return a non-0 value. * to return a non-0 value.
* *
* If there is a playlist being edited, the * If there is a playlist being edited, the
* SimplePlaylistManagementWindow's confirmation message is displayed. * PlaylistWindow's confirmation message is displayed.
* If the user presses "Cancel", then this function does nothing. * If the user presses "Cancel", then this function does nothing.
* *
* @param playlistId the id of the playlist to open for editing. * @param playlistId the id of the playlist to open for editing.
@ -1072,13 +1115,12 @@ class GLiveSupport : public LocalizedConfigurable,
throw (); throw ();
/** /**
* Return an image containing the radio station logo. * Return a pixbuf containing the radio station logo.
* It is the responsibility of the caller to dispose of this object.
* *
* @return the station logo image. * @return a pixbuf containing the station logo image.
*/ */
Gtk::Image* Glib::RefPtr<Gdk::Pixbuf>
getStationLogoImage() throw (); getStationLogoPixbuf() throw ();
/** /**
* The signal raised when the edited playlist is modified. * The signal raised when the edited playlist is modified.
@ -1151,6 +1193,8 @@ class GLiveSupport : public LocalizedConfigurable,
/** /**
* Save the position and size of the window. * Save the position and size of the window.
* *
* TODO: remove this function, and only use its overloaded pair.
*
* The coordinates of the window's North-West corner and the * The coordinates of the window's North-West corner and the
* size of the window are read, and stored in a variable of the * size of the window are read, and stored in a variable of the
* GLiveSupport object, indexed by the window's get_name(). * GLiveSupport object, indexed by the window's get_name().
@ -1164,6 +1208,8 @@ class GLiveSupport : public LocalizedConfigurable,
/** /**
* Apply saved position and size data to the window. * Apply saved position and size data to the window.
* *
* TODO: remove this function, and only use its overloaded pair.
*
* If position and size data were previously saved for a window * If position and size data were previously saved for a window
* with the same get_name(), then these data are read and applied to * with the same get_name(), then these data are read and applied to
* the window, restoring its position and size. * the window, restoring its position and size.
@ -1174,6 +1220,32 @@ class GLiveSupport : public LocalizedConfigurable,
void void
getWindowPosition(Ptr<Gtk::Window>::Ref window) throw (); getWindowPosition(Ptr<Gtk::Window>::Ref window) throw ();
/**
* Save the position and size of the window.
*
* The coordinates of the window's North-West corner and the
* size of the window are read, and stored in a variable of the
* GLiveSupport object, indexed by the window's get_name().
*
* @param window the window to save the position and size of.
* @see getWindowPosition()
*/
void
putWindowPosition(const BasicWindow * window) throw ();
/**
* Apply saved position and size data to the window.
*
* If position and size data were previously saved for a window
* with the same get_name(), then these data are read and applied to
* the window, restoring its position and size.
*
* @param window the window to apply the position and size info to.
* @see putWindowPosition()
*/
void
getWindowPosition(BasicWindow * window) throw ();
/** /**
* Store the saved window positions. * Store the saved window positions.
* *

View file

@ -67,7 +67,7 @@ const Glib::ustring applicationTitle = "Campcaster";
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
GuiWindow :: GuiWindow (Ptr<GLiveSupport>::Ref gLiveSupport, GuiWindow :: GuiWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton, Gtk::ToggleButton * windowOpenerButton,
int properties) int properties)
throw () throw ()
: WhiteWindow(Colors::White, : WhiteWindow(Colors::White,
@ -89,7 +89,7 @@ GuiWindow :: on_show (void) throw ()
gLiveSupport->getWindowPosition(shared_from_this()); gLiveSupport->getWindowPosition(shared_from_this());
if (windowOpenerButton) { if (windowOpenerButton) {
windowOpenerButton->setSelected(true); windowOpenerButton->set_active(true);
} }
WhiteWindow::on_show(); WhiteWindow::on_show();
@ -105,7 +105,7 @@ GuiWindow :: on_hide (void) throw ()
gLiveSupport->putWindowPosition(shared_from_this()); gLiveSupport->putWindowPosition(shared_from_this());
if (windowOpenerButton) { if (windowOpenerButton) {
windowOpenerButton->setSelected(false); windowOpenerButton->set_active(false);
} }
WhiteWindow::on_hide(); WhiteWindow::on_hide();

View file

@ -45,7 +45,6 @@
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/WhiteWindow.h" #include "LiveSupport/Widgets/WhiteWindow.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/WidgetConstants.h" #include "LiveSupport/Widgets/WidgetConstants.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -76,7 +75,7 @@ class GuiWindow : public WhiteWindow,
/** /**
* The button which was pressed to open this window. * The button which was pressed to open this window.
*/ */
Button * windowOpenerButton; Gtk::ToggleButton * windowOpenerButton;
protected: protected:
/** /**
@ -103,7 +102,6 @@ class GuiWindow : public WhiteWindow,
* button. * button.
* *
* @see LiveSupport::GLiveSupport::GLiveSupport::putWindowPosition() * @see LiveSupport::GLiveSupport::GLiveSupport::putWindowPosition()
* @see LiveSupport::Widgets::Button::setSelected()
*/ */
virtual void virtual void
on_hide(void) throw (); on_hide(void) throw ();
@ -122,7 +120,7 @@ class GuiWindow : public WhiteWindow,
*/ */
GuiWindow(Ptr<GLiveSupport>::Ref gLiveSupport, GuiWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton = 0, Gtk::ToggleButton * windowOpenerButton = 0,
int properties = 0) int properties = 0)
throw (); throw ();

View file

@ -38,7 +38,6 @@
#include <glibmm.h> #include <glibmm.h>
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveModeWindow.h" #include "LiveModeWindow.h"
@ -46,7 +45,6 @@
using namespace Glib; using namespace Glib;
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -56,10 +54,10 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/** /*------------------------------------------------------------------------------
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc). * The name of the glade file.
*/ *----------------------------------------------------------------------------*/
const Glib::ustring windowName = "liveModeWindow"; const Glib::ustring gladeFileName = "LiveModeWindow.glade";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the user preference for storing contents of the window. * The name of the user preference for storing contents of the window.
@ -78,42 +76,24 @@ const Glib::ustring userPreferencesKeyName = "liveModeContents";
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport, LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw () throw ()
: GuiWindow(gLiveSupport, : BasicWindow(gLiveSupport,
bundle, bundle,
windowOpenerButton), windowOpenerButton,
gladeDir + gladeFileName),
gladeDir(gladeDir),
isDeleting(false) isDeleting(false)
{ {
try { glade->get_widget_derived("treeView1", treeView);
set_title(*getResourceUstring("windowTitle"));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
// Create the tree model:
treeModel = Gtk::ListStore::create(modelColumns); treeModel = Gtk::ListStore::create(modelColumns);
treeView->set_model(treeModel);
// ... and the tree view: treeView->connectModelSignals(treeModel);
treeView = Gtk::manage(wf->createTreeView(treeModel));
treeView->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
treeView->set_reorderable(true);
treeView->set_headers_visible(false);
treeView->set_enable_search(false);
// Add the TreeView's view columns: treeView->appendLineNumberColumn("", 2 /* offset */, 50);
try { treeView->appendColumn("", modelColumns.infoColumn, 200);
treeView->appendLineNumberColumn("", 2 /* offset */, 50);
treeView->appendColumn("", modelColumns.infoColumn, 200);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// register the signal handler for treeview entries being clicked
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this, treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
&LiveModeWindow::onEntryClicked)); &LiveModeWindow::onEntryClicked));
treeView->signal_row_activated().connect(sigc::mem_fun(*this, treeView->signal_row_activated().connect(sigc::mem_fun(*this,
@ -121,91 +101,26 @@ LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
treeView->signalTreeModelChanged().connect(sigc::mem_fun(*this, treeView->signalTreeModelChanged().connect(sigc::mem_fun(*this,
&LiveModeWindow::onTreeModelChanged)); &LiveModeWindow::onTreeModelChanged));
// register the signal handler for keyboard key presses
treeView->signal_key_press_event().connect(sigc::mem_fun(*this, treeView->signal_key_press_event().connect(sigc::mem_fun(*this,
&LiveModeWindow::onKeyPressed)); &LiveModeWindow::onKeyPressed));
// Add the TreeView, inside a ScrolledWindow, with the button underneath: glade->get_widget("cueLabel1", cueLabel);
scrolledWindow.add(*treeView); cueLabel->set_label(*getResourceUstring("cuePlayerLabel"));
cuePlayer.reset(new CuePlayer(gLiveSupport,
treeView,
modelColumns,
glade));
// Only show the scrollbars when they are necessary: glade->get_widget("autoPlayNext1", autoPlayNext);
scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); autoPlayNext->set_label(*getResourceUstring("autoPlayNextLabel"));
glade->connect_clicked("outputPlayButton1", sigc::mem_fun(*this,
&LiveModeWindow::onOutputPlay));
// Create the play etc buttons:
Gtk::HBox * topButtonBox = Gtk::manage(new Gtk::HBox);
Gtk::HButtonBox * bottomButtonBox = Gtk::manage(new Gtk::HButtonBox);
ImageButton * outputPlayButton = Gtk::manage(wf->createButton(
WidgetConstants::hugePlayButton ));
Gtk::VBox * cueAudioBox = Gtk::manage(new Gtk::VBox);
Gtk::HBox * cueAudioLabelBox = Gtk::manage(new Gtk::HBox);
try {
cueAudioLabel = Gtk::manage(new Gtk::Label(
*getResourceUstring("cuePlayerLabel") ));
clearListButton = Gtk::manage(wf->createButton(
*getResourceUstring("clearListButtonLabel")));
removeButton = Gtk::manage(wf->createButton(
*getResourceUstring("removeButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
Gtk::HBox * cueAudioButtonsBox = Gtk::manage(new Gtk::HBox);
cueAudioButtons = Gtk::manage(new CuePlayer(
gLiveSupport, treeView, modelColumns ));
Gtk::HBox * autoPlayNextBox = Gtk::manage(new Gtk::HBox);
try {
autoPlayNext = Gtk::manage(new Gtk::CheckButton(
*getResourceUstring("autoPlayNextLabel") ));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
autoPlayNextBox->pack_start(*autoPlayNext, Gtk::PACK_SHRINK, 10);
topButtonBox->pack_start(*outputPlayButton, Gtk::PACK_EXPAND_PADDING, 10);
topButtonBox->pack_start(*cueAudioBox, Gtk::PACK_EXPAND_PADDING, 10);
cueAudioBox->pack_start(*cueAudioLabelBox, Gtk::PACK_SHRINK, 6);
cueAudioLabelBox->pack_start(*cueAudioLabel, Gtk::PACK_EXPAND_PADDING, 1);
cueAudioBox->pack_start(*cueAudioButtonsBox, Gtk::PACK_SHRINK, 0);
cueAudioButtonsBox->pack_start(*cueAudioButtons,
Gtk::PACK_EXPAND_PADDING, 1);
bottomButtonBox->set_layout(Gtk::BUTTONBOX_END);
bottomButtonBox->set_spacing(5);
bottomButtonBox->pack_start(*clearListButton);
bottomButtonBox->pack_start(*removeButton);
vBox.pack_start(*topButtonBox, Gtk::PACK_SHRINK, 5);
vBox.pack_start(*autoPlayNextBox, Gtk::PACK_SHRINK, 5);
vBox.pack_start(scrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5);
vBox.pack_start(*bottomButtonBox, Gtk::PACK_SHRINK, 5);
add(vBox);
// connect the signal handlers for the buttons
outputPlayButton->signal_clicked().connect(sigc::mem_fun(*this,
&LiveModeWindow::onOutputPlay ));
clearListButton->signal_clicked().connect(sigc::mem_fun(*this,
&LiveModeWindow::onClearListButtonClicked));
removeButton->signal_clicked().connect(sigc::mem_fun(*this,
&LiveModeWindow::onRemoveItemButtonClicked));
// create the right-click context menus
audioClipContextMenu = constructAudioClipContextMenu(); audioClipContextMenu = constructAudioClipContextMenu();
playlistContextMenu = constructPlaylistContextMenu(); playlistContextMenu = constructPlaylistContextMenu();
userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName)); userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName));
// show
set_name(windowName);
set_default_size(400, 500);
set_modal(false);
property_window_position().set_value(Gtk::WIN_POS_NONE);
show_all_children();
} }
@ -424,7 +339,7 @@ LiveModeWindow :: onKeyPressed(GdkEventKey * event) throw ()
if (iter) { if (iter) {
KeyboardShortcut::Action action = gLiveSupport->findAction( KeyboardShortcut::Action action = gLiveSupport->findAction(
windowName, "liveModeWindow",
Gdk::ModifierType(event->state), Gdk::ModifierType(event->state),
event->keyval); event->keyval);
switch (action) { switch (action) {
@ -469,7 +384,7 @@ LiveModeWindow :: onEditPlaylist(void) throw ()
try { try {
gLiveSupport->openPlaylistForEditing(playlist->getId()); gLiveSupport->openPlaylistForEditing(playlist->getId());
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(getResourceUstring( gLiveSupport->displayMessageWindow(*getResourceUstring(
"cannotEditPlaylistMsg" )); "cannotEditPlaylistMsg" ));
} }
} }
@ -492,10 +407,10 @@ LiveModeWindow :: onSchedulePlaylist(void) throw ()
if (playlist) { if (playlist) {
schedulePlaylistWindow.reset(new SchedulePlaylistWindow( schedulePlaylistWindow.reset(new SchedulePlaylistWindow(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("schedulePlaylistWindow"), gladeDir,
playlist)); playlist));
schedulePlaylistWindow->set_transient_for(*this); schedulePlaylistWindow->getWindow()->set_transient_for(*mainWindow);
Gtk::Main::run(*schedulePlaylistWindow); Gtk::Main::run(*schedulePlaylistWindow->getWindow());
} }
} }
} }
@ -515,10 +430,10 @@ LiveModeWindow :: onExportPlaylist(void) throw ()
if (playlist) { if (playlist) {
exportPlaylistWindow.reset(new ExportPlaylistWindow( exportPlaylistWindow.reset(new ExportPlaylistWindow(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("exportPlaylistWindow"), gladeDir,
playlist)); playlist));
exportPlaylistWindow->set_transient_for(*this); exportPlaylistWindow->getWindow()->set_transient_for(*mainWindow);
Gtk::Main::run(*exportPlaylistWindow); Gtk::Main::run(*exportPlaylistWindow->getWindow());
} }
} }
} }
@ -580,40 +495,35 @@ LiveModeWindow :: refreshPlaylist(Ptr<Playlist>::Ref playlist) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the right-click context menu for local audio clips. * Construct the right-click context menu for local audio clips.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Menu * Ptr<Gtk::Menu>::Ref
LiveModeWindow :: constructAudioClipContextMenu(void) throw () LiveModeWindow :: constructAudioClipContextMenu(void) throw ()
{ {
Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); Ptr<Gtk::Menu>::Ref contextMenu(new Gtk::Menu());
Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); Gtk::Menu::MenuList & contextMenuList = contextMenu->items();
try { contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("playMenuItem"),
*getResourceUstring("playMenuItem"),
sigc::mem_fun(*this,
&LiveModeWindow::onOutputPlay)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("cueMenuItem"),
sigc::mem_fun(*cueAudioButtons,
&CuePlayer::onPlayItem)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToPlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&LiveModeWindow::onAddToPlaylist))); &LiveModeWindow::onOutputPlay)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("removeMenuItem"), *getResourceUstring("cueMenuItem"),
sigc::mem_fun(*treeView, sigc::mem_fun(*cuePlayer,
&ZebraTreeView::onRemoveMenuOption))); &CuePlayer::onPlayItem)));
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToPlaylistMenuItem"),
*getResourceUstring("uploadToHubMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &LiveModeWindow::onAddToPlaylist)));
&LiveModeWindow::onUploadToHub))); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
} catch (std::invalid_argument &e) { *getResourceUstring("removeMenuItem"),
std::cerr << e.what() << std::endl; sigc::mem_fun(*treeView,
std::exit(1); &ZebraTreeView::onRemoveMenuOption)));
} contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("uploadToHubMenuItem"),
sigc::mem_fun(*this,
&LiveModeWindow::onUploadToHub)));
contextMenu->accelerate(*this); contextMenu->accelerate(*mainWindow);
return contextMenu; return contextMenu;
} }
@ -621,70 +531,52 @@ LiveModeWindow :: constructAudioClipContextMenu(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the right-click context menu for local playlists. * Construct the right-click context menu for local playlists.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Menu * Ptr<Gtk::Menu>::Ref
LiveModeWindow :: constructPlaylistContextMenu(void) throw () LiveModeWindow :: constructPlaylistContextMenu(void) throw ()
{ {
Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); Ptr<Gtk::Menu>::Ref contextMenu(new Gtk::Menu());
Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); Gtk::Menu::MenuList & contextMenuList = contextMenu->items();
try { contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("playMenuItem"),
*getResourceUstring("playMenuItem"),
sigc::mem_fun(*this,
&LiveModeWindow::onOutputPlay)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("cueMenuItem"),
sigc::mem_fun(*cueAudioButtons,
&CuePlayer::onPlayItem)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToPlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&LiveModeWindow::onAddToPlaylist))); &LiveModeWindow::onOutputPlay)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("removeMenuItem"), *getResourceUstring("cueMenuItem"),
sigc::mem_fun(*treeView, sigc::mem_fun(*cuePlayer,
&ZebraTreeView::onRemoveMenuOption))); &CuePlayer::onPlayItem)));
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToPlaylistMenuItem"),
*getResourceUstring("editPlaylistMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &LiveModeWindow::onAddToPlaylist)));
&LiveModeWindow::onEditPlaylist))); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("removeMenuItem"),
*getResourceUstring("schedulePlaylistMenuItem"), sigc::mem_fun(*treeView,
&ZebraTreeView::onRemoveMenuOption)));
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("editPlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&LiveModeWindow::onSchedulePlaylist))); &LiveModeWindow::onEditPlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("exportPlaylistMenuItem"), *getResourceUstring("schedulePlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&LiveModeWindow::onExportPlaylist))); &LiveModeWindow::onSchedulePlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("exportPlaylistMenuItem"),
*getResourceUstring("uploadToHubMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &LiveModeWindow::onExportPlaylist)));
&LiveModeWindow::onUploadToHub))); contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
} catch (std::invalid_argument &e) { contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
std::cerr << e.what() << std::endl; *getResourceUstring("uploadToHubMenuItem"),
std::exit(1); sigc::mem_fun(*this,
} &LiveModeWindow::onUploadToHub)));
contextMenu->accelerate(*this); contextMenu->accelerate(*mainWindow);
return contextMenu; return contextMenu;
} }
/*------------------------------------------------------------------------------
* Event handler for the clear list button getting clicked.
*----------------------------------------------------------------------------*/
void
LiveModeWindow :: onClearListButtonClicked (void) throw ()
{
isDeleting = true;
treeModel->clear();
isDeleting = false;
onTreeModelChanged();
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler for the Remove menu button getting clicked. * Event handler for the Remove menu button getting clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -730,20 +622,10 @@ LiveModeWindow :: onTreeModelChanged(void) throw ()
void void
LiveModeWindow :: updateStrings(void) throw () LiveModeWindow :: updateStrings(void) throw ()
{ {
try { setBundle(gLiveSupport->getBundle("liveModeWindow"));
setBundle(gLiveSupport->getBundle("liveModeWindow"));
set_title(*getResourceUstring("windowTitle"));
cueAudioLabel->set_label(*getResourceUstring("cuePlayerLabel"));
clearListButton->set_label(*getResourceUstring("clearListButtonLabel"));
removeButton->set_label(*getResourceUstring("removeButtonLabel"));
} catch (std::invalid_argument &e) { setTitle(getResourceUstring("windowTitle"));
std::cerr << e.what() << std::endl; cueLabel->set_label(*getResourceUstring("cuePlayerLabel"));
std::exit(1);
}
show_all_children();
} }
@ -813,15 +695,15 @@ LiveModeWindow :: setContents(Ptr<const Glib::ustring>::Ref contents)
* Event handler called when the the window gets hidden. * Event handler called when the the window gets hidden.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveModeWindow :: on_hide(void) throw () LiveModeWindow :: hide(void) throw ()
{ {
if (exportPlaylistWindow) { if (exportPlaylistWindow) {
exportPlaylistWindow->hide(); exportPlaylistWindow->getWindow()->hide();
} }
if (schedulePlaylistWindow) { if (schedulePlaylistWindow) {
schedulePlaylistWindow->hide(); schedulePlaylistWindow->getWindow()->hide();
} }
GuiWindow::on_hide(); BasicWindow::hide();
} }

View file

@ -41,17 +41,13 @@
#endif #endif
#include <string> #include <string>
#include <unicode/resbund.h> #include <unicode/resbund.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" #include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "GuiWindow.h" #include "BasicWindow.h"
#include "ContentsStorable.h" #include "ContentsStorable.h"
#include "CuePlayer.h" #include "CuePlayer.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -79,10 +75,16 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class LiveModeWindow : public GuiWindow, class LiveModeWindow : public BasicWindow,
public ContentsStorable public ContentsStorable
{ {
private: private:
/**
* The directory where the Glade files are.
*/
Glib::ustring gladeDir;
/** /**
* The Playable item at the top of the window. * The Playable item at the top of the window.
*/ */
@ -111,22 +113,12 @@ class LiveModeWindow : public GuiWindow,
/** /**
* The cue player widget with play/pause and stop buttons. * The cue player widget with play/pause and stop buttons.
*/ */
CuePlayer * cueAudioButtons; Ptr<CuePlayer>::Ref cuePlayer;
/** /**
* The label for the cue player. * The label for the cue player.
*/ */
Gtk::Label * cueAudioLabel; Gtk::Label * cueLabel;
/**
* The button for removing every item from the window.
*/
Button * clearListButton;
/**
* The button for removing the selected items from the window.
*/
Button * removeButton;
/** /**
* If checked, the top item in the window will start playing * If checked, the top item in the window will start playing
@ -137,17 +129,17 @@ class LiveModeWindow : public GuiWindow,
/** /**
* Construct the right-click context menu for local audio clips. * Construct the right-click context menu for local audio clips.
* *
* @return the context menu created (already Gtk::manage()'ed). * @return the context menu created.
*/ */
Gtk::Menu * Ptr<Gtk::Menu>::Ref
constructAudioClipContextMenu(void) throw (); constructAudioClipContextMenu(void) throw ();
/** /**
* Construct the right-click context menu for local playlists. * Construct the right-click context menu for local playlists.
* *
* @return the context menu created (already Gtk::manage()'ed). * @return the context menu created.
*/ */
Gtk::Menu * Ptr<Gtk::Menu>::Ref
constructPlaylistContextMenu(void) throw (); constructPlaylistContextMenu(void) throw ();
/** /**
@ -173,12 +165,6 @@ class LiveModeWindow : public GuiWindow,
class ModelColumns : public PlayableTreeModelColumnRecord class ModelColumns : public PlayableTreeModelColumnRecord
{ {
public: public:
/**
* The column for the play button.
*/
// Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> >
// playButtonColumn;
/** /**
* The column for the title, creator, etc. * The column for the title, creator, etc.
*/ */
@ -189,7 +175,6 @@ class LiveModeWindow : public GuiWindow,
*/ */
ModelColumns(void) throw () ModelColumns(void) throw ()
{ {
// add(playButtonColumn);
add(infoColumn); add(infoColumn);
} }
}; };
@ -223,12 +208,12 @@ class LiveModeWindow : public GuiWindow,
/** /**
* The right-click context menu for audio clips. * The right-click context menu for audio clips.
*/ */
Gtk::Menu * audioClipContextMenu; Ptr<Gtk::Menu>::Ref audioClipContextMenu;
/** /**
* The right-click context menu for playlists. * The right-click context menu for playlists.
*/ */
Gtk::Menu * playlistContextMenu; Ptr<Gtk::Menu>::Ref playlistContextMenu;
/** /**
* Signal handler for the output play button clicked * Signal handler for the output play button clicked
@ -306,12 +291,6 @@ class LiveModeWindow : public GuiWindow,
virtual void virtual void
onUploadToHub(void) throw (); onUploadToHub(void) throw ();
/**
* Signal handler for the clear list button clicked.
*/
virtual void
onClearListButtonClicked(void) throw ();
/** /**
* Signal handler for the remove item button clicked. * Signal handler for the remove item button clicked.
*/ */
@ -324,17 +303,9 @@ class LiveModeWindow : public GuiWindow,
virtual void virtual void
onTreeModelChanged(void) throw (); onTreeModelChanged(void) throw ();
/**
* Event handler called when the the window gets hidden.
*
* This overrides GuiWindow::on_hide(), and closes the Export Playlist
* window, if it is still open.
*/
virtual void
on_hide(void) throw ();
public: public:
/** /**
* Constructor. * Constructor.
* *
@ -342,12 +313,14 @@ class LiveModeWindow : public GuiWindow,
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
* @param windowOpenerButton the button which was pressed to open * @param windowOpenerButton the button which was pressed to open
* this window. * this window.
* @param gladeDir the directory where the glade file is.
*/ */
LiveModeWindow(Ptr<GLiveSupport>::Ref gLiveSupport, LiveModeWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw (); throw ();
/** /**
@ -400,7 +373,7 @@ class LiveModeWindow : public GuiWindow,
void void
showCuePlayerStopped(void) throw () showCuePlayerStopped(void) throw ()
{ {
cueAudioButtons->onStop(); cuePlayer->onStop();
} }
/** /**
@ -466,6 +439,15 @@ class LiveModeWindow : public GuiWindow,
{ {
return userPreferencesKey; return userPreferencesKey;
} }
/**
* Hide the window.
*
* This overrides BasicWindow::hide(), and closes the Export Playlist
* and Schedule Playlist pop-up windows, if they are still open.
*/
virtual void
hide(void) throw ();
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -36,14 +36,12 @@
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LoginWindow.h" #include "LoginWindow.h"
using namespace Glib; using namespace Glib;
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -51,6 +49,14 @@ using namespace LiveSupport::GLiveSupport;
/* ================================================ local constants & macros */ /* ================================================ local constants & macros */
namespace {
/*------------------------------------------------------------------------------
* The name of the glade file.
*----------------------------------------------------------------------------*/
const Glib::ustring gladeFileName = "LoginWindow.glade";
}
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -62,197 +68,111 @@ using namespace LiveSupport::GLiveSupport;
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
LoginWindow :: LoginWindow (Ptr<GLiveSupport>::Ref gLiveSupport, LoginWindow :: LoginWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) const Glib::ustring & gladeDir)
throw () throw ()
: GuiWindow(gLiveSupport, : LocalizedObject(bundle),
bundle, gLiveSupport(gLiveSupport),
windowOpenerButton,
WhiteWindow::isNotResizable),
loggedIn(false) loggedIn(false)
{ {
this->gLiveSupport = gLiveSupport; glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance(); // localize everything
glade->get_widget("mainWindow1", loginWindow);
loginWindow->set_title(*getResourceUstring("windowTitle"));
set_default_size(350, 265); Gtk::Label * userNameLabel;
Gtk::Label * passwordLabel;
try { Gtk::Label * languageLabel;
set_title(*getResourceUstring("windowTitle")); glade->get_widget("userNameLabel1", userNameLabel);
loginLabel = Gtk::manage( glade->get_widget("passwordLabel1", passwordLabel);
new Gtk::Label(*getResourceUstring("loginLabel"))); glade->get_widget("languageLabel1", languageLabel);
passwordLabel = Gtk::manage( userNameLabel->set_text(*getResourceUstring("userNameLabel"));
new Gtk::Label( *getResourceUstring("passwordLabel"))); passwordLabel->set_text(*getResourceUstring("passwordLabel"));
loginEntryBin = Gtk::manage(widgetFactory->createEntryBin()); languageLabel->set_text(*getResourceUstring("languageLabel"));
loginEntry = loginEntryBin->getEntry();
passwordEntryBin = Gtk::manage(widgetFactory->createEntryBin());
passwordEntry = passwordEntryBin->getEntry();
languageList = Gtk::manage(widgetFactory->createComboBoxText());
okButton = Gtk::manage(widgetFactory->createButton(
*getResourceUstring("okButtonLabel")));
cancelButton = Gtk::manage(widgetFactory->createButton(
*getResourceUstring("cancelButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// set up the login label
loginLabel->set_name("loginLabel");
loginLabel->set_alignment(0, 0.5);
loginLabel->set_padding(0, 0);
loginLabel->set_justify(Gtk::JUSTIFY_RIGHT);
loginLabel->set_line_wrap(false);
loginLabel->set_use_markup(false);
loginLabel->set_selectable(false);
// set up the password label
passwordLabel->set_name("passwordLabel");
passwordLabel->set_alignment(0, 0.5);
passwordLabel->set_padding(0, 0);
passwordLabel->set_justify(Gtk::JUSTIFY_RIGHT);
passwordLabel->set_line_wrap(false);
passwordLabel->set_use_markup(false);
passwordLabel->set_selectable(false);
// set up the login text entry area
loginEntry->set_visibility(true);
loginEntry->set_activates_default(true);
// set up the password text entry area
passwordEntry->set_visibility(false);
passwordEntry->set_activates_default(true);
// set up the drop down list for available languages
languageList->set_name("languageList");
// fill up the language list with the list of available languages // fill up the language list with the list of available languages
Ptr<const GLiveSupport::LanguageMap>::Ref languages; glade->get_widget_derived("languageEntry1", languageEntry);
languages = gLiveSupport->getSupportedLanguages();
GLiveSupport::LanguageMap::const_iterator lang = languages->begin();
GLiveSupport::LanguageMap::const_iterator end = languages->end();
// insert the inital, 'default' language Ptr<const GLiveSupport::LanguageMap>::Ref
languageList->set_active_text(""); languages = gLiveSupport->getSupportedLanguages();
selectedLocale.reset(new std::string("")); for (GLiveSupport::LanguageMap::const_iterator
it = languages->begin(); it != languages->end(); ++it) {
while (lang != end) { Glib::ustring language = it->first;
const Glib::ustring & language = (*lang).first; languageEntry->append_text(language);
languageList->append_text(language);
lang++;
} }
languageEntry->set_active(0);
// set up the OK button // connect signal handlers
okButton->set_name("okButton"); glade->connect_clicked("okButton1", sigc::mem_fun(*this,
okButton->set_flags(Gtk::CAN_FOCUS|Gtk::CAN_DEFAULT|Gtk::HAS_DEFAULT); &LoginWindow::onOkButtonClicked));
okButton->set_relief(Gtk::RELIEF_NORMAL); glade->connect_clicked("cancelButton1", sigc::mem_fun(*this,
// Register the signal handler for the button getting clicked. &LoginWindow::onCancelButtonClicked));
okButton->signal_clicked().connect(sigc::mem_fun(*this,
&LoginWindow::onOkButtonClicked));
// set up the Cancel button glade->get_widget("userNameEntry1", userNameEntry);
cancelButton->set_name("cancelButton"); userNameEntry->signal_activate().connect(sigc::mem_fun(*this,
cancelButton->set_flags(Gtk::CAN_FOCUS); &LoginWindow::onUserNameEntryActivated));
cancelButton->set_relief(Gtk::RELIEF_NORMAL); glade->get_widget("passwordEntry1", passwordEntry);
// Register the signal handler for the button getting clicked. passwordEntry->signal_activate().connect(sigc::mem_fun(*this,
cancelButton->signal_clicked().connect(sigc::mem_fun(*this, &LoginWindow::onPasswordEntryActivated));
&LoginWindow::onCancelButtonClicked));
// set up the box for the buttons
buttonBox = Gtk::manage(new Gtk::HButtonBox());
buttonBox->set_layout(Gtk::BUTTONBOX_END);
buttonBox->set_spacing(5);
buttonBox->add(*cancelButton);
buttonBox->add(*okButton);
// set up the status bar // clear the status bar
statusBar = Gtk::manage(new Gtk::Label()); glade->get_widget("statusBar1", statusBar);
statusBar->set_text("");
// set up the table, which provides the layout, and place the widgets // set the OK button as the default action, when the user presses Enter;
// inside the table // this does not work when one of the entry fields have focus,
table = Gtk::manage(new Gtk::Table(8, 10, false)); // so we need to connect the 'activate' signals explicitly above
table->set_name("table"); loginWindow->set_default_response(Gtk::RESPONSE_OK);
table->set_row_spacings(5);
table->set_col_spacings(0);
table->attach(*loginLabel,
0, 8, 3, 4,
Gtk::FILL, Gtk::AttachOptions(), 0, 0);
table->attach(*loginEntryBin,
0, 8, 4, 5,
Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
table->attach(*passwordLabel,
0, 8, 5, 6,
Gtk::FILL, Gtk::AttachOptions(), 0, 5);
table->attach(*passwordEntryBin,
0, 8, 6, 7,
Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
table->attach(*languageList,
0, 1, 7, 8,
Gtk::SHRINK, Gtk::AttachOptions(), 0, 10);
table->attach(*buttonBox,
0, 8, 8, 9,
Gtk::FILL, Gtk::AttachOptions(), 0, 10);
table->attach(*statusBar,
0, 8, 9, 10,
Gtk::FILL, Gtk::AttachOptions(), 0, 0);
// set up the window itself
set_name("loginWindow");
set_modal(true);
property_window_position().set_value(Gtk::WIN_POS_CENTER);
set_keep_above(true);
set_resizable(false);
property_destroy_with_parent().set_value(false);
set_default(*okButton);
// add the table to the window, and show everything
add(*table);
loginEntry->grab_focus();
show_all_children();
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Destructor. * Destructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
LoginWindow :: ~LoginWindow (void) throw () LoginWindow :: ~LoginWindow (void) throw ()
{ {
} }
/*------------------------------------------------------------------------------
* Signal handler for the Enter key pressed in the user name entry.
*----------------------------------------------------------------------------*/
void
LoginWindow :: onUserNameEntryActivated (void) throw ()
{
passwordEntry->grab_focus();
}
/*------------------------------------------------------------------------------
* Signal handler for the Enter key pressed in the password entry.
*----------------------------------------------------------------------------*/
void
LoginWindow :: onPasswordEntryActivated (void) throw ()
{
onOkButtonClicked();
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler for the OK button getting clicked. * Event handler for the OK button getting clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LoginWindow :: onOkButtonClicked (void) throw () LoginWindow :: onOkButtonClicked (void) throw ()
{ {
Ptr<Glib::ustring>::Ref pleaseWaitMessage; statusBar->set_text(*getResourceUstring("pleaseWaitMsg"));
try { loginWindow->set_sensitive(false);
pleaseWaitMessage.reset(new Glib::ustring(
*getResourceUstring("pleaseWaitMsg")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
setStatusBarText(pleaseWaitMessage);
this->set_sensitive(false);
gLiveSupport->runMainLoop(); // redraw the window gLiveSupport->runMainLoop(); // redraw the window
loginText.reset(new Glib::ustring(loginEntry->get_text())); userNameText.reset(new Glib::ustring(userNameEntry->get_text()));
passwordText.reset(new Glib::ustring(passwordEntry->get_text())); passwordText.reset(new Glib::ustring(passwordEntry->get_text()));
Ptr<const GLiveSupport::LanguageMap>::Ref languages; Ptr<const GLiveSupport::LanguageMap>::Ref languages;
languages = gLiveSupport->getSupportedLanguages(); languages = gLiveSupport->getSupportedLanguages();
GLiveSupport::LanguageMap::const_iterator end = languages->end(); GLiveSupport::LanguageMap::const_iterator
GLiveSupport::LanguageMap::const_iterator langSel = langSel = languages->find(languageEntry->get_active_text());
languages->find(languageList->get_active_text()); selectedLocale.reset(new std::string(langSel->second));
if (langSel != end) {
selectedLocale.reset(new std::string((*langSel).second));
} else {
selectedLocale.reset(new std::string(""));
}
loggedIn = gLiveSupport->login(*getLogin(), *getPassword()); loggedIn = gLiveSupport->login(*getLogin(), *getPassword());
@ -266,7 +186,7 @@ LoginWindow :: onOkButtonClicked (void) throw ()
gLiveSupport->createScratchpadWindow(); gLiveSupport->createScratchpadWindow();
} }
hide(); loginWindow->hide();
} }
@ -276,7 +196,7 @@ LoginWindow :: onOkButtonClicked (void) throw ()
void void
LoginWindow :: onCancelButtonClicked (void) throw () LoginWindow :: onCancelButtonClicked (void) throw ()
{ {
hide(); loginWindow->hide();
} }
@ -286,18 +206,8 @@ LoginWindow :: onCancelButtonClicked (void) throw ()
bool bool
LoginWindow :: run(void) throw () LoginWindow :: run(void) throw ()
{ {
Gtk::Main::run(*this); Gtk::Main::run(*loginWindow);
return loggedIn; return loggedIn;
} }
/*------------------------------------------------------------------------------
* Set the text of the status bar.
*----------------------------------------------------------------------------*/
void
LoginWindow :: setStatusBarText(Ptr<const Glib::ustring>::Ref text)
throw ()
{
statusBar->set_text(*text);
}

View file

@ -41,22 +41,13 @@
#endif #endif
#include <string> #include <string>
#include <unicode/resbund.h> #include <unicode/resbund.h>
#include <gtkmm.h>
#include <gtkmm/window.h> #include <libglademm.h>
#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/label.h>
#include <gtkmm/entry.h>
#include <gtkmm/table.h>
#include <gtkmm/combo.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/EntryBin.h"
#include "LiveSupport/Widgets/ComboBoxText.h" #include "LiveSupport/Widgets/ComboBoxText.h"
#include "GuiWindow.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
@ -79,77 +70,52 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class LoginWindow : public GuiWindow class LoginWindow : public LocalizedObject
{ {
private:
protected:
/**
* The table, which provides the layout for the window.
*/
Gtk::Table * table;
/** /**
* The login label in the window. * The Glade object, containing the visual design.
*/ */
Gtk::Label * loginLabel; Glib::RefPtr<Gnome::Glade::Xml> glade;
/** /**
* The password label in the window. * The GLiveSupport object, holding the state of the application.
*/ */
Gtk::Label * passwordLabel; Ptr<GLiveSupport>::Ref gLiveSupport;
/** /**
* The container for the login text entry area. * The window itself.
*/ */
EntryBin * loginEntryBin; Gtk::Dialog * loginWindow;
/** /**
* The login text entry area. * The user name text entry area.
*/ */
Gtk::Entry * loginEntry; Gtk::Entry * userNameEntry;
/**
* The container for the password text entry area.
*/
EntryBin * passwordEntryBin;
/** /**
* The password text entry area. * The password text entry area.
*/ */
Gtk::Entry * passwordEntry; Gtk::Entry * passwordEntry;
/** /**
* The drop-down list to select the desired language. * The drop-down list to select the desired language.
*/ */
ComboBoxText * languageList; ComboBoxText * languageEntry;
/**
* The horizontal box for the buttons.
*/
Gtk::HButtonBox * buttonBox;
/**
* The OK button.
*/
Button * okButton;
/**
* The Cancel button.
*/
Button * cancelButton;
/** /**
* The status bar. * The status bar.
*/ */
Gtk::Label * statusBar; Gtk::Label * statusBar;
/** /**
* The login text, that was entered by the user. * The user name text entered by the user.
*/ */
Ptr<Glib::ustring>::Ref loginText; Ptr<Glib::ustring>::Ref userNameText;
/** /**
* The password text, that was entered by the user. * The password text entered by the user.
*/ */
Ptr<Glib::ustring>::Ref passwordText; Ptr<Glib::ustring>::Ref passwordText;
@ -163,6 +129,18 @@ class LoginWindow : public GuiWindow
*/ */
bool loggedIn; bool loggedIn;
/**
* Signal handler for the Enter key pressed in the user name entry.
*/
virtual void
onUserNameEntryActivated(void) throw ();
/**
* Signal handler for the Enter key pressed in the password entry.
*/
virtual void
onPasswordEntryActivated(void) throw ();
/** /**
* Signal handler for the ok button clicked. * Signal handler for the ok button clicked.
*/ */
@ -176,14 +154,18 @@ class LoginWindow : public GuiWindow
onCancelButtonClicked(void) throw (); onCancelButtonClicked(void) throw ();
/** /**
* Set the text of the status bar. * Get the password entered by the user.
*
* @return the password entered by the user.
*/ */
virtual void Ptr<const Glib::ustring>::Ref
setStatusBarText(Ptr<const Glib::ustring>::Ref text) getPassword(void) const throw ()
throw (); {
return passwordText;
}
public: public:
/** /**
* Constructor. * Constructor.
* *
@ -191,12 +173,11 @@ class LoginWindow : public GuiWindow
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
* @param windowOpenerButton the button which was pressed to open * @param gladeDir the directory where the glade file is.
* this window.
*/ */
LoginWindow(Ptr<GLiveSupport>::Ref gLiveSupport, LoginWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) const Glib::ustring & gladeDir)
throw (); throw ();
/** /**
@ -213,30 +194,7 @@ class LoginWindow : public GuiWindow
Ptr<const Glib::ustring>::Ref Ptr<const Glib::ustring>::Ref
getLogin(void) const throw () getLogin(void) const throw ()
{ {
return loginText; return userNameText;
}
/**
* Get the password entered by the user.
*
* @return the password entered by the user.
*/
Ptr<const Glib::ustring>::Ref
getPassword(void) const throw ()
{
return passwordText;
}
/**
* Get the locale selected by the user.
*
* @return the locale selected by the user. if this is an empty
* string, the user selected the default locale.
*/
Ptr<const std::string>::Ref
getSelectedLocale(void) const throw ()
{
return selectedLocale;
} }
/** /**

View file

@ -1,287 +0,0 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <iostream>
#include <unicode/msgfmt.h>
#include <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
#include "LiveSupport/Core/TimeConversion.h"
#include "LoginWindow.h"
#include "MasterPanelUserInfoWidget.h"
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
MasterPanelUserInfoWidget :: MasterPanelUserInfoWidget (
Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ()
: LocalizedObject(bundle),
gLiveSupport(gLiveSupport),
loggedIn(false)
{
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
logInOutButton = Gtk::manage(wf->createButton(
"",
WidgetConstants::radioButton));
logInOutSignalConnection =
logInOutButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelUserInfoWidget::onLoginButtonClicked));
closeButton = Gtk::manage(wf->createButton(WidgetConstants::deleteButton));
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelUserInfoWidget::onCloseButtonClicked));
userInfoLabel = Gtk::manage(new Gtk::Label());
changeLanguage(bundle);
// set up the main window, and show everything
attach(*logInOutButton, 0, 1, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
5, 0);
attach(*userInfoLabel, 1, 2, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
5, 0);
attach(*closeButton, 2, 3, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
5, 0);
// show everything
show_all();
Ptr<Glib::ustring>::Ref confirmationMessage;
try {
confirmationMessage.reset(new Glib::ustring(
*getResourceUstring("sureToExitMsg") ));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
dialogWindow.reset(new DialogWindow(confirmationMessage,
DialogWindow::noButton |
DialogWindow::yesButton,
gLiveSupport->getBundle() ));
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
MasterPanelUserInfoWidget :: ~MasterPanelUserInfoWidget (void) throw ()
{
}
/*------------------------------------------------------------------------------
* Event handler for the logout button getting clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelUserInfoWidget :: onLogoutButtonClicked (void) throw ()
{
bool userCanceledTheLogout = !gLiveSupport->logout();
if (userCanceledTheLogout) {
return;
}
loggedIn = false;
login.reset();
Ptr<Glib::ustring>::Ref notLoggedInMsg;
Ptr<Glib::ustring>::Ref loginButtonLabel;
try {
loginButtonLabel = getResourceUstring("loginButtonLabel");
notLoggedInMsg = getResourceUstring("notLoggedInMsg");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
userInfoLabel->set_label(*notLoggedInMsg);
// change the logout button to a login button
logInOutButton->set_label(*loginButtonLabel);
logInOutButton->setSelected(false);
logInOutSignalConnection.disconnect();
logInOutSignalConnection =
logInOutButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelUserInfoWidget::onLoginButtonClicked));
// add the close button
attach(*closeButton, 2, 3, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
5, 0);
show_all_children();
}
/*------------------------------------------------------------------------------
* Event handler for the login button getting clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelUserInfoWidget :: onLoginButtonClicked (void) throw ()
{
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(gLiveSupport,
loginBundle,
logInOutButton));
loggedIn = loginWindow->run();
if (loggedIn) {
login = loginWindow->getLogin();
try {
updateStrings();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// change the login button to a logout button
logInOutSignalConnection.disconnect();
logInOutSignalConnection =
logInOutButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelUserInfoWidget::onLogoutButtonClicked));
// remove the close button
remove(*closeButton);
// show the logged in UI
gLiveSupport->showLoggedInUI();
}
}
/*------------------------------------------------------------------------------
* Change the language of the panel
*----------------------------------------------------------------------------*/
void
MasterPanelUserInfoWidget :: changeLanguage(Ptr<ResourceBundle>::Ref bundle)
throw ()
{
setBundle(bundle);
try {
updateStrings();
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
}
/*------------------------------------------------------------------------------
* Update the strings in the widget.
*----------------------------------------------------------------------------*/
void
MasterPanelUserInfoWidget :: updateStrings(void)
throw (std::invalid_argument)
{
Ptr<Glib::ustring>::Ref loggedInMsg;
Ptr<Glib::ustring>::Ref loginButtonLabel;
if (!loggedIn) {
loginButtonLabel = getResourceUstring("loginButtonLabel");
loggedInMsg = getResourceUstring("notLoggedInMsg");
} else {
loggedInMsg = formatMessage("loggedInMsg", *login);
loginButtonLabel = getResourceUstring("logoutButtonLabel");
}
userInfoLabel->set_label(*loggedInMsg);
logInOutButton->set_label(*loginButtonLabel);
logInOutButton->setSelected(false);
dialogWindow.reset(new DialogWindow(getResourceUstring("sureToExitMsg"),
DialogWindow::noButton |
DialogWindow::yesButton,
gLiveSupport->getBundle() ));
}
/*------------------------------------------------------------------------------
* Event handler for the close button getting clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelUserInfoWidget :: onCloseButtonClicked (void) throw ()
{
// TODO: make this disableable (nice word, isn't it?) from config
DialogWindow::ButtonType userReply = dialogWindow->run();
if (userReply != DialogWindow::yesButton) {
return;
}
gLiveSupport->stopOutputAudio();
Ptr<OptionsContainer>::Ref optionsContainer
= gLiveSupport->getOptionsContainer();
if (optionsContainer && optionsContainer->isTouched()) {
optionsContainer->writeToFile();
}
// get the topmost container, should be the application window itself
Gtk::Container * container = get_parent();
while (container->get_parent()) {
container = container->get_parent();
}
container->hide();
}

View file

@ -1,191 +0,0 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster 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.
Campcaster 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 Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
#ifndef MasterPanelUserInfoWidget_h
#define MasterPanelUserInfoWidget_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <gtkmm/button.h>
#include <gtkmm/table.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/DialogWindow.h"
#include "GLiveSupport.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport;
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* The user info widget of the master panel.
*
* This widget handles login and login info display.
*
* @author $Author$
* @version $Revision$
*/
class MasterPanelUserInfoWidget : public Gtk::Table,
public LocalizedObject
{
protected:
/**
* The login / logout button.
*/
Widgets::Button * logInOutButton;
/**
* The close application button.
*/
Widgets::ImageButton * closeButton;
/**
* A label to display the currently logged in user.
*/
Gtk::Label * userInfoLabel;
/**
* The "are you sure you want to exit?" dialog window.
*/
Ptr<DialogWindow>::Ref dialogWindow;
/**
* The gLiveSupport object, handling the logic of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The sigc connection object, that connects the button clicked
* event on the logInOutButton to either onLoginButtonClicked()
* or onLogoutButtonClicked().
*/
sigc::connection logInOutSignalConnection;
/**
* Flag to indicate if the user is logged in or not.
*/
bool loggedIn;
/**
* The user id logged in as.
*/
Ptr<const Glib::ustring>::Ref login;
/**
* Signal handler for the login button clicked.
*/
virtual void
onLoginButtonClicked(void) throw ();
/**
* Signal handler for the logout button clicked.
*/
virtual void
onLogoutButtonClicked(void) throw ();
/**
* Signal handler for the close button clicked.
*/
virtual void
onCloseButtonClicked(void) throw ();
/**
* Update the strings in the widget, including the localized strings.
*
* @exception std::invalid_argument if some localized resources
* could not be attained.
*/
void
updateStrings(void) throw (std::invalid_argument);
public:
/**
* Constructor.
*
* @param gLiveSupport the gLiveSupport object, handling the
* logic of the application
* @param bundle the resource bundle holding localized resources
*/
MasterPanelUserInfoWidget(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ();
/**
* Virtual destructor.
*/
virtual
~MasterPanelUserInfoWidget(void) throw ();
/**
* Change the user interface language of the application
* by providing a new resource bundle.
* This call assumes that only the MasterPanel is visilbe,
* and will only change the language of the currently open
* MasterPanel. No other open windows will be affected by
* this call, but subsequently opened windows are.
*
* @param bundle the new resource bundle.
*/
void
changeLanguage(Ptr<ResourceBundle>::Ref bundle) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace GLiveSupport
} // namespace LiveSupport
#endif // MasterPanelUserInfoWidget_h

View file

@ -40,7 +40,7 @@
#include <gdkmm/pixbuf.h> #include <gdkmm/pixbuf.h>
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Widgets/MasterPanelBin.h" #include "LoginWindow.h"
#include "MasterPanelWindow.h" #include "MasterPanelWindow.h"
@ -56,9 +56,9 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/** /**
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc). * The name of the glade file.
*/ */
const Glib::ustring windowName = "masterPanelWindow"; const Glib::ustring gladeFileName = "MasterPanelWindow.glade";
/** /**
* The name of the application, shown on the task bar. * The name of the application, shown on the task bar.
@ -68,7 +68,6 @@ const Glib::ustring applicationTitleSuffix = " - Campcaster";
/** /**
* Number of times per second that onUpdateTime() is called. * Number of times per second that onUpdateTime() is called.
* It's a good idea to make this a divisor of 1000. * It's a good idea to make this a divisor of 1000.
* If you change this, then you must change NowPlaying::blinkingConstant, too.
*/ */
const int updateTimeConstant = 20; const int updateTimeConstant = 20;
@ -94,140 +93,100 @@ const int rdsUpdateFrequency = 10;
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport, MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
const Glib::ustring & gladeDir)
throw () throw ()
: LocalizedObject(bundle), : LocalizedObject(bundle),
gLiveSupport(gLiveSupport) gLiveSupport(gLiveSupport),
gladeDir(gladeDir),
userIsLoggedIn(false)
{ {
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance(); glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
radioLogoWidget = Gtk::manage(gLiveSupport->getStationLogoImage()); // load the station logo image
resizeImage(radioLogoWidget, 120, 104); Gtk::Image * stationLogoImage;
radioLogoWidget->set_size_request(120, 104); glade->get_widget("stationLogoImage1", stationLogoImage);
stationLogoImage->set(gLiveSupport->getStationLogoPixbuf());
// set up the layout, which is a button box
layout = Gtk::manage(new Gtk::Table());
// set up the time label // set up the time label
timeWidget = Gtk::manage(new Gtk::Label()); glade->get_widget("timeLabel1", timeLabel);
Pango::Attribute fontDescriptionAttribute = Pango::Attribute fontDescriptionAttribute =
Pango::Attribute::create_attr_font_desc( Pango::Attribute::create_attr_font_desc(
Pango::FontDescription( Pango::FontDescription(
"Bitstream Vera Sans Bold 20")); "Bitstream Vera Sans Bold 20"));
fontDescriptionAttribute.set_start_index(0); fontDescriptionAttribute.set_start_index(0);
fontDescriptionAttribute.set_end_index(10); fontDescriptionAttribute.set_end_index(10);
Pango::AttrList timeWidgetAttributes; Pango::AttrList timeLabelAttributes;
timeWidgetAttributes.insert(fontDescriptionAttribute); timeLabelAttributes.insert(fontDescriptionAttribute);
timeWidget->set_attributes(timeWidgetAttributes); timeLabel->set_attributes(timeLabelAttributes);
timeBin = Gtk::manage(widgetFactory->createBlueBin());
timeBin->add(*timeWidget);
timeBin->set_size_request(140, 104);
// set up the now playing widget // register the signal handlers for the main window
nowPlayingWidget = Gtk::manage(new NowPlaying(gLiveSupport, bundle)); glade->get_widget("mainWindow1", masterPanelWindow);
Gtk::Alignment * nowPlayingAlignment = Gtk::manage(new Gtk::Alignment( masterPanelWindow->signal_key_press_event().connect(sigc::mem_fun(
0.0, 0.7, 1.0, 0.0 )); *this,
nowPlayingAlignment->add(*nowPlayingWidget);
nowPlayingBin = Gtk::manage(widgetFactory->createDarkBlueBin());
nowPlayingBin->add(*nowPlayingAlignment);
nowPlayingBin->set_size_request(-1, 104);
/* temporarily disabled
// set up the VU meter widget
vuMeterWidget = Gtk::manage(new Gtk::Label(""));
vuMeterBin = Gtk::manage(widgetFactory->createBlueBin());
vuMeterBin->add(*vuMeterWidget);
vuMeterBin->set_size_request(200, 40);
*/
/* temporarily disabled
// set up the next playing widget
nextPlayingWidget = Gtk::manage(new Gtk::Label(""));
nextPlayingBin = Gtk::manage(widgetFactory->createBlueBin());
nextPlayingBin->add(*nextPlayingWidget);
nextPlayingBin->set_size_request(200, 59);
*/
// create the bottom bar
bottomBar = Gtk::manage(new Gtk::HBox());
buttonBar = Gtk::manage(new Gtk::Table());
buttonBar->set_homogeneous(true);
buttonBarAlignment = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER,
0, 0));
buttonBarAlignment->add(*buttonBar);
userInfoWidget = Gtk::manage(new MasterPanelUserInfoWidget(gLiveSupport,
bundle));
userInfoAlignment = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_RIGHT,
Gtk::ALIGN_CENTER,
0, 0));
userInfoAlignment->add(*userInfoWidget);
bottomBar->pack_start(*buttonBarAlignment, Gtk::PACK_EXPAND_WIDGET, 0);
bottomBar->pack_start(*userInfoAlignment, Gtk::PACK_EXPAND_WIDGET, 0);
// a bit of extra vertical space above the buttons
Gtk::HBox * extraSpace = Gtk::manage(new Gtk::HBox());
// set up the main window, and show everything
// all the localized widgets were set up in changeLanguage()
layout->set_border_width(5);
layout->attach(*timeBin, 0, 1, 0, 2,
Gtk::SHRINK, Gtk::SHRINK,
0, 0);
layout->attach(*nowPlayingBin, 1, 2, 0, 2,
Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK,
5, 0);
// layout->attach(*vuMeterBin, 2, 3, 0, 1,
// Gtk::SHRINK, Gtk::SHRINK,
// 0, 0);
// layout->attach(*nextPlayingBin, 2, 3, 1, 2,
// Gtk::SHRINK, Gtk::SHRINK,
// 0, 0);
layout->attach(*radioLogoWidget, 3, 4, 0, 2,
Gtk::SHRINK, Gtk::SHRINK,
5, 0);
layout->attach(*extraSpace, 0, 4, 2, 3,
Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL,
0, 2);
layout->attach(*bottomBar, 0, 4, 3, 4,
Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL,
0, 0);
// add the bottom border
MasterPanelBin * bin = Gtk::manage(new MasterPanelBin());
bin->add(*layout);
this->add(*bin);
// register the signal handler for keyboard key presses
this->signal_key_press_event().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onKeyPressed)); &MasterPanelWindow::onKeyPressed));
masterPanelWindow->signal_delete_event().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onDeleteEvent));
// set the background to white // create the Now Playing widget
bgColor = Colors::getColor(Colors::White); Gtk::Box * nowPlayingBox;
modify_bg(Gtk::STATE_NORMAL, bgColor); glade->get_widget("nowPlayingWidget1", nowPlayingBox);
nowPlayingWidget.reset(new NowPlaying(gLiveSupport,
bundle,
glade));
// get a reference for the window-opener buttons
glade->get_widget("liveModeButton1", liveModeButton);
glade->get_widget("uploadFileButton1", uploadFileButton);
glade->get_widget("scratchpadButton1", scratchpadButton);
glade->get_widget("playlistButton1", playlistButton);
glade->get_widget("schedulerButton1", schedulerButton);
glade->get_widget("searchButton1", searchButton);
glade->get_widget("optionsButton1", optionsButton);
// get a reference for some other widgets
glade->get_widget("mainButtonBox1", mainButtonBox);
glade->get_widget("userInfoLabel1", userInfoLabel);
glade->get_widget("loginButton1", loginButton);
// bind events to the buttons
liveModeButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onLiveModeButtonClicked));
uploadFileButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onUploadFileButtonClicked));
scratchpadButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onScratchpadButtonClicked));
playlistButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onPlaylistButtonClicked));
schedulerButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onSchedulerButtonClicked));
searchButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onSearchButtonClicked));
optionsButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onOptionsButtonClicked));
loginButton->signal_clicked().connect(sigc::mem_fun(
*this,
&MasterPanelWindow::onLoginButtonClicked));
// set the size and location of the window, according to the screen size // set the size and location of the window, according to the screen size
Glib::RefPtr<Gdk::Screen> screen = get_screen(); Glib::RefPtr<Gdk::Screen> screen = masterPanelWindow->get_screen();
int width = screen->get_width(); masterPanelWindow->set_default_size(screen->get_width(), -1);
set_default_size(width, -1); masterPanelWindow->move(0, 0);
move(0, 0);
set_decorated(false);
set_name(windowName);
// set the localized resources
liveModeButton = 0;
uploadFileButton = 0;
scratchpadButton = 0;
simplePlaylistMgmtButton = 0;
schedulerButton = 0;
searchButton = 0;
optionsButton = 0;
changeLanguage(bundle);
// show what's there to see // show what's there to see
showAnonymousUI(); showAnonymousUI();
updateUserInfo();
// set the timer, that will update timeWidget // set the timer, that will update timeLabel
setTimer(); setTimer();
} }
@ -235,7 +194,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Destructor. * Destructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
MasterPanelWindow :: ~MasterPanelWindow (void) throw () MasterPanelWindow :: ~MasterPanelWindow (void) throw ()
{ {
resetTimer(); resetTimer();
gLiveSupport->stopOutputAudio(); gLiveSupport->stopOutputAudio();
@ -252,115 +211,40 @@ MasterPanelWindow :: changeLanguage(Ptr<ResourceBundle>::Ref bundle)
{ {
setBundle(bundle); setBundle(bundle);
if (liveModeButton) { Glib::ustring title = *getResourceUstring(
buttonBar->remove(*liveModeButton); "masterPanelWindow",
} "windowTitle");
if (uploadFileButton) { title += applicationTitleSuffix;
buttonBar->remove(*uploadFileButton); masterPanelWindow->set_title(title);
}
if (scratchpadButton) {
buttonBar->remove(*scratchpadButton);
}
if (simplePlaylistMgmtButton) {
buttonBar->remove(*simplePlaylistMgmtButton);
}
if (schedulerButton) {
buttonBar->remove(*schedulerButton);
}
if (searchButton) {
buttonBar->remove(*searchButton);
}
if (optionsButton) {
buttonBar->remove(*optionsButton);
}
try { nowPlayingWidget->changeLanguage(bundle);
Ptr<Glib::ustring>::Ref title = getResourceUstring(
windowName.c_str(),
"windowTitle");
title->append(applicationTitleSuffix);
set_title(*title);
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); liveModeButton->set_label(*getResourceUstring(
"liveModeButtonLabel"));
uploadFileButton->set_label(*getResourceUstring(
"uploadFileButtonLabel"));
scratchpadButton->set_label(*getResourceUstring(
"scratchpadButtonLabel"));
playlistButton->set_label(*getResourceUstring(
"playlistButtonLabel"));
schedulerButton->set_label(*getResourceUstring(
"schedulerButtonLabel"));
searchButton->set_label(*getResourceUstring(
"searchButtonLabel"));
optionsButton->set_label(*getResourceUstring(
"optionsButtonLabel"));
liveModeButton = Gtk::manage(wf->createButton( updateUserInfo();
*getResourceUstring("liveModeButtonLabel"),
WidgetConstants::radioButton));
uploadFileButton = Gtk::manage(wf->createButton(
*getResourceUstring("uploadFileButtonLabel"),
WidgetConstants::radioButton));
scratchpadButton = Gtk::manage(wf->createButton(
*getResourceUstring("scratchpadButtonLabel"),
WidgetConstants::radioButton));
simplePlaylistMgmtButton = Gtk::manage(wf->createButton(
*getResourceUstring("simplePlaylistMgmtButtonLabel"),
WidgetConstants::radioButton));
schedulerButton = Gtk::manage(wf->createButton(
*getResourceUstring("schedulerButtonLabel"),
WidgetConstants::radioButton));
searchButton = Gtk::manage(wf->createButton(
*getResourceUstring("searchButtonLabel"),
WidgetConstants::radioButton));
optionsButton = Gtk::manage(wf->createButton(
*getResourceUstring("optionsButtonLabel"),
WidgetConstants::radioButton));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
userInfoWidget->changeLanguage(bundle); if (!gLiveSupport->isStorageAvailable()) {
// re-attach the localized widgets to the layout
buttonBar->attach(*liveModeButton, 0, 1, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
0, 0);
buttonBar->attach(*uploadFileButton, 1, 2, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
5, 0);
buttonBar->attach(*scratchpadButton, 2, 3, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
0, 0);
buttonBar->attach(*simplePlaylistMgmtButton, 3, 4, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
5, 0);
buttonBar->attach(*schedulerButton, 4, 5, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
0, 0);
buttonBar->attach(*searchButton, 5, 6, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
5, 0);
buttonBar->attach(*optionsButton, 6, 7, 0, 1,
Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL,
0, 0);
if (gLiveSupport->isStorageAvailable()) {
// re-bind events to the buttons
liveModeButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onLiveModeButtonClicked));
uploadFileButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onUploadFileButtonClicked));
scratchpadButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onScratchpadButtonClicked));
simplePlaylistMgmtButton->signal_clicked().connect(
sigc::mem_fun(*this,
&MasterPanelWindow::onSimplePlaylistMgmtButtonClicked));
schedulerButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onSchedulerButtonClicked));
searchButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onSearchButtonClicked));
} else {
// gray out all the buttons except Options // gray out all the buttons except Options
liveModeButton->setDisabled(true); liveModeButton->set_sensitive(false);
uploadFileButton->setDisabled(true); uploadFileButton->set_sensitive(false);
scratchpadButton->setDisabled(true); scratchpadButton->set_sensitive(false);
simplePlaylistMgmtButton->setDisabled(true); playlistButton->set_sensitive(false);
schedulerButton->setDisabled(true); schedulerButton->set_sensitive(false);
searchButton->setDisabled(true); searchButton->set_sensitive(false);
} }
optionsButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onOptionsButtonClicked));
} }
@ -368,11 +252,11 @@ MasterPanelWindow :: changeLanguage(Ptr<ResourceBundle>::Ref bundle)
* Set the timer * Set the timer
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: setTimer(void) throw () MasterPanelWindow :: setTimer(void) throw ()
{ {
sigc::slot<bool> slot = sigc::bind(sigc::mem_fun(*this, sigc::slot<bool> slot = sigc::bind(sigc::mem_fun(*this,
&MasterPanelWindow::onUpdateTime), &MasterPanelWindow::onUpdateTime),
0); 0);
// set the timer to activate every 1/somethingth of a second // set the timer to activate every 1/somethingth of a second
timer.reset(new sigc::connection( timer.reset(new sigc::connection(
@ -384,7 +268,7 @@ MasterPanelWindow :: setTimer(void) throw ()
* Clear the timer * Clear the timer
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: resetTimer(void) throw () MasterPanelWindow :: resetTimer(void) throw ()
{ {
timer->disconnect(); timer->disconnect();
timer.reset(); timer.reset();
@ -392,10 +276,10 @@ MasterPanelWindow :: resetTimer(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Update the timeWidget display, with the current time * Update the timeLabel display, with the current time
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
bool bool
MasterPanelWindow :: onUpdateTime(int dummy) throw () MasterPanelWindow :: onUpdateTime(int dummy) throw ()
{ {
Ptr<const ptime>::Ref now; Ptr<const ptime>::Ref now;
@ -419,7 +303,7 @@ MasterPanelWindow :: onUpdateTime(int dummy) throw ()
dayTime.seconds(), dayTime.seconds(),
0); 0);
timeWidget->set_text(to_simple_string(dayTimeSec)); timeLabel->set_text(to_simple_string(dayTimeSec));
} }
nowPlayingWidget->onUpdateTime(); nowPlayingWidget->onUpdateTime();
@ -428,7 +312,7 @@ MasterPanelWindow :: onUpdateTime(int dummy) throw ()
static int backupCounter = 0; static int backupCounter = 0;
if (backupCounter == 0) { if (backupCounter == 0) {
if (optionsWindow) { if (optionsWindow) {
BackupList * backupList = optionsWindow->getBackupList(); Ptr<BackupList>::Ref backupList = optionsWindow->getBackupList();
if (backupList) { if (backupList) {
backupList->updateSilently(); backupList->updateSilently();
} }
@ -466,21 +350,17 @@ MasterPanelWindow :: updateLiveModeWindow(Ptr<Playable>::Ref playable)
throw () throw ()
{ {
if (!liveModeWindow.get()) { if (!liveModeWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("liveModeWindow");
try {
bundle = getBundle("liveModeWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
liveModeWindow.reset(new LiveModeWindow(gLiveSupport, liveModeWindow.reset(new LiveModeWindow(gLiveSupport,
bundle, bundle,
liveModeButton)); liveModeButton,
gladeDir));
gLiveSupport->loadWindowContents(liveModeWindow); gLiveSupport->loadWindowContents(liveModeWindow);
} }
liveModeWindow->present(); liveModeWindow->show();
liveModeWindow->getWindow()->present();
if (playable) { if (playable) {
liveModeWindow->addItem(playable); liveModeWindow->addItem(playable);
@ -495,20 +375,16 @@ void
MasterPanelWindow :: updateUploadFileWindow(void) throw () MasterPanelWindow :: updateUploadFileWindow(void) throw ()
{ {
if (!uploadFileWindow.get()) { if (!uploadFileWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("uploadFileWindow");
try {
bundle = getBundle("uploadFileWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
uploadFileWindow.reset(new UploadFileWindow(gLiveSupport, uploadFileWindow.reset(new UploadFileWindow(gLiveSupport,
bundle, bundle,
uploadFileButton)); uploadFileButton,
gladeDir));
} }
uploadFileWindow->present(); uploadFileWindow->show();
uploadFileWindow->getWindow()->present();
} }
@ -517,19 +393,15 @@ MasterPanelWindow :: updateUploadFileWindow(void) throw ()
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: createScratchpadWindow(void) MasterPanelWindow :: createScratchpadWindow(void)
throw () throw ()
{ {
if (!scratchpadWindow.get()) { if (!scratchpadWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("scratchpadWindow");
try {
bundle = getBundle("scratchpadWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
scratchpadWindow.reset(new ScratchpadWindow(gLiveSupport, scratchpadWindow.reset(new ScratchpadWindow(gLiveSupport,
bundle, bundle,
scratchpadButton)); scratchpadButton,
gladeDir));
gLiveSupport->loadWindowContents(scratchpadWindow); gLiveSupport->loadWindowContents(scratchpadWindow);
} }
} }
@ -540,7 +412,7 @@ MasterPanelWindow :: createScratchpadWindow(void)
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: updateScratchpadWindow(Ptr<Playable>::Ref playable) MasterPanelWindow :: updateScratchpadWindow(Ptr<Playable>::Ref playable)
throw () throw ()
{ {
createScratchpadWindow(); createScratchpadWindow();
@ -548,34 +420,30 @@ MasterPanelWindow :: updateScratchpadWindow(Ptr<Playable>::Ref playable)
scratchpadWindow->addItem(playable); scratchpadWindow->addItem(playable);
} }
scratchpadWindow->present(); scratchpadWindow->show();
scratchpadWindow->getWindow()->present();
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The event when the Simple Playlist Management button has been clicked. * The event when the Playlist button has been clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: updateSimplePlaylistMgmtWindow(void) throw () MasterPanelWindow :: updatePlaylistWindow(void) throw ()
{ {
if (!simplePlaylistMgmtWindow.get()) { if (!playlistWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("playlistWindow");
try {
bundle = getBundle("simplePlaylistManagementWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
simplePlaylistMgmtWindow.reset(new SimplePlaylistManagementWindow( playlistWindow.reset(new PlaylistWindow(gLiveSupport,
gLiveSupport, bundle,
bundle, playlistButton,
simplePlaylistMgmtButton)); gladeDir));
} }
simplePlaylistMgmtWindow->showContents(); playlistWindow->showContents();
simplePlaylistMgmtWindow->present(); playlistWindow->show();
playlistWindow->getWindow()->present();
} }
@ -588,18 +456,13 @@ MasterPanelWindow :: updateSchedulerWindow(
throw () throw ()
{ {
if (!schedulerWindow.get()) { if (!schedulerWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("schedulerWindow");
try {
bundle = getBundle("schedulerWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
try { try {
schedulerWindow.reset(new SchedulerWindow(gLiveSupport, schedulerWindow.reset(new SchedulerWindow(gLiveSupport,
bundle, bundle,
schedulerButton)); schedulerButton,
gladeDir));
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return; return;
@ -617,7 +480,8 @@ MasterPanelWindow :: updateSchedulerWindow(
return; return;
} }
schedulerWindow->present(); schedulerWindow->show();
schedulerWindow->getWindow()->present();
} }
@ -628,20 +492,16 @@ void
MasterPanelWindow :: updateSearchWindow(void) throw () MasterPanelWindow :: updateSearchWindow(void) throw ()
{ {
if (!searchWindow.get()) { if (!searchWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("searchWindow");
try {
bundle = getBundle("searchWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
searchWindow.reset(new SearchWindow(gLiveSupport, searchWindow.reset(new SearchWindow(gLiveSupport,
bundle, bundle,
searchButton)); searchButton,
gladeDir));
} }
searchWindow->present(); searchWindow->show();
searchWindow->getWindow()->present();
} }
@ -652,24 +512,20 @@ void
MasterPanelWindow :: updateOptionsWindow(void) throw () MasterPanelWindow :: updateOptionsWindow(void) throw ()
{ {
if (!optionsWindow.get()) { if (!optionsWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("optionsWindow");
try {
bundle = getBundle("optionsWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
optionsWindow.reset(new OptionsWindow(gLiveSupport, optionsWindow.reset(new OptionsWindow(gLiveSupport,
bundle, bundle,
optionsButton)); optionsButton,
ContentsStorable * backupList = optionsWindow->getBackupList(); gladeDir));
Ptr<BackupList>::Ref backupList = optionsWindow->getBackupList();
if (backupList) { if (backupList) {
gLiveSupport->loadWindowContents(backupList); gLiveSupport->loadWindowContents(backupList.get());
} }
} }
optionsWindow->present(); optionsWindow->show();
optionsWindow->getWindow()->present();
} }
@ -679,59 +535,52 @@ MasterPanelWindow :: updateOptionsWindow(void) throw ()
void void
MasterPanelWindow :: showAnonymousUI(void) throw () MasterPanelWindow :: showAnonymousUI(void) throw ()
{ {
show_all(); mainButtonBox->hide();
liveModeButton->hide();
uploadFileButton->hide();
scratchpadButton->hide();
simplePlaylistMgmtButton->hide();
schedulerButton->hide();
searchButton->hide();
optionsButton->hide();
if (liveModeWindow.get()) { if (liveModeWindow.get()) {
gLiveSupport->storeWindowContents(liveModeWindow); gLiveSupport->storeWindowContents(liveModeWindow);
if (liveModeWindow->is_visible()) { if (liveModeWindow->getWindow()->is_visible()) {
liveModeWindow->hide(); liveModeWindow->hide();
} }
// the Live Mode window is not destroyed at logout, unlike the others // the Live Mode window is not destroyed at logout, unlike the others
} }
if (uploadFileWindow.get()) { if (uploadFileWindow.get()) {
if (uploadFileWindow->is_visible()) { if (uploadFileWindow->getWindow()->is_visible()) {
uploadFileWindow->hide(); uploadFileWindow->hide();
} }
uploadFileWindow.reset(); uploadFileWindow.reset();
} }
if (scratchpadWindow.get()) { if (scratchpadWindow.get()) {
gLiveSupport->storeWindowContents(scratchpadWindow); gLiveSupport->storeWindowContents(scratchpadWindow);
if (scratchpadWindow->is_visible()) { if (scratchpadWindow->getWindow()->is_visible()) {
scratchpadWindow->hide(); scratchpadWindow->hide();
} }
scratchpadWindow.reset(); scratchpadWindow.reset();
} }
if (simplePlaylistMgmtWindow.get()) { if (playlistWindow.get()) {
if (simplePlaylistMgmtWindow->is_visible()) { if (playlistWindow->getWindow()->is_visible()) {
simplePlaylistMgmtWindow->hide(); playlistWindow->hide();
} }
simplePlaylistMgmtWindow.reset(); playlistWindow.reset();
} }
if (schedulerWindow.get()) { if (schedulerWindow.get()) {
if (schedulerWindow->is_visible()) { if (schedulerWindow->getWindow()->is_visible()) {
schedulerWindow->hide(); schedulerWindow->hide();
} }
schedulerWindow.reset(); schedulerWindow.reset();
} }
if (searchWindow.get()) { if (searchWindow.get()) {
if (searchWindow->is_visible()) { if (searchWindow->getWindow()->is_visible()) {
searchWindow->hide(); searchWindow->hide();
} }
searchWindow.reset(); searchWindow.reset();
} }
if (optionsWindow.get()) { if (optionsWindow.get()) {
ContentsStorable * backupList = optionsWindow->getBackupList(); Ptr<BackupList>::Ref backupList = optionsWindow->getBackupList();
if (backupList) { if (backupList) {
gLiveSupport->storeWindowContents(backupList); gLiveSupport->storeWindowContents(backupList.get());
} }
if (optionsWindow->is_visible()) { if (optionsWindow->getWindow()->is_visible()) {
optionsWindow->hide(); optionsWindow->hide();
} }
optionsWindow.reset(); optionsWindow.reset();
@ -740,13 +589,13 @@ MasterPanelWindow :: showAnonymousUI(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Cancel the playlist edited in the SimplePlaylistMgmtWindow, if any. * Cancel the playlist edited in the PlaylistWindow, if any.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
bool bool
MasterPanelWindow :: cancelEditedPlaylist(void) throw () MasterPanelWindow :: cancelEditedPlaylist(void) throw ()
{ {
if (simplePlaylistMgmtWindow) { if (playlistWindow) {
return simplePlaylistMgmtWindow->cancelPlaylist(); return playlistWindow->cancelPlaylist();
} else { } else {
return true; return true;
} }
@ -759,14 +608,14 @@ MasterPanelWindow :: cancelEditedPlaylist(void) throw ()
void void
MasterPanelWindow :: showLoggedInUI(void) throw () MasterPanelWindow :: showLoggedInUI(void) throw ()
{ {
show_all(); mainButtonBox->show();
if (!gLiveSupport->isStorageAvailable()) { if (!gLiveSupport->isStorageAvailable()) {
liveModeButton->setDisabled(true); liveModeButton->set_sensitive(false);
uploadFileButton->setDisabled(true); uploadFileButton->set_sensitive(false);
scratchpadButton->setDisabled(true); scratchpadButton->set_sensitive(false);
simplePlaylistMgmtButton->setDisabled(true); playlistButton->set_sensitive(false);
searchButton->setDisabled(true); searchButton->set_sensitive(false);
} }
setSchedulerAvailable(gLiveSupport->isSchedulerAvailable()); setSchedulerAvailable(gLiveSupport->isSchedulerAvailable());
@ -774,7 +623,8 @@ MasterPanelWindow :: showLoggedInUI(void) throw ()
if (liveModeWindow) { if (liveModeWindow) {
liveModeWindow->updateStrings(); liveModeWindow->updateStrings();
if (liveModeWindow->isNotEmpty()) { if (liveModeWindow->isNotEmpty()) {
liveModeWindow->present(); liveModeWindow->show();
liveModeWindow->getWindow()->present();
} }
} }
} }
@ -830,16 +680,14 @@ MasterPanelWindow :: onKeyPressed(GdkEventKey * event) throw ()
{ {
if (event->type == GDK_KEY_PRESS) { if (event->type == GDK_KEY_PRESS) {
KeyboardShortcut::Action action = gLiveSupport->findAction( KeyboardShortcut::Action action = gLiveSupport->findAction(
windowName, "masterPanelWindow",
Gdk::ModifierType(event->state), Gdk::ModifierType(event->state),
event->keyval); event->keyval);
switch (action) { switch (action) {
case KeyboardShortcut::playAudio : case KeyboardShortcut::playAudio :
nowPlayingWidget->onPlayAudio();
return true;
case KeyboardShortcut::pauseAudio : case KeyboardShortcut::pauseAudio :
nowPlayingWidget->onPauseAudio(); nowPlayingWidget->onPlayAudio();
return true; return true;
case KeyboardShortcut::stopAudio : case KeyboardShortcut::stopAudio :
@ -867,22 +715,18 @@ MasterPanelWindow :: uploadToHub(Ptr<Playable>::Ref playable)
throw () throw ()
{ {
if (!searchWindow.get()) { if (!searchWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle = getBundle("searchWindow");
try {
bundle = getBundle("searchWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
searchWindow.reset(new SearchWindow(gLiveSupport, searchWindow.reset(new SearchWindow(gLiveSupport,
bundle, bundle,
searchButton)); searchButton,
gladeDir));
} }
searchWindow->uploadToHub(playable); searchWindow->uploadToHub(playable);
searchWindow->present(); searchWindow->show();
searchWindow->getWindow()->present();
} }
@ -893,13 +737,13 @@ void
MasterPanelWindow :: setSchedulerAvailable(bool status) throw () MasterPanelWindow :: setSchedulerAvailable(bool status) throw ()
{ {
if (status == false) { if (status == false) {
if (schedulerWindow && schedulerWindow->is_visible()) { if (schedulerWindow && schedulerWindow->getWindow()->is_visible()) {
schedulerWindow->hide(); schedulerWindow->hide();
} }
} }
if (schedulerButton) { if (schedulerButton) {
schedulerButton->setDisabled(!status); schedulerButton->set_sensitive(status);
} }
} }
@ -919,3 +763,112 @@ MasterPanelWindow :: showCuePlayerStopped(void) throw ()
} }
} }
/*------------------------------------------------------------------------------
* Handle the event of the Login/Logout button being clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: onLoginButtonClicked(void) throw ()
{
if (userIsLoggedIn) {
logout();
} else {
login();
}
}
/*------------------------------------------------------------------------------
* Let the user log in.
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: login(void) throw ()
{
Ptr<ResourceBundle>::Ref loginBundle = getBundle("loginWindow");
Ptr<LoginWindow>::Ref loginWindow(new LoginWindow(gLiveSupport,
loginBundle,
gladeDir));
userIsLoggedIn = loginWindow->run();
if (userIsLoggedIn) {
Ptr<const Glib::ustring>::Ref loginName = loginWindow->getLogin();
updateUserInfo(loginName);
showLoggedInUI();
} else {
// TODO: display an "incorrect login" dialog
}
}
/*------------------------------------------------------------------------------
* Let the user log out.
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: logout(void) throw ()
{
bool userCanceledTheLogout = !gLiveSupport->logout();
if (userCanceledTheLogout) {
return;
}
userIsLoggedIn = false;
updateUserInfo();
}
/*------------------------------------------------------------------------------
* Show the user info and the login button.
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: updateUserInfo(Ptr<const Glib::ustring>::Ref loginName)
throw ()
{
if (userIsLoggedIn) {
Ptr<Glib::ustring>::Ref logoutButtonLabel;
Ptr<Glib::ustring>::Ref loggedInMsg;
logoutButtonLabel = getResourceUstring("logoutButtonLabel");
loggedInMsg = formatMessage("loggedInMsg", *loginName);
loginButton->set_label(*logoutButtonLabel);
userInfoLabel->set_label(*loggedInMsg);
} else {
Ptr<Glib::ustring>::Ref loginButtonLabel;
Ptr<Glib::ustring>::Ref notLoggedInMsg;
loginButtonLabel = getResourceUstring("loginButtonLabel");
notLoggedInMsg = getResourceUstring("notLoggedInMsg");
loginButton->set_label(*loginButtonLabel);
userInfoLabel->set_label(*notLoggedInMsg);
}
}
/*------------------------------------------------------------------------------
* Event handler for when the user closes the master panel.
*----------------------------------------------------------------------------*/
bool
MasterPanelWindow :: onDeleteEvent(GdkEventAny * event) throw ()
{
Gtk::ResponseType response = gLiveSupport->runNoYesDialog(
*getResourceUstring("sureToExitMsg"));
if (response != Gtk::RESPONSE_YES) {
return true;
}
gLiveSupport->logout();
gLiveSupport->stopOutputAudio();
Ptr<OptionsContainer>::Ref optionsContainer
= gLiveSupport->getOptionsContainer();
if (optionsContainer && optionsContainer->isTouched()) {
optionsContainer->writeToFile();
}
return false;
}

View file

@ -40,31 +40,26 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/button.h> #include <gtkmm.h>
#include <gtkmm/table.h> #include <libglademm.h>
#include <gtkmm/image.h>
#include <gtkmm/window.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
#include "NowPlaying.h" #include "NowPlaying.h"
#include "MasterPanelUserInfoWidget.h"
#include "LiveModeWindow.h" #include "LiveModeWindow.h"
#include "UploadFileWindow.h" #include "UploadFileWindow.h"
#include "ScratchpadWindow.h" #include "ScratchpadWindow.h"
#include "SimplePlaylistManagementWindow.h" #include "PlaylistWindow.h"
#include "SchedulerWindow.h" #include "SchedulerWindow.h"
#include "SearchWindow.h" #include "SearchWindow.h"
#include "OptionsWindow.h" #include "OptionsWindow.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -92,172 +87,156 @@ using namespace LiveSupport::Widgets;
* +--------------------------------------------------+ * +--------------------------------------------------+
* </code></pre> * </code></pre>
* *
* The layout of the window is contained in the file
* "var/glade/MasterPanelWindow.glade".
*
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class MasterPanelWindow : public Gtk::Window, public LocalizedObject class MasterPanelWindow : public LocalizedObject
{ {
private:
/**
* The directory where the Glade files are.
*/
Glib::ustring gladeDir;
/**
* The Glade object, containing the visual design.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* The gLiveSupport object, handling the logic of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* Whether a user is currently logged in.
*/
bool userIsLoggedIn;
/**
* Log in.
*/
void
login(void) throw ();
/**
* Log out.
*/
void
logout(void) throw ();
protected: protected:
/**
* The layout used in the window.
*/
Gtk::Table * layout;
/** /**
* The background color. * The main window.
*/ */
Gdk::Color bgColor; Gtk::Window * masterPanelWindow;
/**
* The container for the time widget
*/
BlueBin * timeBin;
/** /**
* The time display * The time display
*/ */
Gtk::Label * timeWidget; Gtk::Label * timeLabel;
/** /**
* The signal connection, that is notified by the GTK timer each * The signal connection, that is notified by the GTK timer each
* second, and will update the time display on each wakeup. * second, and will update the time display on each wakeup.
*/ */
Ptr<sigc::connection>::Ref timer; Ptr<sigc::connection>::Ref timer;
/**
* The container for the now playing widget
*/
BlueBin * nowPlayingBin;
/** /**
* The 'now playing' display. * The 'now playing' display.
*/ */
NowPlaying * nowPlayingWidget; Ptr<NowPlaying>::Ref nowPlayingWidget;
/** /**
* The container for the VU meter widget * The button to invoke the Live Mode window.
*/ */
// BlueBin * vuMeterBin; Gtk::ToggleButton * liveModeButton;
/** /**
* The VU meter display. * The button to invoke the Upload File window.
*/ */
// Gtk::Widget * vuMeterWidget; Gtk::ToggleButton * uploadFileButton;
/**
* The container for the next playing widget.
*/
// BlueBin * nextPlayingBin;
/**
* The 'next playing' display.
*/
// Gtk::Widget * nextPlayingWidget;
/**
* The user info alignment helper.
*/
Gtk::Alignment * userInfoAlignment;
/**
* The user info widget.
*/
MasterPanelUserInfoWidget * userInfoWidget;
/**
* The radio logo.
*/
Gtk::Image * radioLogoWidget;
/**
* The bottom bar.
*/
Gtk::HBox * bottomBar;
/**
* The button bar alignment helper
*/
Gtk::Alignment * buttonBarAlignment;
/**
* The button bar.
*/
Gtk::Table * buttonBar;
/**
* The button to invoke the live mode window.
*/
Button * liveModeButton;
/**
* The button to invoke the upload file window.
*/
Button * uploadFileButton;
/** /**
* The button to invoke the Scratchpad window. * The button to invoke the Scratchpad window.
*/ */
Button * scratchpadButton; Gtk::ToggleButton * scratchpadButton;
/** /**
* The button to invoke the Simple Playlist Management Window. * The button to invoke the Playlist Window.
*/ */
Button * simplePlaylistMgmtButton; Gtk::ToggleButton * playlistButton;
/** /**
* The button to invoke the Scheduler Window. * The button to invoke the Scheduler Window.
*/ */
Button * schedulerButton; Gtk::ToggleButton * schedulerButton;
/** /**
* The button to invoke the Search Window. * The button to invoke the Search Window.
*/ */
Button * searchButton; Gtk::ToggleButton * searchButton;
/** /**
* The button to invoke the Options Window. * The button to invoke the Options window.
*/ */
Button * optionsButton; Gtk::ToggleButton * optionsButton;
/** /**
* The gLiveSupport object, handling the logic of the application. * The box containing the window opener buttons.
*/ */
Ptr<GLiveSupport>::Ref gLiveSupport; Gtk::ButtonBox * mainButtonBox;
/**
* The label for the "logged in as" info.
*/
Gtk::Label * userInfoLabel;
/**
* The button to log in or log out.
*/
Gtk::Button * loginButton;
/** /**
* The one and only Live Mode window. * The one and only Live Mode window.
*/ */
Ptr<LiveModeWindow>::Ref liveModeWindow; Ptr<LiveModeWindow>::Ref liveModeWindow;
/** /**
* The one and only Upload File window. * The one and only Upload File window.
*/ */
Ptr<UploadFileWindow>::Ref uploadFileWindow; Ptr<UploadFileWindow>::Ref uploadFileWindow;
/** /**
* The one and only Scratchpad window. * The one and only Scratchpad window.
*/ */
Ptr<ScratchpadWindow>::Ref scratchpadWindow; Ptr<ScratchpadWindow>::Ref scratchpadWindow;
/** /**
* The one and only simple playlist management window. * The one and only simple playlist management window.
*/ */
Ptr<SimplePlaylistManagementWindow>::Ref simplePlaylistMgmtWindow; Ptr<PlaylistWindow>::Ref playlistWindow;
/** /**
* The one and only scheduler window. * The one and only scheduler window.
*/ */
Ptr<SchedulerWindow>::Ref schedulerWindow; Ptr<SchedulerWindow>::Ref schedulerWindow;
/** /**
* The one and only search window. * The one and only search window.
*/ */
Ptr<SearchWindow>::Ref searchWindow; Ptr<SearchWindow>::Ref searchWindow;
/** /**
* The one and only options window. * The one and only options window.
*/ */
Ptr<OptionsWindow>::Ref optionsWindow; Ptr<OptionsWindow>::Ref optionsWindow;
/** /**
* Function that updates timeLabel with the current time. * Function that updates timeLabel with the current time.
@ -294,7 +273,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
onUploadFileButtonClicked(void) throw () onUploadFileButtonClicked(void) throw ()
{ {
if (!uploadFileWindow || if (!uploadFileWindow ||
uploadFileWindow && !uploadFileWindow->is_visible()) { uploadFileWindow && !uploadFileWindow->getWindow()
->is_visible()) {
updateUploadFileWindow(); updateUploadFileWindow();
} else { } else {
uploadFileWindow->hide(); uploadFileWindow->hide();
@ -309,7 +289,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
onLiveModeButtonClicked(void) throw () onLiveModeButtonClicked(void) throw ()
{ {
if (!liveModeWindow || if (!liveModeWindow ||
liveModeWindow && !liveModeWindow->is_visible()) { liveModeWindow && !liveModeWindow->getWindow()
->is_visible()) {
updateLiveModeWindow(); updateLiveModeWindow();
} else { } else {
liveModeWindow->hide(); liveModeWindow->hide();
@ -324,7 +305,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
onScratchpadButtonClicked(void) throw () onScratchpadButtonClicked(void) throw ()
{ {
if (!scratchpadWindow || if (!scratchpadWindow ||
scratchpadWindow && !scratchpadWindow->is_visible()) { scratchpadWindow && !scratchpadWindow->getWindow()
->is_visible()) {
updateScratchpadWindow(); updateScratchpadWindow();
} else { } else {
scratchpadWindow->hide(); scratchpadWindow->hide();
@ -336,14 +318,14 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
* Management button being pressed. * Management button being pressed.
*/ */
virtual void virtual void
onSimplePlaylistMgmtButtonClicked(void) throw () onPlaylistButtonClicked(void) throw ()
{ {
if (!simplePlaylistMgmtWindow || if (!playlistWindow ||
simplePlaylistMgmtWindow && playlistWindow && !playlistWindow->getWindow()
!simplePlaylistMgmtWindow->is_visible()) { ->is_visible()) {
updateSimplePlaylistMgmtWindow(); updatePlaylistWindow();
} else { } else {
simplePlaylistMgmtWindow->hide(); playlistWindow->hide();
} }
} }
@ -352,10 +334,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
* button being pressed. * button being pressed.
*/ */
virtual void virtual void
onSchedulerButtonClicked(void) throw () onSchedulerButtonClicked(void) throw ()
{ {
if (!schedulerWindow || if (!schedulerWindow ||
schedulerWindow && !schedulerWindow->is_visible()) { schedulerWindow && !schedulerWindow->getWindow()
->is_visible()) {
updateSchedulerWindow(); updateSchedulerWindow();
} else { } else {
schedulerWindow->hide(); schedulerWindow->hide();
@ -370,7 +353,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
onSearchButtonClicked(void) throw () onSearchButtonClicked(void) throw ()
{ {
if (!searchWindow || if (!searchWindow ||
searchWindow && !searchWindow->is_visible()) { searchWindow && !searchWindow->getWindow()
->is_visible()) {
updateSearchWindow(); updateSearchWindow();
} else { } else {
searchWindow->hide(); searchWindow->hide();
@ -385,13 +369,21 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
onOptionsButtonClicked(void) throw () onOptionsButtonClicked(void) throw ()
{ {
if (!optionsWindow || if (!optionsWindow ||
optionsWindow && !optionsWindow->is_visible()) { optionsWindow && !optionsWindow->getWindow()
->is_visible()) {
updateOptionsWindow(); updateOptionsWindow();
} else { } else {
optionsWindow->hide(); optionsWindow->hide();
} }
} }
/**
* Function to catch the event of the Login/Logout button
* button being pressed.
*/
virtual void
onLoginButtonClicked(void) throw ();
/** /**
* Signal handler for a key pressed at one of the entries. * Signal handler for a key pressed at one of the entries.
* The keys can be customized by the keyboardShortcutContainer * The keys can be customized by the keyboardShortcutContainer
@ -406,31 +398,55 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
bool bool
onKeyPressed(GdkEventKey * event) throw (); onKeyPressed(GdkEventKey * event) throw ();
/**
* Event handler for when the user closes the master panel.
* It pops up a confirmation dialog.
*
* @param event attributes for the event (?)
* @return true if handled the event, false to continue deleting
*/
bool
onDeleteEvent(GdkEventAny * event) throw ();
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param gLiveSupport the gLiveSupport object, handling the * @param gLiveSupport the gLiveSupport object, handling the
* logic of the application * logic of the application.
* @param bundle the resource bundle holding localized resources * @param bundle the resource bundle holding localized resources.
* @param gladeDir the directory where the Glade files are.
*/ */
MasterPanelWindow(Ptr<GLiveSupport>::Ref gLiveSupport, MasterPanelWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
const Glib::ustring & gladeDir)
throw (); throw ();
/** /**
* Virtual destructor. * Virtual destructor.
*/ */
virtual virtual
~MasterPanelWindow(void) throw (); ~MasterPanelWindow(void) throw ();
/**
* Give access to the Gtk::Window of the window.
* The caller does not get ownership of the widget, and he
* should not / does not need to dispose of it.
*/
Gtk::Window *
getWindow(void) throw ()
{
return masterPanelWindow;
}
/** /**
* Change the user interface language of the application * Change the user interface language of the application
* by providing a new resource bundle. * by providing a new resource bundle.
* This call assumes that only the MasterPanel is visilbe, * This call assumes that only the MasterPanelWindow is visible,
* and will only change the language of the currently open * and will only change the language of the currently open
* MasterPanel. No other open windows will be affected by * MasterPanelWindow. No other open windows will be affected by
* this call, but subsequently opened windows are. * this call, but subsequently opened windows are.
* *
* @param bundle the new resource bundle. * @param bundle the new resource bundle.
@ -445,11 +461,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
showAnonymousUI(void) throw (); showAnonymousUI(void) throw ();
/** /**
* Cancel the playlist edited in the SimplePlaylistMgmtWindow. * Cancel the playlist edited in the PlaylistWindow.
* *
* @return true if the canceling worked (or if there was nothing * @return true if the canceling worked (or if there was nothing
* to cancel); false if the user canceled the canceling * to cancel); false if the user canceled the canceling
* @see SimplePlaylistManagementWindow::cancelPlaylist() * @see PlaylistWindow::cancelPlaylist()
*/ */
bool bool
cancelEditedPlaylist(void) throw (); cancelEditedPlaylist(void) throw ();
@ -513,7 +529,7 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
* Update the Simple Playlist Management Window * Update the Simple Playlist Management Window
*/ */
void void
updateSimplePlaylistMgmtWindow(void) throw (); updatePlaylistWindow(void) throw ();
/** /**
* Update the Scheduler Window, optionally to display a new time. * Update the Scheduler Window, optionally to display a new time.
@ -537,6 +553,16 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
void void
updateOptionsWindow(void) throw (); updateOptionsWindow(void) throw ();
/**
* Update the User info.
*
* @param loginName the login name (only when userIsLoggedIn).
*/
void
updateUserInfo(Ptr<const Glib::ustring>::Ref loginName
= Ptr<const Glib::ustring>::Ref())
throw ();
/** /**
* Get the next item from the top of the Live Mode window. * Get the next item from the top of the Live Mode window.
* The item is removed from the Live Mode window. * The item is removed from the Live Mode window.
@ -556,6 +582,7 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
setNowPlaying(Ptr<Playable>::Ref playable) throw () setNowPlaying(Ptr<Playable>::Ref playable) throw ()
{ {
nowPlayingWidget->setPlayable(playable); nowPlayingWidget->setPlayable(playable);
gLiveSupport->updateRds();
} }
/** /**

View file

@ -36,14 +36,11 @@
#include <iostream> #include <iostream>
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Colors.h"
#include "NowPlaying.h" #include "NowPlaying.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -58,6 +55,16 @@ namespace {
*/ */
const int blinkingConstant = 5; const int blinkingConstant = 5;
/**
* The string which identifies the Play stock image.
*/
const Glib::ustring playStockImageName = "gtk-media-play";
/**
* The string which identifies the Pause stock image.
*/
const Glib::ustring pauseStockImageName = "gtk-media-pause";
} }
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -68,106 +75,39 @@ const int blinkingConstant = 5;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
NowPlaying :: NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport, NowPlaying :: NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: LocalizedObject(bundle), : LocalizedObject(bundle),
glade(glade),
gLiveSupport(gLiveSupport) gLiveSupport(gLiveSupport)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); glade->get_widget("playButton1", playButton);
glade->get_widget("stopButton1", stopButton);
playButton = Gtk::manage(wf->createButton(
WidgetConstants::masterPlayButton ));
pauseButton = Gtk::manage(wf->createButton(
WidgetConstants::masterPauseButton ));
stopButton = Gtk::manage(wf->createButton(
WidgetConstants::masterStopButton ));
playButton->signal_clicked().connect(sigc::mem_fun(*this, playButton->signal_clicked().connect(sigc::mem_fun(*this,
&NowPlaying::onPlayButtonClicked )); &NowPlaying::onPlayButtonClicked ));
pauseButton->signal_clicked().connect(sigc::mem_fun(*this,
&NowPlaying::onPauseButtonClicked ));
stopButton->signal_clicked().connect(sigc::mem_fun(*this, stopButton->signal_clicked().connect(sigc::mem_fun(*this,
&NowPlaying::onStopButtonClicked )); &NowPlaying::onStopButtonClicked ));
isActive = false; isActive = false;
isPaused = false; isPaused = false;
titleLabel = createFormattedLabel(14); glade->get_widget("titleLabel1", titleLabel);
titleLabel->set_ellipsize(Pango::ELLIPSIZE_END); glade->get_widget("creatorLabel1", creatorLabel);
glade->get_widget("elapsedTimeLabel1", elapsedTimeLabel);
creatorLabel = createFormattedLabel(8); glade->get_widget("remainsTimeBox1", remainsTimeBox);
creatorLabel->set_ellipsize(Pango::ELLIPSIZE_END); glade->get_widget("remainsTimeLabel1", remainsTimeLabel);
glade->get_widget("playlistLabel1", playlistLabel);
playlistLabel = createFormattedLabel(8);
playlistLabel->set_ellipsize(Pango::ELLIPSIZE_END);
Gtk::Label * elapsedLabel = createFormattedLabel(7);
Gtk::Label * remainsLabel = createFormattedLabel(7);
elapsedTime = createFormattedLabel(16);
remainsTime = createFormattedLabel(16);
Gtk::HBox * elapsedTimeHBox = Gtk::manage(new Gtk::HBox);
Gtk::VBox * elapsedTimeVBox = Gtk::manage(new Gtk::VBox);
elapsedTimeHBox->pack_start(*elapsedTime, Gtk::PACK_SHRINK, 5);
elapsedTimeVBox->pack_start(*elapsedTimeHBox, Gtk::PACK_SHRINK, 2);
remainsTimeBox = Gtk::manage(new Gtk::EventBox);
Gtk::HBox * remainsTimeHBox = Gtk::manage(new Gtk::HBox);
Gtk::VBox * remainsTimeVBox = Gtk::manage(new Gtk::VBox);
remainsTimeHBox->pack_start(*remainsTime, Gtk::PACK_SHRINK, 5);
remainsTimeVBox->pack_start(*remainsTimeHBox, Gtk::PACK_SHRINK, 2);
remainsTimeBox->add(*remainsTimeVBox);
resetRemainsTimeState();
try { glade->get_widget("elapsedTimeText1", elapsedTimeText);
elapsedLabel->set_text(*getResourceUstring("elapsedTimeLabel")); glade->get_widget("remainsTimeText1", remainsTimeText);
remainsLabel->set_text(*getResourceUstring("remainingTimeLabel")); elapsedTimeText->set_text(*getResourceUstring("elapsedTimeLabel"));
} catch (std::invalid_argument &e) { remainsTimeText->set_text(*getResourceUstring("remainingTimeLabel"));
std::cerr << e.what() << std::endl;
std::exit(1);
}
Gtk::Box * titleBox = Gtk::manage(new Gtk::HBox); Ptr<Playable>::Ref nullPointer;
titleBox->pack_start(*titleLabel, Gtk::PACK_EXPAND_WIDGET, 5); setPlayable(nullPointer);
Gtk::Box * creatorBox = Gtk::manage(new Gtk::HBox);
creatorBox->pack_start(*creatorLabel, Gtk::PACK_EXPAND_WIDGET, 5);
Gtk::Box * extraSpace = Gtk::manage(new Gtk::HBox);
Gtk::Box * playlistBox = Gtk::manage(new Gtk::HBox);
playlistBox->pack_start(*playlistLabel, Gtk::PACK_EXPAND_WIDGET, 5);
Gtk::Box * elapsedTextBox = Gtk::manage(new Gtk::HBox);
elapsedTextBox->pack_start(*elapsedLabel, Gtk::PACK_EXPAND_WIDGET, 5);
elapsedTextBox->set_size_request(150); // set a fixed width
Gtk::Box * elapsedBox = Gtk::manage(new Gtk::VBox);
elapsedBox->pack_start(*elapsedTextBox, Gtk::PACK_SHRINK, 0);
elapsedBox->pack_start(*elapsedTimeVBox, Gtk::PACK_SHRINK, 0);
Gtk::Box * remainsTextBox = Gtk::manage(new Gtk::HBox);
remainsTextBox->pack_start(*remainsLabel, Gtk::PACK_EXPAND_WIDGET, 5);
Gtk::Box * remainsBox = Gtk::manage(new Gtk::VBox);
remainsBox->pack_start(*remainsTextBox, Gtk::PACK_SHRINK, 0);
remainsBox->pack_start(*remainsTimeBox, Gtk::PACK_SHRINK, 0);
Gtk::Box * timeBox = Gtk::manage(new Gtk::HBox);
timeBox->pack_start(*elapsedBox, Gtk::PACK_SHRINK, 0);
timeBox->pack_start(*remainsBox, Gtk::PACK_SHRINK, 0);
Gtk::Box * textBox = Gtk::manage(new Gtk::VBox);
textBox->pack_start(*titleBox, Gtk::PACK_SHRINK, 0);
textBox->pack_start(*creatorBox, Gtk::PACK_SHRINK, 0);
textBox->pack_start(*extraSpace, Gtk::PACK_SHRINK, 2);
textBox->pack_start(*timeBox, Gtk::PACK_SHRINK, 0);
textBox->pack_start(*playlistBox, Gtk::PACK_SHRINK, 0);
pack_end(*textBox, Gtk::PACK_EXPAND_WIDGET, 0);
pack_end(*stopButton, Gtk::PACK_SHRINK, 0);
pack_end(*playButton, Gtk::PACK_SHRINK, 2);
} }
@ -177,12 +117,16 @@ NowPlaying :: NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
void void
NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw () NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
{ {
playableMutex.lock();
// BEGIN synchronized block
if (playable) { if (playable) {
if (!isActive || isPaused) { if (!isActive || isPaused) {
remove(*playButton); playButton->set_label(pauseStockImageName);
pack_end(*pauseButton, Gtk::PACK_SHRINK, 2);
pauseButton->show();
} }
playButton->set_sensitive(true);
stopButton->set_sensitive(true);
this->playable = playable; this->playable = playable;
isActive = true; isActive = true;
isPaused = false; isPaused = false;
@ -191,22 +135,24 @@ NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
} else { } else {
if (isActive && !isPaused) { if (isActive && !isPaused) {
remove(*pauseButton); playButton->set_label(playStockImageName);
pack_end(*playButton, Gtk::PACK_SHRINK, 2);
playButton->show();
isActive = false; isActive = false;
} }
playButton->set_sensitive(false);
stopButton->set_sensitive(false);
titleLabel->set_text(""); titleLabel->set_text("");
creatorLabel->set_text(""); creatorLabel->set_text("");
elapsedTime->set_text(""); elapsedTimeLabel->set_text("");
remainsTime->set_text(""); remainsTimeLabel->set_text("");
playlistLabel->set_text(""); playlistLabel->set_text("");
resetRemainsTimeState(); resetRemainsTimeState();
this->playable.reset(); this->playable.reset();
this->currentInnerPlayable.reset(); this->currentInnerPlayable.reset();
} }
gLiveSupport->updateRds(); // END synchronized block
playableMutex.unlock();
} }
@ -216,32 +162,16 @@ NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
void void
NowPlaying :: onPlayButtonClicked(void) throw () NowPlaying :: onPlayButtonClicked(void) throw ()
{ {
if (isActive && isPaused) { if (isActive) {
gLiveSupport->pauseOutputAudio(); // i.e., restart if (isPaused) {
gLiveSupport->pauseOutputAudio(); // i.e., restart
remove(*playButton); playButton->set_label(pauseStockImageName);
pack_end(*pauseButton, Gtk::PACK_SHRINK, 2); isPaused = false;
pauseButton->show(); } else {
gLiveSupport->pauseOutputAudio();
isPaused = false; playButton->set_label(playStockImageName);
} isPaused = true;
} }
/*------------------------------------------------------------------------------
* Event handler for the Pause button being clicked.
*----------------------------------------------------------------------------*/
void
NowPlaying :: onPauseButtonClicked(void) throw ()
{
if (isActive && !isPaused) {
gLiveSupport->pauseOutputAudio();
remove(*pauseButton);
pack_end(*playButton, Gtk::PACK_SHRINK, 2);
playButton->show();
isPaused = true;
} }
} }
@ -258,34 +188,6 @@ NowPlaying :: onStopButtonClicked(void) throw ()
} // setPlayable() with a 0 argument } // setPlayable() with a 0 argument
/*------------------------------------------------------------------------------
* Construct a label with the font attribute already set.
*----------------------------------------------------------------------------*/
Gtk::Label *
NowPlaying :: createFormattedLabel(int fontSize) throw ()
{
Gtk::Label * label = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER));
Pango::FontDescription fontDescription;
fontDescription.set_family("Bitstream Vera Sans");
fontDescription.set_weight(Pango::WEIGHT_BOLD);
fontDescription.set_size(fontSize * Pango::SCALE);
Pango::Attribute fontDescriptionAttribute =
Pango::Attribute::create_attr_font_desc(
fontDescription);
fontDescriptionAttribute.set_start_index(0);
fontDescriptionAttribute.set_end_index(255);
Pango::AttrList attributeList;
attributeList.insert(fontDescriptionAttribute);
label->set_attributes(attributeList);
return label;
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Update the timer displays. This is called every second by the master panel. * Update the timer displays. This is called every second by the master panel.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -333,6 +235,15 @@ NowPlaying :: onUpdateTime(void) throw ()
} }
setRemainsTimeColor(remainsTimeState); setRemainsTimeColor(remainsTimeState);
if (!playableMutex.tryLock()) { // if the 'playable' variable is being
return; // written to, then just give up for now
}
// BEGIN synchronized block
if (!playable) {
playableMutex.unlock();
return;
}
Ptr<Playable>::Ref innerPlayable = playable; Ptr<Playable>::Ref innerPlayable = playable;
Ptr<time_duration>::Ref innerElapsed = elapsed; Ptr<time_duration>::Ref innerElapsed = elapsed;
Ptr<time_duration>::Ref innerRemains = remains; Ptr<time_duration>::Ref innerRemains = remains;
@ -379,12 +290,15 @@ NowPlaying :: onUpdateTime(void) throw ()
creatorLabel->set_text(""); creatorLabel->set_text("");
} }
elapsedTime->set_text(*TimeConversion::timeDurationToHhMmSsString( elapsedTimeLabel->set_text(*TimeConversion::timeDurationToHhMmSsString(
innerElapsed )); innerElapsed ));
remainsTime->set_text(*TimeConversion::timeDurationToHhMmSsString( remainsTimeLabel->set_text(*TimeConversion::timeDurationToHhMmSsString(
innerRemains )); innerRemains ));
currentInnerPlayable = innerPlayable; currentInnerPlayable = innerPlayable;
// END synchronized block
playableMutex.unlock();
} }
@ -396,28 +310,28 @@ NowPlaying :: setRemainsTimeColor(RemainsTimeStateType state) throw ()
{ {
bool isBlinkOn = (remainsTimeCounter < blinkingConstant); bool isBlinkOn = (remainsTimeCounter < blinkingConstant);
Gdk::Color color;
if (isBlinkOn) { if (isBlinkOn) {
switch (state) { switch (state) {
case TIME_GREEN: case TIME_GREEN:
color = Colors::getColor(Colors::MasterPanelCenterBlue); remainsTimeBox->unset_bg(Gtk::STATE_NORMAL);
break; break;
case TIME_YELLOW: case TIME_YELLOW:
color = Colors::getColor(Colors::Yellow); remainsTimeBox->modify_bg(Gtk::STATE_NORMAL,
Colors::getColor(Colors::Yellow));
break; break;
case TIME_RED: case TIME_RED:
color = Colors::getColor(Colors::Red); remainsTimeBox->modify_bg(Gtk::STATE_NORMAL,
Colors::getColor(Colors::Red));
break; break;
} }
} else { } else {
color = Colors::getColor(Colors::MasterPanelCenterBlue); remainsTimeBox->unset_bg(Gtk::STATE_NORMAL);
} }
remainsTimeBox->modify_bg(Gtk::STATE_NORMAL, color); gLiveSupport->runMainLoop();
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
@ -431,3 +345,18 @@ NowPlaying :: resetRemainsTimeState(void) throw ()
setRemainsTimeColor(TIME_GREEN); setRemainsTimeColor(TIME_GREEN);
} }
/*------------------------------------------------------------------------------
* Change the language of the widget.
*----------------------------------------------------------------------------*/
void
NowPlaying :: changeLanguage(Ptr<ResourceBundle>::Ref bundle)
throw ()
{
setBundle(bundle);
elapsedTimeText->set_text(*getResourceUstring("elapsedTimeLabel"));
remainsTimeText->set_text(*getResourceUstring("remainingTimeLabel"));
}

View file

@ -41,9 +41,11 @@
#endif #endif
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/Mutex.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -52,7 +54,6 @@ namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -68,11 +69,15 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class NowPlaying : public Gtk::HBox, class NowPlaying : public LocalizedObject
public LocalizedObject
{ {
private: private:
/**
* The Glade object, containing the visual design.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/** /**
* Whether anything is shown in the widget. * Whether anything is shown in the widget.
*/ */
@ -110,15 +115,25 @@ class NowPlaying : public Gtk::HBox,
*/ */
Gtk::Label * playlistLabel; Gtk::Label * playlistLabel;
/**
* The label which says "elapsed time".
*/
Gtk::Label * elapsedTimeText;
/** /**
* The label holding the elapsed time. * The label holding the elapsed time.
*/ */
Gtk::Label * elapsedTime; Gtk::Label * elapsedTimeLabel;
/**
* The label which says "remaining time".
*/
Gtk::Label * remainsTimeText;
/** /**
* The label holding the remaining time. * The label holding the remaining time.
*/ */
Gtk::Label * remainsTime; Gtk::Label * remainsTimeLabel;
/** /**
* A box around the remaining time label, so we can modify its color. * A box around the remaining time label, so we can modify its color.
@ -128,17 +143,12 @@ class NowPlaying : public Gtk::HBox,
/** /**
* The play button. * The play button.
*/ */
ImageButton * playButton; Gtk::Button * playButton;
/**
* The pause button.
*/
ImageButton * pauseButton;
/** /**
* The stop button. * The stop button.
*/ */
ImageButton * stopButton; Gtk::Button * stopButton;
/** /**
* The possible states of the 'time remains' label. * The possible states of the 'time remains' label.
@ -160,7 +170,13 @@ class NowPlaying : public Gtk::HBox,
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
*/ */
Ptr<GLiveSupport>::Ref gLiveSupport; Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* A mutex to make the writing, and some reading, of the
* 'playable' variable atomic.
*/
Mutex playableMutex;
/** /**
* Default constructor. * Default constructor.
*/ */
@ -172,28 +188,12 @@ class NowPlaying : public Gtk::HBox,
void void
onPlayButtonClicked(void) throw (); onPlayButtonClicked(void) throw ();
/**
* Event handler for the Pause button being clicked.
*/
void
onPauseButtonClicked(void) throw ();
/** /**
* Event handler for the Stop button being clicked. * Event handler for the Stop button being clicked.
*/ */
void void
onStopButtonClicked(void) throw (); onStopButtonClicked(void) throw ();
/**
* Return a Gtk::manage'd Gtk::Label*, with the Bitstream Vera
* font attributes set.
*
* @param fontSize the size of the text in the label, in points
* @return the new label
*/
Gtk::Label *
createFormattedLabel(int fontSize) throw ();
/** /**
* Set the color of the 'remains time' label. * Set the color of the 'remains time' label.
* *
@ -225,9 +225,12 @@ class NowPlaying : public Gtk::HBox,
* @param gLiveSupport the GLiveSupport, application object. * @param gLiveSupport the GLiveSupport, application object.
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this widget * resources for this widget
* @param glade the Glade file which specifies the visual
* components for this class.
*/ */
NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport, NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**
@ -264,17 +267,6 @@ class NowPlaying : public Gtk::HBox,
onPlayButtonClicked(); onPlayButtonClicked();
} }
/**
* Public interface for pausing the audio.
*
* This is used by MasterPanelWindow::onKeyPressed().
*/
void
onPauseAudio(void) throw ()
{
onPauseButtonClicked();
}
/** /**
* Public interface for stopping the audio. * Public interface for stopping the audio.
* *
@ -300,6 +292,14 @@ class NowPlaying : public Gtk::HBox,
{ {
return currentInnerPlayable; return currentInnerPlayable;
} }
/**
* Change the user interface language of the widget.
*
* @param bundle the new resource bundle.
*/
void
changeLanguage(Ptr<ResourceBundle>::Ref bundle) throw ();
}; };

View file

@ -33,18 +33,10 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm.h>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ScrolledNotebook.h"
#include "LiveSupport/Widgets/EntryBin.h"
#include "OptionsWindow.h" #include "OptionsWindow.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -54,10 +46,10 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/** /*------------------------------------------------------------------------------
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc). * The name of the glade file.
*/ *----------------------------------------------------------------------------*/
const Glib::ustring windowName = "optionsWindow"; const Glib::ustring gladeFileName = "OptionsWindow.glade";
} }
@ -71,107 +63,61 @@ const Glib::ustring windowName = "optionsWindow";
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
OptionsWindow :: OptionsWindow (Ptr<GLiveSupport>::Ref gLiveSupport, OptionsWindow :: OptionsWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw () throw ()
: GuiWindow(gLiveSupport, : BasicWindow(gLiveSupport,
bundle, bundle,
windowOpenerButton), windowOpenerButton,
backupView(0) gladeDir + gladeFileName)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
try {
set_title(*getResourceUstring("windowTitle"));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
bool canBackup = (gLiveSupport->getSessionId() bool canBackup = (gLiveSupport->getSessionId()
&& gLiveSupport->isStorageAvailable()); && gLiveSupport->isStorageAvailable());
// build up the notepad for the various sections // build up the notepad for the various sections
mainNotebook = Gtk::manage(new ScrolledNotebook); glade->get_widget("mainNotebook1", mainNotebook);
Gtk::Box * soundSectionBox = constructSoundSection(); constructSoundSection();
Gtk::Box * keyBindingsSectionBox = constructKeyBindingsSection(); constructKeyBindingsSection();
Gtk::Box * serversSectionBox = constructServersSection(); constructServersSection();
Gtk::Box * schedulerSectionBox = constructSchedulerSection(); constructSchedulerSection();
Gtk::Box * backupSectionBox = 0;
if (canBackup) { if (canBackup) {
backupSectionBox = constructBackupSection(); constructBackupSection();
} }
Gtk::Box * rdsSectionBox = constructRdsSection(); constructRdsSection();
Gtk::Box * aboutSectionBox = constructAboutSection(); constructAboutSection();
try { Gtk::Label * soundTabLabel;
mainNotebook->appendPage(*soundSectionBox, Gtk::Label * keyBindingsTabLabel;
*getResourceUstring("soundSectionLabel")); Gtk::Label * serversTabLabel;
mainNotebook->appendPage(*keyBindingsSectionBox, Gtk::Label * schedulerTabLabel;
*getResourceUstring("keyBindingsSectionLabel")); Gtk::Label * backupTabLabel;
mainNotebook->appendPage(*serversSectionBox, Gtk::Label * rdsTabLabel;
*getResourceUstring("serversSectionLabel")); Gtk::Label * aboutTabLabel;
mainNotebook->appendPage(*schedulerSectionBox, glade->get_widget("soundTabLabel1", soundTabLabel);
*getResourceUstring("schedulerSectionLabel")); glade->get_widget("keyBindingsTabLabel1", keyBindingsTabLabel);
if (canBackup) { glade->get_widget("serversTabLabel1", serversTabLabel);
mainNotebook->appendPage(*backupSectionBox, glade->get_widget("schedulerTabLabel1", schedulerTabLabel);
*getResourceUstring("backupSectionLabel")); glade->get_widget("backupTabLabel1", backupTabLabel);
} glade->get_widget("rdsTabLabel1", rdsTabLabel);
mainNotebook->appendPage(*rdsSectionBox, glade->get_widget("aboutTabLabel1", aboutTabLabel);
*getResourceUstring("rdsSectionLabel")); soundTabLabel->set_label(*getResourceUstring("soundSectionLabel"));
mainNotebook->appendPage(*aboutSectionBox, keyBindingsTabLabel->set_label(*getResourceUstring(
*getResourceUstring("aboutSectionLabel")); "keyBindingsSectionLabel"));
serversTabLabel->set_label(*getResourceUstring("serversSectionLabel"));
} catch (std::invalid_argument &e) { schedulerTabLabel->set_label(*getResourceUstring("schedulerSectionLabel"));
// TODO: signal error if (canBackup) {
std::cerr << e.what() << std::endl; backupTabLabel->set_label(*getResourceUstring("backupSectionLabel"));
std::exit(1);
} }
rdsTabLabel->set_label(*getResourceUstring("rdsSectionLabel"));
// build up the button box aboutTabLabel->set_label(*getResourceUstring("aboutSectionLabel"));
buttonBox = Gtk::manage(new Gtk::HButtonBox);
buttonBox->set_layout(Gtk::BUTTONBOX_END);
buttonBox->set_spacing(5);
try {
cancelButton = Gtk::manage(wf->createButton(
*getResourceUstring("cancelButtonLabel") ));
applyButton = Gtk::manage(wf->createButton(
*getResourceUstring("applyButtonLabel") ));
okButton = Gtk::manage(wf->createButton(
*getResourceUstring("okButtonLabel") ));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
buttonBox->pack_start(*cancelButton);
buttonBox->pack_start(*applyButton);
buttonBox->pack_start(*okButton);
// set up the main window
Gtk::Box * layout = Gtk::manage(new Gtk::VBox);
layout->pack_start(*mainNotebook, Gtk::PACK_EXPAND_WIDGET, 5);
layout->pack_start(*buttonBox, Gtk::PACK_SHRINK, 5);
add(*layout);
// bind events // bind events
cancelButton->signal_clicked().connect(sigc::mem_fun(*this, glade->connect_clicked("applyButton1", sigc::mem_fun(*this,
&OptionsWindow::onCancelButtonClicked));
applyButton->signal_clicked().connect(sigc::mem_fun(*this,
&OptionsWindow::onApplyButtonClicked)); &OptionsWindow::onApplyButtonClicked));
okButton->signal_clicked().connect(sigc::mem_fun(*this, glade->connect_clicked("cancelButton1", sigc::mem_fun(*this,
&OptionsWindow::onCancelButtonClicked));
glade->connect_clicked("okButton1", sigc::mem_fun(*this,
&OptionsWindow::onOkButtonClicked)); &OptionsWindow::onOkButtonClicked));
// show everything
set_name(windowName);
set_default_size(700, 500);
set_modal(false);
show_all_children();
} }
@ -199,16 +145,8 @@ OptionsWindow :: onApplyButtonClicked(void) throw ()
saveChangesInRds(); // no need to restart saveChangesInRds(); // no need to restart
if (changed) { if (changed) {
try { gLiveSupport->displayMessageWindow(*getResourceUstring(
Ptr<Glib::ustring>::Ref "needToRestartMsg"));
restartMessage(new Glib::ustring(
*getResourceUstring("needToRestartMsg") ));
gLiveSupport->displayMessageWindow(restartMessage);
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
} }
} }
@ -227,7 +165,7 @@ OptionsWindow :: saveChangesInStringEntryFields(void) throw ()
for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) { for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) {
OptionsContainer::OptionItemString optionItem = it->first; OptionsContainer::OptionItemString optionItem = it->first;
EntryBin * entry = it->second; Gtk::Entry * entry = it->second;
Ptr<const Glib::ustring>::Ref Ptr<const Glib::ustring>::Ref
oldValue = optionsContainer->getOptionItem(optionItem); oldValue = optionsContainer->getOptionItem(optionItem);
@ -244,7 +182,7 @@ OptionsWindow :: saveChangesInStringEntryFields(void) throw ()
errorMessage(new Glib::ustring( errorMessage(new Glib::ustring(
*getResourceUstring("errorMsg") )); *getResourceUstring("errorMsg") ));
errorMessage->append(e.what()); errorMessage->append(e.what());
gLiveSupport->displayMessageWindow(errorMessage); gLiveSupport->displayMessageWindow(*errorMessage);
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
std::exit(1); std::exit(1);
@ -304,7 +242,7 @@ OptionsWindow :: saveChangesInKeyBindings(void) throw ()
errorMessage(new Glib::ustring( errorMessage(new Glib::ustring(
*getResourceUstring("errorMsg") )); *getResourceUstring("errorMsg") ));
errorMessage->append(e.what()); errorMessage->append(e.what());
gLiveSupport->displayMessageWindow(errorMessage); gLiveSupport->displayMessageWindow(*errorMessage);
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
std::exit(1); std::exit(1);
@ -356,7 +294,7 @@ OptionsWindow :: onCloseButtonClicked(bool needConfirm) throw ()
* Event handler for the test button * Event handler for the test button
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
OptionsWindow :: onTestButtonClicked(const EntryBin * entry) OptionsWindow :: onTestButtonClicked(const Gtk::Entry * entry)
throw () throw ()
{ {
Ptr<OptionsContainer>::Ref optionsContainer Ptr<OptionsContainer>::Ref optionsContainer
@ -376,15 +314,16 @@ OptionsWindow :: onTestButtonClicked(const EntryBin * entry)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Create a new user entry field item. * Create a new user entry field item.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
EntryBin * Gtk::Entry *
OptionsWindow :: createEntry(OptionsContainer::OptionItemString optionItem) OptionsWindow :: createEntry(const Glib::ustring & entryName,
OptionsContainer::OptionItemString optionItem)
throw () throw ()
{ {
Ptr<OptionsContainer>::Ref optionsContainer Ptr<OptionsContainer>::Ref optionsContainer
= gLiveSupport->getOptionsContainer(); = gLiveSupport->getOptionsContainer();
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
EntryBin * entry = Gtk::manage(wf->createEntryBin()); Gtk::Entry * entry;
glade->get_widget(entryName, entry);
try { try {
entry->set_text(*optionsContainer->getOptionItem(optionItem)); entry->set_text(*optionsContainer->getOptionItem(optionItem));
@ -395,7 +334,7 @@ OptionsWindow :: createEntry(OptionsContainer::OptionItemString optionItem)
} }
stringEntryList.push_back(std::make_pair(optionItem, entry)); stringEntryList.push_back(std::make_pair(optionItem, entry));
return entry; return entry;
} }
@ -403,145 +342,75 @@ OptionsWindow :: createEntry(OptionsContainer::OptionItemString optionItem)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the "Sound" section. * Construct the "Sound" section.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
OptionsWindow :: constructSoundSection(void) throw () OptionsWindow :: constructSoundSection(void) throw ()
{ {
Ptr<OptionsContainer>::Ref optionsContainer Ptr<OptionsContainer>::Ref optionsContainer
= gLiveSupport->getOptionsContainer(); = gLiveSupport->getOptionsContainer();
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
Gtk::Table * audioDeviceTable = Gtk::manage(new Gtk::Table); Gtk::Label * cueDeviceLabel;
audioDeviceTable->set_row_spacings(10); Gtk::Label * outputDeviceLabel;
audioDeviceTable->set_col_spacings(5); glade->get_widget("cueDeviceLabel1", cueDeviceLabel);
glade->get_widget("outputDeviceLabel1", outputDeviceLabel);
// display the settings for the cue player device cueDeviceLabel->set_label(*getResourceUstring("cueDeviceLabel"));
Glib::ustring cuePlayerLabelContents; outputDeviceLabel->set_label(*getResourceUstring("outputDeviceLabel"));
try {
cuePlayerLabelContents.append(*getResourceUstring("cueDeviceLabel")); Gtk::Entry * cueDeviceEntry;
Gtk::Entry * outputDeviceEntry;
} catch (std::invalid_argument &e) { cueDeviceEntry = createEntry("cueDeviceEntry1",
// TODO: signal error OptionsContainer::cuePlayerDeviceName);
std::cerr << e.what() << std::endl; outputDeviceEntry = createEntry("outputDeviceEntry1",
std::exit(1);
}
Gtk::Label * cuePlayerLabel = Gtk::manage(
new Gtk::Label(cuePlayerLabelContents) );
audioDeviceTable->attach(*cuePlayerLabel,
0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 5, 0);
EntryBin * cuePlayerEntry = createEntry(
OptionsContainer::cuePlayerDeviceName);
audioDeviceTable->attach(*cuePlayerEntry, 1, 2, 0, 1);
Button * cueTestButton;
try {
cueTestButton = Gtk::manage(wf->createButton(
*getResourceUstring("testButtonLabel") ));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
cueTestButton->signal_clicked().connect(sigc::bind<EntryBin*>(
sigc::mem_fun(*this,&OptionsWindow::onTestButtonClicked),
cuePlayerEntry));
audioDeviceTable->attach(*cueTestButton, 2, 3, 0, 1);
// display the settings for the output player device
Glib::ustring outputPlayerLabelContents;
try {
outputPlayerLabelContents.append(*getResourceUstring(
"outputDeviceLabel"));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
Gtk::Label * outputPlayerLabel = Gtk::manage(
new Gtk::Label(outputPlayerLabelContents) );
audioDeviceTable->attach(*outputPlayerLabel,
0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 5, 0);
EntryBin * outputPlayerEntry = createEntry(
OptionsContainer::outputPlayerDeviceName); OptionsContainer::outputPlayerDeviceName);
audioDeviceTable->attach(*outputPlayerEntry, 1, 2, 1, 2);
Button * outputTestButton; Gtk::Button * cueTestButton;
try { Gtk::Button * outputTestButton;
outputTestButton = Gtk::manage(wf->createButton( glade->get_widget("cueTestButton1", cueTestButton);
*getResourceUstring("testButtonLabel") )); glade->get_widget("outputTestButton1", outputTestButton);
} catch (std::invalid_argument &e) { cueTestButton->set_label(*getResourceUstring("testButtonLabel"));
// TODO: signal error outputTestButton->set_label(*getResourceUstring("testButtonLabel"));
std::cerr << e.what() << std::endl; cueTestButton->signal_clicked().connect(sigc::bind<Gtk::Entry*>(
std::exit(1);
}
outputTestButton->signal_clicked().connect(sigc::bind<EntryBin*>(
sigc::mem_fun(*this, &OptionsWindow::onTestButtonClicked), sigc::mem_fun(*this, &OptionsWindow::onTestButtonClicked),
outputPlayerEntry)); cueDeviceEntry));
audioDeviceTable->attach(*outputTestButton, 2, 3, 1, 2); outputTestButton->signal_clicked().connect(sigc::bind<Gtk::Entry*>(
sigc::mem_fun(*this, &OptionsWindow::onTestButtonClicked),
// make a new box and pack the components into it outputDeviceEntry));
Gtk::VBox * section = Gtk::manage(new Gtk::VBox);
section->pack_start(*audioDeviceTable, Gtk::PACK_SHRINK, 5);
return section;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the "Key bindings" section. * Construct the "Key bindings" section.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
OptionsWindow :: constructKeyBindingsSection(void) throw () OptionsWindow :: constructKeyBindingsSection(void) throw ()
{ {
// create the TreeView // create the TreeView
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
keyBindingsModel = Gtk::TreeStore::create(keyBindingsColumns); keyBindingsModel = Gtk::TreeStore::create(keyBindingsColumns);
keyBindingsView = Gtk::manage(wf->createTreeView(keyBindingsModel)); glade->get_widget_derived("keyBindingsTreeView1", keyBindingsTreeView);
keyBindingsTreeView->set_model(keyBindingsModel);
keyBindingsTreeView->connectModelSignals(keyBindingsModel);
keyBindingsView->appendColumn("", keyBindingsColumns.actionColumn); keyBindingsTreeView->appendColumn("", keyBindingsColumns.actionColumn);
keyBindingsView->appendColumn("", keyBindingsColumns.keyDisplayColumn); keyBindingsTreeView->appendColumn("", keyBindingsColumns.keyDisplayColumn);
// fill in the data
fillKeyBindingsModel(); fillKeyBindingsModel();
// set TreeView properties keyBindingsTreeView->columns_autosize();
keyBindingsView->set_headers_visible(false); keyBindingsTreeView->expand_all();
keyBindingsView->set_enable_search(false);
keyBindingsView->columns_autosize();
keyBindingsView->expand_all();
// connect the callbacks // connect the callbacks
keyBindingsView->signal_row_activated().connect(sigc::mem_fun(*this, keyBindingsTreeView->signal_row_activated().connect(sigc::mem_fun(*this,
&OptionsWindow::onKeyBindingsRowActivated )); &OptionsWindow::onKeyBindingsRowActivated));
keyBindingsView->signal_key_press_event().connect(sigc::mem_fun(*this, keyBindingsTreeView->signal_key_press_event().connect(sigc::mem_fun(*this,
&OptionsWindow::onKeyBindingsKeyPressed )); &OptionsWindow::onKeyBindingsKeyPressed));
keyBindingsView->signal_focus_out_event().connect_notify(sigc::mem_fun( keyBindingsTreeView->signal_focus_out_event().connect_notify(sigc::mem_fun(
*this, *this,
&OptionsWindow::onKeyBindingsFocusOut )); &OptionsWindow::onKeyBindingsFocusOut));
// add instructions // add instructions
Ptr<const Glib::ustring>::Ref instructionsText; Gtk::Label * instructionsLabel;
try { glade->get_widget("keyBindingsInstructionsLabel1", instructionsLabel);
instructionsText = getResourceUstring("keyBindingsInstructionsText"); instructionsLabel->set_label(*getResourceUstring(
"keyBindingsInstructionsText"));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
Gtk::Label * instructionsLabel = Gtk::manage(new Gtk::Label(
*instructionsText,
Gtk::ALIGN_CENTER,
Gtk::ALIGN_CENTER));
instructionsLabel->set_justify(Gtk::JUSTIFY_CENTER);
// make a new box and pack the components into it
Gtk::VBox * section = Gtk::manage(new Gtk::VBox);
section->pack_start(*instructionsLabel, Gtk::PACK_SHRINK, 5);
section->pack_start(*keyBindingsView, Gtk::PACK_SHRINK, 5);
return section;
} }
@ -554,40 +423,34 @@ OptionsWindow :: fillKeyBindingsModel(void) throw ()
Ptr<const KeyboardShortcutList>::Ref Ptr<const KeyboardShortcutList>::Ref
list = gLiveSupport->getKeyboardShortcutList(); list = gLiveSupport->getKeyboardShortcutList();
try { KeyboardShortcutList::iterator it;
KeyboardShortcutList::iterator it; for (it = list->begin(); it != list->end(); ++it) {
for (it = list->begin(); it != list->end(); ++it) { Ptr<const KeyboardShortcutContainer>::Ref
Ptr<const KeyboardShortcutContainer>::Ref container = *it;
container = *it; Ptr<const Glib::ustring>::Ref
windowName = container->getWindowName();
Gtk::TreeRow parent = *keyBindingsModel->append();
parent[keyBindingsColumns.actionColumn]
= *gLiveSupport->getLocalizedWindowName(windowName);
KeyboardShortcutContainer::iterator iter;
for (iter = container->begin(); iter != container->end(); ++iter) {
Ptr<const KeyboardShortcut>::Ref
shortcut = *iter;
Ptr<const Glib::ustring>::Ref Ptr<const Glib::ustring>::Ref
windowName = container->getWindowName(); actionString = shortcut->getActionString();
Gtk::TreeRow parent = *keyBindingsModel->append(); Ptr<const Glib::ustring>::Ref
parent[keyBindingsColumns.actionColumn] keyString = shortcut->getKeyString();
= *gLiveSupport->getLocalizedWindowName(windowName); Gtk::TreeRow child
= *keyBindingsModel->append(parent.children());
KeyboardShortcutContainer::iterator iter; child[keyBindingsColumns.actionColumn]
for (iter = container->begin(); iter != container->end(); ++iter) { = *gLiveSupport->getLocalizedKeyboardActionName(
Ptr<const KeyboardShortcut>::Ref actionString);
shortcut = *iter; child[keyBindingsColumns.keyNameColumn]
Ptr<const Glib::ustring>::Ref = *keyString; // TODO: localize this?
actionString = shortcut->getActionString(); child[keyBindingsColumns.keyDisplayColumn]
Ptr<const Glib::ustring>::Ref = Glib::Markup::escape_text(*keyString);
keyString = shortcut->getKeyString();
Gtk::TreeRow child
= *keyBindingsModel->append(parent.children());
child[keyBindingsColumns.actionColumn]
= *gLiveSupport->getLocalizedKeyboardActionName(
actionString);
child[keyBindingsColumns.keyNameColumn]
= *keyString; // TODO: localize this?
child[keyBindingsColumns.keyDisplayColumn]
= Glib::Markup::escape_text(*keyString);
}
} }
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
} }
} }
@ -595,250 +458,124 @@ OptionsWindow :: fillKeyBindingsModel(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the "Servers" section. * Construct the "Servers" section.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
OptionsWindow :: constructServersSection(void) throw () OptionsWindow :: constructServersSection(void) throw ()
{ {
Ptr<OptionsContainer>::Ref optionsContainer Ptr<OptionsContainer>::Ref optionsContainer
= gLiveSupport->getOptionsContainer(); = gLiveSupport->getOptionsContainer();
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
// the settings for the authentication server
Gtk::Table * authenticationTable = Gtk::manage(new Gtk::Table);
authenticationTable->set_row_spacings(5);
authenticationTable->set_col_spacings(5);
// authentication server
Gtk::Label * authenticationLabel; Gtk::Label * authenticationLabel;
Gtk::Label * authenticationServerLabel; Gtk::Label * authenticationServerLabel;
Gtk::Label * authenticationPortLabel; Gtk::Label * authenticationPortLabel;
Gtk::Label * authenticationPathLabel; Gtk::Label * authenticationPathLabel;
try { glade->get_widget("authenticationServerLabel1", authenticationLabel);
authenticationLabel = Gtk::manage(new Gtk::Label( glade->get_widget("authenticationServerServerLabel1",
*getResourceUstring("authenticationLabel") )); authenticationServerLabel);
authenticationServerLabel = Gtk::manage(new Gtk::Label( glade->get_widget("authenticationServerPortLabel1",
*getResourceUstring("serverLabel") )); authenticationPortLabel);
authenticationPortLabel = Gtk::manage(new Gtk::Label( glade->get_widget("authenticationServerPathLabel1",
*getResourceUstring("portLabel") )); authenticationPathLabel);
authenticationPathLabel = Gtk::manage(new Gtk::Label( authenticationLabel->set_label(*getResourceUstring("authenticationLabel"));
*getResourceUstring("pathLabel") )); authenticationServerLabel->set_label(*getResourceUstring("serverLabel"));
authenticationPortLabel->set_label(*getResourceUstring("portLabel"));
} catch (std::invalid_argument &e) { authenticationPathLabel->set_label(*getResourceUstring("pathLabel"));
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
authenticationTable->attach(*authenticationLabel,
0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 5, 0);
authenticationTable->attach(*authenticationServerLabel,
1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
authenticationTable->attach(*authenticationPortLabel,
1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
authenticationTable->attach(*authenticationPathLabel,
1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
EntryBin * authenticationServerEntry = createEntry( createEntry("authenticationServerServerEntry1",
OptionsContainer::authenticationServer); OptionsContainer::authenticationServer);
EntryBin * authenticationPortEntry = createEntry( createEntry("authenticationServerPortEntry1",
OptionsContainer::authenticationPort); OptionsContainer::authenticationPort);
EntryBin * authenticationPathEntry = createEntry( createEntry("authenticationServerPathEntry1",
OptionsContainer::authenticationPath); OptionsContainer::authenticationPath);
authenticationTable->attach(*authenticationServerEntry, 2, 3, 0, 1); // storage server
authenticationTable->attach(*authenticationPortEntry, 2, 3, 1, 2);
authenticationTable->attach(*authenticationPathEntry, 2, 3, 2, 3);
// the settings for the storage server
Gtk::Table * storageTable = Gtk::manage(new Gtk::Table);
storageTable->set_row_spacings(5);
storageTable->set_col_spacings(5);
Gtk::Label * storageLabel; Gtk::Label * storageLabel;
Gtk::Label * storageServerLabel; Gtk::Label * storageServerLabel;
Gtk::Label * storagePortLabel; Gtk::Label * storagePortLabel;
Gtk::Label * storagePathLabel; Gtk::Label * storagePathLabel;
try { glade->get_widget("storageServerLabel1", storageLabel);
storageLabel = Gtk::manage(new Gtk::Label( glade->get_widget("storageServerServerLabel1", storageServerLabel);
*getResourceUstring("storageLabel") )); glade->get_widget("storageServerPortLabel1", storagePortLabel);
storageServerLabel = Gtk::manage(new Gtk::Label( glade->get_widget("storageServerPathLabel1", storagePathLabel);
*getResourceUstring("serverLabel") )); storageLabel->set_label(*getResourceUstring("storageLabel"));
storagePortLabel = Gtk::manage(new Gtk::Label( storageServerLabel->set_label(*getResourceUstring("serverLabel"));
*getResourceUstring("portLabel") )); storagePortLabel->set_label(*getResourceUstring("portLabel"));
storagePathLabel = Gtk::manage(new Gtk::Label( storagePathLabel->set_label(*getResourceUstring("pathLabel"));
*getResourceUstring("pathLabel") ));
createEntry("storageServerServerEntry1", OptionsContainer::storageServer);
} catch (std::invalid_argument &e) { createEntry("storageServerPortEntry1", OptionsContainer::storagePort);
// TODO: signal error createEntry("storageServerPathEntry1", OptionsContainer::storagePath);
std::cerr << e.what() << std::endl;
std::exit(1);
}
storageTable->attach(*storageLabel, // scheduler server
0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 5, 0);
storageTable->attach(*storageServerLabel,
1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
storageTable->attach(*storagePortLabel,
1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
storageTable->attach(*storagePathLabel,
1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
EntryBin * storageServerEntry = createEntry(
OptionsContainer::storageServer);
EntryBin * storagePortEntry = createEntry(
OptionsContainer::storagePort);
EntryBin * storagePathEntry = createEntry(
OptionsContainer::storagePath);
storageTable->attach(*storageServerEntry, 2, 3, 0, 1);
storageTable->attach(*storagePortEntry, 2, 3, 1, 2);
storageTable->attach(*storagePathEntry, 2, 3, 2, 3);
// the settings for the scheduler
Gtk::Table * schedulerTable = Gtk::manage(new Gtk::Table);
schedulerTable->set_row_spacings(5);
schedulerTable->set_col_spacings(5);
Gtk::Label * schedulerLabel; Gtk::Label * schedulerLabel;
Gtk::Label * schedulerServerLabel; Gtk::Label * schedulerServerLabel;
Gtk::Label * schedulerPortLabel; Gtk::Label * schedulerPortLabel;
Gtk::Label * schedulerPathLabel; Gtk::Label * schedulerPathLabel;
try { glade->get_widget("schedulerServerLabel1", schedulerLabel);
schedulerLabel = Gtk::manage(new Gtk::Label( glade->get_widget("schedulerServerServerLabel1", schedulerServerLabel);
*getResourceUstring("schedulerLabel") )); glade->get_widget("schedulerServerPortLabel1", schedulerPortLabel);
schedulerServerLabel = Gtk::manage(new Gtk::Label( glade->get_widget("schedulerServerPathLabel1", schedulerPathLabel);
*getResourceUstring("serverLabel") )); schedulerLabel->set_label(*getResourceUstring("schedulerLabel"));
schedulerPortLabel = Gtk::manage(new Gtk::Label( schedulerServerLabel->set_label(*getResourceUstring("serverLabel"));
*getResourceUstring("portLabel") )); schedulerPortLabel->set_label(*getResourceUstring("portLabel"));
schedulerPathLabel = Gtk::manage(new Gtk::Label( schedulerPathLabel->set_label(*getResourceUstring("pathLabel"));
*getResourceUstring("pathLabel") ));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
schedulerTable->attach(*schedulerLabel,
0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 5, 0);
schedulerTable->attach(*schedulerServerLabel,
1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
schedulerTable->attach(*schedulerPortLabel,
1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
schedulerTable->attach(*schedulerPathLabel,
1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
EntryBin * schedulerServerEntry = createEntry( createEntry("schedulerServerServerEntry1",
OptionsContainer::schedulerServer); OptionsContainer::schedulerServer);
EntryBin * schedulerPortEntry = createEntry( createEntry("schedulerServerPortEntry1", OptionsContainer::schedulerPort);
OptionsContainer::schedulerPort); createEntry("schedulerServerPathEntry1", OptionsContainer::schedulerPath);
EntryBin * schedulerPathEntry = createEntry(
OptionsContainer::schedulerPath);
schedulerTable->attach(*schedulerServerEntry, 2, 3, 0, 1);
schedulerTable->attach(*schedulerPortEntry, 2, 3, 1, 2);
schedulerTable->attach(*schedulerPathEntry, 2, 3, 2, 3);
// make a new box and pack the components into it
Gtk::VBox * section = Gtk::manage(new Gtk::VBox);
section->pack_start(*authenticationTable, Gtk::PACK_SHRINK, 10);
section->pack_start(*storageTable, Gtk::PACK_SHRINK, 10);
section->pack_start(*schedulerTable, Gtk::PACK_SHRINK, 10);
return section;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the "Scheduler" section. * Construct the "Scheduler" section.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
OptionsWindow :: constructSchedulerSection(void) throw () OptionsWindow :: constructSchedulerSection(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); Gtk::Label * schedulerTextLabel;
Gtk::Button * startButton;
Gtk::Label * statusTextLabel; Gtk::Button * stopButton;
Button * startButton; glade->get_widget("schedulerTextLabel1", schedulerTextLabel);
Button * stopButton; glade->get_widget("schedulerStatusLabel1", schedulerStatusLabel);
try { glade->get_widget("schedulerStartButton1", startButton);
statusTextLabel = Gtk::manage(new Gtk::Label(*getResourceUstring( glade->get_widget("schedulerStopButton1", stopButton);
"schedulerStatusText"))); schedulerTextLabel->set_label(*getResourceUstring("schedulerStatusText"));
startButton = Gtk::manage(wf->createButton(*getResourceUstring( updateSchedulerStatus(); // sets the schedulerStatusLabel
"schedulerStartButtonLabel"))); startButton->set_label(*getResourceUstring("schedulerStartButtonLabel"));
stopButton = Gtk::manage(wf->createButton(*getResourceUstring( stopButton->set_label(*getResourceUstring("schedulerStopButtonLabel"));
"schedulerStopButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
startButton->signal_clicked().connect(sigc::mem_fun(*this, startButton->signal_clicked().connect(sigc::mem_fun(*this,
&OptionsWindow::onSchedulerStartButtonClicked)); &OptionsWindow::onSchedulerStartButtonClicked));
stopButton->signal_clicked().connect(sigc::mem_fun(*this, stopButton->signal_clicked().connect(sigc::mem_fun(*this,
&OptionsWindow::onSchedulerStopButtonClicked)); &OptionsWindow::onSchedulerStopButtonClicked));
Gtk::HBox * statusReportBox = Gtk::manage(new Gtk::HBox);
statusReportBox->pack_start(*statusTextLabel, Gtk::PACK_SHRINK, 5);
schedulerStatusLabel = Gtk::manage(new Gtk::Label);
statusReportBox->pack_start(*schedulerStatusLabel, Gtk::PACK_SHRINK, 0);
Gtk::ButtonBox * startStopButtons = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_SPREAD, 20));
startStopButtons->pack_start(*startButton);
startStopButtons->pack_start(*stopButton);
Gtk::VBox * section = Gtk::manage(new Gtk::VBox);
section->pack_start(*statusReportBox, Gtk::PACK_SHRINK, 20);
section->pack_start(*startStopButtons, Gtk::PACK_SHRINK);
updateSchedulerStatus();
return section;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the "Backup" section. * Construct the "Backup" section.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
OptionsWindow :: constructBackupSection(void) throw () OptionsWindow :: constructBackupSection(void) throw ()
{ {
Ptr<ResourceBundle>::Ref backupBundle; backupView.reset(new BackupView(gLiveSupport, glade));
try {
backupBundle = gLiveSupport->getBundle("backupView");
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
backupView = Gtk::manage(new BackupView(gLiveSupport, backupBundle));
return backupView;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the "RDS" section. * Construct the "RDS" section.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
OptionsWindow :: constructRdsSection(void) throw () OptionsWindow :: constructRdsSection(void) throw ()
{ {
Ptr<ResourceBundle>::Ref rdsBundle; rdsView.reset(new RdsView(gLiveSupport, glade));
try {
rdsBundle = gLiveSupport->getBundle("rdsView");
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
rdsView = Gtk::manage(new RdsView(gLiveSupport, rdsBundle));
return rdsView;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the "About" section. * Construct the "About" section.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
OptionsWindow :: constructAboutSection(void) throw () OptionsWindow :: constructAboutSection(void) throw ()
{ {
Glib::ustring aboutLabelContents; Glib::ustring aboutLabelContents;
@ -847,26 +584,15 @@ OptionsWindow :: constructAboutSection(void) throw ()
aboutLabelContents.append(PACKAGE_NAME); aboutLabelContents.append(PACKAGE_NAME);
aboutLabelContents.append(" "); aboutLabelContents.append(" ");
aboutLabelContents.append(PACKAGE_VERSION); aboutLabelContents.append(PACKAGE_VERSION);
try { aboutLabelContents.append("\n\n");
aboutLabelContents.append("\n\n"); aboutLabelContents.append(*formatMessage("reportBugsToText",
aboutLabelContents.append(*formatMessage("reportBugsToText", PACKAGE_BUGREPORT ));
PACKAGE_BUGREPORT )); aboutLabelContents.append("\n\n");
aboutLabelContents.append("\n\n"); aboutLabelContents.append(*getBinaryResourceAsUstring("creditsText"));
aboutLabelContents.append(*getBinaryResourceAsUstring("creditsText"));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
Gtk::Label * aboutLabel = Gtk::manage(
new Gtk::Label(aboutLabelContents) );
// make a new box and pack the components into it Gtk::Label * aboutLabel;
Gtk::VBox * section = Gtk::manage(new Gtk::VBox); glade->get_widget("aboutLabel1", aboutLabel);
section->pack_start(*aboutLabel, Gtk::PACK_SHRINK, 5); aboutLabel->set_label(aboutLabelContents);
return section;
} }
@ -882,8 +608,8 @@ OptionsWindow :: resetEntries() throw ()
StringEntryListType::iterator it; StringEntryListType::iterator it;
for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) { for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) {
OptionsContainer::OptionItemString optionItem = it->first; OptionsContainer::OptionItemString optionItem = it->first;
EntryBin * entry = it->second; Gtk::Entry * entry = it->second;
try { try {
entry->set_text(*optionsContainer->getOptionItem(optionItem)); entry->set_text(*optionsContainer->getOptionItem(optionItem));
@ -903,7 +629,7 @@ OptionsWindow :: resetKeyBindings(void) throw ()
{ {
keyBindingsModel->clear(); keyBindingsModel->clear();
fillKeyBindingsModel(); fillKeyBindingsModel();
keyBindingsView->expand_all(); keyBindingsTreeView->expand_all();
} }
@ -933,14 +659,8 @@ OptionsWindow :: onKeyBindingsRowActivated(const Gtk::TreePath & path,
editedKeyName.reset(new const Glib::ustring( editedKeyName.reset(new const Glib::ustring(
row[keyBindingsColumns.keyNameColumn])); row[keyBindingsColumns.keyNameColumn]));
editedKeyRow = row; editedKeyRow = row;
try { row[keyBindingsColumns.keyDisplayColumn]
row[keyBindingsColumns.keyDisplayColumn]
= *getResourceUstring("pressAKeyMsg"); = *getResourceUstring("pressAKeyMsg");
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
} }
} }
@ -1016,10 +736,11 @@ OptionsWindow :: resetEditedKeyBinding(void) throw ()
void void
OptionsWindow :: run(void) throw () OptionsWindow :: run(void) throw ()
{ {
mainNotebook->setActivePage(2); // "Servers" mainNotebook->set_current_page(2); // "Servers"
property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS); mainWindow->property_window_position().set_value(
show_all(); Gtk::WIN_POS_CENTER_ALWAYS);
Gtk::Main::run(*this); mainWindow->show_all();
Gtk::Main::run(*mainWindow);
} }
@ -1058,17 +779,12 @@ void
OptionsWindow :: updateSchedulerStatus(void) throw () OptionsWindow :: updateSchedulerStatus(void) throw ()
{ {
gLiveSupport->checkSchedulerClient(); gLiveSupport->checkSchedulerClient();
try { if (gLiveSupport->isSchedulerAvailable()) {
if (gLiveSupport->isSchedulerAvailable()) { schedulerStatusLabel->set_text(
schedulerStatusLabel->set_text( *getResourceUstring("schedulerRunningStatus"));
*getResourceUstring("schedulerRunningStatus")); } else {
} else { schedulerStatusLabel->set_text(
schedulerStatusLabel->set_text( *getResourceUstring("schedulerStoppedStatus"));
*getResourceUstring("schedulerStoppedStatus"));
}
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
} }
} }

View file

@ -40,26 +40,17 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/button.h> #include <gtkmm.h>
#include <gtkmm/table.h> #include <libglademm.h>
#include <gtkmm/entry.h>
#include <gtkmm/alignment.h>
#include <gtkmm/box.h>
#include <gtkmm/window.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/OptionsContainer.h" #include "LiveSupport/Core/OptionsContainer.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/EntryBin.h"
#include "LiveSupport/Widgets/ComboBoxText.h" #include "LiveSupport/Widgets/ComboBoxText.h"
#include "LiveSupport/Widgets/Notebook.h"
#include "LiveSupport/Widgets/ScrolledWindow.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ZebraTreeView.h" #include "LiveSupport/Widgets/ZebraTreeView.h"
#include "GuiWindow.h" #include "BasicWindow.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
#include "MasterPanelUserInfoWidget.h"
#include "BackupView.h" #include "BackupView.h"
#include "RdsView.h" #include "RdsView.h"
@ -89,50 +80,31 @@ using namespace LiveSupport::Widgets;
* | +-- currently ------------------+ | * | +-- currently ------------------+ |
* | +-- selected tab ---------------+ | * | +-- selected tab ---------------+ |
* | +-------------------------------+ | * | +-------------------------------+ |
* +------------(Cancel)-(Apply)-(OK)--+ * +------------(Apply)-(Cancel)-(OK)--+
* </code></pre> * </code></pre>
* *
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class OptionsWindow : public GuiWindow class OptionsWindow : public BasicWindow
{ {
private: private:
/** /**
* The notepad holding the different sections. * The notepad holding the different sections.
*/ */
Notebook * mainNotebook; Gtk::Notebook * mainNotebook;
/**
* The button box.
*/
Gtk::ButtonBox * buttonBox;
/**
* The Cancel button.
*/
Gtk::Button * cancelButton;
/**
* The Apply button.
*/
Gtk::Button * applyButton;
/**
* The OK button.
*/
Gtk::Button * okButton;
/** /**
* The label showing the current status of the scheduler. * The label showing the current status of the scheduler.
*/ */
Gtk::Label * schedulerStatusLabel; Gtk::Label * schedulerStatusLabel;
/** /**
* The type for the list of user entry fields of string type. * The type for the list of user entry fields of string type.
*/ */
typedef std::vector<std::pair<OptionsContainer::OptionItemString, typedef std::vector<std::pair<OptionsContainer::OptionItemString,
EntryBin*> > StringEntryListType; Gtk::Entry*> > StringEntryListType;
/** /**
* The list of user entry fields of string type. * The list of user entry fields of string type.
@ -142,15 +114,17 @@ class OptionsWindow : public GuiWindow
/** /**
* Create a new user entry field item. * Create a new user entry field item.
* *
* This constructs [and Gtk::manage()s] the EntryBin, and * This gets a reference to the Gtk::Entry from the Glade file, and
* sets its text to the current value of the option. * sets its text to the current value of the option.
* The EntryBin is then added to the list of user entry fields. * The Gtk::Entry is then added to the list of user entry fields.
* *
* @param optionItem the name of the option item for this entry * @param entryName the name of the Entry in the Glade file.
* @return the newly created EntryBin * @param optionItem the name of the option item for this entry.
* @return the text entry field just processed.
*/ */
EntryBin * Gtk::Entry *
createEntry(OptionsContainer::OptionItemString optionItem) createEntry(const Glib::ustring & entryName,
OptionsContainer::OptionItemString optionItem)
throw (); throw ();
/** /**
@ -216,59 +190,45 @@ class OptionsWindow : public GuiWindow
/** /**
* Construct the "Sound" section. * Construct the "Sound" section.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructSoundSection(void) throw (); constructSoundSection(void) throw ();
/** /**
* Construct the "Key bindings" section. * Construct the "Key bindings" section.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructKeyBindingsSection(void) throw (); constructKeyBindingsSection(void) throw ();
/** /**
* Construct the "Servers" section. * Construct the "Servers" section.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructServersSection(void) throw (); constructServersSection(void) throw ();
/** /**
* Construct the "Scheduler" section. * Construct the "Scheduler" section.
* This section contains the scheduler start and stop buttons. * This section contains the scheduler start and stop buttons.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructSchedulerSection(void) throw (); constructSchedulerSection(void) throw ();
/** /**
* Construct the "Backup" section. * Construct the "Backup" section.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructBackupSection(void) throw (); constructBackupSection(void) throw ();
/** /**
* Construct the "RDS" section. * Construct the "RDS" section.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructRdsSection(void) throw (); constructRdsSection(void) throw ();
/** /**
* Construct the "About" section. * Construct the "About" section.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructAboutSection(void) throw (); constructAboutSection(void) throw ();
/** /**
@ -279,6 +239,7 @@ class OptionsWindow : public GuiWindow
protected: protected:
/** /**
* Event handler for the Cancel button. * Event handler for the Cancel button.
*/ */
@ -303,7 +264,6 @@ class OptionsWindow : public GuiWindow
* @param needConfirm if true, we check if changes has been * @param needConfirm if true, we check if changes has been
* made to the input fields, and if yes, then * made to the input fields, and if yes, then
* a "save changes?" dialog is displayed * a "save changes?" dialog is displayed
* @see WhiteWindow::onCloseButtonClicked()
*/ */
virtual void virtual void
onCloseButtonClicked(bool needConfirm = true) throw (); onCloseButtonClicked(bool needConfirm = true) throw ();
@ -316,7 +276,7 @@ class OptionsWindow : public GuiWindow
* @see GLiveSupport::playTestSoundOnCue() * @see GLiveSupport::playTestSoundOnCue()
*/ */
virtual void virtual void
onTestButtonClicked(const EntryBin * entry) throw (); onTestButtonClicked(const Gtk::Entry * entry) throw ();
/** /**
* Event handler for double-clicking a row in the key bindings table. * Event handler for double-clicking a row in the key bindings table.
@ -366,6 +326,7 @@ class OptionsWindow : public GuiWindow
class ModelColumns : public ZebraTreeModelColumnRecord class ModelColumns : public ZebraTreeModelColumnRecord
{ {
public: public:
/** /**
* The column for the name of the action. * The column for the name of the action.
* This contains the name of the window (for parent rows), * This contains the name of the window (for parent rows),
@ -422,20 +383,21 @@ class OptionsWindow : public GuiWindow
/** /**
* The tree view for the key bindings. * The tree view for the key bindings.
*/ */
ZebraTreeView * keyBindingsView; ZebraTreeView * keyBindingsTreeView;
/** /**
* The backup view shown in the backup section. * The backup view shown in the backup section.
*/ */
BackupView * backupView; Ptr<BackupView>::Ref backupView;
/** /**
* The RdsView shown in the RDS section. * The RdsView shown in the RDS section.
*/ */
RdsView * rdsView; Ptr<RdsView>::Ref rdsView;
public: public:
/** /**
* Constructor. * Constructor.
* *
@ -445,10 +407,12 @@ class OptionsWindow : public GuiWindow
* resources for this window. * resources for this window.
* @param windowOpenerButton the button which was pressed to open * @param windowOpenerButton the button which was pressed to open
* this window. * this window.
* @param gladeDir the directory where the glade file is.
*/ */
OptionsWindow(Ptr<GLiveSupport>::Ref gLiveSupport, OptionsWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw (); throw ();
/** /**
@ -462,10 +426,11 @@ class OptionsWindow : public GuiWindow
/** /**
* Return the BackupList object shown by the widget. * Return the BackupList object shown by the widget.
*/ */
BackupList * Ptr<BackupList>::Ref
getBackupList(void) throw () getBackupList(void) throw ()
{ {
return backupView ? backupView->getBackupList() : 0; return backupView ? backupView->getBackupList()
: Ptr<BackupList>::Ref();
} }
/** /**

View file

@ -38,13 +38,12 @@
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "SimplePlaylistManagementWindow.h" #include "PlaylistWindow.h"
using namespace Glib; using namespace Glib;
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -54,10 +53,10 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/** /*------------------------------------------------------------------------------
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc). * The name of the glade file.
*/ *----------------------------------------------------------------------------*/
const Glib::ustring windowName = "simplePlaylistManagementWindow"; const Glib::ustring gladeFileName = "PlaylistWindow.glade";
} }
@ -69,196 +68,116 @@ const Glib::ustring windowName = "simplePlaylistManagementWindow";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( PlaylistWindow :: PlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<ResourceBundle>::Ref bundle,
Ptr<ResourceBundle>::Ref bundle, Gtk::ToggleButton * windowOpenerButton,
Button * windowOpenerButton) const Glib::ustring & gladeDir)
throw () throw ()
: GuiWindow(gLiveSupport, : BasicWindow(gLiveSupport,
bundle, bundle,
windowOpenerButton), windowOpenerButton,
gladeDir + gladeFileName),
isPlaylistModified(false) isPlaylistModified(false)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); // set up the file name entry
Gtk::Label * nameLabel;
glade->get_widget("nameLabel1", nameLabel);
nameLabel->set_label(*getResourceUstring("nameLabel"));
glade->get_widget("nameEntry1", nameEntry);
nameEntry->signal_changed().connect(sigc::mem_fun(*this,
&PlaylistWindow::onTitleEdited));
// set up the entries tree view
entriesModel = Gtk::ListStore::create(modelColumns);
glade->get_widget_derived("entriesView1", entriesView);
entriesView->set_model(entriesModel);
entriesView->connectModelSignals(entriesModel);
try { entriesView->appendColumn(*getResourceUstring("startColumnLabel"),
set_title(*getResourceUstring("windowTitle")); modelColumns.startColumn,
nameLabel = Gtk::manage(new Gtk::Label( 60);
*getResourceUstring("nameLabel"))); entriesView->appendColumn(*getResourceUstring("titleColumnLabel"),
saveButton = Gtk::manage(wf->createButton( modelColumns.titleColumn,
*getResourceUstring("saveButtonLabel"))); 200);
closeButton = Gtk::manage(wf->createButton( entriesView->appendEditableColumn(
*getResourceUstring("closeButtonLabel"))); *getResourceUstring("fadeInColumnLabel"),
} catch (std::invalid_argument &e) { modelColumns.fadeInColumn,
std::cerr << e.what() << std::endl; fadeInColumnId,
std::exit(1); 60);
} entriesView->appendColumn(*getResourceUstring("lengthColumnLabel"),
modelColumns.lengthColumn,
60);
entriesView->appendEditableColumn(
*getResourceUstring("fadeOutColumnLabel"),
modelColumns.fadeOutColumn,
fadeOutColumnId,
60);
nameEntry = Gtk::manage(wf->createEntryBin()); entriesView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
nameEntry->signal_changed().connect(sigc::mem_fun( &PlaylistWindow::onEntryClicked));
*this, &SimplePlaylistManagementWindow::onTitleEdited )); entriesView->signalCellEdited().connect(sigc::mem_fun(*this,
&PlaylistWindow::onFadeInfoEdited ));
entriesView->signal_key_press_event().connect(sigc::mem_fun(*this,
&PlaylistWindow::onKeyPressed));
entriesScrolledWindow = Gtk::manage(new Gtk::ScrolledWindow()); // set up the status bar
entriesModel = Gtk::ListStore::create(modelColumns); glade->get_widget("statusBar1", statusBar);
entriesView = Gtk::manage(wf->createTreeView(entriesModel)); statusBar->set_label("");
// set up the entry scrolled window, with the entry treeview inside.
entriesScrolledWindow->add(*entriesView);
entriesScrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
// Add the TreeView's view columns:
try {
entriesView->appendColumn(*getResourceUstring("startColumnLabel"),
modelColumns.startColumn,
60);
entriesView->appendColumn(*getResourceUstring("titleColumnLabel"),
modelColumns.titleColumn,
200);
entriesView->appendEditableColumn(
*getResourceUstring("fadeInColumnLabel"),
modelColumns.fadeInColumn,
fadeInColumnId,
60);
entriesView->appendColumn(*getResourceUstring("lengthColumnLabel"),
modelColumns.lengthColumn,
60);
entriesView->appendEditableColumn(
*getResourceUstring("fadeOutColumnLabel"),
modelColumns.fadeOutColumn,
fadeOutColumnId,
60);
statusBar = Gtk::manage(new Gtk::Label(""));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
entriesView->signal_button_press_event().connect_notify(sigc::mem_fun(
*this, &SimplePlaylistManagementWindow::onEntryClicked ));
entriesView->signalCellEdited().connect(sigc::mem_fun(
*this, &SimplePlaylistManagementWindow::onFadeInfoEdited ));
entriesView->signal_key_press_event().connect(sigc::mem_fun(
*this, &SimplePlaylistManagementWindow::onKeyPressed));
// create the right-click entry context menu // create the right-click entry context menu
rightClickMenu = Gtk::manage(new Gtk::Menu()); rightClickMenu.reset(new Gtk::Menu());
Gtk::Menu::MenuList& rightClickMenuList = rightClickMenu->items(); Gtk::Menu::MenuList & rightClickMenuList = rightClickMenu->items();
try { rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("upMenuItem"),
*getResourceUstring("upMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &PlaylistWindow::onUpItem)));
&SimplePlaylistManagementWindow::onUpItem))); rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("downMenuItem"),
*getResourceUstring("downMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &PlaylistWindow::onDownItem)));
&SimplePlaylistManagementWindow::onDownItem))); rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("removeMenuItem"),
*getResourceUstring("removeMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &PlaylistWindow::onRemoveItem)));
&SimplePlaylistManagementWindow::onRemoveItem)));
} catch (std::invalid_argument &e) { // set up the "lock fades" check button
std::cerr << e.what() << std::endl; Gtk::CheckButton * lockFadesCheckButton;
std::exit(1); glade->get_widget("lockFadesCheckButton1", lockFadesCheckButton);
} lockFadesCheckButton->set_label(*getResourceUstring(
"lockFadesCheckButtonLabel"));
// construct the "lock fades" check button
Ptr<Glib::ustring>::Ref lockFadesCheckButtonLabel;
try {
lockFadesCheckButtonLabel = getResourceUstring(
"lockFadesCheckButtonLabel");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
Gtk::CheckButton * lockFadesCheckButton = Gtk::manage(new Gtk::CheckButton(
*lockFadesCheckButtonLabel ));
lockFadesCheckButton->set_active(true); lockFadesCheckButton->set_active(true);
areFadesLocked = true; areFadesLocked = true;
lockFadesCheckButton->signal_toggled().connect(sigc::mem_fun( lockFadesCheckButton->signal_toggled().connect(sigc::mem_fun(*this,
*this, &PlaylistWindow::onLockFadesCheckButtonClicked));
&SimplePlaylistManagementWindow::onLockFadesCheckButtonClicked ));
// construct the "total time" display // set up the "total time" display
Gtk::Label * lengthTextLabel = Gtk::manage(new Gtk::Label( Gtk::Label * lengthTextLabel;
*getResourceUstring("lengthLabel") )); glade->get_widget("lengthTextLabel1", lengthTextLabel);
lengthValueLabel = Gtk::manage(new Gtk::Label("00:00:00")); lengthTextLabel->set_label(*getResourceUstring("lengthLabel"));
Gtk::HBox * lengthBox = Gtk::manage(new Gtk::HBox());
lengthBox->pack_start(*lengthTextLabel, Gtk::PACK_SHRINK, 5);
lengthBox->pack_start(*lengthValueLabel, Gtk::PACK_SHRINK, 5);
// set up the layout glade->get_widget("lengthValueLabel1", lengthValueLabel);
Gtk::VBox * mainBox = Gtk::manage(new Gtk::VBox); lengthValueLabel->set_label("00:00:00");
Gtk::HBox * nameBox = Gtk::manage(new Gtk::HBox); // register the signal handlers for the buttons
nameBox->pack_start(*nameLabel, Gtk::PACK_SHRINK, 10); Gtk::Button * closeButton;
Gtk::Alignment * nameEntryAlignment = Gtk::manage(new Gtk::Alignment( glade->get_widget("saveButton1", saveButton);
Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, glade->get_widget("closeButton1", closeButton);
0.7)); // take up 70% of available room
nameEntryAlignment->add(*nameEntry);
nameBox->pack_start(*nameEntryAlignment, Gtk::PACK_EXPAND_WIDGET, 5);
Gtk::ButtonBox * buttonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_END, 5));
buttonBox->pack_start(*saveButton);
buttonBox->pack_start(*closeButton);
Gtk::Alignment * statusBarAlignment = Gtk::manage(new Gtk::Alignment(
Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
0.0)); // do not expand the label
statusBarAlignment->add(*statusBar);
mainBox->pack_start(*nameBox, Gtk::PACK_SHRINK, 5);
mainBox->pack_start(*entriesScrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5);
mainBox->pack_start(*lengthBox, Gtk::PACK_SHRINK, 5);
mainBox->pack_start(*lockFadesCheckButton, Gtk::PACK_SHRINK, 5);
mainBox->pack_start(*buttonBox, Gtk::PACK_SHRINK, 0);
mainBox->pack_start(*statusBarAlignment, Gtk::PACK_SHRINK, 5);
add(*mainBox);
// Register the signal handlers for the buttons
saveButton->signal_clicked().connect(sigc::mem_fun(*this, saveButton->signal_clicked().connect(sigc::mem_fun(*this,
&SimplePlaylistManagementWindow::onSaveButtonClicked)); &PlaylistWindow::onSaveButtonClicked));
closeButton->signal_clicked().connect(sigc::mem_fun(*this, closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&SimplePlaylistManagementWindow::onBottomCloseButtonClicked)); &PlaylistWindow::onBottomCloseButtonClicked));
// show // get notified when the playlist is modified outside of the window
set_name(windowName); gLiveSupport->signalEditedPlaylistModified().connect(sigc::mem_fun(*this,
set_default_size(480, 350); &PlaylistWindow::onPlaylistModified ));
set_modal(false);
property_window_position().set_value(Gtk::WIN_POS_NONE);
saveButton->set_sensitive(false);
show_all_children();
// set up the dialog windows
Ptr<Glib::ustring>::Ref confirmationMessage;
try {
confirmationMessage.reset(new Glib::ustring(
*getResourceUstring("savePlaylistDialogMsg") ));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
dialogWindow.reset(new DialogWindow(confirmationMessage,
DialogWindow::cancelButton |
DialogWindow::noButton |
DialogWindow::yesButton,
gLiveSupport->getBundle() ));
gLiveSupport->signalEditedPlaylistModified().connect(sigc::mem_fun(
*this, &SimplePlaylistManagementWindow::onPlaylistModified ));
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Destructor. * Destructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
SimplePlaylistManagementWindow :: ~SimplePlaylistManagementWindow (void) PlaylistWindow :: ~PlaylistWindow (void)
throw () throw ()
{ {
} }
@ -268,7 +187,7 @@ SimplePlaylistManagementWindow :: ~SimplePlaylistManagementWindow (void)
* Save the edited playlist. * Save the edited playlist.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
bool bool
SimplePlaylistManagementWindow :: savePlaylist(bool reopen) throw () PlaylistWindow :: savePlaylist(bool reopen) throw ()
{ {
try { try {
Ptr<Playlist>::Ref playlist Ptr<Playlist>::Ref playlist
@ -308,7 +227,7 @@ SimplePlaylistManagementWindow :: savePlaylist(bool reopen) throw ()
* Signal handler for the save button getting clicked. * Signal handler for the save button getting clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onSaveButtonClicked(void) throw () PlaylistWindow :: onSaveButtonClicked(void) throw ()
{ {
savePlaylist(true); savePlaylist(true);
} }
@ -318,15 +237,15 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked(void) throw ()
* Cancel the edited playlist, after asking for confirmation. * Cancel the edited playlist, after asking for confirmation.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
bool bool
SimplePlaylistManagementWindow :: cancelPlaylist(void) throw () PlaylistWindow :: cancelPlaylist(void) throw ()
{ {
if (gLiveSupport->getEditedPlaylist()) { if (gLiveSupport->getEditedPlaylist()) {
if (!isPlaylistModified) { if (!isPlaylistModified) {
gLiveSupport->cancelEditedPlaylist(); gLiveSupport->cancelEditedPlaylist();
} else { } else {
DialogWindow::ButtonType result = dialogWindow->run(); Gtk::ResponseType result = runConfirmationDialog();
switch (result) { switch (result) {
case DialogWindow::noButton: case Gtk::RESPONSE_NO:
try { try {
gLiveSupport->cancelEditedPlaylist(); gLiveSupport->cancelEditedPlaylist();
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
@ -336,18 +255,18 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
setPlaylistModified(false); setPlaylistModified(false);
break; break;
case DialogWindow::yesButton: case Gtk::RESPONSE_YES:
if (!savePlaylist(false)) { if (!savePlaylist(false)) {
return false; return false;
} }
break; break;
case DialogWindow::cancelButton: case Gtk::RESPONSE_CANCEL:
return false; return false;
default : return false; default : // can happen if the window
// can happen if window is closed return false; // is closed with Alt-F4
} // with Alt-F4 -- treated as cancel } // -- treated as cancel
} }
} }
@ -355,17 +274,43 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
} }
/*------------------------------------------------------------------------------
* Run the confirmation window.
*----------------------------------------------------------------------------*/
Gtk::ResponseType
PlaylistWindow :: runConfirmationDialog(void) throw ()
{
Gtk::Dialog * confirmationDialog;
Gtk::Label * confirmationDialogLabel;
Gtk::Button * noButton;
glade->get_widget("confirmationDialog1", confirmationDialog);
glade->get_widget("confirmationDialogLabel1", confirmationDialogLabel);
glade->get_widget("noButton1", noButton);
Glib::ustring message = "<span weight=\"bold\" ";
message += " size=\"larger\">";
message += *getResourceUstring("savePlaylistDialogMsg");
message += "</span>";
confirmationDialogLabel->set_label(message);
noButton->set_label(*getResourceUstring("closeWithoutSavingButtonLabel"));
Gtk::ResponseType response = Gtk::ResponseType(
confirmationDialog->run());
confirmationDialog->hide();
return response;
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Clean and close the window. * Clean and close the window.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: closeWindow(void) throw () PlaylistWindow :: closeWindow(void) throw ()
{ {
statusBar->set_text(""); statusBar->set_text("");
nameEntry->set_text(""); nameEntry->set_text("");
entriesModel->clear(); entriesModel->clear();
setPlaylistModified(false); setPlaylistModified(false);
gLiveSupport->putWindowPosition(shared_from_this());
hide(); hide();
} }
@ -374,7 +319,7 @@ SimplePlaylistManagementWindow :: closeWindow(void) throw ()
* Signal handler for the save button getting clicked. * Signal handler for the save button getting clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onBottomCloseButtonClicked(void) throw () PlaylistWindow :: onBottomCloseButtonClicked(void) throw ()
{ {
if (cancelPlaylist()) { if (cancelPlaylist()) {
closeWindow(); closeWindow();
@ -386,7 +331,7 @@ SimplePlaylistManagementWindow :: onBottomCloseButtonClicked(void) throw ()
* Signal handler for the "lock fades" check button toggled. * Signal handler for the "lock fades" check button toggled.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onLockFadesCheckButtonClicked(void) PlaylistWindow :: onLockFadesCheckButtonClicked(void)
throw () throw ()
{ {
areFadesLocked = !areFadesLocked; areFadesLocked = !areFadesLocked;
@ -397,7 +342,7 @@ SimplePlaylistManagementWindow :: onLockFadesCheckButtonClicked(void)
* Show the contents of the currently edited playlist. * Show the contents of the currently edited playlist.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: showContents(void) throw () PlaylistWindow :: showContents(void) throw ()
{ {
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
Playlist::const_iterator it; Playlist::const_iterator it;
@ -454,7 +399,7 @@ SimplePlaylistManagementWindow :: showContents(void) throw ()
* Signal handler for the fade info being edited. * Signal handler for the fade info being edited.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onTitleEdited(void) throw() PlaylistWindow :: onTitleEdited(void) throw()
{ {
Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist(); Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist();
if (!playlist) { if (!playlist) {
@ -463,7 +408,7 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
playlist = gLiveSupport->getEditedPlaylist(); playlist = gLiveSupport->getEditedPlaylist();
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
std::cerr << "error in SimplePlaylistManagementWindow::" std::cerr << "error in PlaylistWindow::"
"onTitleEdited(): " "onTitleEdited(): "
<< e.what() << std::endl; << e.what() << std::endl;
return; return;
@ -484,7 +429,7 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
* Signal handler for the fade info being edited. * Signal handler for the fade info being edited.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onFadeInfoEdited( PlaylistWindow :: onFadeInfoEdited(
const Glib::ustring & pathString, const Glib::ustring & pathString,
int columnId, int columnId,
const Glib::ustring & newText) const Glib::ustring & newText)
@ -543,7 +488,7 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited(
* Auxilliary function: set the fade in of a playlist element. * Auxilliary function: set the fade in of a playlist element.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: setFadeIn( PlaylistWindow :: setFadeIn(
Ptr<PlaylistElement>::Ref playlistElement, Ptr<PlaylistElement>::Ref playlistElement,
Ptr<time_duration>::Ref newFadeIn) Ptr<time_duration>::Ref newFadeIn)
throw() throw()
@ -571,7 +516,7 @@ SimplePlaylistManagementWindow :: setFadeIn(
* Auxilliary function: set the fade out of a playlist element. * Auxilliary function: set the fade out of a playlist element.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: setFadeOut( PlaylistWindow :: setFadeOut(
Ptr<PlaylistElement>::Ref playlistElement, Ptr<PlaylistElement>::Ref playlistElement,
Ptr<time_duration>::Ref newFadeOut) Ptr<time_duration>::Ref newFadeOut)
throw() throw()
@ -599,7 +544,7 @@ SimplePlaylistManagementWindow :: setFadeOut(
* Auxilliary function: check that fades are not longer than the whole clip. * Auxilliary function: check that fades are not longer than the whole clip.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
inline bool inline bool
SimplePlaylistManagementWindow :: isLengthOkay( PlaylistWindow :: isLengthOkay(
Ptr<PlaylistElement>::Ref playlistElement, Ptr<PlaylistElement>::Ref playlistElement,
Ptr<FadeInfo>::Ref newFadeInfo) Ptr<FadeInfo>::Ref newFadeInfo)
throw() throw()
@ -614,7 +559,7 @@ SimplePlaylistManagementWindow :: isLengthOkay(
* Signal handler for the playlist being modified outside the window. * Signal handler for the playlist being modified outside the window.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onPlaylistModified(void) throw() PlaylistWindow :: onPlaylistModified(void) throw()
{ {
setPlaylistModified(true); setPlaylistModified(true);
} }
@ -624,7 +569,7 @@ SimplePlaylistManagementWindow :: onPlaylistModified(void) throw()
* Event handler for an entry being clicked in the list * Event handler for an entry being clicked in the list
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onEntryClicked(GdkEventButton * event) PlaylistWindow :: onEntryClicked(GdkEventButton * event)
throw() throw()
{ {
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
@ -651,7 +596,7 @@ SimplePlaylistManagementWindow :: onEntryClicked(GdkEventButton * event)
* Event handler for the Up menu item selected from the context menu. * Event handler for the Up menu item selected from the context menu.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onUpItem(void) throw() PlaylistWindow :: onUpItem(void) throw()
{ {
if (currentItem && currentItem != entriesModel->children().begin()) { if (currentItem && currentItem != entriesModel->children().begin()) {
int rowNumber = (*currentItem) int rowNumber = (*currentItem)
@ -670,7 +615,7 @@ SimplePlaylistManagementWindow :: onUpItem(void) throw()
* Event handler for the Down menu item selected from the context menu. * Event handler for the Down menu item selected from the context menu.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onDownItem(void) throw() PlaylistWindow :: onDownItem(void) throw()
{ {
if (currentItem) { if (currentItem) {
Gtk::TreeIter nextItem = currentItem; Gtk::TreeIter nextItem = currentItem;
@ -691,7 +636,7 @@ SimplePlaylistManagementWindow :: onDownItem(void) throw()
* Swap two playlist elements in the edited playlist. * Swap two playlist elements in the edited playlist.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: swapPlaylistElements( PlaylistWindow :: swapPlaylistElements(
Gtk::TreeIter firstIter, Gtk::TreeIter firstIter,
Gtk::TreeIter secondIter) Gtk::TreeIter secondIter)
throw() throw()
@ -769,7 +714,7 @@ SimplePlaylistManagementWindow :: swapPlaylistElements(
* Event handler for the Remove menu item selected from the context menu. * Event handler for the Remove menu item selected from the context menu.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: onRemoveItem(void) throw() PlaylistWindow :: onRemoveItem(void) throw()
{ {
if (currentItem) { if (currentItem) {
Ptr<Playlist>::Ref Ptr<Playlist>::Ref
@ -791,12 +736,12 @@ SimplePlaylistManagementWindow :: onRemoveItem(void) throw()
* Event handler for a key pressed. * Event handler for a key pressed.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
bool bool
SimplePlaylistManagementWindow :: onKeyPressed(GdkEventKey * event) PlaylistWindow :: onKeyPressed(GdkEventKey * event)
throw () throw ()
{ {
if (event->type == GDK_KEY_PRESS) { if (event->type == GDK_KEY_PRESS) {
KeyboardShortcut::Action action = gLiveSupport->findAction( KeyboardShortcut::Action action = gLiveSupport->findAction(
windowName, "playlistWindow",
Gdk::ModifierType(event->state), Gdk::ModifierType(event->state),
event->keyval); event->keyval);
switch (action) { switch (action) {
@ -827,7 +772,7 @@ SimplePlaylistManagementWindow :: onKeyPressed(GdkEventKey * event)
* Find (an iterator pointing to) the currently selected row. * Find (an iterator pointing to) the currently selected row.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: findCurrentItem(void) throw () PlaylistWindow :: findCurrentItem(void) throw ()
{ {
Glib::RefPtr<Gtk::TreeView::Selection> selection Glib::RefPtr<Gtk::TreeView::Selection> selection
= entriesView->get_selection(); = entriesView->get_selection();
@ -839,7 +784,7 @@ SimplePlaylistManagementWindow :: findCurrentItem(void) throw ()
* Select (highlight) the nth row. * Select (highlight) the nth row.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: selectRow(int rowNumber) throw () PlaylistWindow :: selectRow(int rowNumber) throw ()
{ {
Gtk::TreeModel::iterator iter = entriesModel->children().begin(); Gtk::TreeModel::iterator iter = entriesModel->children().begin();
for (; rowNumber > 0; --rowNumber) { for (; rowNumber > 0; --rowNumber) {
@ -857,7 +802,7 @@ SimplePlaylistManagementWindow :: selectRow(int rowNumber) throw ()
* Set the value of the isPlaylistModified variable. * Set the value of the isPlaylistModified variable.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SimplePlaylistManagementWindow :: setPlaylistModified(bool newValue) PlaylistWindow :: setPlaylistModified(bool newValue)
throw () throw ()
{ {
isPlaylistModified = newValue; isPlaylistModified = newValue;

View file

@ -26,8 +26,8 @@
Location : $URL$ Location : $URL$
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef SimplePlaylistManagementWindow_h #ifndef PlaylistWindow_h
#define SimplePlaylistManagementWindow_h #define PlaylistWindow_h
#ifndef __cplusplus #ifndef __cplusplus
#error This is a C++ include file #error This is a C++ include file
@ -41,17 +41,15 @@
#endif #endif
#include <string> #include <string>
#include <unicode/resbund.h> #include <unicode/resbund.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ZebraTreeView.h" #include "LiveSupport/Widgets/ZebraTreeView.h"
#include "LiveSupport/Widgets/DialogWindow.h" #include "BasicWindow.h"
#include "GuiWindow.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
@ -90,7 +88,7 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class SimplePlaylistManagementWindow : public GuiWindow class PlaylistWindow : public BasicWindow
{ {
private: private:
@ -119,24 +117,14 @@ class SimplePlaylistManagementWindow : public GuiWindow
Gtk::TreeIter currentItem; Gtk::TreeIter currentItem;
/** /**
* The label for the name entry. * The input text field for the name of the playlist.
*/ */
Gtk::Label * nameLabel; Gtk::Entry * nameEntry;
/**
* The test input entry for the name of the playlist.
*/
EntryBin * nameEntry;
/**
* A scrolled window, so that the entry list can be scrolled.
*/
Gtk::ScrolledWindow * entriesScrolledWindow;
/** /**
* The entry tree view, now only showing rows. * The entry tree view, now only showing rows.
*/ */
ZebraTreeView * entriesView; ZebraTreeView * entriesView;
/** /**
* The entry tree model, as a GTK reference. * The entry tree model, as a GTK reference.
@ -146,32 +134,23 @@ class SimplePlaylistManagementWindow : public GuiWindow
/** /**
* The label containing the length of the playlist. * The label containing the length of the playlist.
*/ */
Gtk::Label * lengthValueLabel; Gtk::Label * lengthValueLabel;
/**
* The save button.
*/
Button * saveButton;
/**
* The close button.
*/
Button * closeButton;
/** /**
* The status bar. * The status bar.
*/ */
Gtk::Label * statusBar; Gtk::Label * statusBar;
/** /**
* The "are you sure you want to exit?" dialog window. * The Save Button.
*/ */
Ptr<DialogWindow>::Ref dialogWindow; Gtk::Button * saveButton;
/** /**
* The right-click context menu that comes up when right-clicking * The right-click context menu that comes up when right-clicking
* a playlist element. * a playlist element.
*/ */
Gtk::Menu * rightClickMenu; Ptr<Gtk::Menu>::Ref rightClickMenu;
/** /**
* Find (an iterator pointing to) the currently selected row. * Find (an iterator pointing to) the currently selected row.
@ -255,6 +234,14 @@ class SimplePlaylistManagementWindow : public GuiWindow
void void
setPlaylistModified(bool newValue) throw (); setPlaylistModified(bool newValue) throw ();
/**
* Run the confirmation dialog.
*
* @return the response ID returned by the dialog.
*/
Gtk::ResponseType
runConfirmationDialog(void) throw ();
protected: protected:
@ -349,7 +336,7 @@ class SimplePlaylistManagementWindow : public GuiWindow
* @param event the button event recieved * @param event the button event recieved
*/ */
void void
onEntryClicked(GdkEventButton * event) throw (); onEntryClicked(GdkEventButton * event) throw ();
/** /**
* Signal handler for a key pressed at one of the entries. * Signal handler for a key pressed at one of the entries.
@ -403,6 +390,7 @@ class SimplePlaylistManagementWindow : public GuiWindow
public: public:
/** /**
* Constructor. * Constructor.
* *
@ -410,20 +398,21 @@ class SimplePlaylistManagementWindow : public GuiWindow
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
* @param windowOpenerButton the button which was pressed to open * @param windowOpenerButton the button which was pressed to open
* this window. * this window.
* @param gladeDir the directory where the glade file is.
*/ */
SimplePlaylistManagementWindow( PlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<ResourceBundle>::Ref bundle,
Ptr<ResourceBundle>::Ref bundle, Gtk::ToggleButton * windowOpenerButton,
Button * windowOpenerButton) const Glib::ustring & gladeDir)
throw (); throw ();
/** /**
* Virtual destructor. * Virtual destructor.
*/ */
virtual virtual
~SimplePlaylistManagementWindow(void) throw (); ~PlaylistWindow(void) throw ();
/** /**
* Show / update the contents of the playlist management window. * Show / update the contents of the playlist management window.
@ -455,5 +444,5 @@ class SimplePlaylistManagementWindow : public GuiWindow
} // namespace GLiveSupport } // namespace GLiveSupport
} // namespace LiveSupport } // namespace LiveSupport
#endif // SimplePlaylistManagementWindow_h #endif // PlaylistWindow_h

View file

@ -33,13 +33,11 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "RdsEntry.h" #include "RdsEntry.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -56,34 +54,21 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
RdsEntry :: RdsEntry(Ptr<ResourceBundle>::Ref bundle, RdsEntry :: RdsEntry(Ptr<ResourceBundle>::Ref bundle,
const Glib::ustring & type, Glib::RefPtr<Gnome::Glade::Xml> glade,
int width) int index,
const Glib::ustring & type,
int width)
throw () throw ()
: LocalizedObject(bundle) : LocalizedObject(bundle)
{ {
this->type.reset(new const Glib::ustring(type)); this->type.reset(new const Glib::ustring(type));
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); glade->get_widget(addIndex("rdsCheckButton", index), checkButton);
checkButton->set_label(*getResourceUstring(type + "rdsLabel"));
checkBox = Gtk::manage(new Gtk::CheckButton()); glade->get_widget(addIndex("rdsEntry", index), entry);
entry->set_width_chars(width);
Gtk::Label * label;
Glib::ustring labelKey = type + "rdsLabel";
try {
label = Gtk::manage(new Gtk::Label(*getResourceUstring(labelKey)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
entryBin = Gtk::manage(wf->createEntryBin());
// entryBin->? // set the size somehow
pack_start(*checkBox, Gtk::PACK_SHRINK, 5);
pack_start(*label, Gtk::PACK_SHRINK, 5);
pack_start(*entryBin, Gtk::PACK_EXPAND_WIDGET, 5);
} }
@ -94,11 +79,11 @@ void
RdsEntry :: setOptions(bool enabled, RdsEntry :: setOptions(bool enabled,
Ptr<const Glib::ustring>::Ref value) throw () Ptr<const Glib::ustring>::Ref value) throw ()
{ {
checkBox->set_active(enabled); checkButton->set_active(enabled);
entryBin->set_text(*value); entry->set_text(*value);
checkBoxSaved = enabled; checkButtonSaved = enabled;
entryBinSaved = value; entrySaved = value;
} }
@ -108,17 +93,17 @@ RdsEntry :: setOptions(bool enabled,
bool bool
RdsEntry :: saveChanges(Ptr<GLiveSupport>::Ref gLiveSupport) throw () RdsEntry :: saveChanges(Ptr<GLiveSupport>::Ref gLiveSupport) throw ()
{ {
bool checkBoxNow = checkBox->get_active(); bool checkButtonNow = checkButton->get_active();
Ptr<const Glib::ustring>::Ref Ptr<const Glib::ustring>::Ref
entryBinNow(new const Glib::ustring(entryBin->get_text())); entryNow(new const Glib::ustring(entry->get_text()));
if (!entryBinSaved || checkBoxNow != checkBoxSaved if (!entrySaved || checkButtonNow != checkButtonSaved
|| *entryBinNow != *entryBinSaved) { || *entryNow != *entrySaved) {
Ptr<OptionsContainer>::Ref optionsContainer = Ptr<OptionsContainer>::Ref optionsContainer =
gLiveSupport->getOptionsContainer(); gLiveSupport->getOptionsContainer();
optionsContainer->setRdsOptions(type, entryBinNow, checkBoxNow); optionsContainer->setRdsOptions(type, entryNow, checkButtonNow);
checkBoxSaved = checkBoxNow; checkButtonSaved = checkButtonNow;
entryBinSaved = entryBinNow; entrySaved = entryNow;
return true; return true;
} else { } else {
return false; return false;

View file

@ -40,12 +40,12 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/box.h> #include <gtkmm.h>
#include <gtkmm/checkbutton.h> #include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/EntryBin.h" #include "LiveSupport/Core/NumericTools.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -53,7 +53,6 @@ namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* ================================================================ constants */ /* ================================================================ constants */
@ -70,39 +69,42 @@ using namespace LiveSupport::GLiveSupport;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class RdsEntry : public Gtk::HBox, class RdsEntry : public LocalizedObject,
public LocalizedObject private NumericTools
{ {
private: private:
/** /**
* The RDS type of the object (PS, PI, RT, etc). * The RDS type of the object (PS, PI, RT, etc).
*/ */
Ptr<const Glib::ustring>::Ref type; Ptr<const Glib::ustring>::Ref type;
/** /**
* The saved state of the checkbox. * The saved state of the check button.
*/ */
bool checkBoxSaved; bool checkButtonSaved;
/** /**
* The saved contents of the entry bin. * The saved contents of the entry.
*/ */
Ptr<const Glib::ustring>::Ref entryBinSaved; Ptr<const Glib::ustring>::Ref entrySaved;
protected: protected:
/** /**
* The enable/disable checkbox. * The enable/disable checkbox.
*/ */
Gtk::CheckButton * checkBox; Gtk::CheckButton * checkButton;
/** /**
* The entry field. * The entry field.
*/ */
EntryBin * entryBin; Gtk::Entry * entry;
public: public:
/** /**
* Constructor. * Constructor.
* The type parameter is a string of 2 or 3 upper-case characters, * The type parameter is a string of 2 or 3 upper-case characters,
@ -110,12 +112,18 @@ class RdsEntry : public Gtk::HBox,
* *
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param index the position of this item in the list of
* RDS entries.
* @param type the type of RDS data (PS, PI, RT, etc). * @param type the type of RDS data (PS, PI, RT, etc).
* @param width the width of the entry, in characters. * @param width the width of the entry, in characters.
*/ */
RdsEntry(Ptr<ResourceBundle>::Ref bundle, RdsEntry(Ptr<ResourceBundle>::Ref bundle,
const Glib::ustring & type, Glib::RefPtr<Gnome::Glade::Xml> glade,
int width) throw (); int index,
const Glib::ustring & type,
int width) throw ();
/** /**
* A virtual destructor. * A virtual destructor.

View file

@ -37,7 +37,6 @@
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -54,38 +53,27 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
RdsView :: RdsView (Ptr<GLiveSupport>::Ref gLiveSupport, RdsView :: RdsView (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: LocalizedObject(bundle), : gLiveSupport(gLiveSupport)
gLiveSupport(gLiveSupport)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle("rdsView");
Gtk::Label * deviceLabel; setBundle(bundle);
try {
deviceLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
"deviceLabel" )));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
deviceEntryBin = Gtk::manage(wf->createEntryBin());
Gtk::Box * deviceBox = Gtk::manage(new Gtk::HBox());
deviceBox->pack_start(*deviceLabel, Gtk::PACK_SHRINK, 5);
deviceBox->pack_start(*deviceEntryBin, Gtk::PACK_EXPAND_WIDGET, 5);
Ptr<RdsEntry>::Ref psEntry(new RdsEntry(getBundle(), "PS", 8)); Gtk::Label * deviceLabel;
Ptr<RdsEntry>::Ref piEntry(new RdsEntry(getBundle(), "PI", 4)); glade->get_widget("rdsDeviceLabel1", deviceLabel);
Ptr<RdsEntry>::Ref rtEntry(new RdsEntry(getBundle(), "RT", 32)); deviceLabel->set_label(*getResourceUstring("deviceLabel"));
glade->get_widget("rdsDeviceEntry1", deviceEntry);
Ptr<RdsEntry>::Ref psEntry(new RdsEntry(getBundle(), glade, 0, "PS", 8));
Ptr<RdsEntry>::Ref piEntry(new RdsEntry(getBundle(), glade, 1, "PI", 4));
Ptr<RdsEntry>::Ref rtEntry(new RdsEntry(getBundle(), glade, 2, "RT", 32));
rdsEntryList.push_back(psEntry); rdsEntryList.push_back(psEntry);
rdsEntryList.push_back(piEntry); rdsEntryList.push_back(piEntry);
rdsEntryList.push_back(rtEntry); rdsEntryList.push_back(rtEntry);
pack_start(*deviceBox, Gtk::PACK_SHRINK, 5);
pack_start(*psEntry, Gtk::PACK_SHRINK, 5);
pack_start(*piEntry, Gtk::PACK_SHRINK, 5);
pack_start(*rtEntry, Gtk::PACK_SHRINK, 5);
reset(); reset();
} }
@ -103,7 +91,7 @@ RdsView :: saveChanges(void) throw ()
Ptr<const Glib::ustring>::Ref oldDevice = options->getOptionItem( Ptr<const Glib::ustring>::Ref oldDevice = options->getOptionItem(
OptionsContainer::serialDeviceName); OptionsContainer::serialDeviceName);
Ptr<const Glib::ustring>::Ref newDevice(new const Glib::ustring( Ptr<const Glib::ustring>::Ref newDevice(new const Glib::ustring(
deviceEntryBin->get_text() )); deviceEntry->get_text() ));
if (*oldDevice != *newDevice) { if (*oldDevice != *newDevice) {
options->setOptionItem(OptionsContainer::serialDeviceName, newDevice); options->setOptionItem(OptionsContainer::serialDeviceName, newDevice);
touched = true; touched = true;
@ -126,7 +114,7 @@ void
RdsView :: reset(void) throw () RdsView :: reset(void) throw ()
{ {
Ptr<OptionsContainer>::Ref options = gLiveSupport->getOptionsContainer(); Ptr<OptionsContainer>::Ref options = gLiveSupport->getOptionsContainer();
deviceEntryBin->set_text(*options->getOptionItem( deviceEntry->set_text(*options->getOptionItem(
OptionsContainer::serialDeviceName)); OptionsContainer::serialDeviceName));
RdsEntryListType::const_iterator it; RdsEntryListType::const_iterator it;

View file

@ -40,13 +40,12 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <gtkmm/box.h> #include <gtkmm.h>
#include <libglademm.h>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ScrolledWindow.h"
#include "RdsEntry.h" #include "RdsEntry.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -54,7 +53,6 @@ namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -90,10 +88,10 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class RdsView : public Gtk::VBox, class RdsView : public LocalizedObject
public LocalizedObject
{ {
private: private:
/** /**
* The type for the list of entry widgets. * The type for the list of entry widgets.
*/ */
@ -114,6 +112,7 @@ class RdsView : public Gtk::VBox,
protected: protected:
/** /**
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
*/ */
@ -122,7 +121,7 @@ class RdsView : public Gtk::VBox,
/** /**
* The entry field for the serial device. * The entry field for the serial device.
*/ */
EntryBin * deviceEntryBin; Gtk::Entry * deviceEntry;
public: public:
@ -131,11 +130,11 @@ class RdsView : public Gtk::VBox,
* *
* @param gLiveSupport the gLiveSupport object, containing * @param gLiveSupport the gLiveSupport object, containing
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param glade the Glade file which specifies the visual
* resources for this window. * components for this class.
*/ */
RdsView(Ptr<GLiveSupport>::Ref gLiveSupport, RdsView(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Glib::RefPtr<Gnome::Glade::Xml> glade)
throw (); throw ();
/** /**

View file

@ -29,10 +29,13 @@
/* ============================================================ include files */ /* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "RestoreBackupWindow.h" #include "RestoreBackupWindow.h"
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -58,66 +61,34 @@ const unsigned int timerInterval = 10000;
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
RestoreBackupWindow :: RestoreBackupWindow ( RestoreBackupWindow :: RestoreBackupWindow (
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Glib::RefPtr<Gnome::Glade::Xml> glade,
Ptr<const Glib::ustring>::Ref fileName) Ptr<const Glib::ustring>::Ref fileName)
throw () throw ()
: GuiWindow(gLiveSupport, : gLiveSupport(gLiveSupport),
bundle),
fileName(fileName), fileName(fileName),
currentState(AsyncState::pendingState) currentState(AsyncState::pendingState)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
"restoreBackupWindow");
setBundle(bundle);
messageLabel = Gtk::manage(new Gtk::Label()); glade->get_widget("restoreBackupWindow1", mainWindow);
try { mainWindow->set_title(*getResourceUstring("windowTitle"));
set_title(*getResourceUstring("windowTitle"));
cancelButton = Gtk::manage(wf->createButton( Gtk::Button * cancelButton;
*gLiveSupport->getResourceUstring( glade->get_widget("restoreBackupMessageLabel1", messageLabel);
"cancelButtonLabel"))); glade->get_widget("restoreBackupCancelButton1", cancelButton);
okButton = Gtk::manage(wf->createButton( glade->get_widget("restoreBackupOkButton1", okButton);
*gLiveSupport->getResourceUstring(
"okButtonLabel")));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
// pack the widgets mainWindow->signal_delete_event().connect(sigc::mem_fun(*this,
Gtk::Box * messageBox = Gtk::manage(new Gtk::HBox()); &RestoreBackupWindow::onDeleteEvent));
messageBox->pack_start(*messageLabel, Gtk::PACK_EXPAND_WIDGET, 10); cancelButton->signal_clicked().connect(sigc::mem_fun(*this,
Gtk::ButtonBox * buttonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_END, 5));
buttonBox->pack_start(*cancelButton);
buttonBox->pack_start(*okButton);
Gtk::Box * layout = Gtk::manage(new Gtk::VBox());
layout->pack_start(*messageBox, Gtk::PACK_EXPAND_PADDING, 10);
layout->pack_start(*buttonBox, Gtk::PACK_SHRINK, 0);
add(*layout);
// set widget properties
messageLabel->set_justify(Gtk::JUSTIFY_CENTER);
okButton->set_sensitive(false);
//connect callbacks
cancelButton->signal_clicked().connect(sigc::mem_fun(
*this,
&RestoreBackupWindow::onCancelButtonClicked)); &RestoreBackupWindow::onCancelButtonClicked));
okButton->signal_clicked().connect(sigc::mem_fun( okButton->signal_clicked().connect(sigc::mem_fun(*this,
*this,
&RestoreBackupWindow::onOkButtonClicked)); &RestoreBackupWindow::onOkButtonClicked));
// start the restore backup operation
restoreBackupOpen(); restoreBackupOpen();
// set name, size, etc. and show the widgets (not the window itself yet)
set_name("restoreBackupWindow");
show_all_children();
} }
@ -149,12 +120,7 @@ inline void
RestoreBackupWindow :: displayMessage(const Glib::ustring & messageKey) RestoreBackupWindow :: displayMessage(const Glib::ustring & messageKey)
throw () throw ()
{ {
try { setLabelText(*getResourceUstring(messageKey));
setLabelText(*getResourceUstring(messageKey));
} catch (std::invalid_argument &e) {
messageLabel->set_text(e.what());
}
} }
@ -166,12 +132,7 @@ RestoreBackupWindow :: displayMessage(const Glib::ustring & messageKey,
const Glib::ustring & argument) const Glib::ustring & argument)
throw () throw ()
{ {
try { setLabelText(*formatMessage(messageKey, argument));
setLabelText(*formatMessage(messageKey, argument));
} catch (std::invalid_argument &e) {
messageLabel->set_text(e.what());
}
} }
@ -220,7 +181,6 @@ RestoreBackupWindow :: restoreBackupCheck(void) throw ()
{ {
Ptr<StorageClientInterface>::Ref Ptr<StorageClientInterface>::Ref
storage = gLiveSupport->getStorageClient(); storage = gLiveSupport->getStorageClient();
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
Ptr<const Glib::ustring>::Ref errorMessage; Ptr<const Glib::ustring>::Ref errorMessage;
try { try {
@ -252,7 +212,6 @@ RestoreBackupWindow :: restoreBackupClose(void) throw ()
if (token) { if (token) {
Ptr<StorageClientInterface>::Ref Ptr<StorageClientInterface>::Ref
storage = gLiveSupport->getStorageClient(); storage = gLiveSupport->getStorageClient();
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
try { try {
storage->restoreBackupClose(*token); storage->restoreBackupClose(*token);
@ -307,12 +266,33 @@ RestoreBackupWindow :: resetTimer(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Detach the timer when the window is hidden. * Show the window.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
RestoreBackupWindow :: on_hide(void) throw () RestoreBackupWindow :: show(void) throw ()
{ {
restoreBackupClose(); mainWindow->show();
GuiWindow::on_hide(); }
/*------------------------------------------------------------------------------
* Close the connection and hide the window.
*----------------------------------------------------------------------------*/
void
RestoreBackupWindow :: hide(void) throw ()
{
restoreBackupClose();
mainWindow->hide();
}
/*------------------------------------------------------------------------------
* Event handler for closing the window from the window manager.
*----------------------------------------------------------------------------*/
bool
RestoreBackupWindow :: onDeleteEvent(GdkEventAny * event) throw ()
{
restoreBackupClose();
return false;
} }

View file

@ -40,17 +40,20 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <unicode/resbund.h>
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/StorageClient/StorageClientInterface.h" #include "LiveSupport/StorageClient/StorageClientInterface.h"
#include "LiveSupport/Widgets/Button.h" #include "GLiveSupport.h"
#include "GuiWindow.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::StorageClient; using namespace LiveSupport::StorageClient;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -66,23 +69,29 @@ using namespace LiveSupport::Widgets;
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision$ * @version $Revision$
*/ */
class RestoreBackupWindow : public GuiWindow class RestoreBackupWindow : public LocalizedObject
{ {
private: private:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The main window for this class.
*/
Gtk::Window * mainWindow;
/** /**
* The label holding the current message displayed by the window. * The label holding the current message displayed by the window.
*/ */
Gtk::Label * messageLabel; Gtk::Label * messageLabel;
/**
* The cancel button.
*/
Button * cancelButton;
/** /**
* The OK button. * The OK button.
*/ */
Button * okButton; Gtk::Button * okButton;
/** /**
* The file name of the backup file to be uploaded. * The file name of the backup file to be uploaded.
@ -106,6 +115,7 @@ class RestoreBackupWindow : public GuiWindow
protected: protected:
/** /**
* Event handler for the cancel button being clicked. * Event handler for the cancel button being clicked.
*/ */
@ -118,6 +128,12 @@ class RestoreBackupWindow : public GuiWindow
virtual void virtual void
onOkButtonClicked(void) throw (); onOkButtonClicked(void) throw ();
/**
* Event handler for closing the window from the window manager.
*/
virtual bool
onDeleteEvent(GdkEventAny * event) throw ();
/** /**
* Set the text of the label. * Set the text of the label.
* *
@ -197,32 +213,22 @@ class RestoreBackupWindow : public GuiWindow
*/ */
virtual void virtual void
resetTimer(void) throw (); resetTimer(void) throw ();
/**
* Hide the window.
*
* This overrides GuiWindow::on_hide(), and adds a call to
* restoreBackupClose() before calling the parent GuiWindow's
* on_hide() function.
*/
virtual void
on_hide(void) throw ();
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param gLiveSupport the gLiveSupport object, containing * @param gLiveSupport the gLiveSupport object, containing
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param glade the Glade object, which contains the
* resources for this window. * visual design.
* @param windowOpenerButton the button which was pressed to open * @param fileName the file name of the backup to be restored.
* this window.
*/ */
RestoreBackupWindow(Ptr<GLiveSupport>::Ref gLiveSupport, RestoreBackupWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Glib::RefPtr<Gnome::Glade::Xml> glade,
Ptr<const Glib::ustring>::Ref fileName) Ptr<const Glib::ustring>::Ref fileName)
throw (); throw ();
/** /**
@ -233,6 +239,17 @@ class RestoreBackupWindow : public GuiWindow
{ {
} }
/**
* Show the window.
*/
virtual void
show(void) throw ();
/**
* Close the connection and hide the window.
*/
virtual void
hide(void) throw ();
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -33,17 +33,14 @@
#include "configure.h" #include "configure.h"
#endif #endif
#include <iostream> #include <boost/date_time/gregorian/gregorian.hpp>
#include <stdexcept> #include "boost/date_time/posix_time/posix_time.hpp"
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "SchedulePlaylistWindow.h" #include "SchedulePlaylistWindow.h"
using namespace boost;
using namespace Glib;
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
@ -52,6 +49,14 @@ using namespace LiveSupport::GLiveSupport;
/* ================================================ local constants & macros */ /* ================================================ local constants & macros */
namespace {
/*------------------------------------------------------------------------------
* The name of the glade file.
*----------------------------------------------------------------------------*/
const Glib::ustring gladeFileName = "SchedulePlaylistWindow.glade";
}
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -63,69 +68,51 @@ using namespace LiveSupport::GLiveSupport;
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
SchedulePlaylistWindow :: SchedulePlaylistWindow ( SchedulePlaylistWindow :: SchedulePlaylistWindow (
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, const Glib::ustring & gladeDir,
Ptr<Playlist>::Ref playlist) Ptr<Playlist>::Ref playlist)
throw () throw ()
: GuiWindow(gLiveSupport, : gLiveSupport(gLiveSupport),
bundle),
playlist(playlist) playlist(playlist)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
"schedulePlaylistWindow");
setBundle(bundle);
try { glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
set_title(*getResourceUstring("windowTitle"));
hourLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
"hourLabel")));
minuteLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
"minuteLabel")));
secondLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
"secondLabel")));
scheduleButton = Gtk::manage(wf->createButton(
*getResourceUstring("scheduleButtonLabel")));
closeButton = Gtk::manage(wf->createButton(
*getResourceUstring("closeButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
playlistLabel = Gtk::manage(new Gtk::Label(*playlist->getTitle())); glade->get_widget("mainWindow1", mainWindow);
calendar = Gtk::manage(new Gtk::Calendar()); mainWindow->set_title(*getResourceUstring("windowTitle"));
hourEntry = Gtk::manage(wf->createNumericComboBoxText(0, 23));
minuteEntry = Gtk::manage(wf->createNumericComboBoxText(0, 59, 2));
secondEntry = Gtk::manage(wf->createNumericComboBoxText(0, 59, 2));
layout = Gtk::manage(new Gtk::Table()); Gtk::Label * playlistLabel;
glade->get_widget("playlistLabel1", playlistLabel);
playlistLabel->set_label(*playlist->getTitle());
layout->attach(*playlistLabel, 0, 6, 0, 1); Gtk::Label * hourLabel;
layout->attach(*calendar, 0, 6, 1, 2); Gtk::Label * minuteLabel;
layout->attach(*hourLabel, 0, 1, 2, 3); Gtk::Label * secondLabel;
layout->attach(*hourEntry, 1, 2, 2, 3); glade->get_widget("hourLabel1", hourLabel);
layout->attach(*minuteLabel, 2, 3, 2, 3); glade->get_widget("minuteLabel1", minuteLabel);
layout->attach(*minuteEntry, 3, 4, 2, 3); glade->get_widget("secondLabel1", secondLabel);
layout->attach(*secondLabel, 4, 5, 2, 3); hourLabel->set_label(*getResourceUstring("hourLabel"));
layout->attach(*secondEntry, 5, 6, 2, 3); hourLabel->set_label(*getResourceUstring("minuteLabel"));
layout->attach(*scheduleButton, 4, 6, 3, 4); hourLabel->set_label(*getResourceUstring("secondLabel"));
layout->attach(*closeButton , 4, 6, 4, 5);
// register the signal handler for the schedule getting clicked. glade->get_widget("calendar1", calendar);
glade->get_widget("hourSpinButton1", hourEntry);
glade->get_widget("minuteSpinButton1", minuteEntry);
glade->get_widget("secondSpinButton1", secondEntry);
Ptr<boost::posix_time::ptime>::Ref now = TimeConversion::now();
boost::posix_time::time_duration time = now->time_of_day();
hourEntry->set_value(time.hours());
minuteEntry->set_value(time.minutes() + 1);
secondEntry->set_value(0);
Gtk::Button * scheduleButton;
glade->get_widget("scheduleButton1", scheduleButton);
scheduleButton->set_label(*getResourceUstring("scheduleButtonLabel"));
scheduleButton->signal_clicked().connect(sigc::mem_fun(*this, scheduleButton->signal_clicked().connect(sigc::mem_fun(*this,
&SchedulePlaylistWindow::onScheduleButtonClicked)); &SchedulePlaylistWindow::onScheduleButtonClicked));
// register the signal handler for the button getting clicked.
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&SchedulePlaylistWindow::onCloseButtonClicked));
add(*layout);
show_all_children();
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
SchedulePlaylistWindow :: ~SchedulePlaylistWindow (void) throw ()
{
} }
@ -135,53 +122,33 @@ SchedulePlaylistWindow :: ~SchedulePlaylistWindow (void) throw ()
void void
SchedulePlaylistWindow :: onScheduleButtonClicked (void) throw () SchedulePlaylistWindow :: onScheduleButtonClicked (void) throw ()
{ {
// get the date from the calendar unsigned int year;
guint year; unsigned int month;
guint month; unsigned int day;
guint day;
calendar->get_date(year, month, day); calendar->get_date(year, month, day);
++month; // Gtk+ months are 0-based, Boost months are 1-based
// get the hour and minute from the entries int hours = hourEntry->get_value_as_int();
// and construct an HH:MM:00.00 string from it int minutes = minuteEntry->get_value_as_int();
Ptr<std::string>::Ref timeStr(new std::string( int seconds = secondEntry->get_value_as_int();
hourEntry->get_active_text()));
*timeStr += ":"; Ptr<boost::posix_time::ptime>::Ref dateTime(new boost::posix_time::ptime(
Glib::ustring minutes = minuteEntry->get_active_text(); boost::gregorian::date(year,
if (minutes == "") { month,
minutes = "00"; day),
} boost::posix_time::time_duration(
*timeStr += minutes; hours,
*timeStr += ":"; minutes,
Glib::ustring seconds = secondEntry->get_active_text(); seconds) ));
if (seconds == "") {
seconds = "00";
}
*timeStr += seconds;
*timeStr += ".00";
Ptr<posix_time::ptime>::Ref selectedTime;
try { try {
gregorian::date date(year, month+1, day); gLiveSupport->schedulePlaylist(playlist, dateTime);
Ptr<posix_time::time_duration>::Ref
time = TimeConversion::parseTimeDuration(timeStr);
selectedTime.reset(new posix_time::ptime(date, *time));
} catch (std::exception &e) {
// most probably duration_from_string failed
// TODO: notify user
std::cerr << "date format problem: " << e.what() << std::endl;
return;
}
try {
gLiveSupport->schedulePlaylist(playlist, selectedTime);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
// TODO: notify user // TODO: notify user
std::cerr << "scheduling problem: " << e.what() << std::endl; std::cerr << "scheduling problem: " << e.what() << std::endl;
return; return;
} }
hide(); mainWindow->hide();
} }

View file

@ -41,20 +41,15 @@
#endif #endif
#include <string> #include <string>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <unicode/resbund.h> #include <unicode/resbund.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/EntryBin.h"
#include "LiveSupport/Widgets/Button.h"
#include "GuiWindow.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
@ -89,90 +84,72 @@ using namespace LiveSupport::Core;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class SchedulePlaylistWindow : public GuiWindow class SchedulePlaylistWindow : public LocalizedObject
{ {
private:
protected: /**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The Glade object, containing the visual design.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* The main window for this class.
*/
Gtk::Window * mainWindow;
/** /**
* The playlist to schedule. * The playlist to schedule.
*/ */
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
/**
* The main container in the window.
*/
Gtk::Table * layout;
/**
* The label displaying the name of the playlist to schedule.
*/
Gtk::Label * playlistLabel;
/** /**
* The calendar to select a specific date from. * The calendar to select a specific date from.
*/ */
Gtk::Calendar * calendar; Gtk::Calendar * calendar;
/** /**
* The hour label. * The entry field for hours.
*/ */
Gtk::Label * hourLabel; Gtk::SpinButton * hourEntry;
/** /**
* The entry field for hour. * The entry field for minutes.
*/ */
ComboBoxText * hourEntry; Gtk::SpinButton * minuteEntry;
/** /**
* The minute label. * The entry field for seconds.
*/ */
Gtk::Label * minuteLabel; Gtk::SpinButton * secondEntry;
protected:
/** /**
* The minute entry field. * Event handler for the schedule button clicked.
*/
ComboBoxText * minuteEntry;
/**
* The second label.
*/
Gtk::Label * secondLabel;
/**
* The second entry field.
*/
ComboBoxText * secondEntry;
/**
* The schedule button.
*/
Button * scheduleButton;
/**
* The close button.
*/
Button * closeButton;
/**
* Signal handler for the schedule button clicked.
*/ */
virtual void virtual void
onScheduleButtonClicked(void) throw (); onScheduleButtonClicked(void) throw ();
public: public:
/** /**
* Constructor. * Constructor.
* *
* @param gLiveSupport the gLiveSupport object, containing * @param gLiveSupport the gLiveSupport object, containing
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param gladeDir the directory where the Glade files are.
* resources for this window.
* @param playlist the playlist to schedule. * @param playlist the playlist to schedule.
*/ */
SchedulePlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport, SchedulePlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, const Glib::ustring & gladeDir,
Ptr<Playlist>::Ref playlist) Ptr<Playlist>::Ref playlist)
throw (); throw ();
@ -180,8 +157,18 @@ class SchedulePlaylistWindow : public GuiWindow
* Virtual destructor. * Virtual destructor.
*/ */
virtual virtual
~SchedulePlaylistWindow(void) throw (); ~SchedulePlaylistWindow(void) throw ()
{
}
/**
* Get the underlying Gtk::Window.
*/
virtual Gtk::Window *
getWindow(void) throw ()
{
return mainWindow;
}
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -37,7 +37,6 @@
#include <stdexcept> #include <stdexcept>
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Widgets/ScrolledNotebook.h"
#include "SchedulerWindow.h" #include "SchedulerWindow.h"
@ -54,10 +53,10 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/** /*------------------------------------------------------------------------------
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc). * The name of the glade file.
*/ *----------------------------------------------------------------------------*/
const Glib::ustring windowName = "schedulerWindow"; const Glib::ustring gladeFileName = "SchedulerWindow.glade";
} }
@ -72,63 +71,28 @@ const Glib::ustring windowName = "schedulerWindow";
SchedulerWindow :: SchedulerWindow ( SchedulerWindow :: SchedulerWindow (
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw (XmlRpcException) throw (XmlRpcException)
: GuiWindow(gLiveSupport, : BasicWindow(gLiveSupport,
bundle, bundle,
windowOpenerButton) windowOpenerButton,
gladeDir + gladeFileName)
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); constructScheduleView();
constructStatusView();
Gtk::Box * scheduleView = constructScheduleView(); Gtk::Label * scheduleTabLabel;
Gtk::Box * statusView = constructStatusView(); Gtk::Label * statusTabLabel;
glade->get_widget("scheduleTabLabel1", scheduleTabLabel);
glade->get_widget("statusTabLabel1", statusTabLabel);
scheduleTabLabel->set_label(*getResourceUstring("scheduleTab"));
statusTabLabel->set_label(*getResourceUstring("statusTab"));
ScrolledNotebook * notebook = Gtk::manage(new ScrolledNotebook); glade->connect_clicked("closeButton1", sigc::mem_fun(*this,
try { &SchedulerWindow::hide));
set_title(*getResourceUstring("windowTitle"));
closeButton = Gtk::manage(wf->createButton(*getResourceUstring(
"closeButtonLabel")));
notebook->appendPage(*scheduleView, *getResourceUstring(
"scheduleTab"));
notebook->appendPage(*statusView, *getResourceUstring(
"statusTab"));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&SchedulerWindow::onCloseButtonClicked));
Gtk::ButtonBox * bottomButtonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_END, 5));
bottomButtonBox->pack_start(*closeButton);
Gtk::VBox * bigBox = Gtk::manage(new Gtk::VBox);
bigBox->pack_start(*notebook, Gtk::PACK_EXPAND_WIDGET);
bigBox->pack_start(*bottomButtonBox, Gtk::PACK_SHRINK, 5);
add(*bigBox);
set_name(windowName);
set_default_size(330, 400);
showContents(); showContents();
show_all_children();
// set up the dialog window
Ptr<Glib::ustring>::Ref confirmationMessage;
try {
confirmationMessage.reset(new Glib::ustring(
*getResourceUstring("stopCurrentlyPlayingDialogMsg") ));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
dialogWindow.reset(new DialogWindow(confirmationMessage,
DialogWindow::noButton |
DialogWindow::yesButton,
gLiveSupport->getBundle() ));
} }
@ -143,56 +107,38 @@ SchedulerWindow :: ~SchedulerWindow (void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the Schedule view. * Construct the Schedule view.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox * void
SchedulerWindow :: constructScheduleView(void) throw () SchedulerWindow :: constructScheduleView(void) throw ()
{ {
calendar = Gtk::manage(new Gtk::Calendar()); glade->get_widget("calendar1", calendar);
dateLabel = Gtk::manage(new Gtk::Label()); glade->get_widget("dateLabel1", dateLabel);
// create the tree view for the entries // create the tree view for the entries
entryColumns.reset(new ModelColumns()); entriesModel = Gtk::ListStore::create(entryColumns);
entriesModel = Gtk::ListStore::create(*entryColumns); glade->get_widget_derived("entriesTreeView1", entriesTreeView);
entriesView = Gtk::manage(new Gtk::TreeView()); entriesTreeView->set_model(entriesModel);
entriesView->set_model(entriesModel); entriesTreeView->connectModelSignals(entriesModel);
// Add the TreeView's view columns: entriesTreeView->append_column(*getResourceUstring("startColumnLabel"),
try { entryColumns.startColumn);
entriesView->append_column(*getResourceUstring("startColumnLabel"), entriesTreeView->append_column(*getResourceUstring("titleColumnLabel"),
entryColumns->startColumn); entryColumns.titleColumn);
entriesView->append_column(*getResourceUstring("titleColumnLabel"), entriesTreeView->append_column(*getResourceUstring("endColumnLabel"),
entryColumns->titleColumn); entryColumns.endColumn);
entriesView->append_column(*getResourceUstring("endColumnLabel"),
entryColumns->endColumn);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// register the signal handler for entries view entries being clicked // register the signal handler for entries view entries being clicked
entriesView->signal_button_press_event().connect_notify(sigc::mem_fun(*this, entriesTreeView->signal_button_press_event().connect_notify(
&SchedulerWindow::onEntryClicked)); sigc::mem_fun(*this,
&SchedulerWindow::onEntryClicked));
// create the right-click entry context menu for audio clips // create the right-click entry context menu
entryMenu = Gtk::manage(new Gtk::Menu()); entryMenu.reset(new Gtk::Menu());
Gtk::Menu::MenuList& menuList = entryMenu->items(); Gtk::Menu::MenuList& menuList = entryMenu->items();
// register the signal handlers for the popup menu menuList.push_back(Gtk::Menu_Helpers::MenuElem(
try { *getResourceUstring("deleteMenuItem"),
menuList.push_back(Gtk::Menu_Helpers::MenuElem( sigc::mem_fun(*this,
*getResourceUstring("deleteMenuItem"), &SchedulerWindow::onDeleteItem)));
sigc::mem_fun(*this, entryMenu->accelerate(*mainWindow);
&SchedulerWindow::onDeleteItem)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
entryMenu->accelerate(*this);
layout = Gtk::manage(new Gtk::Table());
layout->attach(*calendar, 0, 1, 0, 1);
layout->attach(*dateLabel, 0, 1, 1, 2);
layout->attach(*entriesView, 0, 1, 2, 3);
// register the signal handle for when a date is selected in the calendar // register the signal handle for when a date is selected in the calendar
calendar->signal_day_selected().connect(sigc::mem_fun(*this, calendar->signal_day_selected().connect(sigc::mem_fun(*this,
@ -200,48 +146,26 @@ SchedulerWindow :: constructScheduleView(void) throw ()
// initialize the selected date for today // initialize the selected date for today
selectedDate.reset(new gregorian::date(TimeConversion::now()->date())); selectedDate.reset(new gregorian::date(TimeConversion::now()->date()));
// make a new box and pack the main components into it
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*layout, Gtk::PACK_SHRINK);
return view;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the Status view. * Construct the Status view.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox * void
SchedulerWindow :: constructStatusView(void) throw () SchedulerWindow :: constructStatusView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
Gtk::Label * stopCurrentlyPlayingLabel; Gtk::Label * stopCurrentlyPlayingLabel;
Button * stopCurrentlyPlayingButton; Gtk::Button * stopCurrentlyPlayingButton;
try { glade->get_widget("stopCurrentlyPlayingLabel1", stopCurrentlyPlayingLabel);
stopCurrentlyPlayingLabel = Gtk::manage(new Gtk::Label( glade->get_widget("stopCurrentlyPlayingButton1",
*getResourceUstring("stopCurrentlyPlayingText"))); stopCurrentlyPlayingButton);
stopCurrentlyPlayingButton = Gtk::manage(wf->createButton( stopCurrentlyPlayingLabel->set_label(
*getResourceUstring("stopCurrentlyPlayingButtonLabel"))); *getResourceUstring("stopCurrentlyPlayingText"));
} catch (std::invalid_argument &e) { stopCurrentlyPlayingButton->set_label(
std::cerr << e.what() << std::endl; *getResourceUstring("stopCurrentlyPlayingButtonLabel"));
std::exit(1); stopCurrentlyPlayingButton->signal_clicked().connect(sigc::mem_fun(*this,
}
stopCurrentlyPlayingButton->signal_clicked().connect(sigc::mem_fun(
*this,
&SchedulerWindow::onStopCurrentlyPlayingButtonClicked)); &SchedulerWindow::onStopCurrentlyPlayingButtonClicked));
Gtk::HBox * stopCurrentlyPlayingBox = Gtk::manage(new Gtk::HBox);
stopCurrentlyPlayingBox->pack_start(*stopCurrentlyPlayingLabel,
Gtk::PACK_SHRINK, 5);
stopCurrentlyPlayingBox->pack_start(*stopCurrentlyPlayingButton,
Gtk::PACK_SHRINK, 5);
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*stopCurrentlyPlayingBox, Gtk::PACK_SHRINK, 20);
return view;
} }
@ -329,11 +253,11 @@ SchedulerWindow :: showContents(void) throw (XmlRpcException)
Gtk::TreeModel::Row row = *(entriesModel->append()); Gtk::TreeModel::Row row = *(entriesModel->append());
row[entryColumns->idColumn] = entry->getId(); row[entryColumns.idColumn] = entry->getId();
row[entryColumns->startColumn] = row[entryColumns.startColumn] =
to_simple_string(*entry->getStartTime()); to_simple_string(*entry->getStartTime());
row[entryColumns->titleColumn] = *playlist->getTitle(); row[entryColumns.titleColumn] = *playlist->getTitle();
row[entryColumns->endColumn] = to_simple_string(*entry->getEndTime()); row[entryColumns.endColumn] = to_simple_string(*entry->getEndTime());
++it; ++it;
} }
@ -349,7 +273,7 @@ SchedulerWindow :: onEntryClicked (GdkEventButton * event) throw ()
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
// only show the context menu, if something is already selected // only show the context menu, if something is already selected
Glib::RefPtr<Gtk::TreeView::Selection> refSelection = Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
entriesView->get_selection(); entriesTreeView->get_selection();
if (refSelection) { if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected(); Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) { if (iter) {
@ -367,12 +291,12 @@ void
SchedulerWindow :: onDeleteItem(void) throw () SchedulerWindow :: onDeleteItem(void) throw ()
{ {
Glib::RefPtr<Gtk::TreeView::Selection> refSelection = Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
entriesView->get_selection(); entriesTreeView->get_selection();
if (refSelection) { if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected(); Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) { if (iter) {
Ptr<const UniqueId>::Ref entryId = (*iter)[entryColumns->idColumn]; Ptr<const UniqueId>::Ref entryId = (*iter)[entryColumns.idColumn];
try { try {
gLiveSupport->removeFromSchedule(entryId); gLiveSupport->removeFromSchedule(entryId);
@ -396,16 +320,18 @@ SchedulerWindow :: onDeleteItem(void) throw ()
void void
SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw () SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw ()
{ {
DialogWindow::ButtonType result = dialogWindow->run(); Gtk::ResponseType result = runConfirmationDialog();
switch (result) { switch (result) {
case DialogWindow::yesButton: break; case Gtk::RESPONSE_YES:
break;
case DialogWindow::noButton: return; case Gtk::RESPONSE_NO:
break; return;
break;
// can happen if the window is closed with Alt-F4 -- treated as No default : // can happen if the window
default : return; return; // is closed with Alt-F4
break; break; // -- treated as No
} }
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId(); Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
@ -416,10 +342,33 @@ SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw ()
scheduler->stopCurrentlyPlaying(sessionId); scheduler->stopCurrentlyPlaying(sessionId);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring(e.what())); gLiveSupport->displayMessageWindow(e.what());
gLiveSupport->displayMessageWindow(errorMessage);
} }
showContents(); showContents();
} }
/*------------------------------------------------------------------------------
* Run the confirmation window.
*----------------------------------------------------------------------------*/
Gtk::ResponseType
SchedulerWindow :: runConfirmationDialog(void) throw ()
{
Gtk::Dialog * confirmationDialog;
Gtk::Label * confirmationDialogLabel;
glade->get_widget("confirmationDialog1", confirmationDialog);
glade->get_widget("confirmationDialogLabel1", confirmationDialogLabel);
Glib::ustring message = "<span weight=\"bold\" ";
message += " size=\"larger\">";
message += *getResourceUstring("stopCurrentlyPlayingDialogMsg");
message += "</span>";
confirmationDialogLabel->set_label(message);
Gtk::ResponseType response = Gtk::ResponseType(
confirmationDialog->run());
confirmationDialog->hide();
return response;
}

View file

@ -41,17 +41,16 @@
#endif #endif
#include <string> #include <string>
#include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/gregorian/gregorian.hpp>
#include <unicode/resbund.h> #include <unicode/resbund.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/DialogWindow.h" #include "LiveSupport/Widgets/ZebraTreeView.h"
#include "GuiWindow.h" #include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "BasicWindow.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
@ -71,7 +70,8 @@ using namespace LiveSupport::Core;
* The Scheduler window, showing and allowing scheduling of playlists. * The Scheduler window, showing and allowing scheduling of playlists.
* *
* The window is tabbed, with a main Schedule tab, and a Status tab showing * The window is tabbed, with a main Schedule tab, and a Status tab showing
* the status of the scheduler daemon (running/stopped). * the status of the scheduler daemon (running/stopped). In the Status tab,
* one can send a Stop signal to the Scheduler, to stop the audio player.
* *
* The rough layout of the Schedule tab: * The rough layout of the Schedule tab:
* <code><pre> * <code><pre>
@ -95,27 +95,32 @@ using namespace LiveSupport::Core;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class SchedulerWindow : public GuiWindow class SchedulerWindow : public BasicWindow
{ {
private: private:
/** /**
* Construct the Schedule view. * Construct the Schedule view.
* This displays the list of scheduled playlists. * This displays the list of scheduled playlists.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructScheduleView(void) throw (); constructScheduleView(void) throw ();
/** /**
* Construct the Status view. * Construct the Status view.
* This shows the status of the scheduler daemon. * This shows the status of the scheduler daemon.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructStatusView(void) throw (); constructStatusView(void) throw ();
/**
* Run the confirmation dialog.
*
* @return the response ID returned by the dialog.
*/
Gtk::ResponseType
runConfirmationDialog(void) throw ();
protected: protected:
@ -126,7 +131,7 @@ class SchedulerWindow : public GuiWindow
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class ModelColumns : public Gtk::TreeModel::ColumnRecord class ModelColumns : public ZebraTreeModelColumnRecord
{ {
public: public:
/** /**
@ -167,31 +172,26 @@ class SchedulerWindow : public GuiWindow
*/ */
Ptr<boost::gregorian::date>::Ref selectedDate; Ptr<boost::gregorian::date>::Ref selectedDate;
/**
* The main container in the window.
*/
Gtk::Table * layout;
/** /**
* The calendar to select a specific date from. * The calendar to select a specific date from.
*/ */
Gtk::Calendar * calendar; Gtk::Calendar * calendar;
/** /**
* The label saying which day is being displayed. * The label saying which day is being displayed.
*/ */
Gtk::Label * dateLabel; Gtk::Label * dateLabel;
/** /**
* The column model. * The column model.
*/ */
Ptr<ModelColumns>::Ref entryColumns; ModelColumns entryColumns;
/** /**
* The tree view, now only showing rows, each scheduled entry for a * The tree view, now only showing rows, each scheduled entry for a
* specific day. * specific day.
*/ */
Gtk::TreeView * entriesView; ZebraTreeView * entriesTreeView;
/** /**
* The tree model, as a GTK reference. * The tree model, as a GTK reference.
@ -201,18 +201,7 @@ class SchedulerWindow : public GuiWindow
/** /**
* The right-click context menu for schedule entries. * The right-click context menu for schedule entries.
*/ */
Gtk::Menu * entryMenu; Ptr<Gtk::Menu>::Ref entryMenu;
/**
* The close button.
*/
Gtk::Button * closeButton;
/**
* The "are you sure you want to stop the currently playing item?"
* dialog window.
*/
Ptr<DialogWindow>::Ref dialogWindow;
/** /**
* Signal handler for when a date is selected in the calendar. * Signal handler for when a date is selected in the calendar.
@ -244,6 +233,7 @@ class SchedulerWindow : public GuiWindow
public: public:
/** /**
* Constructor. * Constructor.
* *
@ -253,10 +243,12 @@ class SchedulerWindow : public GuiWindow
* resources for this window. * resources for this window.
* @param windowOpenerButton the button which was pressed to open * @param windowOpenerButton the button which was pressed to open
* this window. * this window.
* @param gladeDir the directory where the glade file is.
*/ */
SchedulerWindow(Ptr<GLiveSupport>::Ref gLiveSupport, SchedulerWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw (XmlRpcException); throw (XmlRpcException);
/** /**

View file

@ -37,13 +37,10 @@
#include <stdexcept> #include <stdexcept>
#include "LiveSupport/Widgets/WidgetFactory.h" #include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
#include "ScratchpadWindow.h" #include "ScratchpadWindow.h"
using namespace Glib;
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets; using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
@ -55,10 +52,10 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/** /*------------------------------------------------------------------------------
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc). * The name of the glade file.
*/ *----------------------------------------------------------------------------*/
const Glib::ustring windowName = "scratchpadWindow"; const Glib::ustring gladeFileName = "ScratchpadWindow.glade";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the user preference for storing Scratchpad contents * The name of the user preference for storing Scratchpad contents
@ -78,232 +75,109 @@ const Glib::ustring userPreferencesKeyName = "scratchpadContents";
ScratchpadWindow :: ScratchpadWindow ( ScratchpadWindow :: ScratchpadWindow (
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw () throw ()
: GuiWindow(gLiveSupport, : BasicWindow(gLiveSupport,
bundle, bundle,
windowOpenerButton) windowOpenerButton,
gladeDir + gladeFileName),
gladeDir(gladeDir)
{ {
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance(); // create the tree view
glade->get_widget_derived("treeView1", treeView);
try {
set_title(*getResourceUstring("windowTitle"));
addToPlaylistButton = Gtk::manage(widgetFactory->createButton(
*getResourceUstring("addToPlaylistButtonLabel")));
clearListButton = Gtk::manage(widgetFactory->createButton(
*getResourceUstring("clearListButtonLabel")));
removeButton = Gtk::manage(widgetFactory->createButton(
*getResourceUstring("removeButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
addToPlaylistButton->set_name("addToPlaylistButton");
addToPlaylistButton->signal_clicked().connect(sigc::mem_fun(*this,
&ScratchpadWindow::onAddToPlaylistButtonClicked));
clearListButton->set_name("clearListButton");
clearListButton->signal_clicked().connect(sigc::mem_fun(*this,
&ScratchpadWindow::onClearListButtonClicked));
removeButton->set_name("removeButton");
removeButton->signal_clicked().connect(sigc::mem_fun(*this,
&ScratchpadWindow::onRemoveItemButtonClicked));
add(vBox);
// Create the Tree model:
treeModel = Gtk::ListStore::create(modelColumns);
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel));
treeView->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); treeView->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
treeView->set_reorderable(true);
treeView->set_enable_search(false);
// Add the TreeView's view columns: treeView->appendColumn("",
try { modelColumns.typeColumn);
treeView->appendColumn(*getResourceUstring("typeColumnLabel"), treeView->appendColumn(*getResourceUstring("creatorColumnLabel"),
modelColumns.typeColumn, 20); modelColumns.creatorColumn);
treeView->appendColumn(*getResourceUstring("titleColumnLabel"), treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
modelColumns.titleColumn, 200); modelColumns.titleColumn);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// register the signal handler for treeview entries being clicked treeModel = Gtk::ListStore::create(modelColumns);
treeView->set_model(treeModel);
treeView->connectModelSignals(treeModel);
// register the signal handlers for treeview
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this, treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
&ScratchpadWindow::onEntryClicked)); &ScratchpadWindow::onEntryClicked));
treeView->signal_row_activated().connect(sigc::mem_fun(*this, treeView->signal_row_activated().connect(sigc::mem_fun(*this,
&ScratchpadWindow::onDoubleClick)); &ScratchpadWindow::onDoubleClick));
// register the signal handler for keyboard key presses
treeView->signal_key_press_event().connect(sigc::mem_fun(*this, treeView->signal_key_press_event().connect(sigc::mem_fun(*this,
&ScratchpadWindow::onKeyPressed)); &ScratchpadWindow::onKeyPressed));
// Add the TreeView, inside a ScrolledWindow, with the button underneath: // create the cue player widget
scrolledWindow.add(*treeView); cuePlayer.reset(new CuePlayer(gLiveSupport,
treeView,
// Only show the scrollbars when they are necessary: modelColumns,
scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); glade));
cueAudioButtons = Gtk::manage(new CuePlayer(
gLiveSupport, treeView, modelColumns ));
topButtonBox.pack_start(*cueAudioButtons, Gtk::PACK_EXPAND_PADDING);
middleButtonBox.set_layout(Gtk::BUTTONBOX_END);
middleButtonBox.set_spacing(5);
middleButtonBox.pack_start(*addToPlaylistButton);
bottomButtonBox.set_layout(Gtk::BUTTONBOX_END);
bottomButtonBox.set_spacing(5);
bottomButtonBox.pack_start(*clearListButton);
bottomButtonBox.pack_start(*removeButton);
// pack everything in the main box
vBox.pack_start(topButtonBox, Gtk::PACK_SHRINK, 5);
vBox.pack_start(scrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5);
vBox.pack_start(middleButtonBox, Gtk::PACK_SHRINK, 5);
vBox.pack_start(bottomButtonBox, Gtk::PACK_SHRINK, 5);
// create the right-click entry context menu for audio clips // create the right-click entry context menu for audio clips
audioClipMenu = Gtk::manage(new Gtk::Menu()); audioClipMenu.reset(new Gtk::Menu());
Gtk::Menu::MenuList& audioClipMenuList = audioClipMenu->items(); audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
// register the signal handlers for the popup menu *getResourceUstring("cueMenuItem"),
try { sigc::mem_fun(*cuePlayer,
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( &CuePlayer::onPlayItem)));
*getResourceUstring("cueMenuItem"), audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
sigc::mem_fun(*cueAudioButtons, *getResourceUstring("addToLiveModeMenuItem"),
&CuePlayer::onPlayItem))); sigc::mem_fun(*this,
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( &ScratchpadWindow::onAddToLiveMode)));
*getResourceUstring("addToLiveModeMenuItem"), audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
sigc::mem_fun(*this, *getResourceUstring("addToPlaylistMenuItem"),
&ScratchpadWindow::onAddToLiveMode))); sigc::mem_fun(*this,
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( &ScratchpadWindow::onAddToPlaylist)));
*getResourceUstring("addToPlaylistMenuItem"), audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
sigc::mem_fun(*this, *getResourceUstring("removeMenuItem"),
&ScratchpadWindow::onAddToPlaylist))); sigc::mem_fun(*this,
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( &ScratchpadWindow::onRemoveMenuOption)));
*getResourceUstring("removeMenuItem"), audioClipMenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
sigc::mem_fun(*treeView, audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
&ZebraTreeView::onRemoveMenuOption))); *getResourceUstring("uploadToHubMenuItem"),
audioClipMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); sigc::mem_fun(*this,
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( &ScratchpadWindow::onUploadToHub)));
*getResourceUstring("uploadToHubMenuItem"), audioClipMenu->accelerate(*mainWindow);
sigc::mem_fun(*this,
&ScratchpadWindow::onUploadToHub)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
audioClipMenu->accelerate(*this);
// create the right-click entry context menu for playlists // create the right-click entry context menu for playlists
playlistMenu = Gtk::manage(new Gtk::Menu()); playlistMenu.reset(new Gtk::Menu());
Gtk::Menu::MenuList& playlistMenuList = playlistMenu->items(); playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
// register the signal handlers for the popup menu *getResourceUstring("cueMenuItem"),
sigc::mem_fun(*cuePlayer,
try{ &CuePlayer::onPlayItem)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("cueMenuItem"), *getResourceUstring("addToLiveModeMenuItem"),
sigc::mem_fun(*cueAudioButtons, sigc::mem_fun(*this,
&CuePlayer::onPlayItem))); &ScratchpadWindow::onAddToLiveMode)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToLiveModeMenuItem"), *getResourceUstring("addToPlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&ScratchpadWindow::onAddToLiveMode))); &ScratchpadWindow::onAddToPlaylist)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToPlaylistMenuItem"), *getResourceUstring("removeMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&ScratchpadWindow::onAddToPlaylist))); &ScratchpadWindow::onRemoveMenuOption)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
*getResourceUstring("removeMenuItem"), playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
sigc::mem_fun(*treeView, *getResourceUstring("editPlaylistMenuItem"),
&ZebraTreeView::onRemoveMenuOption))); sigc::mem_fun(*this,
playlistMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); &ScratchpadWindow::onEditPlaylist)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("editPlaylistMenuItem"), *getResourceUstring("schedulePlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&ScratchpadWindow::onEditPlaylist))); &ScratchpadWindow::onSchedulePlaylist)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("schedulePlaylistMenuItem"), *getResourceUstring("exportPlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&ScratchpadWindow::onSchedulePlaylist))); &ScratchpadWindow::onExportPlaylist)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
*getResourceUstring("exportPlaylistMenuItem"), playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
sigc::mem_fun(*this, *getResourceUstring("uploadToHubMenuItem"),
&ScratchpadWindow::onExportPlaylist))); sigc::mem_fun(*this,
playlistMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); &ScratchpadWindow::onUploadToHub)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenu->accelerate(*mainWindow);
*getResourceUstring("uploadToHubMenuItem"),
sigc::mem_fun(*this,
&ScratchpadWindow::onUploadToHub)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
playlistMenu->accelerate(*this);
// set the user preferences key
userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName)); userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName));
// show
set_name(windowName);
set_default_size(300, 330);
set_modal(false);
property_window_position().set_value(Gtk::WIN_POS_NONE);
show_all_children();
}
/*------------------------------------------------------------------------------
* Event handler for the add to playlist button getting clicked.
*----------------------------------------------------------------------------*/
void
ScratchpadWindow :: onAddToPlaylistButtonClicked (void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection>
selection = treeView->get_selection();
std::vector<Gtk::TreePath>
selectedRows = selection->get_selected_rows();
std::vector<Gtk::TreePath>::iterator iter;
for (iter = selectedRows.begin(); iter != selectedRows.end(); ++iter) {
Gtk::TreeIter ti = treeModel->get_iter(*iter);
if (ti) {
Ptr<Playable>::Ref playable = (*ti)[modelColumns.playableColumn];
try {
gLiveSupport->addToPlaylist(playable->getId());
} catch (XmlRpcException &e) {
// just ignore the bad items
std::cerr << "error in ScratchpadWindow::"
"onAddToPlaylistButtonClicked(): "
<< e.what() << std::endl;
}
}
}
}
/*------------------------------------------------------------------------------
* Event handler for the clear list button getting clicked.
*----------------------------------------------------------------------------*/
void
ScratchpadWindow :: onClearListButtonClicked (void) throw ()
{
treeModel->clear();
}
/*------------------------------------------------------------------------------
* Event handler for the Remove menu button getting clicked.
*----------------------------------------------------------------------------*/
void
ScratchpadWindow :: onRemoveItemButtonClicked(void) throw ()
{
treeView->onRemoveMenuOption();
} }
@ -311,7 +185,7 @@ ScratchpadWindow :: onRemoveItemButtonClicked(void) throw ()
* Event handler for an entry being clicked in the list * Event handler for an entry being clicked in the list
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw () ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw ()
{ {
if (event->type == GDK_BUTTON_PRESS && event->button == 3) { if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
Gtk::TreePath currentPath; Gtk::TreePath currentPath;
@ -353,7 +227,7 @@ ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw ()
* Select the row which contains the playable specified. * Select the row which contains the playable specified.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw () ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw ()
{ {
Gtk::TreeModel::const_iterator it; Gtk::TreeModel::const_iterator it;
@ -377,7 +251,7 @@ ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw ()
* Remove an item from the Scratchpad * Remove an item from the Scratchpad
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw () ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw ()
{ {
Gtk::TreeModel::const_iterator it; Gtk::TreeModel::const_iterator it;
@ -400,13 +274,13 @@ ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw ()
* entry context menu * entry context menu
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onEditPlaylist(void) throw () ScratchpadWindow :: onEditPlaylist(void) throw ()
{ {
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
try { try {
gLiveSupport->openPlaylistForEditing(playable->getId()); gLiveSupport->openPlaylistForEditing(playable->getId());
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(getResourceUstring( gLiveSupport->displayMessageWindow(*getResourceUstring(
"cannotEditPlaylistMsg" )); "cannotEditPlaylistMsg" ));
} }
} }
@ -417,12 +291,11 @@ ScratchpadWindow :: onEditPlaylist(void) throw ()
* entry context menu * entry context menu
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onSchedulePlaylist(void) throw () ScratchpadWindow :: onSchedulePlaylist(void) throw ()
{ {
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
Ptr<UniqueId>::Ref uid = playable->getId(); Ptr<UniqueId>::Ref uid = playable->getId();
Ptr<ResourceBundle>::Ref bundle;
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
try { try {
@ -432,8 +305,6 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw ()
playlist = gLiveSupport->getPlaylist(uid); playlist = gLiveSupport->getPlaylist(uid);
bundle = gLiveSupport->getBundle("schedulePlaylistWindow");
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return; return;
@ -444,10 +315,10 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw ()
} }
schedulePlaylistWindow.reset(new SchedulePlaylistWindow(gLiveSupport, schedulePlaylistWindow.reset(new SchedulePlaylistWindow(gLiveSupport,
bundle, gladeDir,
playlist)); playlist));
Gtk::Main::run(*schedulePlaylistWindow); Gtk::Main::run(*schedulePlaylistWindow->getWindow());
} }
@ -455,7 +326,7 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw ()
* Signal handler for "export playlist" in the context menu. * Signal handler for "export playlist" in the context menu.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onExportPlaylist(void) throw () ScratchpadWindow :: onExportPlaylist(void) throw ()
{ {
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
Ptr<Playlist>::Ref playlist = playable->getPlaylist(); Ptr<Playlist>::Ref playlist = playable->getPlaylist();
@ -464,10 +335,10 @@ ScratchpadWindow :: onExportPlaylist(void) throw ()
if (playlist) { if (playlist) {
exportPlaylistWindow.reset(new ExportPlaylistWindow( exportPlaylistWindow.reset(new ExportPlaylistWindow(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("exportPlaylistWindow"), gladeDir,
playlist)); playlist));
exportPlaylistWindow->set_transient_for(*this); exportPlaylistWindow->getWindow()->set_transient_for(*mainWindow);
Gtk::Main::run(*exportPlaylistWindow); Gtk::Main::run(*exportPlaylistWindow->getWindow());
} }
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
@ -480,7 +351,7 @@ ScratchpadWindow :: onExportPlaylist(void) throw ()
* entry context menu * entry context menu
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onAddToPlaylist(void) throw () ScratchpadWindow :: onAddToPlaylist(void) throw ()
{ {
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
try { try {
@ -498,7 +369,7 @@ ScratchpadWindow :: onAddToPlaylist(void) throw ()
* entry context menu * entry context menu
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onAddToLiveMode(void) throw () ScratchpadWindow :: onAddToLiveMode(void) throw ()
{ {
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
gLiveSupport->addToLiveMode(playable); gLiveSupport->addToLiveMode(playable);
@ -509,20 +380,54 @@ ScratchpadWindow :: onAddToLiveMode(void) throw ()
* Signal handler for "upload to hub" in the context menu. * Signal handler for "upload to hub" in the context menu.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onUploadToHub(void) throw () ScratchpadWindow :: onUploadToHub(void) throw ()
{ {
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
gLiveSupport->uploadToHub(playable); gLiveSupport->uploadToHub(playable);
} }
/*------------------------------------------------------------------------------
* Event handler for the Remove menu item selected from the entry conext menu
*----------------------------------------------------------------------------*/
void
ScratchpadWindow :: onRemoveMenuOption(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> selection
= treeView->get_selection();
std::vector<Gtk::TreePath> selectedPaths
= selection->get_selected_rows();
std::vector<Gtk::TreeModel::iterator> selectedIters;
for (std::vector<Gtk::TreePath>::iterator pathIt = selectedPaths.begin();
pathIt != selectedPaths.end();
++pathIt) {
selectedIters.push_back(treeModel->get_iter(*pathIt));
}
Gtk::TreeModel::iterator newSelection;
for (std::vector<Gtk::TreeModel::iterator>::iterator
iterIt = selectedIters.begin();
iterIt != selectedIters.end();
++iterIt) {
newSelection = *iterIt;
++newSelection;
treeModel->erase(*iterIt);
}
if (newSelection) {
selection->select(newSelection);
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Signal handler for the user double-clicking or pressing Enter. * Signal handler for the user double-clicking or pressing Enter.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: onDoubleClick(const Gtk::TreeModel::Path & path, ScratchpadWindow :: onDoubleClick(const Gtk::TreeModel::Path & path,
const Gtk::TreeViewColumn * column) const Gtk::TreeViewColumn * column)
throw () throw ()
{ {
Gtk::TreeIter iter = treeModel->get_iter(path); Gtk::TreeIter iter = treeModel->get_iter(path);
if (iter) { if (iter) {
@ -536,11 +441,11 @@ ScratchpadWindow :: onDoubleClick(const Gtk::TreeModel::Path & path,
* Event handler for a key pressed. * Event handler for a key pressed.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
bool bool
ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw () ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw ()
{ {
if (event->type == GDK_KEY_PRESS) { if (event->type == GDK_KEY_PRESS) {
KeyboardShortcut::Action action = gLiveSupport->findAction( KeyboardShortcut::Action action = gLiveSupport->findAction(
windowName, "scratchpadWindow",
Gdk::ModifierType(event->state), Gdk::ModifierType(event->state),
event->keyval); event->keyval);
switch (action) { switch (action) {
@ -559,7 +464,7 @@ ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw ()
break; break;
case KeyboardShortcut::removeItem : case KeyboardShortcut::removeItem :
onRemoveItemButtonClicked(); onRemoveMenuOption();
return true; return true;
default : break; default : break;
@ -574,7 +479,7 @@ ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw ()
* Check whether exactly one row is selected. * Check whether exactly one row is selected.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
bool bool
ScratchpadWindow :: isSelectionSingle(void) throw () ScratchpadWindow :: isSelectionSingle(void) throw ()
{ {
Glib::RefPtr<Gtk::TreeView::Selection> Glib::RefPtr<Gtk::TreeView::Selection>
selection = treeView->get_selection(); selection = treeView->get_selection();
@ -596,7 +501,7 @@ ScratchpadWindow :: isSelectionSingle(void) throw ()
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable) ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
throw () throw ()
{ {
// cache the item if it hasn't been cached yet // cache the item if it hasn't been cached yet
if (!playable->getToken()) { if (!playable->getToken()) {
@ -611,7 +516,7 @@ ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
removeItem(playable->getId()); removeItem(playable->getId());
Gtk::TreeModel::Row row = *treeModel->prepend(); Gtk::TreeModel::Row row = *(treeModel->prepend());
row[modelColumns.playableColumn] = playable; row[modelColumns.playableColumn] = playable;
@ -629,6 +534,12 @@ ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
break; break;
} }
Ptr<const Glib::ustring>::Ref creator = playable->getMetadata(
"dc:creator");
if (creator) {
row[modelColumns.creatorColumn] = Glib::Markup::escape_text(
*creator);
}
row[modelColumns.titleColumn] = Glib::Markup::escape_text( row[modelColumns.titleColumn] = Glib::Markup::escape_text(
*playable->getTitle()); *playable->getTitle());
} }
@ -639,7 +550,7 @@ ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: addItem(Ptr<const UniqueId>::Ref id) ScratchpadWindow :: addItem(Ptr<const UniqueId>::Ref id)
throw () throw ()
{ {
Ptr<Playable>::Ref playable; Ptr<Playable>::Ref playable;
try { try {
@ -658,7 +569,7 @@ ScratchpadWindow :: addItem(Ptr<const UniqueId>::Ref id)
* Return the contents of the Scratchpad. * Return the contents of the Scratchpad.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref Ptr<Glib::ustring>::Ref
ScratchpadWindow :: getContents(void) throw () ScratchpadWindow :: getContents(void) throw ()
{ {
std::ostringstream contentsStream; std::ostringstream contentsStream;
Gtk::TreeModel::const_iterator it; Gtk::TreeModel::const_iterator it;
@ -681,7 +592,7 @@ ScratchpadWindow :: getContents(void) throw ()
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: setContents(Ptr<const Glib::ustring>::Ref contents) ScratchpadWindow :: setContents(Ptr<const Glib::ustring>::Ref contents)
throw () throw ()
{ {
std::vector<UniqueId::IdType> contentsVector; std::vector<UniqueId::IdType> contentsVector;
std::istringstream contentsStream(*contents); std::istringstream contentsStream(*contents);
@ -710,15 +621,15 @@ ScratchpadWindow :: setContents(Ptr<const Glib::ustring>::Ref contents)
* Event handler called when the the window gets hidden. * Event handler called when the the window gets hidden.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
ScratchpadWindow :: on_hide(void) throw () ScratchpadWindow :: hide(void) throw ()
{ {
if (exportPlaylistWindow) { if (exportPlaylistWindow) {
exportPlaylistWindow->hide(); exportPlaylistWindow->getWindow()->hide();
} }
if (schedulePlaylistWindow) { if (schedulePlaylistWindow) {
schedulePlaylistWindow->hide(); schedulePlaylistWindow->getWindow()->hide();
} }
GuiWindow::on_hide(); BasicWindow::hide();
} }

View file

@ -41,17 +41,14 @@
#endif #endif
#include <string> #include <string>
#include <unicode/resbund.h> #include <unicode/resbund.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" #include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "BasicWindow.h"
#include "CuePlayer.h" #include "CuePlayer.h"
#include "GuiWindow.h"
#include "ContentsStorable.h" #include "ContentsStorable.h"
#include "ExportPlaylistWindow.h" #include "ExportPlaylistWindow.h"
#include "SchedulePlaylistWindow.h" #include "SchedulePlaylistWindow.h"
@ -77,10 +74,21 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class ScratchpadWindow : public GuiWindow, class ScratchpadWindow : public BasicWindow,
public ContentsStorable public ContentsStorable
{ {
private: private:
/**
* The directory where the Glade files are.
*/
Glib::ustring gladeDir;
/**
* The user preferences key.
*/
Ptr<const Glib::ustring>::Ref userPreferencesKey;
/** /**
* The Export Playlist pop-up window. * The Export Playlist pop-up window.
*/ */
@ -123,11 +131,6 @@ class ScratchpadWindow : public GuiWindow,
void void
removeItem(Ptr<const UniqueId>::Ref id) throw (); removeItem(Ptr<const UniqueId>::Ref id) throw ();
/**
* The user preferences key.
*/
Ptr<const Glib::ustring>::Ref userPreferencesKey;
protected: protected:
@ -147,6 +150,11 @@ class ScratchpadWindow : public GuiWindow,
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> >
typeColumn; typeColumn;
/**
* The column for the creator of the audio clip or playlist.
*/
Gtk::TreeModelColumn<Glib::ustring> creatorColumn;
/** /**
* The column for the title of the audio clip or playlist. * The column for the title of the audio clip or playlist.
*/ */
@ -158,6 +166,7 @@ class ScratchpadWindow : public GuiWindow,
ModelColumns(void) throw () ModelColumns(void) throw ()
{ {
add(typeColumn); add(typeColumn);
add(creatorColumn);
add(titleColumn); add(titleColumn);
} }
}; };
@ -166,7 +175,7 @@ class ScratchpadWindow : public GuiWindow,
/** /**
* The column model. * The column model.
*/ */
ModelColumns modelColumns; ModelColumns modelColumns;
/** /**
* The tree model, as a GTK reference. * The tree model, as a GTK reference.
@ -176,87 +185,29 @@ class ScratchpadWindow : public GuiWindow,
/** /**
* The tree view, now only showing rows. * The tree view, now only showing rows.
*/ */
ZebraTreeView * treeView; ZebraTreeView * treeView;
/** /**
* The model row at the mouse pointer, set by onEntryClicked() * The model row at the mouse pointer, set by onEntryClicked()
*/ */
Gtk::TreeRow currentRow; Gtk::TreeRow currentRow;
/** /**
* The main container in the window. * The cue player widget controlling the audio buttons.
*/ */
Gtk::VBox vBox; Ptr<CuePlayer>::Ref cuePlayer;
/**
* A scrolled window, so that the list can be scrolled.
*/
Gtk::ScrolledWindow scrolledWindow;
/**
* The box containing the box containing the audio buttons.
*/
Gtk::HBox topButtonBox;
/**
* The cue player widget containing the audio buttons.
*/
CuePlayer * cueAudioButtons;
/**
* The box containing the close button.
*/
Gtk::HButtonBox middleButtonBox;
/**
* The box containing the close button.
*/
Gtk::HButtonBox bottomButtonBox;
/**
* The "add to playlist" button.
*/
Button * addToPlaylistButton;
/**
* The "clear list" button.
*/
Button * clearListButton;
/**
* The "remove selected item" button.
*/
Button * removeButton;
/** /**
* The right-click context menu for audio clips, * The right-click context menu for audio clips,
* that comes up when right-clicking an entry in the entry list. * that comes up when right-clicking an entry in the entry list.
*/ */
Gtk::Menu * audioClipMenu; Ptr<Gtk::Menu>::Ref audioClipMenu;
/** /**
* The right-click context menu for playlists, * The right-click context menu for playlists,
* that comes up when right-clicking an entry in the entry list. * that comes up when right-clicking an entry in the entry list.
*/ */
Gtk::Menu * playlistMenu; Ptr<Gtk::Menu>::Ref playlistMenu;
/**
* Signal handler for the add to playlist button clicked.
*/
virtual void
onAddToPlaylistButtonClicked(void) throw ();
/**
* Signal handler for the clear list button clicked.
*/
virtual void
onClearListButtonClicked(void) throw ();
/**
* Signal handler for the remove item button clicked.
*/
virtual void
onRemoveItemButtonClicked(void) throw ();
/** /**
* Signal handler for the mouse clicked on one of the entries. * Signal handler for the mouse clicked on one of the entries.
@ -265,7 +216,7 @@ class ScratchpadWindow : public GuiWindow,
* @param event the button event recieved * @param event the button event recieved
*/ */
virtual void virtual void
onEntryClicked(GdkEventButton * event) throw (); onEntryClicked(GdkEventButton * event) throw ();
/** /**
* Signal handler for the user double-clicking, or pressing Enter * Signal handler for the user double-clicking, or pressing Enter
@ -334,16 +285,15 @@ class ScratchpadWindow : public GuiWindow,
onUploadToHub(void) throw (); onUploadToHub(void) throw ();
/** /**
* Event handler called when the the window gets hidden. * Event handler for the Remove menu item selected from
* * the entry conext menu.
* This overrides GuiWindow::on_hide(), and closes the Export Playlist
* window, if it is still open.
*/ */
virtual void virtual void
on_hide(void) throw (); onRemoveMenuOption(void) throw ();
public: public:
/** /**
* Constructor. * Constructor.
* *
@ -351,12 +301,14 @@ class ScratchpadWindow : public GuiWindow,
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
* @param windowOpenerButton the button which was pressed to open * @param windowOpenerButton the button which was pressed to open
* this window. * this window.
* @param gladeDir the directory where the glade file is.
*/ */
ScratchpadWindow(Ptr<GLiveSupport>::Ref gLiveSupport, ScratchpadWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw (); throw ();
/** /**
@ -422,8 +374,17 @@ class ScratchpadWindow : public GuiWindow,
void void
showCuePlayerStopped(void) throw () showCuePlayerStopped(void) throw ()
{ {
cueAudioButtons->onStop(); cuePlayer->onStop();
} }
/**
* Hide the window.
*
* This overrides BasicWindow::hide(), and closes the Export Playlist
* and Schedule Playlist pop-up windows, if they are still open.
*/
virtual void
hide(void) throw ();
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -39,7 +39,6 @@
#include "LiveSupport/Core/TimeConversion.h" #include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/Widgets/WidgetFactory.h" #include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ZebraTreeView.h" #include "LiveSupport/Widgets/ZebraTreeView.h"
#include "SearchWindow.h" #include "SearchWindow.h"
@ -60,14 +59,9 @@ using namespace LiveSupport::GLiveSupport;
namespace { namespace {
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The 'search where' combo box key for local searches. * The name of the glade file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
const std::string searchWhereLocalKey = "searchWhereLocal"; const Glib::ustring gladeFileName = "SearchWindow.glade";
/*------------------------------------------------------------------------------
* The 'search where' combo box key for remote searches.
*----------------------------------------------------------------------------*/
const std::string searchWhereRemoteKey = "searchWhereRemote";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The number of items which can be shown in the search results. * The number of items which can be shown in the search results.
@ -86,55 +80,38 @@ const int searchResultsSize = 25;
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
SearchWindow :: SearchWindow (Ptr<GLiveSupport>::Ref gLiveSupport, SearchWindow :: SearchWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
throw () const Glib::ustring & gladeDir)
: GuiWindow(gLiveSupport, throw ()
bundle, : BasicWindow(gLiveSupport,
windowOpenerButton) bundle,
windowOpenerButton,
gladeDir + gladeFileName),
gladeDir(gladeDir)
{ {
Gtk::Box * searchWhereBox = constructSearchWhereBox(); glade->get_widget("searchInputNoteBook1", searchInput);
Gtk::Box * simpleSearchView = constructSimpleSearchView();
Gtk::Box * advancedSearchView = constructAdvancedSearchView();
Gtk::Box * browseView = constructBrowseView();
Gtk::Box * transportsView = constructTransportsView();
searchInput = Gtk::manage(new ScrolledNotebook);
try {
set_title(*getResourceUstring("windowTitle"));
searchInput->appendPage(*simpleSearchView, *getResourceUstring(
"simpleSearchTab"));
searchInput->appendPage(*advancedSearchView, *getResourceUstring(
"advancedSearchTab"));
searchInput->appendPage(*browseView, *getResourceUstring(
"browseTab"));
searchInput->appendPage(*transportsView, *getResourceUstring(
"transportsTab"));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// set up the search results box
Gtk::Box * searchResultsView = constructSearchResultsView();
// set the sizes of the two parts of the window
searchInput ->set_size_request(766, 231);
searchResultsView->set_size_request(766, 343);
// put them in one big box Gtk::Label * simpleSearchTabLabel;
Gtk::VBox * bigBox = Gtk::manage(new Gtk::VBox); Gtk::Label * advancedSearchTabLabel;
bigBox->pack_start(*searchWhereBox, Gtk::PACK_SHRINK); Gtk::Label * browseTabLabel;
bigBox->pack_start(*searchInput, Gtk::PACK_SHRINK); Gtk::Label * transportsTabLabel;
bigBox->pack_start(*searchResultsView); glade->get_widget("simpleSearchTabLabel1", simpleSearchTabLabel);
add(*bigBox); glade->get_widget("advancedSearchTabLabel1", advancedSearchTabLabel);
glade->get_widget("browseTabLabel1", browseTabLabel);
glade->get_widget("transportsTabLabel1", transportsTabLabel);
simpleSearchTabLabel->set_label(*getResourceUstring("simpleSearchTab"));
advancedSearchTabLabel->set_label(*getResourceUstring("advancedSearchTab"));
browseTabLabel->set_label(*getResourceUstring("browseTab"));
transportsTabLabel->set_label(*getResourceUstring("transportsTab"));
constructSearchWhereBox();
// show constructSimpleSearchView();
set_name("searchWindow"); constructAdvancedSearchView();
set_modal(false); constructBrowseView();
property_window_position().set_value(Gtk::WIN_POS_NONE); constructTransportsView();
show_all_children(); constructSearchResultsView();
} }
@ -149,265 +126,130 @@ SearchWindow :: ~SearchWindow (void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the transport type selection box. * Construct the transport type selection box.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
SearchWindow :: constructSearchWhereBox(void) throw () SearchWindow :: constructSearchWhereBox(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
Gtk::Label * searchWhereLabel; Gtk::Label * searchWhereLabel;
try { glade->get_widget("searchWhereLabel1", searchWhereLabel);
searchWhereLabel = Gtk::manage(new Gtk::Label( searchWhereLabel->set_label(*getResourceUstring("searchWhereLabel"));
*getResourceUstring("searchWhereLabel") ));
searchWhereEntry = Gtk::manage(wf->createComboBoxText()); glade->get_widget_derived("searchWhereEntry1", searchWhereEntry);
searchWhereEntry->append_text(*getResourceUstring("searchWhereLocal"));
Ptr<Glib::ustring>::Ref localKey(new Glib::ustring( searchWhereEntry->append_text(*getResourceUstring("searchWhereRemote"));
searchWhereLocalKey));
Ptr<Glib::ustring>::Ref remoteKey(new Glib::ustring(
searchWhereRemoteKey));
searchWhereEntry->appendPair(getResourceUstring(searchWhereLocalKey),
localKey);
searchWhereEntry->appendPair(getResourceUstring(searchWhereRemoteKey),
remoteKey);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
searchWhereEntry->set_active(0); searchWhereEntry->set_active(0);
searchWhereEntry->signalSelectionChanged().connect(sigc::mem_fun( searchWhereEntry->signal_changed().connect(sigc::mem_fun(*this,
*this, &SearchWindow::onSearchWhereChanged )); &SearchWindow::onSearchWhereChanged));
Gtk::HBox * hBox = Gtk::manage(new Gtk::HBox);
hBox->pack_start(*searchWhereLabel, Gtk::PACK_SHRINK, 5);
hBox->pack_start(*searchWhereEntry, Gtk::PACK_SHRINK);
Gtk::HBox * padding = Gtk::manage(new Gtk::HBox);
Gtk::VBox * vBox = Gtk::manage(new Gtk::VBox);
vBox->pack_start(*hBox, Gtk::PACK_SHRINK, 5);
vBox->pack_start(*padding, Gtk::PACK_SHRINK, 5);
return vBox;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the simple search view. * Construct the simple search view.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
SearchWindow :: constructSimpleSearchView(void) throw () SearchWindow :: constructSimpleSearchView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); glade->get_widget("simpleSearchEntry1", simpleSearchEntry);
simpleSearchEntry->signal_activate().connect(sigc::mem_fun(*this,
// set up the entry box &SearchWindow::onSimpleSearch));
simpleSearchEntry = Gtk::manage(wf->createEntryBin());
Button * searchButton; Gtk::Button * simpleSearchButton;
try { glade->get_widget("simpleSearchButton1", simpleSearchButton);
searchButton = Gtk::manage(wf->createButton( simpleSearchButton->set_label(*getResourceUstring("searchButtonLabel"));
*getResourceUstring("searchButtonLabel") )); simpleSearchButton->signal_clicked().connect(sigc::mem_fun(*this,
} catch (std::invalid_argument &e) { &SearchWindow::onSimpleSearch));
std::cerr << e.what() << std::endl;
std::exit(1);
}
simpleSearchEntry->signal_activate().connect(sigc::mem_fun(
*this, &SearchWindow::onSimpleSearch ));
searchButton->signal_clicked().connect(sigc::mem_fun(
*this, &SearchWindow::onSimpleSearch ));
Gtk::HBox * entryBox = Gtk::manage(new Gtk::HBox);
entryBox->pack_start(*simpleSearchEntry, Gtk::PACK_EXPAND_WIDGET, 5);
entryBox->pack_start(*searchButton, Gtk::PACK_SHRINK, 5);
// make the search entry + button take up 50% of the window horizontally
Gtk::Alignment * entryAlignment = Gtk::manage(new Gtk::Alignment(
0, 0, 0.5, 0));
entryAlignment->add(*entryBox);
// make a new box and pack the main components into it
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*entryAlignment, Gtk::PACK_SHRINK, 5);
return view;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the advanced search view. * Construct the advanced search view.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
SearchWindow :: constructAdvancedSearchView(void) throw () SearchWindow :: constructAdvancedSearchView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); advancedSearchEntry.reset(new AdvancedSearchEntry(gLiveSupport, glade));
advancedSearchEntry->connectCallback(sigc::mem_fun(*this,
// the two main components of the window &SearchWindow::onAdvancedSearch ));
advancedSearchEntry = Gtk::manage(new AdvancedSearchEntry(gLiveSupport));
Gtk::Box * searchButtonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_END ));
// set up the callback function for the entry field Gtk::Button * advancedSearchButton;
advancedSearchEntry->connectCallback(sigc::mem_fun( glade->get_widget("advancedSearchButton1", advancedSearchButton);
*this, &SearchWindow::onAdvancedSearch )); advancedSearchButton->set_label(*getResourceUstring("searchButtonLabel"));
advancedSearchButton->signal_clicked().connect(sigc::mem_fun(*this,
// set up the search button box &SearchWindow::onAdvancedSearch));
try {
Button * searchButton = Gtk::manage(wf->createButton(
*getResourceUstring("searchButtonLabel") ));
searchButton->signal_clicked().connect(sigc::mem_fun(
*this, &SearchWindow::onAdvancedSearch ));
searchButtonBox->pack_start(*searchButton, Gtk::PACK_SHRINK, 5);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// make a new box and pack the main components into it
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*advancedSearchEntry, Gtk::PACK_SHRINK, 5);
view->pack_start(*searchButtonBox, Gtk::PACK_SHRINK, 5);
return view;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the browse view. * Construct the browse view.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
SearchWindow :: constructBrowseView(void) throw () SearchWindow :: constructBrowseView(void) throw ()
{ {
// set up the browse input fields browseEntry.reset(new BrowseEntry(gLiveSupport, getBundle(), glade));
browseEntry = Gtk::manage(new BrowseEntry(gLiveSupport, getBundle())); browseEntry->signalChanged().connect(sigc::mem_fun(*this,
&SearchWindow::onBrowse));
browseEntry->signalSelectionChanged().connect(sigc::mem_fun(
*this, &SearchWindow::onBrowse ));
// make a new box and pack the main components into it
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*browseEntry, Gtk::PACK_EXPAND_WIDGET, 5);
return view;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the advanced search view. * Construct the transports view.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::VBox* void
SearchWindow :: constructTransportsView(void) throw () SearchWindow :: constructTransportsView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); transportList.reset(new TransportList(
try {
transportList = Gtk::manage(new TransportList(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("transportList") )); gLiveSupport->getBundle("transportList"),
} catch (std::invalid_argument &e) { glade));
std::cerr << e.what() << std::endl;
std::exit(1);
}
ScrolledWindow * scrolledWindow = Gtk::manage(new ScrolledWindow);
scrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrolledWindow->add(*transportList);
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*scrolledWindow);
return view;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the search results display. * Construct the search results display.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Box * void
SearchWindow :: constructSearchResultsView(void) throw () SearchWindow :: constructSearchResultsView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
localSearchResults = Gtk::ListStore::create(modelColumns); localSearchResults = Gtk::ListStore::create(modelColumns);
remoteSearchResults = Gtk::ListStore::create(modelColumns); remoteSearchResults = Gtk::ListStore::create(modelColumns);
searchResultsTreeView = Gtk::manage(wf->createTreeView(localSearchResults)); glade->get_widget_derived("searchResultsTreeView1", searchResultsTreeView);
searchResultsTreeView->set_model(localSearchResults);
searchResultsTreeView->connectModelSignals(localSearchResults);
searchResultsTreeView->connectModelSignals(remoteSearchResults); searchResultsTreeView->connectModelSignals(remoteSearchResults);
// add the TreeView's view columns searchResultsTreeView->appendColumn(
try { *getResourceUstring("typeColumnLabel"),
searchResultsTreeView->appendColumn( modelColumns.typeColumn, 20);
*getResourceUstring("typeColumnLabel"), searchResultsTreeView->appendColumn(
modelColumns.typeColumn, 20); *getResourceUstring("titleColumnLabel"),
searchResultsTreeView->appendColumn( modelColumns.titleColumn, 300);
*getResourceUstring("titleColumnLabel"), searchResultsTreeView->appendColumn(
modelColumns.titleColumn, 300); *getResourceUstring("creatorColumnLabel"),
searchResultsTreeView->appendColumn( modelColumns.creatorColumn, 200);
*getResourceUstring("creatorColumnLabel"), searchResultsTreeView->appendColumn(
modelColumns.creatorColumn, 200); *getResourceUstring("sourceColumnLabel"),
searchResultsTreeView->appendColumn( modelColumns.sourceColumn, 145);
*getResourceUstring("sourceColumnLabel"), searchResultsTreeView->appendCenteredColumn(
modelColumns.sourceColumn, 145); *getResourceUstring("lengthColumnLabel"),
searchResultsTreeView->appendCenteredColumn( modelColumns.lengthColumn, 55);
*getResourceUstring("lengthColumnLabel"),
modelColumns.lengthColumn, 55);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// register the signal handler for treeview entries being clicked
searchResultsTreeView->signal_button_press_event().connect_notify( searchResultsTreeView->signal_button_press_event().connect_notify(
sigc::mem_fun( sigc::mem_fun(*this,
*this, &SearchWindow::onEntryClicked)); &SearchWindow::onEntryClicked));
searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun( searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun(*this,
*this, &SearchWindow::onDoubleClick)); &SearchWindow::onDoubleClick));
// create the right-click context menus
audioClipContextMenu = constructAudioClipContextMenu(); audioClipContextMenu = constructAudioClipContextMenu();
playlistContextMenu = constructPlaylistContextMenu(); playlistContextMenu = constructPlaylistContextMenu();
remoteContextMenu = constructRemoteContextMenu(); remoteContextMenu = constructRemoteContextMenu();
// put the tree view inside a scrolled window glade->get_widget("searchResultsCountLabel1", searchResultsCountLabel);
ScrolledWindow * resultsWindow = Gtk::manage(new ScrolledWindow); glade->get_widget("backwardButton1", backwardButton);
resultsWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); glade->get_widget("forwardButton1", forwardButton);
resultsWindow->add(*searchResultsTreeView);
// create the paging toolbar
try {
backwardButton = Gtk::manage(wf->createButton(
*getResourceUstring("backwardButtonLabel")));
forwardButton = Gtk::manage(wf->createButton(
*getResourceUstring("forwardButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
backwardButton->signal_clicked().connect(sigc::mem_fun(*this, backwardButton->signal_clicked().connect(sigc::mem_fun(*this,
&SearchWindow::onBackwardButtonClicked)); &SearchWindow::onBackwardButtonClicked));
forwardButton->signal_clicked().connect(sigc::mem_fun(*this, forwardButton->signal_clicked().connect(sigc::mem_fun(*this,
&SearchWindow::onForwardButtonClicked)); &SearchWindow::onForwardButtonClicked));
Gtk::Box * pagingButtonBox = Gtk::manage(new Gtk::HButtonBox(
Gtk::BUTTONBOX_DEFAULT_STYLE, 5));
pagingButtonBox->add(*backwardButton);
pagingButtonBox->add(*forwardButton);
searchResultsCountLabel = Gtk::manage(new Gtk::Label());
Gtk::Box * pagingToolbar = Gtk::manage(new Gtk::HBox);
pagingToolbar->pack_start(*searchResultsCountLabel,
Gtk::PACK_EXPAND_WIDGET, 5);
pagingToolbar->pack_start(*pagingButtonBox, Gtk::PACK_SHRINK, 5);
updatePagingToolbar();
// pack everything in a box
Gtk::Box * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*pagingToolbar, Gtk::PACK_SHRINK, 5);
view->pack_start(*resultsWindow, Gtk::PACK_EXPAND_WIDGET, 0);
return view;
} }
@ -684,8 +526,8 @@ SearchWindow :: remoteSearchClose(void)
} else if (state == AsyncState::failedState) { } else if (state == AsyncState::failedState) {
remoteSearchToken.reset(); remoteSearchToken.reset();
gLiveSupport->displayMessageWindow(formatMessage("longErrorMsg", gLiveSupport->displayMessageWindow(*formatMessage("longErrorMsg",
*errorMessage )); *errorMessage ));
displayMessage("shortErrorMsg", remoteSearchResults); displayMessage("shortErrorMsg", remoteSearchResults);
} }
} }
@ -717,8 +559,8 @@ SearchWindow :: displayError(const XmlRpcException & error,
Glib::RefPtr<Gtk::ListStore> treeModel) Glib::RefPtr<Gtk::ListStore> treeModel)
throw () throw ()
{ {
gLiveSupport->displayMessageWindow(formatMessage("longErrorMsg", gLiveSupport->displayMessageWindow(*formatMessage("longErrorMsg",
error.what() )); error.what() ));
displayMessage("shortErrorMsg", treeModel); displayMessage("shortErrorMsg", treeModel);
} }
@ -814,7 +656,7 @@ SearchWindow :: onAddToScratchpad(void) throw ()
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring( Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring(
"error in SearchWindow::onAddToScratchpad(): ")); "error in SearchWindow::onAddToScratchpad(): "));
errorMessage->append(e.what()); errorMessage->append(e.what());
gLiveSupport->displayMessageWindow(errorMessage); gLiveSupport->displayMessageWindow(*errorMessage);
} }
} }
} }
@ -841,7 +683,7 @@ SearchWindow :: onAddToPlaylist(void) throw ()
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring( Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring(
"error in SearchWindow::onAddToPlaylist(): ")); "error in SearchWindow::onAddToPlaylist(): "));
errorMessage->append(e.what()); errorMessage->append(e.what());
gLiveSupport->displayMessageWindow(errorMessage); gLiveSupport->displayMessageWindow(*errorMessage);
} }
} }
} }
@ -869,7 +711,7 @@ SearchWindow :: onAddToLiveMode(void) throw ()
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring( Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring(
"error in SearchWindow::onAddToLiveMode(): ")); "error in SearchWindow::onAddToLiveMode(): "));
errorMessage->append(e.what()); errorMessage->append(e.what());
gLiveSupport->displayMessageWindow(errorMessage); gLiveSupport->displayMessageWindow(*errorMessage);
} }
} }
} }
@ -895,8 +737,8 @@ SearchWindow :: onEditPlaylist(void) throw ()
try { try {
gLiveSupport->openPlaylistForEditing(playlist->getId()); gLiveSupport->openPlaylistForEditing(playlist->getId());
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(getResourceUstring( gLiveSupport->displayMessageWindow(*getResourceUstring(
"cannotEditPlaylistMsg" )); "cannotEditPlaylistMsg" ));
} }
} }
} }
@ -921,10 +763,10 @@ SearchWindow :: onSchedulePlaylist(void) throw ()
if (playlist) { if (playlist) {
schedulePlaylistWindow.reset(new SchedulePlaylistWindow( schedulePlaylistWindow.reset(new SchedulePlaylistWindow(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("schedulePlaylistWindow"), gladeDir,
playlist)); playlist));
schedulePlaylistWindow->set_transient_for(*this); schedulePlaylistWindow->getWindow()->set_transient_for(*mainWindow);
Gtk::Main::run(*schedulePlaylistWindow); Gtk::Main::run(*schedulePlaylistWindow->getWindow());
} }
} }
} }
@ -949,14 +791,14 @@ SearchWindow :: onExportPlaylist(void) throw ()
try { try {
exportPlaylistWindow.reset(new ExportPlaylistWindow( exportPlaylistWindow.reset(new ExportPlaylistWindow(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("exportPlaylistWindow"), gladeDir,
playlist)); playlist));
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return; return;
} }
exportPlaylistWindow->set_transient_for(*this); exportPlaylistWindow->getWindow()->set_transient_for(*mainWindow);
Gtk::Main::run(*exportPlaylistWindow); Gtk::Main::run(*exportPlaylistWindow->getWindow());
} }
} }
} }
@ -991,12 +833,12 @@ bool
SearchWindow :: uploadToHub(Ptr<Playable>::Ref playable) throw () SearchWindow :: uploadToHub(Ptr<Playable>::Ref playable) throw ()
{ {
try { try {
searchInput->setActivePage(3); searchInput->set_current_page(3);
transportList->addUpload(playable); transportList->addUpload(playable);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage("uploadToHubErrorMsg", gLiveSupport->displayMessageWindow(*formatMessage("uploadToHubErrorMsg",
e.what() )); e.what() ));
return false; return false;
} }
@ -1020,11 +862,11 @@ SearchWindow :: onDownloadFromHub(void) throw ()
if (playable) { if (playable) {
if (!gLiveSupport->existsPlayable(playable->getId())) { if (!gLiveSupport->existsPlayable(playable->getId())) {
try { try {
searchInput->setActivePage(3); searchInput->set_current_page(3);
transportList->addDownload(playable); transportList->addDownload(playable);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage( gLiveSupport->displayMessageWindow(*formatMessage(
"downloadFromHubErrorMsg", e.what() )); "downloadFromHubErrorMsg", e.what() ));
return; return;
} }
@ -1056,16 +898,16 @@ SearchWindow :: onDoubleClick(const Gtk::TreeModel::Path & path,
* Event handler called when the the window gets hidden. * Event handler called when the the window gets hidden.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SearchWindow :: on_hide(void) throw () SearchWindow :: hide(void) throw ()
{ {
if (exportPlaylistWindow) { if (exportPlaylistWindow) {
exportPlaylistWindow->hide(); exportPlaylistWindow->getWindow()->hide();
} }
if (schedulePlaylistWindow) { if (schedulePlaylistWindow) {
schedulePlaylistWindow->hide(); schedulePlaylistWindow->getWindow()->hide();
} }
GuiWindow::on_hide(); BasicWindow::hide();
} }
@ -1075,13 +917,20 @@ SearchWindow :: on_hide(void) throw ()
bool bool
SearchWindow :: searchIsLocal(void) throw () SearchWindow :: searchIsLocal(void) throw ()
{ {
Ptr<const Glib::ustring>::Ref searchWhere int searchWhere = searchWhereEntry->get_active_row_number();
= searchWhereEntry->getActiveKey();
if (*searchWhere == searchWhereLocalKey) { switch (searchWhere) {
return true; case 0: return true;
} else { break;
return false;
case 1: return false;
break;
default:
std::cerr << "impossible value in SearchWindow::searchIsLocal()"
<< std::endl;
std::exit(1);
break;
} }
} }
@ -1093,13 +942,13 @@ void
SearchWindow :: onSearchWhereChanged(void) throw () SearchWindow :: onSearchWhereChanged(void) throw ()
{ {
if (searchIsLocal()) { if (searchIsLocal()) {
searchInput->setPageSensitive(2, true); searchInput->get_nth_page(2)->set_sensitive(true);
searchResultsTreeView->set_model(localSearchResults); searchResultsTreeView->set_model(localSearchResults);
} else { } else {
if (searchInput->getActivePage() == 2) { if (searchInput->get_current_page() == 2) {
searchInput->setActivePage(0); searchInput->set_current_page(0);
} }
searchInput->setPageSensitive(2, false); searchInput->get_nth_page(2)->set_sensitive(false);
searchResultsTreeView->set_model(remoteSearchResults); searchResultsTreeView->set_model(remoteSearchResults);
} }
@ -1121,36 +970,31 @@ SearchWindow :: onTimer(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the right-click context menu for local audio clips. * Construct the right-click context menu for local audio clips.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Menu * Ptr<Gtk::Menu>::Ref
SearchWindow :: constructAudioClipContextMenu(void) throw () SearchWindow :: constructAudioClipContextMenu(void) throw ()
{ {
Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); Ptr<Gtk::Menu>::Ref contextMenu(new Gtk::Menu());
Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); Gtk::Menu::MenuList & contextMenuList = contextMenu->items();
try { contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToLiveModeMenuItem"),
*getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &SearchWindow::onAddToLiveMode)));
&SearchWindow::onAddToLiveMode))); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToPlaylistMenuItem"),
*getResourceUstring("addToPlaylistMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &SearchWindow::onAddToPlaylist)));
&SearchWindow::onAddToPlaylist))); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToScratchpadMenuItem"),
*getResourceUstring("addToScratchpadMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &SearchWindow::onAddToScratchpad)));
&SearchWindow::onAddToScratchpad))); contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("uploadToHubMenuItem"),
*getResourceUstring("uploadToHubMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &SearchWindow::onUploadToHub)));
&SearchWindow::onUploadToHub)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
contextMenu->accelerate(*this); contextMenu->accelerate(*mainWindow);
return contextMenu; return contextMenu;
} }
@ -1158,49 +1002,44 @@ SearchWindow :: constructAudioClipContextMenu(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the right-click context menu for local playlists. * Construct the right-click context menu for local playlists.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Menu * Ptr<Gtk::Menu>::Ref
SearchWindow :: constructPlaylistContextMenu(void) throw () SearchWindow :: constructPlaylistContextMenu(void) throw ()
{ {
Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); Ptr<Gtk::Menu>::Ref contextMenu(new Gtk::Menu());
Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); Gtk::Menu::MenuList & contextMenuList = contextMenu->items();
try { contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToLiveModeMenuItem"),
*getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this,
&SearchWindow::onAddToLiveMode)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToPlaylistMenuItem"),
sigc::mem_fun(*this,
&SearchWindow::onAddToPlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToScratchpadMenuItem"),
sigc::mem_fun(*this,
&SearchWindow::onAddToScratchpad)));
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("editPlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&SearchWindow::onAddToLiveMode))); &SearchWindow::onEditPlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToPlaylistMenuItem"), *getResourceUstring("schedulePlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&SearchWindow::onAddToPlaylist))); &SearchWindow::onSchedulePlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToScratchpadMenuItem"), *getResourceUstring("exportPlaylistMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&SearchWindow::onAddToScratchpad))); &SearchWindow::onExportPlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("editPlaylistMenuItem"), *getResourceUstring("uploadToHubMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
&SearchWindow::onEditPlaylist))); &SearchWindow::onUploadToHub)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("schedulePlaylistMenuItem"),
sigc::mem_fun(*this,
&SearchWindow::onSchedulePlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("exportPlaylistMenuItem"),
sigc::mem_fun(*this,
&SearchWindow::onExportPlaylist)));
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("uploadToHubMenuItem"),
sigc::mem_fun(*this,
&SearchWindow::onUploadToHub)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
contextMenu->accelerate(*this); contextMenu->accelerate(*mainWindow);
return contextMenu; return contextMenu;
} }
@ -1208,23 +1047,18 @@ SearchWindow :: constructPlaylistContextMenu(void) throw ()
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Construct the right-click context menu for remote audio clips & playlists. * Construct the right-click context menu for remote audio clips & playlists.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Menu * Ptr<Gtk::Menu>::Ref
SearchWindow :: constructRemoteContextMenu(void) throw () SearchWindow :: constructRemoteContextMenu(void) throw ()
{ {
Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); Ptr<Gtk::Menu>::Ref contextMenu(new Gtk::Menu());
Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); Gtk::Menu::MenuList & contextMenuList = contextMenu->items();
try { contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("downloadFromHubMenuItem"),
*getResourceUstring("downloadFromHubMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &SearchWindow::onDownloadFromHub)));
&SearchWindow::onDownloadFromHub)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
contextMenu->accelerate(*this); contextMenu->accelerate(*mainWindow);
return contextMenu; return contextMenu;
} }
@ -1302,25 +1136,12 @@ SearchWindow :: updatePagingToolbar(void) throw ()
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
std::exit(1); std::exit(1);
} }
backwardButton->setDisabled(offset == 0); backwardButton->set_sensitive(offset == 0);
forwardButton->setDisabled(offset + getSearchResultsSize() >= count); forwardButton->set_sensitive(offset + getSearchResultsSize() >= count);
} else { } else {
searchResultsCountLabel->set_text(""); searchResultsCountLabel->set_text("");
backwardButton->setDisabled(true); backwardButton->set_sensitive(false);
forwardButton->setDisabled(true); forwardButton->set_sensitive(false);
} }
} }
/*------------------------------------------------------------------------------
* Convert an integer to a string.
*----------------------------------------------------------------------------*/
Glib::ustring
SearchWindow :: itoa(int number) throw ()
{
std::ostringstream stream;
stream << number;
Glib::ustring string = stream.str();
return string;
}

View file

@ -41,17 +41,16 @@
#endif #endif
#include <string> #include <string>
#include <unicode/resbund.h> #include <unicode/resbund.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <libglademm.h>
#include "BasicWindow.h"
#include "LiveSupport/Core/NumericTools.h"
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" #include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ScrolledWindow.h"
#include "LiveSupport/Widgets/ScrolledNotebook.h"
#include "GuiWindow.h"
#include "AdvancedSearchEntry.h" #include "AdvancedSearchEntry.h"
#include "BrowseEntry.h" #include "BrowseEntry.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
@ -80,10 +79,16 @@ using namespace LiveSupport::Widgets;
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
*/ */
class SearchWindow : public GuiWindow class SearchWindow : public BasicWindow,
private NumericTools
{ {
private: private:
/**
* The directory where the Glade files are.
*/
Glib::ustring gladeDir;
/** /**
* The criteria for the last local search. * The criteria for the last local search.
*/ */
@ -112,32 +117,32 @@ class SearchWindow : public GuiWindow
/** /**
* The simple search input field. * The simple search input field.
*/ */
EntryBin * simpleSearchEntry; Gtk::Entry * simpleSearchEntry;
/** /**
* The box containing the advanced search input fields. * The box containing the advanced search input fields.
*/ */
AdvancedSearchEntry * advancedSearchEntry; Ptr<AdvancedSearchEntry>::Ref advancedSearchEntry;
/** /**
* The box containing the browse input fields. * The box containing the browse input fields.
*/ */
BrowseEntry * browseEntry; Ptr<BrowseEntry>::Ref browseEntry;
/** /**
* The list of transports in progress. * The list of transports in progress.
*/ */
TransportList * transportList; Ptr<TransportList>::Ref transportList;
/** /**
* The button for paging in the search results backward. * The button for paging in the search results backward.
*/ */
Button * backwardButton; Gtk::Button * backwardButton;
/** /**
* The button for paging in the search results forward. * The button for paging in the search results forward.
*/ */
Button * forwardButton; Gtk::Button * forwardButton;
/** /**
* The Schedule Playlist pop-up window. * The Schedule Playlist pop-up window.
@ -172,7 +177,7 @@ class SearchWindow : public GuiWindow
/** /**
* The notebook for the various tabs in the window. * The notebook for the various tabs in the window.
*/ */
ScrolledNotebook * searchInput; Gtk::Notebook * searchInput;
/** /**
* The transport token used when a remote search is pending. * The transport token used when a remote search is pending.
@ -182,26 +187,24 @@ class SearchWindow : public GuiWindow
/** /**
* The pop-up context menu for local audio clips. * The pop-up context menu for local audio clips.
*/ */
Gtk::Menu * audioClipContextMenu; Ptr<Gtk::Menu>::Ref audioClipContextMenu;
/** /**
* The pop-up context menu for local playlists. * The pop-up context menu for local playlists.
*/ */
Gtk::Menu * playlistContextMenu; Ptr<Gtk::Menu>::Ref playlistContextMenu;
/** /**
* The pop-up context menu for remote audio clips and playlists. * The pop-up context menu for remote audio clips and playlists.
*/ */
Gtk::Menu * remoteContextMenu; Ptr<Gtk::Menu>::Ref remoteContextMenu;
/** /**
* Construct the "search where" box. * Construct the "search where" box.
* This contains a combo box, where the user can choose between * This contains a combo box, where the user can choose between
* local search or hub search. * local search or hub search.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructSearchWhereBox(void) throw (); constructSearchWhereBox(void) throw ();
/** /**
@ -212,67 +215,57 @@ class SearchWindow : public GuiWindow
* items (both audio clips and playlists) where either the title * items (both audio clips and playlists) where either the title
* (dc:title), the creator (dc:creator) or the album (dc:source) * (dc:title), the creator (dc:creator) or the album (dc:source)
* metadata fields contain this string. * metadata fields contain this string.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructSimpleSearchView(void) throw (); constructSimpleSearchView(void) throw ();
/** /**
* Construct the advanced search view. * Construct the advanced search view.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructAdvancedSearchView(void) throw (); constructAdvancedSearchView(void) throw ();
/** /**
* Construct the browse view. * Construct the browse view.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructBrowseView(void) throw (); constructBrowseView(void) throw ();
/** /**
* Construct the advanced search view. * Construct the advanced search view.
*
* @return a pointer to the new box (already Gtk::manage()'ed)
*/ */
Gtk::VBox* void
constructTransportsView(void) throw (); constructTransportsView(void) throw ();
/** /**
* Construct the search results display. * Construct the search results display.
*
* @return a pointer to the new view (already Gtk::manage()'ed)
*/ */
Gtk::Box * void
constructSearchResultsView(void) throw (); constructSearchResultsView(void) throw ();
/** /**
* Construct the right-click context menu for local audio clips. * Construct the right-click context menu for local audio clips.
* *
* @return the context menu created (already Gtk::manage()'ed). * @return the context menu created.
*/ */
Gtk::Menu * Ptr<Gtk::Menu>::Ref
constructAudioClipContextMenu(void) throw (); constructAudioClipContextMenu(void) throw ();
/** /**
* Construct the right-click context menu for local playlists. * Construct the right-click context menu for local playlists.
* *
* @return the context menu created (already Gtk::manage()'ed). * @return the context menu created.
*/ */
Gtk::Menu * Ptr<Gtk::Menu>::Ref
constructPlaylistContextMenu(void) throw (); constructPlaylistContextMenu(void) throw ();
/** /**
* Construct the right-click context menu for remote audio clips * Construct the right-click context menu for remote audio clips
* and playlists. * and playlists.
* *
* @return the context menu created (already Gtk::manage()'ed). * @return the context menu created.
*/ */
Gtk::Menu * Ptr<Gtk::Menu>::Ref
constructRemoteContextMenu(void) throw (); constructRemoteContextMenu(void) throw ();
/** /**
@ -406,15 +399,6 @@ class SearchWindow : public GuiWindow
displayRemoteSearchError(const XmlRpcException & error) displayRemoteSearchError(const XmlRpcException & error)
throw (); throw ();
/**
* Convert an integer to a string.
*
* @param number the number to be converted.
* @return the string value of the number (in base 10).
*/
static Glib::ustring
itoa(int number) throw ();
protected: protected:
@ -610,15 +594,6 @@ class SearchWindow : public GuiWindow
void void
onForwardButtonClicked(void) throw (); onForwardButtonClicked(void) throw ();
/**
* Event handler called when the the window gets hidden.
*
* This overrides GuiWindow::on_hide(), and closes the Export Playlist
* window, if it is still open.
*/
virtual void
on_hide(void) throw ();
public: public:
@ -629,12 +604,14 @@ class SearchWindow : public GuiWindow
* all the vital info. * all the vital info.
* @param bundle the resource bundle holding the localized * @param bundle the resource bundle holding the localized
* resources for this window. * resources for this window.
* @param windowOpenerButton the button which was pressed to open * @param windowOpenerButton the button which was pressed to open
* this window. * this window.
* @param gladeDir the directory where the glade file is.
*/ */
SearchWindow(Ptr<GLiveSupport>::Ref gLiveSupport, SearchWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Gtk::ToggleButton * windowOpenerButton,
const Glib::ustring & gladeDir)
throw (); throw ();
/** /**
@ -660,6 +637,15 @@ class SearchWindow : public GuiWindow
*/ */
bool bool
uploadToHub(Ptr<Playable>::Ref playable) throw (); uploadToHub(Ptr<Playable>::Ref playable) throw ();
/**
* Hide the window.
*
* This overrides BasicWindow::hide(), and closes the Export Playlist
* and Schedule Playlist windows, if they are still open.
*/
virtual void
hide(void) throw ();
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -39,7 +39,6 @@
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::StorageClient; using namespace LiveSupport::StorageClient;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -89,63 +88,52 @@ const Glib::ustring downloadSymbol = "⇩";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
TransportList :: TransportList (Ptr<GLiveSupport>::Ref gLiveSupport, TransportList :: TransportList(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw () throw ()
: LocalizedObject(bundle), : LocalizedObject(bundle),
gLiveSupport(gLiveSupport) gLiveSupport(gLiveSupport)
{ {
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
// create the tree view // create the tree view
treeModel = Gtk::ListStore::create(modelColumns); treeModel = Gtk::ListStore::create(modelColumns);
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel)); glade->get_widget_derived("transportsTreeView1", treeView);
treeView->set_enable_search(false); treeView->set_model(treeModel);
treeView->connectModelSignals(treeModel);
// Add the TreeView's view columns: // Add the TreeView's view columns:
try { treeView->appendColumn("",
treeView->appendColumn("", modelColumns.directionColumn, 20);
modelColumns.directionColumn, 20); treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
treeView->appendColumn(*getResourceUstring("titleColumnLabel"), modelColumns.titleColumn, 300);
modelColumns.titleColumn, 300); treeView->appendColumn(*getResourceUstring("dateColumnLabel"),
treeView->appendColumn(*getResourceUstring("dateColumnLabel"), modelColumns.dateColumn, 180);
modelColumns.dateColumn, 180); treeView->appendColumn(*getResourceUstring("statusColumnLabel"),
treeView->appendColumn(*getResourceUstring("statusColumnLabel"), modelColumns.statusDisplayColumn, 50);
modelColumns.statusDisplayColumn, 50);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// register the signal handler for treeview entries being clicked // register the signal handler for treeview entries being clicked
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this, treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
&TransportList::onEntryClicked)); &TransportList::onEntryClicked));
// create the right-click entry context menu // create the right-click entry context menu
uploadMenu = Gtk::manage(new Gtk::Menu()); uploadMenu.reset(new Gtk::Menu());
downloadMenu = Gtk::manage(new Gtk::Menu()); downloadMenu.reset(new Gtk::Menu());
Gtk::Menu::MenuList& uploadMenuList = uploadMenu->items(); Gtk::Menu::MenuList& uploadMenuList = uploadMenu->items();
Gtk::Menu::MenuList& downloadMenuList = downloadMenu->items(); Gtk::Menu::MenuList& downloadMenuList = downloadMenu->items();
try{ uploadMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
uploadMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("cancelUploadMenuItem"),
*getResourceUstring("cancelUploadMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &TransportList::onCancelTransport)));
&TransportList::onCancelTransport))); downloadMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
downloadMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("cancelDownloadMenuItem"),
*getResourceUstring("cancelDownloadMenuItem"), sigc::mem_fun(*this,
sigc::mem_fun(*this, &TransportList::onCancelTransport)));
&TransportList::onCancelTransport)));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
uploadMenu->accelerate(*this); Gtk::Window * mainWindow;
downloadMenu->accelerate(*this); glade->get_widget("mainWindow1", mainWindow);
uploadMenu->accelerate(*mainWindow);
// add the tree view to this widget downloadMenu->accelerate(*mainWindow);
Gtk::VBox::pack_start(*treeView);
userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName)); userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName));
} }
@ -486,7 +474,7 @@ TransportList :: onCancelTransport(void) throw ()
removeSelected(); removeSelected();
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage( gLiveSupport->displayMessageWindow(*formatMessage(
"cannotCancelTransportMsg", "cannotCancelTransportMsg",
e.what() )); e.what() ));
} }

Some files were not shown because too many files have changed in this diff Show more