merged the libglade branch (3104:3183) back to the trunk
This commit is contained in:
parent
e6b5b273c4
commit
6d9cf9f3db
|
@ -66,6 +66,7 @@ using namespace LiveSupport::Core;
|
|||
class Bar
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* A static member variable.
|
||||
*/
|
||||
|
@ -76,25 +77,38 @@ class Bar
|
|||
*/
|
||||
int barInt;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
Bar (void) throw ()
|
||||
Bar (void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Say something.
|
||||
*
|
||||
* @param parameter a parameter we don't care about.
|
||||
* @return the bar string.
|
||||
* @exception std::exception on some problems.
|
||||
*/
|
||||
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.
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ system:<br>
|
|||
<li><a href="http://curl.haxx.se/">curl</a> >= 7.12.3</li>
|
||||
<li><a href="http://www.gtk.org/">gtk+</a> >= 2.6.10</li>
|
||||
<li><a href="http://www.gtkmm.org/">gtkmm</a> >= 2.6.5</li>
|
||||
<li><a href="http://www.gtkmm.org/">libglademm</a> >= 2.6.2</li>
|
||||
<li><a href="http://www.ibm.com/software/globalization/icu/">icu</a>
|
||||
>= 3.0</li>
|
||||
<li><a href="http://libxmlplusplus.sourceforge.net/">libxml++</a>
|
||||
|
|
|
@ -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 © 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>
|
|
@ -45,6 +45,7 @@ Build-Depends: debhelper (>= 4.0.0),
|
|||
libboost-date-time-dev (>= 1.33.1),
|
||||
libgtk2.0-dev (>= 2.6.10),
|
||||
libgtkmm-2.4-dev (>= 2.6.5),
|
||||
libglademm-2.4-dev (>= 2.6.2),
|
||||
libxml++2.6-dev (>= 2.8.1),
|
||||
libicu34-dev,
|
||||
apache2,
|
||||
|
@ -164,6 +165,7 @@ Depends: ${shlibs:Depends},
|
|||
libicu34,
|
||||
libgtk2.0-0 (>= 2.6.10),
|
||||
libgtkmm-2.4-1c2a (>= 2.6.5)
|
||||
libglademm-2.4-1c2a (>= 2.6.2)
|
||||
Description: A radio program automation and support tool.
|
||||
Campcaster is the first free and open radio management software that
|
||||
provides live studio broadcast capabilities as well as remote automation
|
||||
|
|
|
@ -149,7 +149,8 @@ CORE_LIB_OBJS = ${TMP_DIR}/UniqueId.o \
|
|||
${TMP_DIR}/NumericRangeConstraint.o \
|
||||
${TMP_DIR}/EnumerationConstraint.o \
|
||||
${TMP_DIR}/RdsItem.o \
|
||||
${TMP_DIR}/RdsContainer.o
|
||||
${TMP_DIR}/RdsContainer.o \
|
||||
${TMP_DIR}/NumericTools.o
|
||||
|
||||
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||
${TMP_DIR}/FileToolsTest.o \
|
||||
|
@ -170,7 +171,8 @@ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
|||
${TMP_DIR}/SearchCriteriaTest.o \
|
||||
${TMP_DIR}/MetadataTypeContainerTest.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 \
|
||||
${TMP_DIR}/${PACKAGE_NAME}_en.res \
|
||||
|
|
|
@ -281,6 +281,7 @@ class AudioClip : public Configurable,
|
|||
* use the constructor with (title, playlength, uri) arguments.
|
||||
*
|
||||
* @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 uri the location of the sound file corresponding to
|
||||
* 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
|
||||
* 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
|
||||
setId(Ptr<UniqueId>::Ref id) throw (std::invalid_argument)
|
||||
|
|
|
@ -172,7 +172,7 @@ class LocalizedObject
|
|||
/**
|
||||
* 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
|
||||
setBundle(Ptr<ResourceBundle>::Ref bundle) throw ()
|
||||
|
|
|
@ -146,7 +146,7 @@ class MetadataConstraint : public Configurable
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information
|
||||
*/
|
||||
|
|
|
@ -69,15 +69,15 @@ class MetadataTypeContainer;
|
|||
* called metadataType. This may look like the following:
|
||||
*
|
||||
* <pre><code>
|
||||
* <metadataType dcName = "dc:creator"
|
||||
* <metadataType dcName = "dc:creator"
|
||||
* id3Tag = "TPE2"
|
||||
* localizationKey = "dc_creator"
|
||||
* tab = "main" >
|
||||
* <constraint type = "numericRange" >
|
||||
* <value>1</value>
|
||||
* <value>12</value>
|
||||
* </constraint>
|
||||
* </metadataType>
|
||||
* tab = "main" >
|
||||
* <constraint type = "numericRange" >
|
||||
* <value>1</value>
|
||||
* <value>12</value>
|
||||
* </constraint>
|
||||
* </metadataType>
|
||||
* </code></pre>
|
||||
*
|
||||
* 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
|
||||
* 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 <constraint> element.
|
||||
*
|
||||
* See the Studio config files for a list of all metadata types.
|
||||
*
|
||||
* 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 localizationKey the key to get the localized name for
|
||||
* 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,
|
||||
Glib::ustring dcName,
|
||||
|
@ -196,7 +200,7 @@ class MetadataType : public Configurable
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information
|
||||
*/
|
||||
|
|
|
@ -86,6 +86,8 @@ namespace Core {
|
|||
* For a description of the metadataType XML element, see the documentation
|
||||
* for the MetadataType class.
|
||||
*
|
||||
* See the Studio config files for a list of all metadata types.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see MetadataType
|
||||
|
@ -164,7 +166,7 @@ class MetadataTypeContainer : public Configurable,
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information
|
||||
*/
|
||||
|
@ -242,6 +244,17 @@ class MetadataTypeContainer : public Configurable,
|
|||
getById3Tag(const Glib::ustring id3Tag)
|
||||
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
|
||||
* type.
|
||||
|
|
|
@ -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
|
||||
|
|
@ -216,6 +216,7 @@ class OptionsContainer
|
|||
/**
|
||||
* Set a string type option.
|
||||
*
|
||||
* @param optionItem which option to set
|
||||
* @param value the new value of the option
|
||||
* @exception std::invalid_argument if the option name is not found
|
||||
*/
|
||||
|
|
|
@ -398,6 +398,7 @@ class Playlist : public Configurable,
|
|||
* see the note at the default constructor.
|
||||
*
|
||||
* @param id the id of the playlist.
|
||||
* @param title the title of the playlist.
|
||||
* @param playlength the playing length of the playlist.
|
||||
* @param uri the location of the SMIL file representing this
|
||||
* playlist (optional)
|
||||
|
|
|
@ -155,7 +155,7 @@ class RdsContainer : public Configurable
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information.
|
||||
*/
|
||||
|
@ -171,6 +171,7 @@ class RdsContainer : public Configurable
|
|||
*
|
||||
* @param key which setting to modify.
|
||||
* @param value the new value of the RDS setting.
|
||||
* @param enabled whether this value will be broadcast.
|
||||
*/
|
||||
void
|
||||
setRdsOptions(Ptr<const Glib::ustring>::Ref key,
|
||||
|
|
|
@ -172,7 +172,7 @@ class RdsItem : public Configurable
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information
|
||||
*/
|
||||
|
|
|
@ -164,10 +164,10 @@ class ScheduleEntry
|
|||
* A constructor based on a DOM element
|
||||
*
|
||||
* @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
|
||||
* @see #getElementName
|
||||
* @see #getDom
|
||||
* @see #toDom
|
||||
*/
|
||||
ScheduleEntry(xmlpp::Element * element)
|
||||
throw (std::invalid_argument);
|
||||
|
|
|
@ -132,7 +132,7 @@ class UniqueId
|
|||
* 2^31-1 (inclusive), the value of the UniqueId will be
|
||||
* 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.
|
||||
*/
|
||||
static Ptr<UniqueId>::Ref
|
||||
|
|
|
@ -357,7 +357,7 @@ class XmlRpcTools
|
|||
static void
|
||||
fromTimeToXmlRpcValue(
|
||||
Ptr<const boost::posix_time::ptime>::Ref from,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -370,7 +370,7 @@ class XmlRpcTools
|
|||
static void
|
||||
toTimeToXmlRpcValue(
|
||||
Ptr<const boost::posix_time::ptime>::Ref to,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -575,7 +575,7 @@ class XmlRpcTools
|
|||
* Convert a SearchCriteria to an XmlRpcValue.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
static void
|
||||
|
@ -599,8 +599,8 @@ class XmlRpcTools
|
|||
/**
|
||||
* Convert a string token to an XmlRpcValue.
|
||||
*
|
||||
* @param criteria the string token to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* @param token the string token to convert.
|
||||
* @param returnValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
|
@ -625,7 +625,7 @@ class XmlRpcTools
|
|||
* of the backup methods to an XmlRpcValue.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
static void
|
||||
|
@ -649,7 +649,7 @@ class XmlRpcTools
|
|||
* Convert a URL string to an XmlRpcValue.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
static void
|
||||
|
@ -673,7 +673,7 @@ class XmlRpcTools
|
|||
* Convert a path string to an XmlRpcValue.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
static void
|
||||
|
@ -696,7 +696,7 @@ class XmlRpcTools
|
|||
/**
|
||||
* 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
|
||||
* the conversion.
|
||||
*/
|
||||
|
|
|
@ -426,7 +426,7 @@ AudioClip :: configure(const xmlpp::Element & element)
|
|||
* Return the value of a metadata field.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
AudioClip :: getMetadata(const string &key) const
|
||||
AudioClip :: getMetadata(const std::string & key) const
|
||||
throw ()
|
||||
{
|
||||
std::string name, prefix;
|
||||
|
|
|
@ -140,7 +140,7 @@ class EnumerationConstraint : public MetadataConstraint
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -112,7 +112,7 @@ class NumericConstraint : public MetadataConstraint
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information
|
||||
*/
|
||||
|
|
|
@ -160,7 +160,7 @@ class NumericRangeConstraint : public MetadataConstraint
|
|||
/**
|
||||
* 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
|
||||
* contains bad configuration information
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -639,7 +639,7 @@ Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
|
|||
* Return the value of a metadata field.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
Playlist :: getMetadata(const string &key) const
|
||||
Playlist :: getMetadata(const std::string & key) const
|
||||
throw ()
|
||||
{
|
||||
std::string name, prefix;
|
||||
|
|
|
@ -90,9 +90,11 @@ class Conversion
|
|||
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 round specify how to round the fractional part
|
||||
* (default: down).
|
||||
* @return an odbc::Timestamp, holding the same time.
|
||||
*/
|
||||
static Ptr<odbc::Timestamp>::Ref
|
||||
|
|
|
@ -214,7 +214,7 @@ class SchedulerThread : public virtual RunnableInterface
|
|||
* </ul>
|
||||
*
|
||||
* @param signalId a value from SignalTypes.
|
||||
* @see #signalTypes
|
||||
* @see #SignalTypes
|
||||
*/
|
||||
virtual void
|
||||
signal(int signalId) throw ();
|
||||
|
|
|
@ -91,6 +91,9 @@ ICU_LIBS=@ICU_LIBS@
|
|||
GTKMM_CFLAGS=@GTKMM_CFLAGS@
|
||||
GTKMM_LIBS=@GTKMM_LIBS@
|
||||
|
||||
LIBGLADEMM_CFLAGS=@LIBGLADEMM_CFLAGS@
|
||||
LIBGLADEMM_LIBS=@LIBGLADEMM_LIBS@
|
||||
|
||||
TEST_RESULTS = ${DOC_DIR}/testResults.xml
|
||||
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
|
||||
TEST_XSLT = ../etc/testResultToHtml.xsl
|
||||
|
@ -115,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
|||
${LIBXMLPP_CFLAGS} \
|
||||
${ICU_CFLAGS} \
|
||||
${GTKMM_CFLAGS} \
|
||||
${LIBGLADEMM_CFLAGS} \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${INCLUDE_DIR} -I${TMP_DIR}
|
||||
|
@ -123,6 +127,7 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
|||
${LIBXMLPP_LIBS} \
|
||||
${ICU_LIBS} \
|
||||
${GTKMM_LIBS} \
|
||||
${LIBGLADEMM_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${LIB_DIR}
|
||||
|
|
|
@ -108,6 +108,10 @@ PKG_CHECK_MODULES(GTKMM,[gtkmm-2.4 >= 2.5.5])
|
|||
AC_SUBST(GTKMM_CFLAGS)
|
||||
AC_SUBST(GTKMM_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(LIBGLADEMM,[libglademm-2.4 >= 2.6.2])
|
||||
AC_SUBST(LIBGLADEMM_CFLAGS)
|
||||
AC_SUBST(LIBGLADEMM_LIBS)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl enable compilaton for code coverage data
|
||||
|
|
|
@ -40,21 +40,12 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <exception>
|
||||
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/menu.h>
|
||||
#include <gtkmm/comboboxtext.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
|
||||
#include <libglademm.h>
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Widgets {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
|
@ -65,296 +56,31 @@ using namespace LiveSupport::Core;
|
|||
|
||||
/**
|
||||
* 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$
|
||||
* @version $Revision$
|
||||
*/
|
||||
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:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor to be used with Glade::Xml::get_widget_derived().
|
||||
*
|
||||
* @param leftImage the left image of the widget.
|
||||
* @param centerImage the image under the text display.
|
||||
* @param rightImage the right image for the widget.
|
||||
* @param baseClass widget of the parent class, created by Glade.
|
||||
* @param glade the Glade object.
|
||||
*/
|
||||
ComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage) throw ();
|
||||
ComboBoxText(GtkComboBox * baseClass,
|
||||
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~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 ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/MetadataTypeContainer.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
|
||||
|
@ -65,22 +67,53 @@ using namespace LiveSupport::Core;
|
|||
*/
|
||||
class MetadataComboBoxText : public ComboBoxText
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*/
|
||||
MetadataComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage,
|
||||
Ptr<MetadataTypeContainer>::Ref metadataTypes)
|
||||
throw ();
|
||||
private:
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
virtual
|
||||
~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 ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -67,14 +67,16 @@ class OperatorComboBoxText : public ComboBoxText,
|
|||
public LocalizedObject
|
||||
{
|
||||
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,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
OperatorComboBoxText(
|
||||
GtkComboBox * baseClass,
|
||||
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -82,6 +84,24 @@ class OperatorComboBoxText : public ComboBoxText,
|
|||
*/
|
||||
virtual
|
||||
~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 ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,12 +40,17 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playable.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
|
||||
#include <LiveSupport/Widgets/ZebraTreeModelColumnRecord.h>
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Widgets {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
|
|
|
@ -42,18 +42,11 @@
|
|||
|
||||
#include <gtkmm/liststore.h>
|
||||
#include <gtkmm/treeview.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/alignment.h>
|
||||
#include <gtkmm/eventbox.h>
|
||||
#include <gtkmm/image.h>
|
||||
#include <gtkmm/window.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Widgets/WidgetConstants.h"
|
||||
#include "LiveSupport/Widgets/CornerImages.h"
|
||||
#include "LiveSupport/Widgets/ImageButton.h"
|
||||
#include "LiveSupport/Widgets/BlueBin.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -182,7 +175,6 @@ class ZebraTreeView : public Gtk::TreeView
|
|||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* 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)
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -33,11 +33,9 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Widgets/Colors.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -54,30 +52,12 @@ using namespace LiveSupport::Widgets;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
ComboBoxText :: ComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage)
|
||||
ComboBoxText :: ComboBoxText(
|
||||
GtkComboBox * baseClass,
|
||||
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,26 +54,50 @@ using namespace LiveSupport::Widgets;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
MetadataComboBoxText :: MetadataComboBoxText(
|
||||
Glib::RefPtr<Gdk::Pixbuf> leftImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage,
|
||||
Ptr<MetadataTypeContainer>::Ref metadataTypes)
|
||||
GtkComboBox * baseClass,
|
||||
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Widgets/OperatorComboBoxText.h"
|
||||
|
||||
|
||||
|
@ -54,37 +57,72 @@ using namespace LiveSupport::Widgets;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
OperatorComboBoxText :: OperatorComboBoxText(
|
||||
Glib::RefPtr<Gdk::Pixbuf> leftImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
GtkComboBox * baseClass,
|
||||
const Glib::RefPtr<Gnome::Glade::Xml> & glade)
|
||||
throw ()
|
||||
: ComboBoxText(leftImage, centerImage, rightImage),
|
||||
LocalizedObject(bundle)
|
||||
: ComboBoxText(baseClass, glade)
|
||||
{
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -470,9 +470,10 @@ WidgetFactory :: createButton(const Glib::ustring & label,
|
|||
ComboBoxText *
|
||||
WidgetFactory :: createComboBoxText(void) throw ()
|
||||
{
|
||||
return new ComboBoxText(comboBoxLeftImage,
|
||||
comboBoxCenterImage,
|
||||
comboBoxRightImage);
|
||||
return 0;
|
||||
// return new ComboBoxText(comboBoxLeftImage,
|
||||
// comboBoxCenterImage,
|
||||
// comboBoxRightImage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -484,10 +485,11 @@ WidgetFactory :: createMetadataComboBoxText(
|
|||
Ptr<MetadataTypeContainer>::Ref metadataTypes)
|
||||
throw ()
|
||||
{
|
||||
return new MetadataComboBoxText(comboBoxLeftImage,
|
||||
comboBoxCenterImage,
|
||||
comboBoxRightImage,
|
||||
metadataTypes);
|
||||
return 0;
|
||||
// return new MetadataComboBoxText(comboBoxLeftImage,
|
||||
// comboBoxCenterImage,
|
||||
// comboBoxRightImage,
|
||||
// metadataTypes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -499,10 +501,11 @@ WidgetFactory :: createOperatorComboBoxText(
|
|||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ()
|
||||
{
|
||||
return new OperatorComboBoxText(comboBoxLeftImage,
|
||||
comboBoxCenterImage,
|
||||
comboBoxRightImage,
|
||||
bundle);
|
||||
return 0;
|
||||
// return new OperatorComboBoxText(comboBoxLeftImage,
|
||||
// comboBoxCenterImage,
|
||||
// comboBoxRightImage,
|
||||
// bundle);
|
||||
}
|
||||
|
||||
|
||||
|
@ -515,13 +518,14 @@ WidgetFactory :: createNumericComboBoxText(int lowerLimit,
|
|||
int minLength)
|
||||
throw ()
|
||||
{
|
||||
ComboBoxText * comboBox = new ComboBoxText(comboBoxLeftImage,
|
||||
comboBoxCenterImage,
|
||||
comboBoxRightImage);
|
||||
for (int i = lowerLimit; i <= upperLimit; ++i) {
|
||||
comboBox->append_text(itoa(i, minLength));
|
||||
}
|
||||
return comboBox;
|
||||
return 0;
|
||||
// ComboBoxText * comboBox = new ComboBoxText(comboBoxLeftImage,
|
||||
// comboBoxCenterImage,
|
||||
// comboBoxRightImage);
|
||||
// for (int i = lowerLimit; i <= upperLimit; ++i) {
|
||||
// comboBox->append_text(itoa(i, minLength));
|
||||
// }
|
||||
// return comboBox;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -184,6 +184,9 @@ CURL_LIBS=@CURL_LIBS@
|
|||
GTKMM_CFLAGS=@GTKMM_CFLAGS@
|
||||
GTKMM_LIBS=@GTKMM_LIBS@
|
||||
|
||||
LIBGLADEMM_CFLAGS=@LIBGLADEMM_CFLAGS@
|
||||
LIBGLADEMM_LIBS=@LIBGLADEMM_LIBS@
|
||||
|
||||
GSTREAMER_CFLAGS=@GSTREAMER_CFLAGS@
|
||||
GSTREAMER_LIBS=@GSTREAMER_LIBS@
|
||||
|
||||
|
@ -219,6 +222,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
|||
${TAGLIB_CFLAGS} \
|
||||
${LIBXMLPP_CFLAGS} \
|
||||
${GTKMM_CFLAGS} \
|
||||
${LIBGLADEMM_CFLAGS} \
|
||||
${GSTREAMER_CFLAGS} \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
|
@ -235,6 +239,7 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
|||
${LIBXMLPP_LIBS} \
|
||||
${CURL_LIBS} \
|
||||
${GTKMM_LIBS} \
|
||||
${LIBGLADEMM_LIBS} \
|
||||
${GSTREAMER_LIBS} \
|
||||
${TAGLIB_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
|
@ -253,12 +258,12 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
|||
G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
|
||||
${TMP_DIR}/MasterPanelWindow.o \
|
||||
${TMP_DIR}/NowPlaying.o \
|
||||
${TMP_DIR}/MasterPanelUserInfoWidget.o \
|
||||
${TMP_DIR}/GuiWindow.o \
|
||||
${TMP_DIR}/BasicWindow.o \
|
||||
${TMP_DIR}/LoginWindow.o \
|
||||
${TMP_DIR}/UploadFileWindow.o \
|
||||
${TMP_DIR}/ScratchpadWindow.o \
|
||||
${TMP_DIR}/SimplePlaylistManagementWindow.o \
|
||||
${TMP_DIR}/PlaylistWindow.o \
|
||||
${TMP_DIR}/SchedulerWindow.o \
|
||||
${TMP_DIR}/SchedulePlaylistWindow.o \
|
||||
${TMP_DIR}/SearchWindow.o \
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
<!ELEMENT gLiveSupport (resourceBundle,
|
||||
supportedLanguages,
|
||||
gladeDirectory,
|
||||
widgetFactory,
|
||||
authenticationClientFactory,
|
||||
storageClientFactory,
|
||||
|
@ -25,8 +26,11 @@
|
|||
<!ELEMENT supportedLanguages (language+) >
|
||||
|
||||
<!ELEMENT language EMPTY >
|
||||
<!ATTLIST language locale CDATA #REQUIRED >
|
||||
<!ATTLIST language name CDATA #REQUIRED >
|
||||
<!ATTLIST language locale CDATA #REQUIRED >
|
||||
<!ATTLIST language name CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT gladeDirectory EMPTY >
|
||||
<!ATTLIST gladeDirectory path CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT widgetFactory EMPTY >
|
||||
<!ATTLIST widgetFactory path CDATA #REQUIRED >
|
||||
|
@ -150,6 +154,8 @@
|
|||
<language locale="sr_CS_CYRILLIC" name="Српски"/>
|
||||
</supportedLanguages>
|
||||
|
||||
<gladeDirectory path = "./var/glade/" />
|
||||
|
||||
<widgetFactory path = "var/widgets/" />
|
||||
|
||||
<authenticationClientFactory>
|
||||
|
@ -430,7 +436,7 @@
|
|||
</keyboardShortcutContainer>
|
||||
|
||||
<keyboardShortcutContainer
|
||||
windowName ="simplePlaylistManagementWindow">
|
||||
windowName ="playlistWindow">
|
||||
<keyboardShortcut action = "moveItemUp"
|
||||
key = "<Alt>Up" />
|
||||
<keyboardShortcut action = "moveItemDown"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
<!ELEMENT gLiveSupport (resourceBundle,
|
||||
supportedLanguages,
|
||||
gladeDirectory,
|
||||
widgetFactory,
|
||||
authenticationClientFactory,
|
||||
storageClientFactory,
|
||||
|
@ -25,8 +26,11 @@
|
|||
<!ELEMENT supportedLanguages (language+) >
|
||||
|
||||
<!ELEMENT language EMPTY >
|
||||
<!ATTLIST language locale CDATA #REQUIRED >
|
||||
<!ATTLIST language name CDATA #REQUIRED >
|
||||
<!ATTLIST language locale CDATA #REQUIRED >
|
||||
<!ATTLIST language name CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT gladeDirectory EMPTY >
|
||||
<!ATTLIST gladeDirectory path CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT widgetFactory EMPTY >
|
||||
<!ATTLIST widgetFactory path CDATA #REQUIRED >
|
||||
|
@ -150,6 +154,8 @@
|
|||
<language locale="sr_CS_CYRILLIC" name="Српски"/>
|
||||
</supportedLanguages>
|
||||
|
||||
<gladeDirectory path = "ls_var_dir/Campcaster/glade/" />
|
||||
|
||||
<widgetFactory path = "ls_var_dir/Campcaster/Widgets/" />
|
||||
|
||||
<authenticationClientFactory>
|
||||
|
@ -429,7 +435,7 @@
|
|||
</keyboardShortcutContainer>
|
||||
|
||||
<keyboardShortcutContainer
|
||||
windowName ="simplePlaylistManagementWindow">
|
||||
windowName ="playlistWindow">
|
||||
<keyboardShortcut action = "moveItemUp"
|
||||
key = "<Alt>Up" />
|
||||
<keyboardShortcut action = "moveItemDown"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
<!ELEMENT gLiveSupport (resourceBundle,
|
||||
supportedLanguages,
|
||||
gladeDirectory,
|
||||
widgetFactory,
|
||||
authenticationClientFactory,
|
||||
storageClientFactory,
|
||||
|
@ -25,8 +26,11 @@
|
|||
<!ELEMENT supportedLanguages (language+) >
|
||||
|
||||
<!ELEMENT language EMPTY >
|
||||
<!ATTLIST language locale CDATA #REQUIRED >
|
||||
<!ATTLIST language name CDATA #REQUIRED >
|
||||
<!ATTLIST language locale CDATA #REQUIRED >
|
||||
<!ATTLIST language name CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT gladeDirectory EMPTY >
|
||||
<!ATTLIST gladeDirectory path CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT widgetFactory EMPTY >
|
||||
<!ATTLIST widgetFactory path CDATA #REQUIRED >
|
||||
|
@ -150,6 +154,8 @@
|
|||
<language locale="sr_CS_CYRILLIC" name="Српски"/>
|
||||
</supportedLanguages>
|
||||
|
||||
<gladeDirectory path = "./var/glade/" />
|
||||
|
||||
<widgetFactory path = "var/widgets/" />
|
||||
|
||||
<authenticationClientFactory>
|
||||
|
@ -429,7 +435,7 @@
|
|||
</keyboardShortcutContainer>
|
||||
|
||||
<keyboardShortcutContainer
|
||||
windowName ="simplePlaylistManagementWindow">
|
||||
windowName ="playlistWindow">
|
||||
<keyboardShortcut action = "moveItemUp"
|
||||
key = "<Alt>Up" />
|
||||
<keyboardShortcut action = "moveItemDown"
|
||||
|
|
|
@ -101,6 +101,10 @@ PKG_CHECK_MODULES(GTKMM,[gtkmm-2.4 >= 2.5.5])
|
|||
AC_SUBST(GTKMM_CFLAGS)
|
||||
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])
|
||||
AC_SUBST(GSTREAMER_CFLAGS)
|
||||
AC_SUBST(GSTREAMER_LIBS)
|
||||
|
|
|
@ -35,12 +35,10 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "AdvancedSearchItem.h"
|
||||
#include "AdvancedSearchEntry.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -51,39 +49,9 @@ using namespace LiveSupport::GLiveSupport;
|
|||
namespace {
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The localization key for "File type: " before the file type selector box.
|
||||
* The maximum number of AdvancedSearchItem children.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string fileTypeLabelKey = "fileTypeTextLabel";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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";
|
||||
const int maxChildren = 5;
|
||||
|
||||
}
|
||||
|
||||
|
@ -95,61 +63,39 @@ const std::string audioClipSearchKey = "audioClip";
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AdvancedSearchEntry :: AdvancedSearchEntry(Ptr<GLiveSupport>::Ref gLiveSupport)
|
||||
AdvancedSearchEntry :: AdvancedSearchEntry(
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: gLiveSupport(gLiveSupport)
|
||||
{
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = gLiveSupport->getBundle("advancedSearchEntry");
|
||||
} catch (std::invalid_argument &e) {
|
||||
// TODO: signal error
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
|
||||
"advancedSearchEntry");
|
||||
setBundle(bundle);
|
||||
|
||||
metadataTypes = gLiveSupport->getMetadataTypeContainer();
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Label * fileTypeLabel;
|
||||
try {
|
||||
fileTypeLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring(fileTypeLabelKey) ));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
glade->get_widget("advancedFileTypeLabel1", fileTypeLabel);
|
||||
fileTypeLabel->set_label(*getResourceUstring("fileTypeTextLabel"));
|
||||
|
||||
glade->get_widget_derived("advancedFileTypeEntry1", fileTypeEntry);
|
||||
fileTypeEntry->append_text(*getResourceUstring("allFileType"));
|
||||
fileTypeEntry->append_text(*getResourceUstring("audioClipFileType"));
|
||||
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());
|
||||
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,
|
||||
children.at(0)->signalAddNew().connect(sigc::mem_fun(*this,
|
||||
&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
|
||||
AdvancedSearchEntry :: onAddNewCondition(void) throw ()
|
||||
{
|
||||
AdvancedSearchItem * searchItem = Gtk::manage(new AdvancedSearchItem(
|
||||
false,
|
||||
metadataTypes,
|
||||
getBundle() ));
|
||||
searchItemsBox->pack_start(*searchItem, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
searchItem->show_all_children();
|
||||
searchItem->show();
|
||||
bool foundAvailableChild = false;
|
||||
Ptr<AdvancedSearchItem>::Ref child;
|
||||
|
||||
for (int i = 1; i < maxChildren; ++i) {
|
||||
child = children.at(i);
|
||||
if (!child->is_visible()) {
|
||||
foundAvailableChild = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundAvailableChild) {
|
||||
child->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,16 +128,26 @@ AdvancedSearchEntry :: onAddNewCondition(void) throw ()
|
|||
Ptr<SearchCriteria>::Ref
|
||||
AdvancedSearchEntry :: getSearchCriteria(void) throw ()
|
||||
{
|
||||
Ptr<const Glib::ustring>::Ref fileType = fileTypeEntry->getActiveKey();
|
||||
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria(*fileType));
|
||||
Glib::ustring 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();
|
||||
Gtk::Box_Helpers::BoxList::type_base::iterator it;
|
||||
|
||||
for (it = children.begin(); it != children.end(); ++it) {
|
||||
AdvancedSearchItem * child = dynamic_cast<AdvancedSearchItem *>(
|
||||
it->get_widget() );
|
||||
criteria->addCondition(child->getSearchCondition());
|
||||
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria(fileType));
|
||||
|
||||
for (int i = 0; i < maxChildren; ++i) {
|
||||
Ptr<AdvancedSearchItem>::Ref child = children.at(i);
|
||||
if (child->is_visible()) {
|
||||
criteria->addCondition(child->getSearchCondition());
|
||||
}
|
||||
}
|
||||
|
||||
return criteria;
|
||||
|
@ -199,12 +161,8 @@ void
|
|||
AdvancedSearchEntry :: connectCallback(const sigc::slot<void> & callback)
|
||||
throw ()
|
||||
{
|
||||
Gtk::Box_Helpers::BoxList children = searchItemsBox->children();
|
||||
Gtk::Box_Helpers::BoxList::type_base::iterator it;
|
||||
|
||||
for (it = children.begin(); it != children.end(); ++it) {
|
||||
AdvancedSearchItem * child = dynamic_cast<AdvancedSearchItem *>(
|
||||
it->get_widget() );
|
||||
for (int i = 0; i < maxChildren; ++i) {
|
||||
Ptr<AdvancedSearchItem>::Ref child = children.at(i);
|
||||
child->signal_activate().connect(callback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,18 +40,23 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <vector>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/MetadataTypeContainer.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
#include "AdvancedSearchItem.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -62,15 +67,15 @@ using namespace LiveSupport::Core;
|
|||
/* =============================================================== 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$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class AdvancedSearchEntry : public Gtk::VBox,
|
||||
public LocalizedObject
|
||||
class AdvancedSearchEntry : public LocalizedObject
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ComboBoxText * fileTypeEntry;
|
||||
|
||||
|
||||
/**
|
||||
* The box containing the AdvancedSearchItem widgets.
|
||||
* The AdvancedSearchItem children of the widget.
|
||||
*/
|
||||
Gtk::VBox * searchItemsBox;
|
||||
|
||||
|
||||
std::vector<Ptr<AdvancedSearchItem>::Ref> children;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, containing
|
||||
* @param gLiveSupport the GLiveSupport object, containing
|
||||
* 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 ();
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,13 +35,10 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "AdvancedSearchItem.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -59,46 +56,39 @@ using namespace LiveSupport::GLiveSupport;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AdvancedSearchItem :: AdvancedSearchItem(
|
||||
bool isFirst,
|
||||
Ptr<MetadataTypeContainer>::Ref metadataTypes,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
int index,
|
||||
Ptr<MetadataTypeContainer>::Ref metadataTypes,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: LocalizedObject(bundle)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
glade->get_widget(addIndex("advancedSearchItem", index), enclosingBox);
|
||||
|
||||
Gtk::Label * searchByLabel;
|
||||
try {
|
||||
searchByLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("searchByTextLabel") ));
|
||||
glade->get_widget(addIndex("advancedSearchByLabel", index), searchByLabel);
|
||||
searchByLabel->set_label(*getResourceUstring("searchByTextLabel"));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
glade->get_widget_derived(addIndex("advancedMetadataEntry", index),
|
||||
metadataEntry);
|
||||
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);
|
||||
|
||||
metadataEntry = Gtk::manage(wf->createMetadataComboBoxText(metadataTypes));
|
||||
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);
|
||||
if (index == 0) {
|
||||
glade->get_widget(addIndex("advancedPlusMinusButton", index),
|
||||
plusButton);
|
||||
plusButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&AdvancedSearchItem::onPlusButtonClicked ));
|
||||
&AdvancedSearchItem::onPlusButtonClicked));
|
||||
} else {
|
||||
closeButton = Gtk::manage(wf->createButton(
|
||||
WidgetConstants::minusButton));
|
||||
glade->get_widget(addIndex("advancedPlusMinusButton", index),
|
||||
closeButton);
|
||||
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&AdvancedSearchItem::destroy_ ));
|
||||
pack_start(*closeButton, Gtk::PACK_SHRINK, 5);
|
||||
&AdvancedSearchItem::onCloseButtonClicked));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +97,7 @@ AdvancedSearchItem :: AdvancedSearchItem(
|
|||
* Return the current state of the search fields.
|
||||
*----------------------------------------------------------------------------*/
|
||||
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 operatorKey = operatorEntry->getActiveKey();
|
||||
|
|
|
@ -42,17 +42,16 @@
|
|||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/NumericTools.h"
|
||||
#include "LiveSupport/Core/MetadataTypeContainer.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Widgets/MetadataComboBoxText.h"
|
||||
#include "LiveSupport/Widgets/OperatorComboBoxText.h"
|
||||
#include "LiveSupport/Widgets/EntryBin.h"
|
||||
#include "LiveSupport/Widgets/ImageButton.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -75,47 +74,45 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class AdvancedSearchItem : public Gtk::HBox,
|
||||
public LocalizedObject
|
||||
class AdvancedSearchItem : public LocalizedObject,
|
||||
private NumericTools
|
||||
{
|
||||
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.
|
||||
*/
|
||||
MetadataComboBoxText * metadataEntry;
|
||||
MetadataComboBoxText * metadataEntry;
|
||||
|
||||
/**
|
||||
* The operator field.
|
||||
*/
|
||||
OperatorComboBoxText * operatorEntry;
|
||||
OperatorComboBoxText * operatorEntry;
|
||||
|
||||
/**
|
||||
* The "search for this value" field.
|
||||
*/
|
||||
EntryBin * valueEntry;
|
||||
Gtk::Entry * valueEntry;
|
||||
|
||||
/**
|
||||
* The "add new search item" button.
|
||||
*/
|
||||
ImageButton * plusButton;
|
||||
Gtk::Button * plusButton;
|
||||
|
||||
/**
|
||||
* The "remove this item" button.
|
||||
*/
|
||||
ImageButton * closeButton;
|
||||
Gtk::Button * closeButton;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -126,19 +123,33 @@ class AdvancedSearchItem : public Gtk::HBox,
|
|||
signalAddNew().emit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handler for the Close button getting clicked.
|
||||
*/
|
||||
void
|
||||
onCloseButtonClicked() throw ()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param isFirst true if this is the first search condition
|
||||
* (so it does not need a Close button)
|
||||
* @param index the position of this item in the list of
|
||||
* advanced search items.
|
||||
* @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,
|
||||
Ptr<MetadataTypeContainer>::Ref metadataTypes,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
AdvancedSearchItem(int index,
|
||||
Ptr<MetadataTypeContainer>::Ref metadataTypes,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -179,6 +190,35 @@ class AdvancedSearchItem : public Gtk::HBox,
|
|||
{
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -78,34 +77,26 @@ const Glib::ustring userPreferencesKeyName = "activeBackups";
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
BackupList :: BackupList (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
BackupList :: BackupList (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
|
||||
|
||||
// create the tree view
|
||||
treeModel = Gtk::ListStore::create(modelColumns);
|
||||
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel));
|
||||
treeView->set_enable_search(false);
|
||||
glade->get_widget_derived("backupListTreeView1", treeView);
|
||||
treeView->set_model(treeModel);
|
||||
treeView->connectModelSignals(treeModel);
|
||||
|
||||
// Add the TreeView's view columns:
|
||||
try {
|
||||
treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn, 300);
|
||||
treeView->appendColumn(*getResourceUstring("dateColumnLabel"),
|
||||
modelColumns.dateColumn, 180);
|
||||
treeView->appendColumn(*getResourceUstring("statusColumnLabel"),
|
||||
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);
|
||||
treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn, 300);
|
||||
treeView->appendColumn(*getResourceUstring("dateColumnLabel"),
|
||||
modelColumns.dateColumn, 180);
|
||||
treeView->appendColumn(*getResourceUstring("statusColumnLabel"),
|
||||
modelColumns.statusDisplayColumn, 50);
|
||||
|
||||
userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName));
|
||||
}
|
||||
|
@ -342,7 +333,7 @@ BackupList :: setStatus(Gtk::TreeIter iter,
|
|||
|
||||
} else {
|
||||
std::cerr << "Impossible status: '" << status
|
||||
<< "' in BackupList::setStatus()." << std::endl;
|
||||
<< "' in BackupList::setStatus()." << std::endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -40,13 +40,12 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/XmlRpcException.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/ScrolledWindow.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
@ -89,11 +88,11 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author: fgerlits $
|
||||
* @version $Revision$
|
||||
*/
|
||||
class BackupList : public Gtk::VBox,
|
||||
public LocalizedObject,
|
||||
class BackupList : public LocalizedObject,
|
||||
public ContentsStorable
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The user preferences key.
|
||||
*/
|
||||
|
@ -144,6 +143,7 @@ class BackupList : public Gtk::VBox,
|
|||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* The GLiveSupport object, holding the state of the application.
|
||||
*/
|
||||
|
@ -220,6 +220,7 @@ class BackupList : public Gtk::VBox,
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -227,9 +228,12 @@ class BackupList : public Gtk::VBox,
|
|||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param glade the Glade file which specifies the visual
|
||||
* components for this class.
|
||||
*/
|
||||
BackupList(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
BackupList(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
|
@ -67,71 +66,42 @@ using namespace boost::posix_time;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
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 * mtimeLabel;
|
||||
Gtk::Button * chooseTimeButton;
|
||||
Gtk::Button * resetTimeButton;
|
||||
try {
|
||||
backupTitleLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("backupTitleLabel")));
|
||||
mtimeLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("mtimeTextLabel")));
|
||||
chooseTimeButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("chooseTimeButtonLabel")));
|
||||
resetTimeButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("resetTimeButtonLabel")));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
glade->get_widget("backupTitleLabel1", backupTitleLabel);
|
||||
glade->get_widget("backupMtimeLabel1", mtimeLabel);
|
||||
glade->get_widget("backupMtimeChooseButton1", chooseTimeButton);
|
||||
glade->get_widget("backupMtimeResetButton1", resetTimeButton);
|
||||
backupTitleLabel->set_label(*getResourceUstring("backupTitleLabel"));
|
||||
mtimeLabel->set_label(*getResourceUstring("mtimeTextLabel"));
|
||||
chooseTimeButton->set_label(*getResourceUstring("chooseTimeButtonLabel"));
|
||||
resetTimeButton->set_label(*getResourceUstring("resetTimeButtonLabel"));
|
||||
|
||||
chooseTimeButton->signal_clicked().connect(sigc::mem_fun(
|
||||
*this, &BackupView::onChooseTimeButtonClicked ));
|
||||
resetTimeButton->signal_clicked().connect(sigc::mem_fun(
|
||||
*this, &BackupView::onResetTimeButtonClicked ));
|
||||
chooseTimeButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&BackupView::onChooseTimeButtonClicked));
|
||||
resetTimeButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&BackupView::onResetTimeButtonClicked));
|
||||
|
||||
backupTitleEntry = Gtk::manage(wf->createEntryBin());
|
||||
mtimeEntry = Gtk::manage(wf->createEntryBin());
|
||||
glade->get_widget("backupTitleEntry1", backupTitleEntry);
|
||||
glade->get_widget("backupMtimeEntry1", mtimeEntry);
|
||||
|
||||
mtimeEntry->getEntry()->set_editable(false);
|
||||
mtimeEntry->getEntry()->set_alignment(0.5);
|
||||
mtimeEntry->getEntry()->set_width_chars(20);
|
||||
writeMtimeEntry();
|
||||
|
||||
constructCriteriaView();
|
||||
constructBackupListView();
|
||||
|
||||
Gtk::Box * backupTitleBox = Gtk::manage(new Gtk::HBox);
|
||||
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(
|
||||
dateTimeChooserWindow.reset(new DateTimeChooserWindow(
|
||||
gLiveSupport->getBundle("dateTimeChooserWindow") ));
|
||||
}
|
||||
|
||||
|
@ -139,86 +109,33 @@ BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the box for entering the backup criteria.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Box *
|
||||
void
|
||||
BackupView :: constructCriteriaView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
criteriaEntry = Gtk::manage(new AdvancedSearchEntry(gLiveSupport));
|
||||
criteriaEntry->connectCallback(sigc::mem_fun(
|
||||
*this, &BackupView::onCreateBackup ));
|
||||
criteriaEntry.reset(new AdvancedSearchEntry(gLiveSupport, glade));
|
||||
criteriaEntry->connectCallback(sigc::mem_fun(*this,
|
||||
&BackupView::onCreateBackup));
|
||||
|
||||
Button * backupButton;
|
||||
try {
|
||||
backupButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("backupButtonLabel") ));
|
||||
} catch (std::invalid_argument &e) {
|
||||
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;
|
||||
Gtk::Button * backupButton;
|
||||
glade->get_widget("backupButton1", backupButton);
|
||||
backupButton->set_label(*getResourceUstring("backupButtonLabel"));
|
||||
backupButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&BackupView::onCreateBackup));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the box for listing the pending backups.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Box *
|
||||
void
|
||||
BackupView :: constructBackupListView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
backupList.reset(new BackupList(gLiveSupport, getBundle(), glade));
|
||||
|
||||
backupList = Gtk::manage(new BackupList(gLiveSupport, getBundle()));
|
||||
// TODO: connect callbacks
|
||||
|
||||
Button * deleteButton;
|
||||
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;
|
||||
glade->connect_clicked("backupDeleteButton1", sigc::mem_fun(*this,
|
||||
&BackupView::onDeleteButtonClicked));
|
||||
glade->connect_clicked("backupSaveButton1", sigc::mem_fun(*this,
|
||||
&BackupView::onSaveButtonClicked));
|
||||
}
|
||||
|
||||
|
||||
|
@ -268,7 +185,7 @@ BackupView :: onCreateBackup(void) throw ()
|
|||
Ptr<Glib::ustring>::Ref errorMsg
|
||||
= getResourceUstring("backupErrorMsg");
|
||||
errorMsg->append(e.what());
|
||||
gLiveSupport->displayMessageWindow(errorMsg);
|
||||
gLiveSupport->displayMessageWindow(*errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +203,7 @@ BackupView :: onDeleteButtonClicked(void) throw ()
|
|||
Ptr<Glib::ustring>::Ref errorMsg
|
||||
= getResourceUstring("backupErrorMsg");
|
||||
errorMsg->append(e.what());
|
||||
gLiveSupport->displayMessageWindow(errorMsg);
|
||||
gLiveSupport->displayMessageWindow(*errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +222,7 @@ BackupView :: onSaveButtonClicked(void) throw ()
|
|||
Ptr<Glib::ustring>::Ref errorMsg
|
||||
= getResourceUstring("backupErrorMsg");
|
||||
errorMsg->append(e.what());
|
||||
gLiveSupport->displayMessageWindow(errorMsg);
|
||||
gLiveSupport->displayMessageWindow(*errorMsg);
|
||||
}
|
||||
|
||||
if (!url) {
|
||||
|
@ -358,16 +275,8 @@ BackupView :: readTitle(void) throw ()
|
|||
{
|
||||
Ptr<Glib::ustring>::Ref title(new Glib::ustring(
|
||||
backupTitleEntry->get_text() ));
|
||||
if (*title != "") {
|
||||
return title;
|
||||
}
|
||||
|
||||
try {
|
||||
if (*title == "") {
|
||||
title = getResourceUstring("defaultBackupTitle");
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
return title;
|
||||
|
|
|
@ -40,14 +40,13 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/ScrolledWindow.h"
|
||||
#include "LiveSupport/Widgets/DateTimeChooserWindow.h"
|
||||
#include "AdvancedSearchEntry.h"
|
||||
#include "BackupList.h"
|
||||
|
@ -89,24 +88,24 @@ using namespace boost::posix_time;
|
|||
* @author $Author: fgerlits $
|
||||
* @version $Revision$
|
||||
*/
|
||||
class BackupView : public Gtk::VBox,
|
||||
public LocalizedObject
|
||||
class BackupView : public LocalizedObject
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The text entry field for entering the title of the backup.
|
||||
*/
|
||||
EntryBin * backupTitleEntry;
|
||||
Gtk::Entry * backupTitleEntry;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
EntryBin * mtimeEntry;
|
||||
Gtk::Entry * mtimeEntry;
|
||||
|
||||
/**
|
||||
* The window for entering the "modified since" time.
|
||||
|
@ -116,19 +115,19 @@ class BackupView : public Gtk::VBox,
|
|||
/**
|
||||
* The object for entering the backup criteria.
|
||||
*/
|
||||
AdvancedSearchEntry * criteriaEntry;
|
||||
Ptr<AdvancedSearchEntry>::Ref criteriaEntry;
|
||||
|
||||
/**
|
||||
* The list of pending backups.
|
||||
*/
|
||||
BackupList * backupList;
|
||||
Ptr<BackupList>::Ref backupList;
|
||||
|
||||
/**
|
||||
* Construct the box for entering the backup criteria.
|
||||
*
|
||||
* @return the constructed box, already Gtk::manage()'ed.
|
||||
*/
|
||||
Gtk::Box *
|
||||
void
|
||||
constructCriteriaView(void) throw ();
|
||||
|
||||
/**
|
||||
|
@ -136,7 +135,7 @@ class BackupView : public Gtk::VBox,
|
|||
*
|
||||
* @return the constructed box, already Gtk::manage()'ed.
|
||||
*/
|
||||
Gtk::Box *
|
||||
void
|
||||
constructBackupListView(void) throw ();
|
||||
|
||||
/**
|
||||
|
@ -156,11 +155,17 @@ class BackupView : public Gtk::VBox,
|
|||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* The GLiveSupport object, holding the state of the application.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -193,16 +198,17 @@ class BackupView : public Gtk::VBox,
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, containing
|
||||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param glade the Glade file which specifies the visual
|
||||
* components for this class.
|
||||
*/
|
||||
BackupView(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
BackupView(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -216,7 +222,7 @@ class BackupView : public Gtk::VBox,
|
|||
/**
|
||||
* Return the BackupList object shown by the widget.
|
||||
*/
|
||||
BackupList *
|
||||
Ptr<BackupList>::Ref
|
||||
getBackupList(void) throw ()
|
||||
{
|
||||
return backupList;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -56,34 +55,36 @@ using namespace LiveSupport::GLiveSupport;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
BrowseEntry :: BrowseEntry(
|
||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ()
|
||||
BrowseEntry :: BrowseEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: LocalizedObject(bundle)
|
||||
{
|
||||
browseItemOne = Gtk::manage(new BrowseItem(gLiveSupport,
|
||||
bundle,
|
||||
4 /* Genre */));
|
||||
browseItemTwo = Gtk::manage(new BrowseItem(gLiveSupport,
|
||||
bundle,
|
||||
1 /* Creator */));
|
||||
browseItemThree = Gtk::manage(new BrowseItem(gLiveSupport,
|
||||
bundle,
|
||||
2 /* Album */));
|
||||
browseItemOne.reset(new BrowseItem(0,
|
||||
gLiveSupport,
|
||||
bundle,
|
||||
glade,
|
||||
4 /* Genre */));
|
||||
browseItemTwo.reset(new BrowseItem(1,
|
||||
gLiveSupport,
|
||||
bundle,
|
||||
glade,
|
||||
1 /* Creator */));
|
||||
browseItemThree.reset(new BrowseItem(2,
|
||||
gLiveSupport,
|
||||
bundle,
|
||||
glade,
|
||||
2 /* Album */));
|
||||
// TODO: change hard-coded indices to stuff read from config
|
||||
|
||||
browseItemOne->signalSelectionChanged().connect(
|
||||
sigc::bind<BrowseItem*>(
|
||||
browseItemOne->signalChanged().connect(
|
||||
sigc::bind<Ptr<BrowseItem>::Ref>(
|
||||
sigc::mem_fun(*browseItemTwo, &BrowseItem::onParentChangedShow),
|
||||
browseItemOne ));
|
||||
browseItemTwo->signalSelectionChanged().connect(
|
||||
sigc::bind<BrowseItem*>(
|
||||
browseItemTwo->signalChanged().connect(
|
||||
sigc::bind<Ptr<BrowseItem>::Ref>(
|
||||
sigc::mem_fun(*browseItemThree, &BrowseItem::onParentChangedShow),
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
|
@ -68,8 +69,7 @@ using namespace LiveSupport::Core;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class BrowseEntry : public Gtk::HBox,
|
||||
public LocalizedObject
|
||||
class BrowseEntry : public LocalizedObject
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -81,34 +81,40 @@ class BrowseEntry : public Gtk::HBox,
|
|||
/**
|
||||
* The first BrowseItem entry field.
|
||||
*/
|
||||
BrowseItem * browseItemOne;
|
||||
Ptr<BrowseItem>::Ref browseItemOne;
|
||||
|
||||
/**
|
||||
* The second BrowseItem entry field.
|
||||
*/
|
||||
BrowseItem * browseItemTwo;
|
||||
Ptr<BrowseItem>::Ref browseItemTwo;
|
||||
|
||||
/**
|
||||
* The third BrowseItem entry field.
|
||||
*/
|
||||
BrowseItem * browseItemThree;
|
||||
Ptr<BrowseItem>::Ref browseItemThree;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* 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(
|
||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ();
|
||||
BrowseEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
*/
|
||||
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
|
||||
* selection has changed.
|
||||
*
|
||||
* @return the signalSelectionChanged() of the last browse item
|
||||
* @return the signalChanged() of the last browse item
|
||||
*/
|
||||
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 */
|
||||
|
||||
|
||||
} // namespace Widgets
|
||||
} // namespace GLiveSupport
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // BrowseEntry_h
|
||||
|
|
|
@ -36,13 +36,10 @@
|
|||
#include <iostream>
|
||||
#include <glibmm.h>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "BrowseItem.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -59,46 +56,36 @@ using namespace LiveSupport::GLiveSupport;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
BrowseItem :: BrowseItem(
|
||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
int defaultIndex)
|
||||
BrowseItem :: BrowseItem(int index,
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade,
|
||||
int defaultIndex)
|
||||
throw ()
|
||||
: LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport)
|
||||
{
|
||||
parentCriteria.reset(new SearchCriteria);
|
||||
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
metadataEntry = Gtk::manage(wf->createMetadataComboBoxText(
|
||||
gLiveSupport->getMetadataTypeContainer()));
|
||||
glade->get_widget_derived(addIndex("browseMetadataEntry", index),
|
||||
metadataEntry);
|
||||
metadataEntry->setContents(gLiveSupport->getMetadataTypeContainer());
|
||||
metadataEntry->set_active(defaultIndex);
|
||||
metadataEntry->signalSelectionChanged().connect(sigc::mem_fun(*this,
|
||||
metadataEntry->signal_changed().connect(sigc::mem_fun(*this,
|
||||
&BrowseItem::onShow ));
|
||||
pack_start(*metadataEntry, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
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->set_size_request(230, 150);
|
||||
metadataValues->set_headers_visible(false);
|
||||
metadataValues->signal_cursor_changed().connect(sigc::mem_fun(*this,
|
||||
&BrowseItem::emitSignalSelectionChanged ));
|
||||
&BrowseItem::emitSignalChanged ));
|
||||
|
||||
Gtk::ScrolledWindow * scrolledWindow = Gtk::manage(new Gtk::ScrolledWindow);
|
||||
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(
|
||||
allString = Glib::Markup::escape_text(
|
||||
*getResourceUstring("allStringForBrowse"));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
onShow();
|
||||
}
|
||||
|
@ -174,6 +161,6 @@ BrowseItem :: onShow(void) throw ()
|
|||
*valuesIt);
|
||||
}
|
||||
|
||||
emitSignalSelectionChanged();
|
||||
emitSignalChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,12 @@
|
|||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/NumericTools.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
|
@ -73,17 +74,17 @@ using namespace LiveSupport::Widgets;
|
|||
* A single browse input field.
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* this one.
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class BrowseItem : public Gtk::VBox,
|
||||
public LocalizedObject
|
||||
class BrowseItem : public LocalizedObject,
|
||||
private NumericTools
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -152,7 +153,7 @@ class BrowseItem : public Gtk::VBox,
|
|||
/**
|
||||
* 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.
|
||||
|
@ -162,15 +163,15 @@ class BrowseItem : public Gtk::VBox,
|
|||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
BrowseItem(void) throw ();
|
||||
BrowseItem(void) throw ();
|
||||
|
||||
/**
|
||||
* Emit the "selection changed" signal.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
sigc::signal<void> signalSelectionChangedObject;
|
||||
sigc::signal<void> signalChangedObject;
|
||||
|
||||
|
||||
public:
|
||||
|
@ -187,22 +188,27 @@ class BrowseItem : public Gtk::VBox,
|
|||
/**
|
||||
* 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 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
|
||||
* initially
|
||||
*/
|
||||
BrowseItem(
|
||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
int defaultIndex)
|
||||
throw ();
|
||||
BrowseItem(int index,
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade,
|
||||
int defaultIndex)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~BrowseItem(void) throw ()
|
||||
~BrowseItem(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -223,18 +229,19 @@ class BrowseItem : public Gtk::VBox,
|
|||
* parent criteria), and set the selection to "all".
|
||||
*/
|
||||
void
|
||||
onShow(void) throw ();
|
||||
onShow(void) throw ();
|
||||
|
||||
/**
|
||||
* The signal handler for refreshing the treeview of metadata values,
|
||||
* if we also need to change the parent criteria. Same as onShow(),
|
||||
* plus changing the parent criteria.
|
||||
*
|
||||
* @param criteria the new parent search criteria
|
||||
* @param leftNeighbor the neighbor where the parent criteria
|
||||
* are coming from.
|
||||
*/
|
||||
void
|
||||
onParentChangedShow(BrowseItem * leftNeighbor)
|
||||
throw ()
|
||||
onParentChangedShow(Ptr<BrowseItem>::Ref leftNeighbor)
|
||||
throw ()
|
||||
{
|
||||
parentCriteria = leftNeighbor->getSearchCriteria();
|
||||
onShow();
|
||||
|
@ -247,9 +254,9 @@ class BrowseItem : public Gtk::VBox,
|
|||
* @return the signal object (a protected member of this class)
|
||||
*/
|
||||
sigc::signal<void>
|
||||
signalSelectionChanged(void) throw ()
|
||||
signalChanged(void) throw ()
|
||||
{
|
||||
return signalSelectionChangedObject;
|
||||
return signalChangedObject;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace LiveSupport {
|
|||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -64,6 +63,7 @@ using namespace LiveSupport::Widgets;
|
|||
class ContentsStorable
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
*/
|
||||
|
|
|
@ -35,13 +35,10 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "CuePlayer.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -49,6 +46,19 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
/* ================================================ 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 */
|
||||
|
||||
|
@ -60,31 +70,21 @@ using namespace LiveSupport::GLiveSupport;
|
|||
*----------------------------------------------------------------------------*/
|
||||
CuePlayer :: CuePlayer(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Gtk::TreeView * treeView,
|
||||
const PlayableTreeModelColumnRecord & modelColumns)
|
||||
const PlayableTreeModelColumnRecord & modelColumns,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: gLiveSupport(gLiveSupport),
|
||||
treeView(treeView),
|
||||
modelColumns(modelColumns)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
playButton = Gtk::manage(wf->createButton(
|
||||
WidgetConstants::smallPlayButton ));
|
||||
pauseButton = Gtk::manage(wf->createButton(
|
||||
WidgetConstants::smallPauseButton ));
|
||||
stopButton = Gtk::manage(wf->createButton(
|
||||
WidgetConstants::smallStopButton ));
|
||||
glade->get_widget("cuePlayButton1", playButton);
|
||||
glade->get_widget("cueStopButton1", stopButton);
|
||||
|
||||
playButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&CuePlayer::onPlayButtonClicked ));
|
||||
pauseButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&CuePlayer::onPauseButtonClicked ));
|
||||
stopButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&CuePlayer::onStopButtonClicked ));
|
||||
|
||||
pack_end(*stopButton, Gtk::PACK_SHRINK, 3);
|
||||
pack_end(*playButton, Gtk::PACK_SHRINK, 3);
|
||||
|
||||
audioState = waitingState;
|
||||
|
||||
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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -148,10 +164,8 @@ CuePlayer :: onPlayButtonClicked(void) throw ()
|
|||
onPlayItem();
|
||||
break;
|
||||
|
||||
case playingState: // should never happen
|
||||
std::cerr << "Assertion failed in CuePlayer:" << std::endl
|
||||
<< "play button clicked when it should not be visible."
|
||||
<< std::endl;
|
||||
case playingState:
|
||||
onPauseItem();
|
||||
break;
|
||||
|
||||
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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -210,7 +208,7 @@ CuePlayer :: onStop(Ptr<const Glib::ustring>::Ref errorMessage) throw ()
|
|||
setAudioState(waitingState);
|
||||
|
||||
if (errorMessage) {
|
||||
gLiveSupport->displayMessageWindow(errorMessage);
|
||||
gLiveSupport->displayMessageWindow(*errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,17 +221,11 @@ CuePlayer :: setAudioState(AudioState newState) throw ()
|
|||
{
|
||||
if ((audioState == waitingState || audioState == pausedState)
|
||||
&& newState == playingState) {
|
||||
remove(*playButton);
|
||||
pack_end(*pauseButton, Gtk::PACK_SHRINK, 3);
|
||||
pauseButton->show();
|
||||
gLiveSupport->runMainLoop();
|
||||
playButton->set_label(pauseStockImageName);
|
||||
|
||||
} else if (audioState == playingState
|
||||
&& (newState == waitingState || newState == pausedState)) {
|
||||
remove(*pauseButton);
|
||||
pack_end(*playButton, Gtk::PACK_SHRINK, 3);
|
||||
playButton->show();
|
||||
gLiveSupport->runMainLoop();
|
||||
playButton->set_label(playStockImageName);
|
||||
}
|
||||
|
||||
audioState = newState;
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
#endif
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerEventListener.h"
|
||||
#include "LiveSupport/Widgets/ImageButton.h"
|
||||
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
|
||||
|
||||
#include "GLiveSupport.h"
|
||||
|
@ -71,11 +71,9 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class CuePlayer : public Gtk::HBox,
|
||||
public PlaylistExecutor::AudioPlayerEventListener
|
||||
class CuePlayer : public PlaylistExecutor::AudioPlayerEventListener
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The possible states of the (cue) audio player.
|
||||
*/
|
||||
|
@ -89,17 +87,12 @@ class CuePlayer : public Gtk::HBox,
|
|||
/**
|
||||
* The play button.
|
||||
*/
|
||||
ImageButton * playButton;
|
||||
|
||||
/**
|
||||
* The pause button.
|
||||
*/
|
||||
ImageButton * pauseButton;
|
||||
Gtk::Button * playButton;
|
||||
|
||||
/**
|
||||
* The stop button.
|
||||
*/
|
||||
ImageButton * stopButton;
|
||||
Gtk::Button * stopButton;
|
||||
|
||||
/**
|
||||
* The GLiveSupport object, holding the state of the application.
|
||||
|
@ -109,7 +102,7 @@ class CuePlayer : public Gtk::HBox,
|
|||
/**
|
||||
* The Gtk::TreeView of the parent.
|
||||
*/
|
||||
Gtk::TreeView * treeView;
|
||||
Gtk::TreeView * treeView;
|
||||
|
||||
/**
|
||||
* The Gtk::TreeModelColumnRecord of the parent.
|
||||
|
@ -122,18 +115,18 @@ class CuePlayer : public Gtk::HBox,
|
|||
*/
|
||||
CuePlayer(void) throw ();
|
||||
|
||||
/**
|
||||
* Pause the song.
|
||||
*/
|
||||
void
|
||||
onPauseItem(void) throw ();
|
||||
|
||||
/**
|
||||
* Event handler for the Play button being clicked.
|
||||
*/
|
||||
void
|
||||
onPlayButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Event handler for the Pause button being clicked.
|
||||
*/
|
||||
void
|
||||
onPauseButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Event handler for the Stop button being clicked.
|
||||
*/
|
||||
|
@ -152,17 +145,19 @@ class CuePlayer : public Gtk::HBox,
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor with parent parameters.
|
||||
*
|
||||
* @param gLiveSupport the GLiveSupport, application object.
|
||||
* @param treeView the TreeView object showing the selection.
|
||||
* @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,
|
||||
Gtk::TreeView * treeView,
|
||||
const PlayableTreeModelColumnRecord & modelColumns)
|
||||
const PlayableTreeModelColumnRecord & modelColumns,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -56,18 +55,17 @@ using namespace LiveSupport::GLiveSupport;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
ExportFormatRadioButtons :: ExportFormatRadioButtons(
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: RadioButtons(),
|
||||
LocalizedObject(bundle)
|
||||
: LocalizedObject(bundle)
|
||||
{
|
||||
try {
|
||||
add(getResourceUstring("internalFormatName"));
|
||||
add(getResourceUstring("smilFormatName"));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
glade->get_widget("internalFormatRadioButton1", internalFormatRadioButton);
|
||||
glade->get_widget("smilFormatRadioButton1", smilFormatRadioButton);
|
||||
internalFormatRadioButton->set_label(*getResourceUstring(
|
||||
"internalFormatName"));
|
||||
smilFormatRadioButton->set_label(*getResourceUstring(
|
||||
"smilFormatName"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,7 +75,16 @@ ExportFormatRadioButtons :: ExportFormatRadioButtons(
|
|||
StorageClientInterface::ExportFormatType
|
||||
ExportFormatRadioButtons :: getFormat(void) throw ()
|
||||
{
|
||||
int button = getActiveButton();
|
||||
return StorageClientInterface::ExportFormatType(button);
|
||||
if (internalFormatRadioButton->get_active()) {
|
||||
return StorageClientInterface::internalFormat;
|
||||
|
||||
} else if (smilFormatRadioButton->get_active()) {
|
||||
return StorageClientInterface::smilFormat;
|
||||
|
||||
} else {
|
||||
std::cerr << "impossible value in ExportFormatRadioButtons::getFormat()"
|
||||
<< std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,11 @@
|
|||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/Widgets/RadioButtons.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -46,7 +48,6 @@ namespace GLiveSupport {
|
|||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -63,17 +64,31 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author: fgerlits $
|
||||
* @version $Revision$
|
||||
*/
|
||||
class ExportFormatRadioButtons : public RadioButtons,
|
||||
public LocalizedObject
|
||||
class ExportFormatRadioButtons : 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:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
*/
|
||||
ExportFormatRadioButtons(Ptr<ResourceBundle>::Ref bundle)
|
||||
ExportFormatRadioButtons(Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,19 +39,12 @@
|
|||
#error need pwd.h
|
||||
#endif
|
||||
|
||||
#include <gtkmm/filechooserdialog.h>
|
||||
#include <gtkmm/stock.h>
|
||||
|
||||
#include "LiveSupport/Core/FileTools.h"
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "ExportPlaylistWindow.h"
|
||||
|
||||
|
||||
using namespace Glib;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -62,9 +55,9 @@ using namespace LiveSupport::GLiveSupport;
|
|||
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(
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
const Glib::ustring & gladeDir,
|
||||
Ptr<Playlist>::Ref playlist)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle),
|
||||
: gLiveSupport(gLiveSupport),
|
||||
playlist(playlist)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
|
||||
"exportPlaylistWindow");
|
||||
setBundle(bundle);
|
||||
|
||||
Gtk::Label * playlistTitleLabel;
|
||||
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);
|
||||
glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
|
||||
|
||||
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);
|
||||
|
||||
show_all_children();
|
||||
formatButtons.reset(new ExportFormatRadioButtons(bundle, glade));
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,7 +115,7 @@ ExportPlaylistWindow :: ExportPlaylistWindow(
|
|||
void
|
||||
ExportPlaylistWindow :: onCancelButtonClicked(void) throw ()
|
||||
{
|
||||
hide();
|
||||
mainWindow->hide();
|
||||
}
|
||||
|
||||
|
||||
|
@ -181,7 +144,7 @@ ExportPlaylistWindow :: onSaveButtonClicked(void) throw ()
|
|||
Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring(
|
||||
"createExportErrorMsg");
|
||||
errorMsg->append(e.what());
|
||||
gLiveSupport->displayMessageWindow(errorMsg);
|
||||
gLiveSupport->displayMessageWindow(*errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -220,19 +183,19 @@ ExportPlaylistWindow :: onSaveButtonClicked(void) throw ()
|
|||
} catch (std::runtime_error &e) {
|
||||
Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring(
|
||||
"saveExportErrorMsg");
|
||||
gLiveSupport->displayMessageWindow(errorMsg);
|
||||
gLiveSupport->displayMessageWindow(*errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// close the exporting operation
|
||||
resetToken();
|
||||
|
||||
hide();
|
||||
mainWindow->hide();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Event handler called when the the window gets hidden.
|
||||
* Cancel the current operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ExportPlaylistWindow :: resetToken(void) throw ()
|
||||
|
@ -247,7 +210,7 @@ ExportPlaylistWindow :: resetToken(void) throw ()
|
|||
Ptr<Glib::ustring>::Ref errorMsg = getResourceUstring(
|
||||
"createExportErrorMsg");
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ExportPlaylistWindow :: on_hide(void) throw ()
|
||||
bool
|
||||
ExportPlaylistWindow :: onDeleteEvent(GdkEventAny * event) throw ()
|
||||
{
|
||||
std::cerr << "ExportPlaylistWindow :: onDeleteEvent called\n";
|
||||
if (token) {
|
||||
resetToken();
|
||||
}
|
||||
|
||||
GuiWindow::on_hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,16 +40,19 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "ExportFormatRadioButtons.h"
|
||||
#include <gtkmm.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 GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -60,7 +63,7 @@ using namespace LiveSupport::Widgets;
|
|||
/* =============================================================== 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.
|
||||
* It lets the user select the format of the exported playlist, and the
|
||||
* location where it will be saved.
|
||||
|
@ -68,23 +71,39 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author: fgerlits $
|
||||
* @version $Revision$
|
||||
*/
|
||||
class ExportPlaylistWindow : public GuiWindow
|
||||
class ExportPlaylistWindow : public LocalizedObject
|
||||
{
|
||||
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.
|
||||
*/
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ExportFormatRadioButtons * formatButtons;
|
||||
Ptr<ExportFormatRadioButtons>::Ref formatButtons;
|
||||
|
||||
/**
|
||||
* Cancel the current operation.
|
||||
|
@ -95,6 +114,7 @@ class ExportPlaylistWindow : public GuiWindow
|
|||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* This overrides GuiWindow::on_hide(), and closes the exporting
|
||||
* operations, if there is one in progress.
|
||||
* It closes the exporting operations, if there is one in progress.
|
||||
*/
|
||||
virtual void
|
||||
on_hide(void) throw ();
|
||||
virtual bool
|
||||
onDeleteEvent(GdkEventAny * event) throw ();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, containing
|
||||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param gladeDir the directory where the Glade files are.
|
||||
* @param playlist the playlist to be exported.
|
||||
*/
|
||||
ExportPlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Ptr<Playlist>::Ref playlist)
|
||||
ExportPlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
const Glib::ustring & gladeDir,
|
||||
Ptr<Playlist>::Ref playlist)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -139,6 +158,15 @@ class ExportPlaylistWindow : public GuiWindow
|
|||
~ExportPlaylistWindow(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying Gtk::Window.
|
||||
*/
|
||||
virtual Gtk::Window *
|
||||
getWindow(void) throw ()
|
||||
{
|
||||
return mainWindow;
|
||||
}
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
|
@ -120,6 +120,16 @@ const std::string localeAttrName = "locale";
|
|||
*----------------------------------------------------------------------------*/
|
||||
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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -191,6 +201,7 @@ const std::string serialPortConfigElementName = "serialPort";
|
|||
* The default serial device
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string serialPortDefaultDevice = "/dev/ttyS0";
|
||||
|
||||
}
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
@ -253,6 +264,17 @@ GLiveSupport :: configure(const xmlpp::Element & element)
|
|||
|
||||
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
|
||||
nodes = element.get_children(WidgetFactory::getConfigElementName());
|
||||
if (nodes.size() < 1) {
|
||||
|
@ -474,7 +496,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
|
|||
Ptr<UnicodeString>::Ref uLanguage = ustringToUnicodeString(language);
|
||||
Ptr<Glib::ustring>::Ref msg = formatMessage(localeNotAvailableKey,
|
||||
(*it).first);
|
||||
displayMessageWindow(msg);
|
||||
displayMessageWindow(*msg);
|
||||
|
||||
changeLocale("");
|
||||
return false;
|
||||
|
@ -496,7 +518,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
|
|||
storageAvailable = true;
|
||||
} catch (XmlRpcException &e) {
|
||||
storageAvailable = false;
|
||||
displayMessageWindow(getResourceUstring(storageNotReachableKey));
|
||||
displayMessageWindow(*getResourceUstring(storageNotReachableKey));
|
||||
}
|
||||
|
||||
// no need to check the widget factory
|
||||
|
@ -504,7 +526,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
|
|||
// check the scheduler client
|
||||
checkSchedulerClient();
|
||||
if (!isSchedulerAvailable()) {
|
||||
displayMessageWindow(getResourceUstring(schedulerNotReachableKey));
|
||||
displayMessageWindow(*getResourceUstring(schedulerNotReachableKey));
|
||||
}
|
||||
|
||||
// TODO: check the audio player?
|
||||
|
@ -516,17 +538,62 @@ GLiveSupport :: checkConfiguration(void) throw ()
|
|||
/*------------------------------------------------------------------------------
|
||||
* Display a message window.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
inline void
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: displayMessageWindow(Ptr<const Glib::ustring>::Ref message)
|
||||
GLiveSupport :: displayMessageWindow(const Glib::ustring & message)
|
||||
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(
|
||||
message,
|
||||
getBundle()));
|
||||
window->run();
|
||||
Glib::ustring formattedMessage = "<span weight=\"bold\" ";
|
||||
formattedMessage += " size=\"larger\">";
|
||||
formattedMessage += message;
|
||||
formattedMessage += "</span>";
|
||||
dialogLabel->set_label(formattedMessage);
|
||||
|
||||
Gtk::ResponseType response = Gtk::ResponseType(dialog->run());
|
||||
dialog->hide();
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
@ -537,13 +604,16 @@ void
|
|||
LiveSupport :: GLiveSupport ::
|
||||
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->set_default_icon_list(taskbarIcons->getIconList());
|
||||
masterPanel->getWindow()->set_icon_list(taskbarIcons->getIconList());
|
||||
masterPanel->getWindow()->set_default_icon_list(
|
||||
taskbarIcons->getIconList());
|
||||
|
||||
// Shows the window and returns when it is closed.
|
||||
Gtk::Main::run(*masterPanel);
|
||||
Gtk::Main::run(*masterPanel->getWindow());
|
||||
|
||||
masterPanel.reset();
|
||||
}
|
||||
|
@ -635,12 +705,12 @@ GLiveSupport :: logout(void) throw ()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (masterPanel && !masterPanel->cancelEditedPlaylist()) {
|
||||
if (!masterPanel->cancelEditedPlaylist()) {
|
||||
return false; // do nothing if the user presses the cancel button
|
||||
}
|
||||
|
||||
stopCueAudio();
|
||||
showAnonymousUI();
|
||||
masterPanel->showAnonymousUI();
|
||||
|
||||
storeWindowPositions();
|
||||
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
|
||||
* object.
|
||||
|
@ -1028,7 +1072,10 @@ LiveSupport :: GLiveSupport ::
|
|||
GLiveSupport :: setNowPlaying(Ptr<Playable>::Ref playable)
|
||||
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();
|
||||
|
||||
masterPanel->updateSimplePlaylistMgmtWindow();
|
||||
masterPanel->updatePlaylistWindow();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1121,7 +1168,7 @@ GLiveSupport :: addToPlaylist(Ptr<const UniqueId>::Ref id)
|
|||
editedPlaylist->addAudioClip(clip, editedPlaylist->getPlaylength());
|
||||
}
|
||||
|
||||
masterPanel->updateSimplePlaylistMgmtWindow();
|
||||
masterPanel->updatePlaylistWindow();
|
||||
emitSignalEditedPlaylistModified();
|
||||
}
|
||||
|
||||
|
@ -1252,21 +1299,21 @@ GLiveSupport :: playOutputAudio(Ptr<Playable>::Ref playable)
|
|||
= getResourceUstring("audioErrorMsg");
|
||||
eMsg->append("\n");
|
||||
eMsg->append(e.what());
|
||||
displayMessageWindow(eMsg);
|
||||
displayMessageWindow(*eMsg);
|
||||
throw std::runtime_error(e.what());
|
||||
} catch (std::invalid_argument &e) {
|
||||
Ptr<Glib::ustring>::Ref eMsg
|
||||
= getResourceUstring("audioErrorMsg");
|
||||
eMsg->append("\n");
|
||||
eMsg->append(e.what());
|
||||
displayMessageWindow(eMsg);
|
||||
displayMessageWindow(*eMsg);
|
||||
throw std::runtime_error(e.what());
|
||||
} catch (std::runtime_error &e) {
|
||||
Ptr<Glib::ustring>::Ref eMsg
|
||||
= getResourceUstring("audioErrorMsg");
|
||||
eMsg->append("\n");
|
||||
eMsg->append(e.what());
|
||||
displayMessageWindow(eMsg);
|
||||
displayMessageWindow(*eMsg);
|
||||
throw std::runtime_error(e.what());
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1383,7 @@ GLiveSupport :: onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
|||
}
|
||||
|
||||
if (errorMessage) {
|
||||
displayMessageWindow(errorMessage);
|
||||
displayMessageWindow(*errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1382,21 +1429,21 @@ GLiveSupport :: playCueAudio(Ptr<Playable>::Ref playable)
|
|||
= getResourceUstring("audioErrorMsg");
|
||||
eMsg->append("\n");
|
||||
eMsg->append(e.what());
|
||||
displayMessageWindow(eMsg);
|
||||
displayMessageWindow(*eMsg);
|
||||
throw std::runtime_error(e.what());
|
||||
} catch (std::invalid_argument &e) {
|
||||
Ptr<Glib::ustring>::Ref eMsg
|
||||
= getResourceUstring("audioErrorMsg");
|
||||
eMsg->append("\n");
|
||||
eMsg->append(e.what());
|
||||
displayMessageWindow(eMsg);
|
||||
displayMessageWindow(*eMsg);
|
||||
throw std::runtime_error(e.what());
|
||||
} catch (std::runtime_error &e) {
|
||||
Ptr<Glib::ustring>::Ref eMsg
|
||||
= getResourceUstring("audioErrorMsg");
|
||||
eMsg->append("\n");
|
||||
eMsg->append(e.what());
|
||||
displayMessageWindow(eMsg);
|
||||
displayMessageWindow(*eMsg);
|
||||
throw std::runtime_error(e.what());
|
||||
}
|
||||
|
||||
|
@ -1436,7 +1483,10 @@ GLiveSupport :: stopCueAudio(void)
|
|||
cuePlayerIsPaused = false;
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Image *
|
||||
Glib::RefPtr<Gdk::Pixbuf>
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -1741,40 +1845,23 @@ void
|
|||
LiveSupport :: GLiveSupport ::
|
||||
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?"
|
||||
Ptr<DialogWindow>::Ref question(widgetFactory->createDialogWindow(
|
||||
message,
|
||||
getBundle(),
|
||||
DialogWindow::noButton
|
||||
| DialogWindow::yesButton ));
|
||||
DialogWindow::ButtonType answer = question->run();
|
||||
Gtk::ResponseType answer = runNoYesDialog(*getResourceUstring(
|
||||
"authenticationNotReachableMsg"));
|
||||
|
||||
if (answer == DialogWindow::yesButton) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("optionsWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (answer == Gtk::RESPONSE_YES) {
|
||||
/* DISABLED TEMPORARILY
|
||||
Ptr<OptionsWindow>::Ref optionsWindow(new OptionsWindow(
|
||||
shared_from_this(),
|
||||
bundle,
|
||||
0));
|
||||
shared_from_this(),
|
||||
getBundle("optionsWindow"),
|
||||
0,
|
||||
gladeDir));
|
||||
optionsWindow->run();
|
||||
|
||||
if (optionsContainer->isTouched()) {
|
||||
optionsContainer->writeToFile();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "KeyboardShortcutList.h"
|
||||
#include "TaskbarIcons.h"
|
||||
#include "ContentsStorable.h"
|
||||
#include "BasicWindow.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -122,6 +123,7 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
public AudioPlayerEventListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* A type for the map of supported languages.
|
||||
* This is an STL map, containing const Glib::ustring as keys, which
|
||||
|
@ -147,8 +149,9 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
|
||||
|
||||
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;
|
||||
|
||||
|
@ -162,6 +165,17 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -398,8 +412,30 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
void
|
||||
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:
|
||||
|
||||
/**
|
||||
* A signal object to notify people that the edited playlist changed.
|
||||
*/
|
||||
|
@ -407,6 +443,7 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
@ -486,9 +523,27 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
* @param message the message to display
|
||||
*/
|
||||
void
|
||||
displayMessageWindow(Ptr<const Glib::ustring>::Ref message)
|
||||
displayMessageWindow(const Glib::ustring & message)
|
||||
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.
|
||||
* This call will only return after the main window has been closed.
|
||||
|
@ -583,18 +638,6 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
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.
|
||||
*
|
||||
|
@ -816,7 +859,7 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
* to return a non-0 value.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @param playlistId the id of the playlist to open for editing.
|
||||
|
@ -1072,13 +1115,12 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
throw ();
|
||||
|
||||
/**
|
||||
* Return an image containing the radio station logo.
|
||||
* It is the responsibility of the caller to dispose of this object.
|
||||
* Return a pixbuf containing the radio station logo.
|
||||
*
|
||||
* @return the station logo image.
|
||||
* @return a pixbuf containing the station logo image.
|
||||
*/
|
||||
Gtk::Image*
|
||||
getStationLogoImage() throw ();
|
||||
Glib::RefPtr<Gdk::Pixbuf>
|
||||
getStationLogoPixbuf() throw ();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* TODO: remove this function, and only use its overloaded pair.
|
||||
*
|
||||
* 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().
|
||||
|
@ -1164,6 +1208,8 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
/**
|
||||
* 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
|
||||
* with the same get_name(), then these data are read and applied to
|
||||
* the window, restoring its position and size.
|
||||
|
@ -1174,6 +1220,32 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
void
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -67,7 +67,7 @@ const Glib::ustring applicationTitle = "Campcaster";
|
|||
*----------------------------------------------------------------------------*/
|
||||
GuiWindow :: GuiWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton,
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
int properties)
|
||||
throw ()
|
||||
: WhiteWindow(Colors::White,
|
||||
|
@ -89,7 +89,7 @@ GuiWindow :: on_show (void) throw ()
|
|||
gLiveSupport->getWindowPosition(shared_from_this());
|
||||
|
||||
if (windowOpenerButton) {
|
||||
windowOpenerButton->setSelected(true);
|
||||
windowOpenerButton->set_active(true);
|
||||
}
|
||||
|
||||
WhiteWindow::on_show();
|
||||
|
@ -105,7 +105,7 @@ GuiWindow :: on_hide (void) throw ()
|
|||
gLiveSupport->putWindowPosition(shared_from_this());
|
||||
|
||||
if (windowOpenerButton) {
|
||||
windowOpenerButton->setSelected(false);
|
||||
windowOpenerButton->set_active(false);
|
||||
}
|
||||
|
||||
WhiteWindow::on_hide();
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/WhiteWindow.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/WidgetConstants.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
|
@ -76,7 +75,7 @@ class GuiWindow : public WhiteWindow,
|
|||
/**
|
||||
* The button which was pressed to open this window.
|
||||
*/
|
||||
Button * windowOpenerButton;
|
||||
Gtk::ToggleButton * windowOpenerButton;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -103,7 +102,6 @@ class GuiWindow : public WhiteWindow,
|
|||
* button.
|
||||
*
|
||||
* @see LiveSupport::GLiveSupport::GLiveSupport::putWindowPosition()
|
||||
* @see LiveSupport::Widgets::Button::setSelected()
|
||||
*/
|
||||
virtual void
|
||||
on_hide(void) throw ();
|
||||
|
@ -122,7 +120,7 @@ class GuiWindow : public WhiteWindow,
|
|||
*/
|
||||
GuiWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton = 0,
|
||||
Gtk::ToggleButton * windowOpenerButton = 0,
|
||||
int properties = 0)
|
||||
throw ();
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <glibmm.h>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "LiveModeWindow.h"
|
||||
|
||||
|
@ -46,7 +45,6 @@
|
|||
using namespace Glib;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -56,10 +54,10 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc).
|
||||
*/
|
||||
const Glib::ustring windowName = "liveModeWindow";
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const Glib::ustring gladeFileName = "LiveModeWindow.glade";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton),
|
||||
: BasicWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton,
|
||||
gladeDir + gladeFileName),
|
||||
gladeDir(gladeDir),
|
||||
isDeleting(false)
|
||||
{
|
||||
try {
|
||||
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:
|
||||
glade->get_widget_derived("treeView1", treeView);
|
||||
treeModel = Gtk::ListStore::create(modelColumns);
|
||||
|
||||
// ... and the tree view:
|
||||
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);
|
||||
treeView->set_model(treeModel);
|
||||
treeView->connectModelSignals(treeModel);
|
||||
|
||||
// Add the TreeView's view columns:
|
||||
try {
|
||||
treeView->appendLineNumberColumn("", 2 /* offset */, 50);
|
||||
treeView->appendColumn("", modelColumns.infoColumn, 200);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
treeView->appendLineNumberColumn("", 2 /* offset */, 50);
|
||||
treeView->appendColumn("", modelColumns.infoColumn, 200);
|
||||
|
||||
// register the signal handler for treeview entries being clicked
|
||||
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onEntryClicked));
|
||||
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,
|
||||
&LiveModeWindow::onTreeModelChanged));
|
||||
|
||||
// register the signal handler for keyboard key presses
|
||||
treeView->signal_key_press_event().connect(sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onKeyPressed));
|
||||
&LiveModeWindow::onKeyPressed));
|
||||
|
||||
// Add the TreeView, inside a ScrolledWindow, with the button underneath:
|
||||
scrolledWindow.add(*treeView);
|
||||
glade->get_widget("cueLabel1", cueLabel);
|
||||
cueLabel->set_label(*getResourceUstring("cuePlayerLabel"));
|
||||
cuePlayer.reset(new CuePlayer(gLiveSupport,
|
||||
treeView,
|
||||
modelColumns,
|
||||
glade));
|
||||
|
||||
// Only show the scrollbars when they are necessary:
|
||||
scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
||||
glade->get_widget("autoPlayNext1", autoPlayNext);
|
||||
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();
|
||||
playlistContextMenu = constructPlaylistContextMenu();
|
||||
|
||||
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) {
|
||||
KeyboardShortcut::Action action = gLiveSupport->findAction(
|
||||
windowName,
|
||||
"liveModeWindow",
|
||||
Gdk::ModifierType(event->state),
|
||||
event->keyval);
|
||||
switch (action) {
|
||||
|
@ -469,7 +384,7 @@ LiveModeWindow :: onEditPlaylist(void) throw ()
|
|||
try {
|
||||
gLiveSupport->openPlaylistForEditing(playlist->getId());
|
||||
} catch (XmlRpcException &e) {
|
||||
gLiveSupport->displayMessageWindow(getResourceUstring(
|
||||
gLiveSupport->displayMessageWindow(*getResourceUstring(
|
||||
"cannotEditPlaylistMsg" ));
|
||||
}
|
||||
}
|
||||
|
@ -492,10 +407,10 @@ LiveModeWindow :: onSchedulePlaylist(void) throw ()
|
|||
if (playlist) {
|
||||
schedulePlaylistWindow.reset(new SchedulePlaylistWindow(
|
||||
gLiveSupport,
|
||||
gLiveSupport->getBundle("schedulePlaylistWindow"),
|
||||
gladeDir,
|
||||
playlist));
|
||||
schedulePlaylistWindow->set_transient_for(*this);
|
||||
Gtk::Main::run(*schedulePlaylistWindow);
|
||||
schedulePlaylistWindow->getWindow()->set_transient_for(*mainWindow);
|
||||
Gtk::Main::run(*schedulePlaylistWindow->getWindow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -515,10 +430,10 @@ LiveModeWindow :: onExportPlaylist(void) throw ()
|
|||
if (playlist) {
|
||||
exportPlaylistWindow.reset(new ExportPlaylistWindow(
|
||||
gLiveSupport,
|
||||
gLiveSupport->getBundle("exportPlaylistWindow"),
|
||||
gladeDir,
|
||||
playlist));
|
||||
exportPlaylistWindow->set_transient_for(*this);
|
||||
Gtk::Main::run(*exportPlaylistWindow);
|
||||
exportPlaylistWindow->getWindow()->set_transient_for(*mainWindow);
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Menu *
|
||||
Ptr<Gtk::Menu>::Ref
|
||||
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();
|
||||
|
||||
try {
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*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"),
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("playMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onAddToPlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*treeView,
|
||||
&ZebraTreeView::onRemoveMenuOption)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("uploadToHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onUploadToHub)));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
&LiveModeWindow::onOutputPlay)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cueMenuItem"),
|
||||
sigc::mem_fun(*cuePlayer,
|
||||
&CuePlayer::onPlayItem)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onAddToPlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*treeView,
|
||||
&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;
|
||||
}
|
||||
|
||||
|
@ -621,70 +531,52 @@ LiveModeWindow :: constructAudioClipContextMenu(void) throw ()
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the right-click context menu for local playlists.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Menu *
|
||||
Ptr<Gtk::Menu>::Ref
|
||||
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();
|
||||
|
||||
try {
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*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"),
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("playMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onAddToPlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
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,
|
||||
&LiveModeWindow::onEditPlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("schedulePlaylistMenuItem"),
|
||||
&LiveModeWindow::onOutputPlay)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cueMenuItem"),
|
||||
sigc::mem_fun(*cuePlayer,
|
||||
&CuePlayer::onPlayItem)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onAddToPlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
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,
|
||||
&LiveModeWindow::onSchedulePlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("exportPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onExportPlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("uploadToHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onUploadToHub)));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
&LiveModeWindow::onEditPlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("schedulePlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onSchedulePlaylist)));
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("exportPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&LiveModeWindow::onExportPlaylist)));
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -730,20 +622,10 @@ LiveModeWindow :: onTreeModelChanged(void) throw ()
|
|||
void
|
||||
LiveModeWindow :: updateStrings(void) throw ()
|
||||
{
|
||||
try {
|
||||
setBundle(gLiveSupport->getBundle("liveModeWindow"));
|
||||
|
||||
set_title(*getResourceUstring("windowTitle"));
|
||||
cueAudioLabel->set_label(*getResourceUstring("cuePlayerLabel"));
|
||||
clearListButton->set_label(*getResourceUstring("clearListButtonLabel"));
|
||||
removeButton->set_label(*getResourceUstring("removeButtonLabel"));
|
||||
setBundle(gLiveSupport->getBundle("liveModeWindow"));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
show_all_children();
|
||||
setTitle(getResourceUstring("windowTitle"));
|
||||
cueLabel->set_label(*getResourceUstring("cuePlayerLabel"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -813,15 +695,15 @@ LiveModeWindow :: setContents(Ptr<const Glib::ustring>::Ref contents)
|
|||
* Event handler called when the the window gets hidden.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LiveModeWindow :: on_hide(void) throw ()
|
||||
LiveModeWindow :: hide(void) throw ()
|
||||
{
|
||||
if (exportPlaylistWindow) {
|
||||
exportPlaylistWindow->hide();
|
||||
exportPlaylistWindow->getWindow()->hide();
|
||||
}
|
||||
if (schedulePlaylistWindow) {
|
||||
schedulePlaylistWindow->hide();
|
||||
schedulePlaylistWindow->getWindow()->hide();
|
||||
}
|
||||
|
||||
GuiWindow::on_hide();
|
||||
BasicWindow::hide();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,17 +41,13 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.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 "GuiWindow.h"
|
||||
#include "BasicWindow.h"
|
||||
#include "ContentsStorable.h"
|
||||
#include "CuePlayer.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
@ -79,10 +75,16 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class LiveModeWindow : public GuiWindow,
|
||||
class LiveModeWindow : public BasicWindow,
|
||||
public ContentsStorable
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The directory where the Glade files are.
|
||||
*/
|
||||
Glib::ustring gladeDir;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
CuePlayer * cueAudioButtons;
|
||||
Ptr<CuePlayer>::Ref cuePlayer;
|
||||
|
||||
/**
|
||||
* The label for the cue player.
|
||||
*/
|
||||
Gtk::Label * cueAudioLabel;
|
||||
|
||||
/**
|
||||
* The button for removing every item from the window.
|
||||
*/
|
||||
Button * clearListButton;
|
||||
|
||||
/**
|
||||
* The button for removing the selected items from the window.
|
||||
*/
|
||||
Button * removeButton;
|
||||
Gtk::Label * cueLabel;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return the context menu created (already Gtk::manage()'ed).
|
||||
* @return the context menu created.
|
||||
*/
|
||||
Gtk::Menu *
|
||||
Ptr<Gtk::Menu>::Ref
|
||||
constructAudioClipContextMenu(void) throw ();
|
||||
|
||||
/**
|
||||
* 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 ();
|
||||
|
||||
/**
|
||||
|
@ -173,12 +165,6 @@ class LiveModeWindow : public GuiWindow,
|
|||
class ModelColumns : public PlayableTreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The column for the play button.
|
||||
*/
|
||||
// Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> >
|
||||
// playButtonColumn;
|
||||
|
||||
/**
|
||||
* The column for the title, creator, etc.
|
||||
*/
|
||||
|
@ -189,7 +175,6 @@ class LiveModeWindow : public GuiWindow,
|
|||
*/
|
||||
ModelColumns(void) throw ()
|
||||
{
|
||||
// add(playButtonColumn);
|
||||
add(infoColumn);
|
||||
}
|
||||
};
|
||||
|
@ -223,12 +208,12 @@ class LiveModeWindow : public GuiWindow,
|
|||
/**
|
||||
* The right-click context menu for audio clips.
|
||||
*/
|
||||
Gtk::Menu * audioClipContextMenu;
|
||||
Ptr<Gtk::Menu>::Ref audioClipContextMenu;
|
||||
|
||||
/**
|
||||
* The right-click context menu for playlists.
|
||||
*/
|
||||
Gtk::Menu * playlistContextMenu;
|
||||
Ptr<Gtk::Menu>::Ref playlistContextMenu;
|
||||
|
||||
/**
|
||||
* Signal handler for the output play button clicked
|
||||
|
@ -306,12 +291,6 @@ class LiveModeWindow : public GuiWindow,
|
|||
virtual void
|
||||
onUploadToHub(void) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the clear list button clicked.
|
||||
*/
|
||||
virtual void
|
||||
onClearListButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the remove item button clicked.
|
||||
*/
|
||||
|
@ -324,17 +303,9 @@ class LiveModeWindow : public GuiWindow,
|
|||
virtual void
|
||||
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:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -342,12 +313,14 @@ class LiveModeWindow : public GuiWindow,
|
|||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param gladeDir the directory where the glade file is.
|
||||
*/
|
||||
LiveModeWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -400,7 +373,7 @@ class LiveModeWindow : public GuiWindow,
|
|||
void
|
||||
showCuePlayerStopped(void) throw ()
|
||||
{
|
||||
cueAudioButtons->onStop();
|
||||
cuePlayer->onStop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -466,6 +439,15 @@ class LiveModeWindow : public GuiWindow,
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -36,14 +36,12 @@
|
|||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
#include "LoginWindow.h"
|
||||
|
||||
|
||||
using namespace Glib;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -51,6 +49,14 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
namespace {
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const Glib::ustring gladeFileName = "LoginWindow.glade";
|
||||
|
||||
}
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -62,197 +68,111 @@ using namespace LiveSupport::GLiveSupport;
|
|||
*----------------------------------------------------------------------------*/
|
||||
LoginWindow :: LoginWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton,
|
||||
WhiteWindow::isNotResizable),
|
||||
: LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport),
|
||||
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);
|
||||
|
||||
try {
|
||||
set_title(*getResourceUstring("windowTitle"));
|
||||
loginLabel = Gtk::manage(
|
||||
new Gtk::Label(*getResourceUstring("loginLabel")));
|
||||
passwordLabel = Gtk::manage(
|
||||
new Gtk::Label( *getResourceUstring("passwordLabel")));
|
||||
loginEntryBin = Gtk::manage(widgetFactory->createEntryBin());
|
||||
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");
|
||||
Gtk::Label * userNameLabel;
|
||||
Gtk::Label * passwordLabel;
|
||||
Gtk::Label * languageLabel;
|
||||
glade->get_widget("userNameLabel1", userNameLabel);
|
||||
glade->get_widget("passwordLabel1", passwordLabel);
|
||||
glade->get_widget("languageLabel1", languageLabel);
|
||||
userNameLabel->set_text(*getResourceUstring("userNameLabel"));
|
||||
passwordLabel->set_text(*getResourceUstring("passwordLabel"));
|
||||
languageLabel->set_text(*getResourceUstring("languageLabel"));
|
||||
|
||||
// fill up the language list with the list of available languages
|
||||
Ptr<const GLiveSupport::LanguageMap>::Ref languages;
|
||||
languages = gLiveSupport->getSupportedLanguages();
|
||||
GLiveSupport::LanguageMap::const_iterator lang = languages->begin();
|
||||
GLiveSupport::LanguageMap::const_iterator end = languages->end();
|
||||
glade->get_widget_derived("languageEntry1", languageEntry);
|
||||
|
||||
// insert the inital, 'default' language
|
||||
languageList->set_active_text("");
|
||||
selectedLocale.reset(new std::string(""));
|
||||
|
||||
while (lang != end) {
|
||||
const Glib::ustring & language = (*lang).first;
|
||||
languageList->append_text(language);
|
||||
|
||||
lang++;
|
||||
Ptr<const GLiveSupport::LanguageMap>::Ref
|
||||
languages = gLiveSupport->getSupportedLanguages();
|
||||
for (GLiveSupport::LanguageMap::const_iterator
|
||||
it = languages->begin(); it != languages->end(); ++it) {
|
||||
Glib::ustring language = it->first;
|
||||
languageEntry->append_text(language);
|
||||
}
|
||||
languageEntry->set_active(0);
|
||||
|
||||
// set up the OK button
|
||||
okButton->set_name("okButton");
|
||||
okButton->set_flags(Gtk::CAN_FOCUS|Gtk::CAN_DEFAULT|Gtk::HAS_DEFAULT);
|
||||
okButton->set_relief(Gtk::RELIEF_NORMAL);
|
||||
// Register the signal handler for the button getting clicked.
|
||||
okButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&LoginWindow::onOkButtonClicked));
|
||||
// connect signal handlers
|
||||
glade->connect_clicked("okButton1", sigc::mem_fun(*this,
|
||||
&LoginWindow::onOkButtonClicked));
|
||||
glade->connect_clicked("cancelButton1", sigc::mem_fun(*this,
|
||||
&LoginWindow::onCancelButtonClicked));
|
||||
|
||||
// set up the Cancel button
|
||||
cancelButton->set_name("cancelButton");
|
||||
cancelButton->set_flags(Gtk::CAN_FOCUS);
|
||||
cancelButton->set_relief(Gtk::RELIEF_NORMAL);
|
||||
// Register the signal handler for the button getting clicked.
|
||||
cancelButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&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);
|
||||
glade->get_widget("userNameEntry1", userNameEntry);
|
||||
userNameEntry->signal_activate().connect(sigc::mem_fun(*this,
|
||||
&LoginWindow::onUserNameEntryActivated));
|
||||
glade->get_widget("passwordEntry1", passwordEntry);
|
||||
passwordEntry->signal_activate().connect(sigc::mem_fun(*this,
|
||||
&LoginWindow::onPasswordEntryActivated));
|
||||
|
||||
// set up the status bar
|
||||
statusBar = Gtk::manage(new Gtk::Label());
|
||||
// clear the status bar
|
||||
glade->get_widget("statusBar1", statusBar);
|
||||
statusBar->set_text("");
|
||||
|
||||
// set up the table, which provides the layout, and place the widgets
|
||||
// inside the table
|
||||
table = Gtk::manage(new Gtk::Table(8, 10, false));
|
||||
table->set_name("table");
|
||||
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();
|
||||
// set the OK button as the default action, when the user presses Enter;
|
||||
// this does not work when one of the entry fields have focus,
|
||||
// so we need to connect the 'activate' signals explicitly above
|
||||
loginWindow->set_default_response(Gtk::RESPONSE_OK);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LoginWindow :: onOkButtonClicked (void) throw ()
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref pleaseWaitMessage;
|
||||
try {
|
||||
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);
|
||||
statusBar->set_text(*getResourceUstring("pleaseWaitMsg"));
|
||||
loginWindow->set_sensitive(false);
|
||||
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()));
|
||||
|
||||
Ptr<const GLiveSupport::LanguageMap>::Ref languages;
|
||||
languages = gLiveSupport->getSupportedLanguages();
|
||||
|
||||
GLiveSupport::LanguageMap::const_iterator end = languages->end();
|
||||
GLiveSupport::LanguageMap::const_iterator langSel =
|
||||
languages->find(languageList->get_active_text());
|
||||
if (langSel != end) {
|
||||
selectedLocale.reset(new std::string((*langSel).second));
|
||||
} else {
|
||||
selectedLocale.reset(new std::string(""));
|
||||
}
|
||||
GLiveSupport::LanguageMap::const_iterator
|
||||
langSel = languages->find(languageEntry->get_active_text());
|
||||
selectedLocale.reset(new std::string(langSel->second));
|
||||
|
||||
loggedIn = gLiveSupport->login(*getLogin(), *getPassword());
|
||||
|
||||
|
@ -266,7 +186,7 @@ LoginWindow :: onOkButtonClicked (void) throw ()
|
|||
gLiveSupport->createScratchpadWindow();
|
||||
}
|
||||
|
||||
hide();
|
||||
loginWindow->hide();
|
||||
}
|
||||
|
||||
|
||||
|
@ -276,7 +196,7 @@ LoginWindow :: onOkButtonClicked (void) throw ()
|
|||
void
|
||||
LoginWindow :: onCancelButtonClicked (void) throw ()
|
||||
{
|
||||
hide();
|
||||
loginWindow->hide();
|
||||
}
|
||||
|
||||
|
||||
|
@ -286,18 +206,8 @@ LoginWindow :: onCancelButtonClicked (void) throw ()
|
|||
bool
|
||||
LoginWindow :: run(void) throw ()
|
||||
{
|
||||
Gtk::Main::run(*this);
|
||||
Gtk::Main::run(*loginWindow);
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the text of the status bar.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LoginWindow :: setStatusBarText(Ptr<const Glib::ustring>::Ref text)
|
||||
throw ()
|
||||
{
|
||||
statusBar->set_text(*text);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,22 +41,13 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
|
||||
#include <gtkmm/window.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 <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/EntryBin.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -79,77 +70,52 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class LoginWindow : public GuiWindow
|
||||
class LoginWindow : public LocalizedObject
|
||||
{
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The table, which provides the layout for the window.
|
||||
*/
|
||||
Gtk::Table * table;
|
||||
private:
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The container for the password text entry area.
|
||||
*/
|
||||
EntryBin * passwordEntryBin;
|
||||
Gtk::Entry * userNameEntry;
|
||||
|
||||
/**
|
||||
* The password text entry area.
|
||||
*/
|
||||
Gtk::Entry * passwordEntry;
|
||||
Gtk::Entry * passwordEntry;
|
||||
|
||||
/**
|
||||
* The drop-down list to select the desired language.
|
||||
*/
|
||||
ComboBoxText * languageList;
|
||||
|
||||
/**
|
||||
* The horizontal box for the buttons.
|
||||
*/
|
||||
Gtk::HButtonBox * buttonBox;
|
||||
|
||||
/**
|
||||
* The OK button.
|
||||
*/
|
||||
Button * okButton;
|
||||
|
||||
/**
|
||||
* The Cancel button.
|
||||
*/
|
||||
Button * cancelButton;
|
||||
ComboBoxText * languageEntry;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
@ -163,6 +129,18 @@ class LoginWindow : public GuiWindow
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -176,14 +154,18 @@ class LoginWindow : public GuiWindow
|
|||
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
|
||||
setStatusBarText(Ptr<const Glib::ustring>::Ref text)
|
||||
throw ();
|
||||
|
||||
Ptr<const Glib::ustring>::Ref
|
||||
getPassword(void) const throw ()
|
||||
{
|
||||
return passwordText;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -191,12 +173,11 @@ class LoginWindow : public GuiWindow
|
|||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param gladeDir the directory where the glade file is.
|
||||
*/
|
||||
LoginWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -213,30 +194,7 @@ class LoginWindow : public GuiWindow
|
|||
Ptr<const Glib::ustring>::Ref
|
||||
getLogin(void) const throw ()
|
||||
{
|
||||
return loginText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
return userNameText;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
#include <gdkmm/pixbuf.h>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/MasterPanelBin.h"
|
||||
#include "LoginWindow.h"
|
||||
|
||||
#include "MasterPanelWindow.h"
|
||||
|
||||
|
@ -56,9 +56,9 @@ using namespace LiveSupport::GLiveSupport;
|
|||
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.
|
||||
|
@ -68,7 +68,6 @@ const Glib::ustring applicationTitleSuffix = " - Campcaster";
|
|||
/**
|
||||
* Number of times per second that onUpdateTime() is called.
|
||||
* 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;
|
||||
|
||||
|
@ -94,140 +93,100 @@ const int rdsUpdateFrequency = 10;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ()
|
||||
: LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport)
|
||||
gLiveSupport(gLiveSupport),
|
||||
gladeDir(gladeDir),
|
||||
userIsLoggedIn(false)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
|
||||
|
||||
radioLogoWidget = Gtk::manage(gLiveSupport->getStationLogoImage());
|
||||
resizeImage(radioLogoWidget, 120, 104);
|
||||
radioLogoWidget->set_size_request(120, 104);
|
||||
|
||||
// set up the layout, which is a button box
|
||||
layout = Gtk::manage(new Gtk::Table());
|
||||
glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
|
||||
|
||||
// load the station logo image
|
||||
Gtk::Image * stationLogoImage;
|
||||
glade->get_widget("stationLogoImage1", stationLogoImage);
|
||||
stationLogoImage->set(gLiveSupport->getStationLogoPixbuf());
|
||||
|
||||
// set up the time label
|
||||
timeWidget = Gtk::manage(new Gtk::Label());
|
||||
glade->get_widget("timeLabel1", timeLabel);
|
||||
Pango::Attribute fontDescriptionAttribute =
|
||||
Pango::Attribute::create_attr_font_desc(
|
||||
Pango::FontDescription(
|
||||
"Bitstream Vera Sans Bold 20"));
|
||||
fontDescriptionAttribute.set_start_index(0);
|
||||
fontDescriptionAttribute.set_end_index(10);
|
||||
Pango::AttrList timeWidgetAttributes;
|
||||
timeWidgetAttributes.insert(fontDescriptionAttribute);
|
||||
timeWidget->set_attributes(timeWidgetAttributes);
|
||||
timeBin = Gtk::manage(widgetFactory->createBlueBin());
|
||||
timeBin->add(*timeWidget);
|
||||
timeBin->set_size_request(140, 104);
|
||||
Pango::AttrList timeLabelAttributes;
|
||||
timeLabelAttributes.insert(fontDescriptionAttribute);
|
||||
timeLabel->set_attributes(timeLabelAttributes);
|
||||
|
||||
// set up the now playing widget
|
||||
nowPlayingWidget = Gtk::manage(new NowPlaying(gLiveSupport, bundle));
|
||||
Gtk::Alignment * nowPlayingAlignment = Gtk::manage(new Gtk::Alignment(
|
||||
0.0, 0.7, 1.0, 0.0 ));
|
||||
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,
|
||||
// register the signal handlers for the main window
|
||||
glade->get_widget("mainWindow1", masterPanelWindow);
|
||||
masterPanelWindow->signal_key_press_event().connect(sigc::mem_fun(
|
||||
*this,
|
||||
&MasterPanelWindow::onKeyPressed));
|
||||
masterPanelWindow->signal_delete_event().connect(sigc::mem_fun(
|
||||
*this,
|
||||
&MasterPanelWindow::onDeleteEvent));
|
||||
|
||||
// set the background to white
|
||||
bgColor = Colors::getColor(Colors::White);
|
||||
modify_bg(Gtk::STATE_NORMAL, bgColor);
|
||||
// create the Now Playing widget
|
||||
Gtk::Box * nowPlayingBox;
|
||||
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
|
||||
Glib::RefPtr<Gdk::Screen> screen = get_screen();
|
||||
int width = screen->get_width();
|
||||
set_default_size(width, -1);
|
||||
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);
|
||||
Glib::RefPtr<Gdk::Screen> screen = masterPanelWindow->get_screen();
|
||||
masterPanelWindow->set_default_size(screen->get_width(), -1);
|
||||
masterPanelWindow->move(0, 0);
|
||||
|
||||
// show what's there to see
|
||||
showAnonymousUI();
|
||||
updateUserInfo();
|
||||
|
||||
// set the timer, that will update timeWidget
|
||||
// set the timer, that will update timeLabel
|
||||
setTimer();
|
||||
}
|
||||
|
||||
|
@ -235,7 +194,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
/*------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
MasterPanelWindow :: ~MasterPanelWindow (void) throw ()
|
||||
MasterPanelWindow :: ~MasterPanelWindow (void) throw ()
|
||||
{
|
||||
resetTimer();
|
||||
gLiveSupport->stopOutputAudio();
|
||||
|
@ -252,115 +211,40 @@ MasterPanelWindow :: changeLanguage(Ptr<ResourceBundle>::Ref bundle)
|
|||
{
|
||||
setBundle(bundle);
|
||||
|
||||
if (liveModeButton) {
|
||||
buttonBar->remove(*liveModeButton);
|
||||
}
|
||||
if (uploadFileButton) {
|
||||
buttonBar->remove(*uploadFileButton);
|
||||
}
|
||||
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);
|
||||
}
|
||||
Glib::ustring title = *getResourceUstring(
|
||||
"masterPanelWindow",
|
||||
"windowTitle");
|
||||
title += applicationTitleSuffix;
|
||||
masterPanelWindow->set_title(title);
|
||||
|
||||
try {
|
||||
Ptr<Glib::ustring>::Ref title = getResourceUstring(
|
||||
windowName.c_str(),
|
||||
"windowTitle");
|
||||
title->append(applicationTitleSuffix);
|
||||
set_title(*title);
|
||||
nowPlayingWidget->changeLanguage(bundle);
|
||||
|
||||
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(
|
||||
*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);
|
||||
}
|
||||
updateUserInfo();
|
||||
|
||||
userInfoWidget->changeLanguage(bundle);
|
||||
|
||||
// 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 {
|
||||
if (!gLiveSupport->isStorageAvailable()) {
|
||||
// gray out all the buttons except Options
|
||||
liveModeButton->setDisabled(true);
|
||||
uploadFileButton->setDisabled(true);
|
||||
scratchpadButton->setDisabled(true);
|
||||
simplePlaylistMgmtButton->setDisabled(true);
|
||||
schedulerButton->setDisabled(true);
|
||||
searchButton->setDisabled(true);
|
||||
liveModeButton->set_sensitive(false);
|
||||
uploadFileButton->set_sensitive(false);
|
||||
scratchpadButton->set_sensitive(false);
|
||||
playlistButton->set_sensitive(false);
|
||||
schedulerButton->set_sensitive(false);
|
||||
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
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
MasterPanelWindow :: setTimer(void) throw ()
|
||||
MasterPanelWindow :: setTimer(void) throw ()
|
||||
{
|
||||
sigc::slot<bool> slot = sigc::bind(sigc::mem_fun(*this,
|
||||
&MasterPanelWindow::onUpdateTime),
|
||||
0);
|
||||
&MasterPanelWindow::onUpdateTime),
|
||||
0);
|
||||
|
||||
// set the timer to activate every 1/somethingth of a second
|
||||
timer.reset(new sigc::connection(
|
||||
|
@ -384,7 +268,7 @@ MasterPanelWindow :: setTimer(void) throw ()
|
|||
* Clear the timer
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
MasterPanelWindow :: resetTimer(void) throw ()
|
||||
MasterPanelWindow :: resetTimer(void) throw ()
|
||||
{
|
||||
timer->disconnect();
|
||||
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
|
||||
MasterPanelWindow :: onUpdateTime(int dummy) throw ()
|
||||
MasterPanelWindow :: onUpdateTime(int dummy) throw ()
|
||||
{
|
||||
Ptr<const ptime>::Ref now;
|
||||
|
||||
|
@ -419,7 +303,7 @@ MasterPanelWindow :: onUpdateTime(int dummy) throw ()
|
|||
dayTime.seconds(),
|
||||
0);
|
||||
|
||||
timeWidget->set_text(to_simple_string(dayTimeSec));
|
||||
timeLabel->set_text(to_simple_string(dayTimeSec));
|
||||
}
|
||||
|
||||
nowPlayingWidget->onUpdateTime();
|
||||
|
@ -428,7 +312,7 @@ MasterPanelWindow :: onUpdateTime(int dummy) throw ()
|
|||
static int backupCounter = 0;
|
||||
if (backupCounter == 0) {
|
||||
if (optionsWindow) {
|
||||
BackupList * backupList = optionsWindow->getBackupList();
|
||||
Ptr<BackupList>::Ref backupList = optionsWindow->getBackupList();
|
||||
if (backupList) {
|
||||
backupList->updateSilently();
|
||||
}
|
||||
|
@ -466,21 +350,17 @@ MasterPanelWindow :: updateLiveModeWindow(Ptr<Playable>::Ref playable)
|
|||
throw ()
|
||||
{
|
||||
if (!liveModeWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("liveModeWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("liveModeWindow");
|
||||
|
||||
liveModeWindow.reset(new LiveModeWindow(gLiveSupport,
|
||||
bundle,
|
||||
liveModeButton));
|
||||
liveModeButton,
|
||||
gladeDir));
|
||||
gLiveSupport->loadWindowContents(liveModeWindow);
|
||||
}
|
||||
|
||||
liveModeWindow->present();
|
||||
liveModeWindow->show();
|
||||
liveModeWindow->getWindow()->present();
|
||||
|
||||
if (playable) {
|
||||
liveModeWindow->addItem(playable);
|
||||
|
@ -495,20 +375,16 @@ void
|
|||
MasterPanelWindow :: updateUploadFileWindow(void) throw ()
|
||||
{
|
||||
if (!uploadFileWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("uploadFileWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("uploadFileWindow");
|
||||
|
||||
uploadFileWindow.reset(new UploadFileWindow(gLiveSupport,
|
||||
bundle,
|
||||
uploadFileButton));
|
||||
uploadFileButton,
|
||||
gladeDir));
|
||||
}
|
||||
|
||||
uploadFileWindow->present();
|
||||
uploadFileWindow->show();
|
||||
uploadFileWindow->getWindow()->present();
|
||||
}
|
||||
|
||||
|
||||
|
@ -517,19 +393,15 @@ MasterPanelWindow :: updateUploadFileWindow(void) throw ()
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
MasterPanelWindow :: createScratchpadWindow(void)
|
||||
throw ()
|
||||
throw ()
|
||||
{
|
||||
if (!scratchpadWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("scratchpadWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("scratchpadWindow");
|
||||
|
||||
scratchpadWindow.reset(new ScratchpadWindow(gLiveSupport,
|
||||
bundle,
|
||||
scratchpadButton));
|
||||
scratchpadButton,
|
||||
gladeDir));
|
||||
gLiveSupport->loadWindowContents(scratchpadWindow);
|
||||
}
|
||||
}
|
||||
|
@ -540,7 +412,7 @@ MasterPanelWindow :: createScratchpadWindow(void)
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
MasterPanelWindow :: updateScratchpadWindow(Ptr<Playable>::Ref playable)
|
||||
throw ()
|
||||
throw ()
|
||||
{
|
||||
createScratchpadWindow();
|
||||
|
||||
|
@ -548,34 +420,30 @@ MasterPanelWindow :: updateScratchpadWindow(Ptr<Playable>::Ref 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
|
||||
MasterPanelWindow :: updateSimplePlaylistMgmtWindow(void) throw ()
|
||||
MasterPanelWindow :: updatePlaylistWindow(void) throw ()
|
||||
{
|
||||
if (!simplePlaylistMgmtWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("simplePlaylistManagementWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
if (!playlistWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("playlistWindow");
|
||||
|
||||
simplePlaylistMgmtWindow.reset(new SimplePlaylistManagementWindow(
|
||||
gLiveSupport,
|
||||
bundle,
|
||||
simplePlaylistMgmtButton));
|
||||
playlistWindow.reset(new PlaylistWindow(gLiveSupport,
|
||||
bundle,
|
||||
playlistButton,
|
||||
gladeDir));
|
||||
}
|
||||
|
||||
simplePlaylistMgmtWindow->showContents();
|
||||
playlistWindow->showContents();
|
||||
|
||||
simplePlaylistMgmtWindow->present();
|
||||
playlistWindow->show();
|
||||
playlistWindow->getWindow()->present();
|
||||
}
|
||||
|
||||
|
||||
|
@ -588,18 +456,13 @@ MasterPanelWindow :: updateSchedulerWindow(
|
|||
throw ()
|
||||
{
|
||||
if (!schedulerWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("schedulerWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("schedulerWindow");
|
||||
|
||||
try {
|
||||
schedulerWindow.reset(new SchedulerWindow(gLiveSupport,
|
||||
bundle,
|
||||
schedulerButton));
|
||||
schedulerButton,
|
||||
gladeDir));
|
||||
} catch (XmlRpcException &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
|
@ -617,7 +480,8 @@ MasterPanelWindow :: updateSchedulerWindow(
|
|||
return;
|
||||
}
|
||||
|
||||
schedulerWindow->present();
|
||||
schedulerWindow->show();
|
||||
schedulerWindow->getWindow()->present();
|
||||
}
|
||||
|
||||
|
||||
|
@ -628,20 +492,16 @@ void
|
|||
MasterPanelWindow :: updateSearchWindow(void) throw ()
|
||||
{
|
||||
if (!searchWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("searchWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("searchWindow");
|
||||
|
||||
searchWindow.reset(new SearchWindow(gLiveSupport,
|
||||
bundle,
|
||||
searchButton));
|
||||
searchButton,
|
||||
gladeDir));
|
||||
}
|
||||
|
||||
searchWindow->present();
|
||||
searchWindow->show();
|
||||
searchWindow->getWindow()->present();
|
||||
}
|
||||
|
||||
|
||||
|
@ -652,24 +512,20 @@ void
|
|||
MasterPanelWindow :: updateOptionsWindow(void) throw ()
|
||||
{
|
||||
if (!optionsWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("optionsWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("optionsWindow");
|
||||
|
||||
optionsWindow.reset(new OptionsWindow(gLiveSupport,
|
||||
bundle,
|
||||
optionsButton));
|
||||
ContentsStorable * backupList = optionsWindow->getBackupList();
|
||||
optionsButton,
|
||||
gladeDir));
|
||||
Ptr<BackupList>::Ref backupList = optionsWindow->getBackupList();
|
||||
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
|
||||
MasterPanelWindow :: showAnonymousUI(void) throw ()
|
||||
{
|
||||
show_all();
|
||||
liveModeButton->hide();
|
||||
uploadFileButton->hide();
|
||||
scratchpadButton->hide();
|
||||
simplePlaylistMgmtButton->hide();
|
||||
schedulerButton->hide();
|
||||
searchButton->hide();
|
||||
optionsButton->hide();
|
||||
mainButtonBox->hide();
|
||||
|
||||
if (liveModeWindow.get()) {
|
||||
gLiveSupport->storeWindowContents(liveModeWindow);
|
||||
if (liveModeWindow->is_visible()) {
|
||||
if (liveModeWindow->getWindow()->is_visible()) {
|
||||
liveModeWindow->hide();
|
||||
}
|
||||
// the Live Mode window is not destroyed at logout, unlike the others
|
||||
}
|
||||
if (uploadFileWindow.get()) {
|
||||
if (uploadFileWindow->is_visible()) {
|
||||
if (uploadFileWindow->getWindow()->is_visible()) {
|
||||
uploadFileWindow->hide();
|
||||
}
|
||||
uploadFileWindow.reset();
|
||||
}
|
||||
if (scratchpadWindow.get()) {
|
||||
gLiveSupport->storeWindowContents(scratchpadWindow);
|
||||
if (scratchpadWindow->is_visible()) {
|
||||
if (scratchpadWindow->getWindow()->is_visible()) {
|
||||
scratchpadWindow->hide();
|
||||
}
|
||||
scratchpadWindow.reset();
|
||||
}
|
||||
if (simplePlaylistMgmtWindow.get()) {
|
||||
if (simplePlaylistMgmtWindow->is_visible()) {
|
||||
simplePlaylistMgmtWindow->hide();
|
||||
if (playlistWindow.get()) {
|
||||
if (playlistWindow->getWindow()->is_visible()) {
|
||||
playlistWindow->hide();
|
||||
}
|
||||
simplePlaylistMgmtWindow.reset();
|
||||
playlistWindow.reset();
|
||||
}
|
||||
if (schedulerWindow.get()) {
|
||||
if (schedulerWindow->is_visible()) {
|
||||
if (schedulerWindow->getWindow()->is_visible()) {
|
||||
schedulerWindow->hide();
|
||||
}
|
||||
schedulerWindow.reset();
|
||||
}
|
||||
if (searchWindow.get()) {
|
||||
if (searchWindow->is_visible()) {
|
||||
if (searchWindow->getWindow()->is_visible()) {
|
||||
searchWindow->hide();
|
||||
}
|
||||
searchWindow.reset();
|
||||
}
|
||||
if (optionsWindow.get()) {
|
||||
ContentsStorable * backupList = optionsWindow->getBackupList();
|
||||
Ptr<BackupList>::Ref backupList = optionsWindow->getBackupList();
|
||||
if (backupList) {
|
||||
gLiveSupport->storeWindowContents(backupList);
|
||||
gLiveSupport->storeWindowContents(backupList.get());
|
||||
}
|
||||
if (optionsWindow->is_visible()) {
|
||||
if (optionsWindow->getWindow()->is_visible()) {
|
||||
optionsWindow->hide();
|
||||
}
|
||||
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
|
||||
MasterPanelWindow :: cancelEditedPlaylist(void) throw ()
|
||||
{
|
||||
if (simplePlaylistMgmtWindow) {
|
||||
return simplePlaylistMgmtWindow->cancelPlaylist();
|
||||
if (playlistWindow) {
|
||||
return playlistWindow->cancelPlaylist();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -759,14 +608,14 @@ MasterPanelWindow :: cancelEditedPlaylist(void) throw ()
|
|||
void
|
||||
MasterPanelWindow :: showLoggedInUI(void) throw ()
|
||||
{
|
||||
show_all();
|
||||
mainButtonBox->show();
|
||||
|
||||
if (!gLiveSupport->isStorageAvailable()) {
|
||||
liveModeButton->setDisabled(true);
|
||||
uploadFileButton->setDisabled(true);
|
||||
scratchpadButton->setDisabled(true);
|
||||
simplePlaylistMgmtButton->setDisabled(true);
|
||||
searchButton->setDisabled(true);
|
||||
liveModeButton->set_sensitive(false);
|
||||
uploadFileButton->set_sensitive(false);
|
||||
scratchpadButton->set_sensitive(false);
|
||||
playlistButton->set_sensitive(false);
|
||||
searchButton->set_sensitive(false);
|
||||
}
|
||||
|
||||
setSchedulerAvailable(gLiveSupport->isSchedulerAvailable());
|
||||
|
@ -774,7 +623,8 @@ MasterPanelWindow :: showLoggedInUI(void) throw ()
|
|||
if (liveModeWindow) {
|
||||
liveModeWindow->updateStrings();
|
||||
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) {
|
||||
KeyboardShortcut::Action action = gLiveSupport->findAction(
|
||||
windowName,
|
||||
"masterPanelWindow",
|
||||
Gdk::ModifierType(event->state),
|
||||
event->keyval);
|
||||
switch (action) {
|
||||
case KeyboardShortcut::playAudio :
|
||||
nowPlayingWidget->onPlayAudio();
|
||||
return true;
|
||||
|
||||
|
||||
case KeyboardShortcut::pauseAudio :
|
||||
nowPlayingWidget->onPauseAudio();
|
||||
nowPlayingWidget->onPlayAudio();
|
||||
return true;
|
||||
|
||||
case KeyboardShortcut::stopAudio :
|
||||
|
@ -867,22 +715,18 @@ MasterPanelWindow :: uploadToHub(Ptr<Playable>::Ref playable)
|
|||
throw ()
|
||||
{
|
||||
if (!searchWindow.get()) {
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
bundle = getBundle("searchWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
Ptr<ResourceBundle>::Ref bundle = getBundle("searchWindow");
|
||||
|
||||
searchWindow.reset(new SearchWindow(gLiveSupport,
|
||||
bundle,
|
||||
searchButton));
|
||||
searchButton,
|
||||
gladeDir));
|
||||
}
|
||||
|
||||
searchWindow->uploadToHub(playable);
|
||||
|
||||
searchWindow->present();
|
||||
searchWindow->show();
|
||||
searchWindow->getWindow()->present();
|
||||
}
|
||||
|
||||
|
||||
|
@ -893,13 +737,13 @@ void
|
|||
MasterPanelWindow :: setSchedulerAvailable(bool status) throw ()
|
||||
{
|
||||
if (status == false) {
|
||||
if (schedulerWindow && schedulerWindow->is_visible()) {
|
||||
if (schedulerWindow && schedulerWindow->getWindow()->is_visible()) {
|
||||
schedulerWindow->hide();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,31 +40,26 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/image.h>
|
||||
#include <gtkmm/window.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
|
||||
#include "GLiveSupport.h"
|
||||
#include "NowPlaying.h"
|
||||
#include "MasterPanelUserInfoWidget.h"
|
||||
#include "LiveModeWindow.h"
|
||||
#include "UploadFileWindow.h"
|
||||
#include "ScratchpadWindow.h"
|
||||
#include "SimplePlaylistManagementWindow.h"
|
||||
#include "PlaylistWindow.h"
|
||||
#include "SchedulerWindow.h"
|
||||
#include "SearchWindow.h"
|
||||
#include "OptionsWindow.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -92,172 +87,156 @@ using namespace LiveSupport::Widgets;
|
|||
* +--------------------------------------------------+
|
||||
* </code></pre>
|
||||
*
|
||||
* The layout of the window is contained in the file
|
||||
* "var/glade/MasterPanelWindow.glade".
|
||||
*
|
||||
* @author $Author$
|
||||
* @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:
|
||||
/**
|
||||
* The layout used in the window.
|
||||
*/
|
||||
Gtk::Table * layout;
|
||||
|
||||
/**
|
||||
* The background color.
|
||||
* The main window.
|
||||
*/
|
||||
Gdk::Color bgColor;
|
||||
|
||||
/**
|
||||
* The container for the time widget
|
||||
*/
|
||||
BlueBin * timeBin;
|
||||
Gtk::Window * masterPanelWindow;
|
||||
|
||||
/**
|
||||
* The time display
|
||||
*/
|
||||
Gtk::Label * timeWidget;
|
||||
Gtk::Label * timeLabel;
|
||||
|
||||
/**
|
||||
* The signal connection, that is notified by the GTK timer each
|
||||
* second, and will update the time display on each wakeup.
|
||||
*/
|
||||
Ptr<sigc::connection>::Ref timer;
|
||||
|
||||
/**
|
||||
* The container for the now playing widget
|
||||
*/
|
||||
BlueBin * nowPlayingBin;
|
||||
Ptr<sigc::connection>::Ref timer;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
Gtk::ToggleButton * uploadFileButton;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Button * schedulerButton;
|
||||
Gtk::ToggleButton * schedulerButton;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Ptr<LiveModeWindow>::Ref liveModeWindow;
|
||||
Ptr<LiveModeWindow>::Ref liveModeWindow;
|
||||
|
||||
/**
|
||||
* The one and only Upload File window.
|
||||
*/
|
||||
Ptr<UploadFileWindow>::Ref uploadFileWindow;
|
||||
Ptr<UploadFileWindow>::Ref uploadFileWindow;
|
||||
|
||||
/**
|
||||
* The one and only Scratchpad window.
|
||||
*/
|
||||
Ptr<ScratchpadWindow>::Ref scratchpadWindow;
|
||||
Ptr<ScratchpadWindow>::Ref scratchpadWindow;
|
||||
|
||||
/**
|
||||
* The one and only simple playlist management window.
|
||||
*/
|
||||
Ptr<SimplePlaylistManagementWindow>::Ref simplePlaylistMgmtWindow;
|
||||
Ptr<PlaylistWindow>::Ref playlistWindow;
|
||||
|
||||
/**
|
||||
* The one and only scheduler window.
|
||||
*/
|
||||
Ptr<SchedulerWindow>::Ref schedulerWindow;
|
||||
Ptr<SchedulerWindow>::Ref schedulerWindow;
|
||||
|
||||
/**
|
||||
* The one and only search window.
|
||||
*/
|
||||
Ptr<SearchWindow>::Ref searchWindow;
|
||||
Ptr<SearchWindow>::Ref searchWindow;
|
||||
|
||||
/**
|
||||
* The one and only options window.
|
||||
*/
|
||||
Ptr<OptionsWindow>::Ref optionsWindow;
|
||||
Ptr<OptionsWindow>::Ref optionsWindow;
|
||||
|
||||
/**
|
||||
* Function that updates timeLabel with the current time.
|
||||
|
@ -294,7 +273,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
onUploadFileButtonClicked(void) throw ()
|
||||
{
|
||||
if (!uploadFileWindow ||
|
||||
uploadFileWindow && !uploadFileWindow->is_visible()) {
|
||||
uploadFileWindow && !uploadFileWindow->getWindow()
|
||||
->is_visible()) {
|
||||
updateUploadFileWindow();
|
||||
} else {
|
||||
uploadFileWindow->hide();
|
||||
|
@ -309,7 +289,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
onLiveModeButtonClicked(void) throw ()
|
||||
{
|
||||
if (!liveModeWindow ||
|
||||
liveModeWindow && !liveModeWindow->is_visible()) {
|
||||
liveModeWindow && !liveModeWindow->getWindow()
|
||||
->is_visible()) {
|
||||
updateLiveModeWindow();
|
||||
} else {
|
||||
liveModeWindow->hide();
|
||||
|
@ -324,7 +305,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
onScratchpadButtonClicked(void) throw ()
|
||||
{
|
||||
if (!scratchpadWindow ||
|
||||
scratchpadWindow && !scratchpadWindow->is_visible()) {
|
||||
scratchpadWindow && !scratchpadWindow->getWindow()
|
||||
->is_visible()) {
|
||||
updateScratchpadWindow();
|
||||
} else {
|
||||
scratchpadWindow->hide();
|
||||
|
@ -336,14 +318,14 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
* Management button being pressed.
|
||||
*/
|
||||
virtual void
|
||||
onSimplePlaylistMgmtButtonClicked(void) throw ()
|
||||
onPlaylistButtonClicked(void) throw ()
|
||||
{
|
||||
if (!simplePlaylistMgmtWindow ||
|
||||
simplePlaylistMgmtWindow &&
|
||||
!simplePlaylistMgmtWindow->is_visible()) {
|
||||
updateSimplePlaylistMgmtWindow();
|
||||
if (!playlistWindow ||
|
||||
playlistWindow && !playlistWindow->getWindow()
|
||||
->is_visible()) {
|
||||
updatePlaylistWindow();
|
||||
} else {
|
||||
simplePlaylistMgmtWindow->hide();
|
||||
playlistWindow->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,10 +334,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
* button being pressed.
|
||||
*/
|
||||
virtual void
|
||||
onSchedulerButtonClicked(void) throw ()
|
||||
onSchedulerButtonClicked(void) throw ()
|
||||
{
|
||||
if (!schedulerWindow ||
|
||||
schedulerWindow && !schedulerWindow->is_visible()) {
|
||||
schedulerWindow && !schedulerWindow->getWindow()
|
||||
->is_visible()) {
|
||||
updateSchedulerWindow();
|
||||
} else {
|
||||
schedulerWindow->hide();
|
||||
|
@ -370,7 +353,8 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
onSearchButtonClicked(void) throw ()
|
||||
{
|
||||
if (!searchWindow ||
|
||||
searchWindow && !searchWindow->is_visible()) {
|
||||
searchWindow && !searchWindow->getWindow()
|
||||
->is_visible()) {
|
||||
updateSearchWindow();
|
||||
} else {
|
||||
searchWindow->hide();
|
||||
|
@ -385,13 +369,21 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
onOptionsButtonClicked(void) throw ()
|
||||
{
|
||||
if (!optionsWindow ||
|
||||
optionsWindow && !optionsWindow->is_visible()) {
|
||||
optionsWindow && !optionsWindow->getWindow()
|
||||
->is_visible()) {
|
||||
updateOptionsWindow();
|
||||
} else {
|
||||
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.
|
||||
* The keys can be customized by the keyboardShortcutContainer
|
||||
|
@ -406,31 +398,55 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
bool
|
||||
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:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, handling the
|
||||
* logic of the application
|
||||
* @param bundle the resource bundle holding localized resources
|
||||
* @param gLiveSupport the gLiveSupport object, handling the
|
||||
* logic of the application.
|
||||
* @param bundle the resource bundle holding localized resources.
|
||||
* @param gladeDir the directory where the Glade files are.
|
||||
*/
|
||||
MasterPanelWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* @param bundle the new resource bundle.
|
||||
|
@ -445,11 +461,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
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
|
||||
* to cancel); false if the user canceled the canceling
|
||||
* @see SimplePlaylistManagementWindow::cancelPlaylist()
|
||||
* @see PlaylistWindow::cancelPlaylist()
|
||||
*/
|
||||
bool
|
||||
cancelEditedPlaylist(void) throw ();
|
||||
|
@ -513,7 +529,7 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
* Update the Simple Playlist Management Window
|
||||
*/
|
||||
void
|
||||
updateSimplePlaylistMgmtWindow(void) throw ();
|
||||
updatePlaylistWindow(void) throw ();
|
||||
|
||||
/**
|
||||
* Update the Scheduler Window, optionally to display a new time.
|
||||
|
@ -537,6 +553,16 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
void
|
||||
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.
|
||||
* 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 ()
|
||||
{
|
||||
nowPlayingWidget->setPlayable(playable);
|
||||
gLiveSupport->updateRds();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,14 +36,11 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
#include "LiveSupport/Widgets/Colors.h"
|
||||
|
||||
#include "NowPlaying.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -58,6 +55,16 @@ namespace {
|
|||
*/
|
||||
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 */
|
||||
|
@ -68,106 +75,39 @@ const int blinkingConstant = 5;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
NowPlaying :: NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
NowPlaying :: NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: LocalizedObject(bundle),
|
||||
glade(glade),
|
||||
gLiveSupport(gLiveSupport)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
playButton = Gtk::manage(wf->createButton(
|
||||
WidgetConstants::masterPlayButton ));
|
||||
pauseButton = Gtk::manage(wf->createButton(
|
||||
WidgetConstants::masterPauseButton ));
|
||||
stopButton = Gtk::manage(wf->createButton(
|
||||
WidgetConstants::masterStopButton ));
|
||||
glade->get_widget("playButton1", playButton);
|
||||
glade->get_widget("stopButton1", stopButton);
|
||||
|
||||
playButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&NowPlaying::onPlayButtonClicked ));
|
||||
pauseButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&NowPlaying::onPauseButtonClicked ));
|
||||
stopButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&NowPlaying::onStopButtonClicked ));
|
||||
|
||||
isActive = false;
|
||||
isPaused = false;
|
||||
|
||||
titleLabel = createFormattedLabel(14);
|
||||
titleLabel->set_ellipsize(Pango::ELLIPSIZE_END);
|
||||
|
||||
creatorLabel = createFormattedLabel(8);
|
||||
creatorLabel->set_ellipsize(Pango::ELLIPSIZE_END);
|
||||
|
||||
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();
|
||||
glade->get_widget("titleLabel1", titleLabel);
|
||||
glade->get_widget("creatorLabel1", creatorLabel);
|
||||
glade->get_widget("elapsedTimeLabel1", elapsedTimeLabel);
|
||||
glade->get_widget("remainsTimeBox1", remainsTimeBox);
|
||||
glade->get_widget("remainsTimeLabel1", remainsTimeLabel);
|
||||
glade->get_widget("playlistLabel1", playlistLabel);
|
||||
|
||||
try {
|
||||
elapsedLabel->set_text(*getResourceUstring("elapsedTimeLabel"));
|
||||
remainsLabel->set_text(*getResourceUstring("remainingTimeLabel"));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
glade->get_widget("elapsedTimeText1", elapsedTimeText);
|
||||
glade->get_widget("remainsTimeText1", remainsTimeText);
|
||||
elapsedTimeText->set_text(*getResourceUstring("elapsedTimeLabel"));
|
||||
remainsTimeText->set_text(*getResourceUstring("remainingTimeLabel"));
|
||||
|
||||
Gtk::Box * titleBox = Gtk::manage(new Gtk::HBox);
|
||||
titleBox->pack_start(*titleLabel, Gtk::PACK_EXPAND_WIDGET, 5);
|
||||
|
||||
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);
|
||||
Ptr<Playable>::Ref nullPointer;
|
||||
setPlayable(nullPointer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,12 +117,16 @@ NowPlaying :: NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
void
|
||||
NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
|
||||
{
|
||||
playableMutex.lock();
|
||||
// BEGIN synchronized block
|
||||
|
||||
if (playable) {
|
||||
if (!isActive || isPaused) {
|
||||
remove(*playButton);
|
||||
pack_end(*pauseButton, Gtk::PACK_SHRINK, 2);
|
||||
pauseButton->show();
|
||||
playButton->set_label(pauseStockImageName);
|
||||
}
|
||||
playButton->set_sensitive(true);
|
||||
stopButton->set_sensitive(true);
|
||||
|
||||
this->playable = playable;
|
||||
isActive = true;
|
||||
isPaused = false;
|
||||
|
@ -191,22 +135,24 @@ NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
|
|||
|
||||
} else {
|
||||
if (isActive && !isPaused) {
|
||||
remove(*pauseButton);
|
||||
pack_end(*playButton, Gtk::PACK_SHRINK, 2);
|
||||
playButton->show();
|
||||
playButton->set_label(playStockImageName);
|
||||
isActive = false;
|
||||
}
|
||||
playButton->set_sensitive(false);
|
||||
stopButton->set_sensitive(false);
|
||||
|
||||
titleLabel->set_text("");
|
||||
creatorLabel->set_text("");
|
||||
elapsedTime->set_text("");
|
||||
remainsTime->set_text("");
|
||||
elapsedTimeLabel->set_text("");
|
||||
remainsTimeLabel->set_text("");
|
||||
playlistLabel->set_text("");
|
||||
resetRemainsTimeState();
|
||||
this->playable.reset();
|
||||
this->currentInnerPlayable.reset();
|
||||
}
|
||||
|
||||
gLiveSupport->updateRds();
|
||||
|
||||
// END synchronized block
|
||||
playableMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,32 +162,16 @@ NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
|
|||
void
|
||||
NowPlaying :: onPlayButtonClicked(void) throw ()
|
||||
{
|
||||
if (isActive && isPaused) {
|
||||
gLiveSupport->pauseOutputAudio(); // i.e., restart
|
||||
|
||||
remove(*playButton);
|
||||
pack_end(*pauseButton, Gtk::PACK_SHRINK, 2);
|
||||
pauseButton->show();
|
||||
|
||||
isPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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;
|
||||
if (isActive) {
|
||||
if (isPaused) {
|
||||
gLiveSupport->pauseOutputAudio(); // i.e., restart
|
||||
playButton->set_label(pauseStockImageName);
|
||||
isPaused = false;
|
||||
} else {
|
||||
gLiveSupport->pauseOutputAudio();
|
||||
playButton->set_label(playStockImageName);
|
||||
isPaused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,34 +188,6 @@ NowPlaying :: onStopButtonClicked(void) throw ()
|
|||
} // 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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -333,6 +235,15 @@ NowPlaying :: onUpdateTime(void) throw ()
|
|||
}
|
||||
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<time_duration>::Ref innerElapsed = elapsed;
|
||||
Ptr<time_duration>::Ref innerRemains = remains;
|
||||
|
@ -379,12 +290,15 @@ NowPlaying :: onUpdateTime(void) throw ()
|
|||
creatorLabel->set_text("");
|
||||
}
|
||||
|
||||
elapsedTime->set_text(*TimeConversion::timeDurationToHhMmSsString(
|
||||
innerElapsed ));
|
||||
remainsTime->set_text(*TimeConversion::timeDurationToHhMmSsString(
|
||||
innerRemains ));
|
||||
elapsedTimeLabel->set_text(*TimeConversion::timeDurationToHhMmSsString(
|
||||
innerElapsed ));
|
||||
remainsTimeLabel->set_text(*TimeConversion::timeDurationToHhMmSsString(
|
||||
innerRemains ));
|
||||
|
||||
currentInnerPlayable = innerPlayable;
|
||||
|
||||
// END synchronized block
|
||||
playableMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
@ -396,28 +310,28 @@ NowPlaying :: setRemainsTimeColor(RemainsTimeStateType state) throw ()
|
|||
{
|
||||
bool isBlinkOn = (remainsTimeCounter < blinkingConstant);
|
||||
|
||||
Gdk::Color color;
|
||||
|
||||
if (isBlinkOn) {
|
||||
switch (state) {
|
||||
case TIME_GREEN:
|
||||
color = Colors::getColor(Colors::MasterPanelCenterBlue);
|
||||
remainsTimeBox->unset_bg(Gtk::STATE_NORMAL);
|
||||
break;
|
||||
|
||||
case TIME_YELLOW:
|
||||
color = Colors::getColor(Colors::Yellow);
|
||||
remainsTimeBox->modify_bg(Gtk::STATE_NORMAL,
|
||||
Colors::getColor(Colors::Yellow));
|
||||
break;
|
||||
|
||||
case TIME_RED:
|
||||
color = Colors::getColor(Colors::Red);
|
||||
remainsTimeBox->modify_bg(Gtk::STATE_NORMAL,
|
||||
Colors::getColor(Colors::Red));
|
||||
break;
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,9 +41,11 @@
|
|||
#endif
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/Mutex.h"
|
||||
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
|
@ -52,7 +54,6 @@ namespace LiveSupport {
|
|||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -68,11 +69,15 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class NowPlaying : public Gtk::HBox,
|
||||
public LocalizedObject
|
||||
class NowPlaying : public LocalizedObject
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The Glade object, containing the visual design.
|
||||
*/
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade;
|
||||
|
||||
/**
|
||||
* Whether anything is shown in the widget.
|
||||
*/
|
||||
|
@ -110,15 +115,25 @@ class NowPlaying : public Gtk::HBox,
|
|||
*/
|
||||
Gtk::Label * playlistLabel;
|
||||
|
||||
/**
|
||||
* The label which says "elapsed time".
|
||||
*/
|
||||
Gtk::Label * elapsedTimeText;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Gtk::Label * remainsTime;
|
||||
Gtk::Label * remainsTimeLabel;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ImageButton * playButton;
|
||||
|
||||
/**
|
||||
* The pause button.
|
||||
*/
|
||||
ImageButton * pauseButton;
|
||||
Gtk::Button * playButton;
|
||||
|
||||
/**
|
||||
* The stop button.
|
||||
*/
|
||||
ImageButton * stopButton;
|
||||
Gtk::Button * stopButton;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport;
|
||||
|
||||
|
||||
/**
|
||||
* A mutex to make the writing, and some reading, of the
|
||||
* 'playable' variable atomic.
|
||||
*/
|
||||
Mutex playableMutex;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
|
@ -172,28 +188,12 @@ class NowPlaying : public Gtk::HBox,
|
|||
void
|
||||
onPlayButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Event handler for the Pause button being clicked.
|
||||
*/
|
||||
void
|
||||
onPauseButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Event handler for the Stop button being clicked.
|
||||
*/
|
||||
void
|
||||
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.
|
||||
*
|
||||
|
@ -225,9 +225,12 @@ class NowPlaying : public Gtk::HBox,
|
|||
* @param gLiveSupport the GLiveSupport, application object.
|
||||
* @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.
|
||||
*/
|
||||
NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -264,17 +267,6 @@ class NowPlaying : public Gtk::HBox,
|
|||
onPlayButtonClicked();
|
||||
}
|
||||
|
||||
/**
|
||||
* Public interface for pausing the audio.
|
||||
*
|
||||
* This is used by MasterPanelWindow::onKeyPressed().
|
||||
*/
|
||||
void
|
||||
onPauseAudio(void) throw ()
|
||||
{
|
||||
onPauseButtonClicked();
|
||||
}
|
||||
|
||||
/**
|
||||
* Public interface for stopping the audio.
|
||||
*
|
||||
|
@ -300,6 +292,14 @@ class NowPlaying : public Gtk::HBox,
|
|||
{
|
||||
return currentInnerPlayable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the user interface language of the widget.
|
||||
*
|
||||
* @param bundle the new resource bundle.
|
||||
*/
|
||||
void
|
||||
changeLanguage(Ptr<ResourceBundle>::Ref bundle) throw ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -33,18 +33,10 @@
|
|||
#include "configure.h"
|
||||
#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"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -54,10 +46,10 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc).
|
||||
*/
|
||||
const Glib::ustring windowName = "optionsWindow";
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const Glib::ustring gladeFileName = "OptionsWindow.glade";
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,107 +63,61 @@ const Glib::ustring windowName = "optionsWindow";
|
|||
*----------------------------------------------------------------------------*/
|
||||
OptionsWindow :: OptionsWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton),
|
||||
backupView(0)
|
||||
: BasicWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton,
|
||||
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()
|
||||
&& gLiveSupport->isStorageAvailable());
|
||||
|
||||
// build up the notepad for the various sections
|
||||
mainNotebook = Gtk::manage(new ScrolledNotebook);
|
||||
Gtk::Box * soundSectionBox = constructSoundSection();
|
||||
Gtk::Box * keyBindingsSectionBox = constructKeyBindingsSection();
|
||||
Gtk::Box * serversSectionBox = constructServersSection();
|
||||
Gtk::Box * schedulerSectionBox = constructSchedulerSection();
|
||||
Gtk::Box * backupSectionBox = 0;
|
||||
glade->get_widget("mainNotebook1", mainNotebook);
|
||||
constructSoundSection();
|
||||
constructKeyBindingsSection();
|
||||
constructServersSection();
|
||||
constructSchedulerSection();
|
||||
if (canBackup) {
|
||||
backupSectionBox = constructBackupSection();
|
||||
constructBackupSection();
|
||||
}
|
||||
Gtk::Box * rdsSectionBox = constructRdsSection();
|
||||
Gtk::Box * aboutSectionBox = constructAboutSection();
|
||||
constructRdsSection();
|
||||
constructAboutSection();
|
||||
|
||||
try {
|
||||
mainNotebook->appendPage(*soundSectionBox,
|
||||
*getResourceUstring("soundSectionLabel"));
|
||||
mainNotebook->appendPage(*keyBindingsSectionBox,
|
||||
*getResourceUstring("keyBindingsSectionLabel"));
|
||||
mainNotebook->appendPage(*serversSectionBox,
|
||||
*getResourceUstring("serversSectionLabel"));
|
||||
mainNotebook->appendPage(*schedulerSectionBox,
|
||||
*getResourceUstring("schedulerSectionLabel"));
|
||||
if (canBackup) {
|
||||
mainNotebook->appendPage(*backupSectionBox,
|
||||
*getResourceUstring("backupSectionLabel"));
|
||||
}
|
||||
mainNotebook->appendPage(*rdsSectionBox,
|
||||
*getResourceUstring("rdsSectionLabel"));
|
||||
mainNotebook->appendPage(*aboutSectionBox,
|
||||
*getResourceUstring("aboutSectionLabel"));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
// TODO: signal error
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
Gtk::Label * soundTabLabel;
|
||||
Gtk::Label * keyBindingsTabLabel;
|
||||
Gtk::Label * serversTabLabel;
|
||||
Gtk::Label * schedulerTabLabel;
|
||||
Gtk::Label * backupTabLabel;
|
||||
Gtk::Label * rdsTabLabel;
|
||||
Gtk::Label * aboutTabLabel;
|
||||
glade->get_widget("soundTabLabel1", soundTabLabel);
|
||||
glade->get_widget("keyBindingsTabLabel1", keyBindingsTabLabel);
|
||||
glade->get_widget("serversTabLabel1", serversTabLabel);
|
||||
glade->get_widget("schedulerTabLabel1", schedulerTabLabel);
|
||||
glade->get_widget("backupTabLabel1", backupTabLabel);
|
||||
glade->get_widget("rdsTabLabel1", rdsTabLabel);
|
||||
glade->get_widget("aboutTabLabel1", aboutTabLabel);
|
||||
soundTabLabel->set_label(*getResourceUstring("soundSectionLabel"));
|
||||
keyBindingsTabLabel->set_label(*getResourceUstring(
|
||||
"keyBindingsSectionLabel"));
|
||||
serversTabLabel->set_label(*getResourceUstring("serversSectionLabel"));
|
||||
schedulerTabLabel->set_label(*getResourceUstring("schedulerSectionLabel"));
|
||||
if (canBackup) {
|
||||
backupTabLabel->set_label(*getResourceUstring("backupSectionLabel"));
|
||||
}
|
||||
|
||||
// build up the button box
|
||||
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);
|
||||
rdsTabLabel->set_label(*getResourceUstring("rdsSectionLabel"));
|
||||
aboutTabLabel->set_label(*getResourceUstring("aboutSectionLabel"));
|
||||
|
||||
// bind events
|
||||
cancelButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&OptionsWindow::onCancelButtonClicked));
|
||||
applyButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
glade->connect_clicked("applyButton1", sigc::mem_fun(*this,
|
||||
&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));
|
||||
|
||||
// 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
|
||||
|
||||
if (changed) {
|
||||
try {
|
||||
Ptr<Glib::ustring>::Ref
|
||||
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);
|
||||
}
|
||||
gLiveSupport->displayMessageWindow(*getResourceUstring(
|
||||
"needToRestartMsg"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +165,7 @@ OptionsWindow :: saveChangesInStringEntryFields(void) throw ()
|
|||
for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) {
|
||||
|
||||
OptionsContainer::OptionItemString optionItem = it->first;
|
||||
EntryBin * entry = it->second;
|
||||
Gtk::Entry * entry = it->second;
|
||||
|
||||
Ptr<const Glib::ustring>::Ref
|
||||
oldValue = optionsContainer->getOptionItem(optionItem);
|
||||
|
@ -244,7 +182,7 @@ OptionsWindow :: saveChangesInStringEntryFields(void) throw ()
|
|||
errorMessage(new Glib::ustring(
|
||||
*getResourceUstring("errorMsg") ));
|
||||
errorMessage->append(e.what());
|
||||
gLiveSupport->displayMessageWindow(errorMessage);
|
||||
gLiveSupport->displayMessageWindow(*errorMessage);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
|
@ -304,7 +242,7 @@ OptionsWindow :: saveChangesInKeyBindings(void) throw ()
|
|||
errorMessage(new Glib::ustring(
|
||||
*getResourceUstring("errorMsg") ));
|
||||
errorMessage->append(e.what());
|
||||
gLiveSupport->displayMessageWindow(errorMessage);
|
||||
gLiveSupport->displayMessageWindow(*errorMessage);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
|
@ -356,7 +294,7 @@ OptionsWindow :: onCloseButtonClicked(bool needConfirm) throw ()
|
|||
* Event handler for the test button
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OptionsWindow :: onTestButtonClicked(const EntryBin * entry)
|
||||
OptionsWindow :: onTestButtonClicked(const Gtk::Entry * entry)
|
||||
throw ()
|
||||
{
|
||||
Ptr<OptionsContainer>::Ref optionsContainer
|
||||
|
@ -376,15 +314,16 @@ OptionsWindow :: onTestButtonClicked(const EntryBin * entry)
|
|||
/*------------------------------------------------------------------------------
|
||||
* Create a new user entry field item.
|
||||
*----------------------------------------------------------------------------*/
|
||||
EntryBin *
|
||||
OptionsWindow :: createEntry(OptionsContainer::OptionItemString optionItem)
|
||||
Gtk::Entry *
|
||||
OptionsWindow :: createEntry(const Glib::ustring & entryName,
|
||||
OptionsContainer::OptionItemString optionItem)
|
||||
throw ()
|
||||
{
|
||||
Ptr<OptionsContainer>::Ref optionsContainer
|
||||
= gLiveSupport->getOptionsContainer();
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
EntryBin * entry = Gtk::manage(wf->createEntryBin());
|
||||
Gtk::Entry * entry;
|
||||
glade->get_widget(entryName, entry);
|
||||
|
||||
try {
|
||||
entry->set_text(*optionsContainer->getOptionItem(optionItem));
|
||||
|
@ -395,7 +334,7 @@ OptionsWindow :: createEntry(OptionsContainer::OptionItemString optionItem)
|
|||
}
|
||||
|
||||
stringEntryList.push_back(std::make_pair(optionItem, entry));
|
||||
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
@ -403,145 +342,75 @@ OptionsWindow :: createEntry(OptionsContainer::OptionItemString optionItem)
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the "Sound" section.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
OptionsWindow :: constructSoundSection(void) throw ()
|
||||
{
|
||||
Ptr<OptionsContainer>::Ref optionsContainer
|
||||
= gLiveSupport->getOptionsContainer();
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Table * audioDeviceTable = Gtk::manage(new Gtk::Table);
|
||||
audioDeviceTable->set_row_spacings(10);
|
||||
audioDeviceTable->set_col_spacings(5);
|
||||
|
||||
// display the settings for the cue player device
|
||||
Glib::ustring cuePlayerLabelContents;
|
||||
try {
|
||||
cuePlayerLabelContents.append(*getResourceUstring("cueDeviceLabel"));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
// TODO: signal error
|
||||
std::cerr << e.what() << std::endl;
|
||||
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(
|
||||
Gtk::Label * cueDeviceLabel;
|
||||
Gtk::Label * outputDeviceLabel;
|
||||
glade->get_widget("cueDeviceLabel1", cueDeviceLabel);
|
||||
glade->get_widget("outputDeviceLabel1", outputDeviceLabel);
|
||||
cueDeviceLabel->set_label(*getResourceUstring("cueDeviceLabel"));
|
||||
outputDeviceLabel->set_label(*getResourceUstring("outputDeviceLabel"));
|
||||
|
||||
Gtk::Entry * cueDeviceEntry;
|
||||
Gtk::Entry * outputDeviceEntry;
|
||||
cueDeviceEntry = createEntry("cueDeviceEntry1",
|
||||
OptionsContainer::cuePlayerDeviceName);
|
||||
outputDeviceEntry = createEntry("outputDeviceEntry1",
|
||||
OptionsContainer::outputPlayerDeviceName);
|
||||
audioDeviceTable->attach(*outputPlayerEntry, 1, 2, 1, 2);
|
||||
|
||||
Button * outputTestButton;
|
||||
try {
|
||||
outputTestButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("testButtonLabel") ));
|
||||
} catch (std::invalid_argument &e) {
|
||||
// TODO: signal error
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
outputTestButton->signal_clicked().connect(sigc::bind<EntryBin*>(
|
||||
Gtk::Button * cueTestButton;
|
||||
Gtk::Button * outputTestButton;
|
||||
glade->get_widget("cueTestButton1", cueTestButton);
|
||||
glade->get_widget("outputTestButton1", outputTestButton);
|
||||
cueTestButton->set_label(*getResourceUstring("testButtonLabel"));
|
||||
outputTestButton->set_label(*getResourceUstring("testButtonLabel"));
|
||||
cueTestButton->signal_clicked().connect(sigc::bind<Gtk::Entry*>(
|
||||
sigc::mem_fun(*this, &OptionsWindow::onTestButtonClicked),
|
||||
outputPlayerEntry));
|
||||
audioDeviceTable->attach(*outputTestButton, 2, 3, 1, 2);
|
||||
|
||||
// make a new box and pack the components into it
|
||||
Gtk::VBox * section = Gtk::manage(new Gtk::VBox);
|
||||
section->pack_start(*audioDeviceTable, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
return section;
|
||||
cueDeviceEntry));
|
||||
outputTestButton->signal_clicked().connect(sigc::bind<Gtk::Entry*>(
|
||||
sigc::mem_fun(*this, &OptionsWindow::onTestButtonClicked),
|
||||
outputDeviceEntry));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the "Key bindings" section.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
OptionsWindow :: constructKeyBindingsSection(void) throw ()
|
||||
{
|
||||
// create the TreeView
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
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);
|
||||
keyBindingsView->appendColumn("", keyBindingsColumns.keyDisplayColumn);
|
||||
keyBindingsTreeView->appendColumn("", keyBindingsColumns.actionColumn);
|
||||
keyBindingsTreeView->appendColumn("", keyBindingsColumns.keyDisplayColumn);
|
||||
|
||||
// fill in the data
|
||||
fillKeyBindingsModel();
|
||||
|
||||
// set TreeView properties
|
||||
keyBindingsView->set_headers_visible(false);
|
||||
keyBindingsView->set_enable_search(false);
|
||||
keyBindingsView->columns_autosize();
|
||||
keyBindingsView->expand_all();
|
||||
|
||||
keyBindingsTreeView->columns_autosize();
|
||||
keyBindingsTreeView->expand_all();
|
||||
|
||||
// connect the callbacks
|
||||
keyBindingsView->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||
&OptionsWindow::onKeyBindingsRowActivated ));
|
||||
keyBindingsView->signal_key_press_event().connect(sigc::mem_fun(*this,
|
||||
&OptionsWindow::onKeyBindingsKeyPressed ));
|
||||
keyBindingsView->signal_focus_out_event().connect_notify(sigc::mem_fun(
|
||||
keyBindingsTreeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||
&OptionsWindow::onKeyBindingsRowActivated));
|
||||
keyBindingsTreeView->signal_key_press_event().connect(sigc::mem_fun(*this,
|
||||
&OptionsWindow::onKeyBindingsKeyPressed));
|
||||
keyBindingsTreeView->signal_focus_out_event().connect_notify(sigc::mem_fun(
|
||||
*this,
|
||||
&OptionsWindow::onKeyBindingsFocusOut ));
|
||||
&OptionsWindow::onKeyBindingsFocusOut));
|
||||
|
||||
// add instructions
|
||||
Ptr<const Glib::ustring>::Ref instructionsText;
|
||||
try {
|
||||
instructionsText = 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;
|
||||
Gtk::Label * instructionsLabel;
|
||||
glade->get_widget("keyBindingsInstructionsLabel1", instructionsLabel);
|
||||
instructionsLabel->set_label(*getResourceUstring(
|
||||
"keyBindingsInstructionsText"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -554,40 +423,34 @@ OptionsWindow :: fillKeyBindingsModel(void) throw ()
|
|||
Ptr<const KeyboardShortcutList>::Ref
|
||||
list = gLiveSupport->getKeyboardShortcutList();
|
||||
|
||||
try {
|
||||
KeyboardShortcutList::iterator it;
|
||||
for (it = list->begin(); it != list->end(); ++it) {
|
||||
Ptr<const KeyboardShortcutContainer>::Ref
|
||||
container = *it;
|
||||
KeyboardShortcutList::iterator it;
|
||||
for (it = list->begin(); it != list->end(); ++it) {
|
||||
Ptr<const KeyboardShortcutContainer>::Ref
|
||||
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
|
||||
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
|
||||
actionString = shortcut->getActionString();
|
||||
Ptr<const Glib::ustring>::Ref
|
||||
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);
|
||||
}
|
||||
actionString = shortcut->getActionString();
|
||||
Ptr<const Glib::ustring>::Ref
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
OptionsWindow :: constructServersSection(void) throw ()
|
||||
{
|
||||
Ptr<OptionsContainer>::Ref optionsContainer
|
||||
= 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 * authenticationServerLabel;
|
||||
Gtk::Label * authenticationPortLabel;
|
||||
Gtk::Label * authenticationPathLabel;
|
||||
try {
|
||||
authenticationLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("authenticationLabel") ));
|
||||
authenticationServerLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("serverLabel") ));
|
||||
authenticationPortLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("portLabel") ));
|
||||
authenticationPathLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("pathLabel") ));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
// 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);
|
||||
glade->get_widget("authenticationServerLabel1", authenticationLabel);
|
||||
glade->get_widget("authenticationServerServerLabel1",
|
||||
authenticationServerLabel);
|
||||
glade->get_widget("authenticationServerPortLabel1",
|
||||
authenticationPortLabel);
|
||||
glade->get_widget("authenticationServerPathLabel1",
|
||||
authenticationPathLabel);
|
||||
authenticationLabel->set_label(*getResourceUstring("authenticationLabel"));
|
||||
authenticationServerLabel->set_label(*getResourceUstring("serverLabel"));
|
||||
authenticationPortLabel->set_label(*getResourceUstring("portLabel"));
|
||||
authenticationPathLabel->set_label(*getResourceUstring("pathLabel"));
|
||||
|
||||
EntryBin * authenticationServerEntry = createEntry(
|
||||
createEntry("authenticationServerServerEntry1",
|
||||
OptionsContainer::authenticationServer);
|
||||
EntryBin * authenticationPortEntry = createEntry(
|
||||
createEntry("authenticationServerPortEntry1",
|
||||
OptionsContainer::authenticationPort);
|
||||
EntryBin * authenticationPathEntry = createEntry(
|
||||
createEntry("authenticationServerPathEntry1",
|
||||
OptionsContainer::authenticationPath);
|
||||
|
||||
authenticationTable->attach(*authenticationServerEntry, 2, 3, 0, 1);
|
||||
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);
|
||||
|
||||
|
||||
// storage server
|
||||
Gtk::Label * storageLabel;
|
||||
Gtk::Label * storageServerLabel;
|
||||
Gtk::Label * storagePortLabel;
|
||||
Gtk::Label * storagePathLabel;
|
||||
try {
|
||||
storageLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("storageLabel") ));
|
||||
storageServerLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("serverLabel") ));
|
||||
storagePortLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("portLabel") ));
|
||||
storagePathLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("pathLabel") ));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
// TODO: signal error
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
glade->get_widget("storageServerLabel1", storageLabel);
|
||||
glade->get_widget("storageServerServerLabel1", storageServerLabel);
|
||||
glade->get_widget("storageServerPortLabel1", storagePortLabel);
|
||||
glade->get_widget("storageServerPathLabel1", storagePathLabel);
|
||||
storageLabel->set_label(*getResourceUstring("storageLabel"));
|
||||
storageServerLabel->set_label(*getResourceUstring("serverLabel"));
|
||||
storagePortLabel->set_label(*getResourceUstring("portLabel"));
|
||||
storagePathLabel->set_label(*getResourceUstring("pathLabel"));
|
||||
|
||||
createEntry("storageServerServerEntry1", OptionsContainer::storageServer);
|
||||
createEntry("storageServerPortEntry1", OptionsContainer::storagePort);
|
||||
createEntry("storageServerPathEntry1", OptionsContainer::storagePath);
|
||||
|
||||
storageTable->attach(*storageLabel,
|
||||
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);
|
||||
|
||||
// scheduler server
|
||||
Gtk::Label * schedulerLabel;
|
||||
Gtk::Label * schedulerServerLabel;
|
||||
Gtk::Label * schedulerPortLabel;
|
||||
Gtk::Label * schedulerPathLabel;
|
||||
try {
|
||||
schedulerLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("schedulerLabel") ));
|
||||
schedulerServerLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("serverLabel") ));
|
||||
schedulerPortLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("portLabel") ));
|
||||
schedulerPathLabel = Gtk::manage(new Gtk::Label(
|
||||
*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);
|
||||
glade->get_widget("schedulerServerLabel1", schedulerLabel);
|
||||
glade->get_widget("schedulerServerServerLabel1", schedulerServerLabel);
|
||||
glade->get_widget("schedulerServerPortLabel1", schedulerPortLabel);
|
||||
glade->get_widget("schedulerServerPathLabel1", schedulerPathLabel);
|
||||
schedulerLabel->set_label(*getResourceUstring("schedulerLabel"));
|
||||
schedulerServerLabel->set_label(*getResourceUstring("serverLabel"));
|
||||
schedulerPortLabel->set_label(*getResourceUstring("portLabel"));
|
||||
schedulerPathLabel->set_label(*getResourceUstring("pathLabel"));
|
||||
|
||||
EntryBin * schedulerServerEntry = createEntry(
|
||||
OptionsContainer::schedulerServer);
|
||||
EntryBin * schedulerPortEntry = createEntry(
|
||||
OptionsContainer::schedulerPort);
|
||||
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;
|
||||
createEntry("schedulerServerServerEntry1",
|
||||
OptionsContainer::schedulerServer);
|
||||
createEntry("schedulerServerPortEntry1", OptionsContainer::schedulerPort);
|
||||
createEntry("schedulerServerPathEntry1", OptionsContainer::schedulerPath);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the "Scheduler" section.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
OptionsWindow :: constructSchedulerSection(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Label * statusTextLabel;
|
||||
Button * startButton;
|
||||
Button * stopButton;
|
||||
try {
|
||||
statusTextLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
|
||||
"schedulerStatusText")));
|
||||
startButton = Gtk::manage(wf->createButton(*getResourceUstring(
|
||||
"schedulerStartButtonLabel")));
|
||||
stopButton = Gtk::manage(wf->createButton(*getResourceUstring(
|
||||
"schedulerStopButtonLabel")));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
Gtk::Label * schedulerTextLabel;
|
||||
Gtk::Button * startButton;
|
||||
Gtk::Button * stopButton;
|
||||
glade->get_widget("schedulerTextLabel1", schedulerTextLabel);
|
||||
glade->get_widget("schedulerStatusLabel1", schedulerStatusLabel);
|
||||
glade->get_widget("schedulerStartButton1", startButton);
|
||||
glade->get_widget("schedulerStopButton1", stopButton);
|
||||
schedulerTextLabel->set_label(*getResourceUstring("schedulerStatusText"));
|
||||
updateSchedulerStatus(); // sets the schedulerStatusLabel
|
||||
startButton->set_label(*getResourceUstring("schedulerStartButtonLabel"));
|
||||
stopButton->set_label(*getResourceUstring("schedulerStopButtonLabel"));
|
||||
|
||||
startButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&OptionsWindow::onSchedulerStartButtonClicked));
|
||||
stopButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
OptionsWindow :: constructBackupSection(void) throw ()
|
||||
{
|
||||
Ptr<ResourceBundle>::Ref backupBundle;
|
||||
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;
|
||||
backupView.reset(new BackupView(gLiveSupport, glade));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the "RDS" section.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
OptionsWindow :: constructRdsSection(void) throw ()
|
||||
{
|
||||
Ptr<ResourceBundle>::Ref rdsBundle;
|
||||
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;
|
||||
rdsView.reset(new RdsView(gLiveSupport, glade));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the "About" section.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
OptionsWindow :: constructAboutSection(void) throw ()
|
||||
{
|
||||
Glib::ustring aboutLabelContents;
|
||||
|
@ -847,26 +584,15 @@ OptionsWindow :: constructAboutSection(void) throw ()
|
|||
aboutLabelContents.append(PACKAGE_NAME);
|
||||
aboutLabelContents.append(" ");
|
||||
aboutLabelContents.append(PACKAGE_VERSION);
|
||||
try {
|
||||
aboutLabelContents.append("\n\n");
|
||||
aboutLabelContents.append(*formatMessage("reportBugsToText",
|
||||
PACKAGE_BUGREPORT ));
|
||||
aboutLabelContents.append("\n\n");
|
||||
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) );
|
||||
aboutLabelContents.append("\n\n");
|
||||
aboutLabelContents.append(*formatMessage("reportBugsToText",
|
||||
PACKAGE_BUGREPORT ));
|
||||
aboutLabelContents.append("\n\n");
|
||||
aboutLabelContents.append(*getBinaryResourceAsUstring("creditsText"));
|
||||
|
||||
// make a new box and pack the components into it
|
||||
Gtk::VBox * section = Gtk::manage(new Gtk::VBox);
|
||||
section->pack_start(*aboutLabel, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
return section;
|
||||
Gtk::Label * aboutLabel;
|
||||
glade->get_widget("aboutLabel1", aboutLabel);
|
||||
aboutLabel->set_label(aboutLabelContents);
|
||||
}
|
||||
|
||||
|
||||
|
@ -882,8 +608,8 @@ OptionsWindow :: resetEntries() throw ()
|
|||
StringEntryListType::iterator it;
|
||||
for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) {
|
||||
OptionsContainer::OptionItemString optionItem = it->first;
|
||||
EntryBin * entry = it->second;
|
||||
|
||||
Gtk::Entry * entry = it->second;
|
||||
|
||||
try {
|
||||
entry->set_text(*optionsContainer->getOptionItem(optionItem));
|
||||
|
||||
|
@ -903,7 +629,7 @@ OptionsWindow :: resetKeyBindings(void) throw ()
|
|||
{
|
||||
keyBindingsModel->clear();
|
||||
fillKeyBindingsModel();
|
||||
keyBindingsView->expand_all();
|
||||
keyBindingsTreeView->expand_all();
|
||||
}
|
||||
|
||||
|
||||
|
@ -933,14 +659,8 @@ OptionsWindow :: onKeyBindingsRowActivated(const Gtk::TreePath & path,
|
|||
editedKeyName.reset(new const Glib::ustring(
|
||||
row[keyBindingsColumns.keyNameColumn]));
|
||||
editedKeyRow = row;
|
||||
try {
|
||||
row[keyBindingsColumns.keyDisplayColumn]
|
||||
row[keyBindingsColumns.keyDisplayColumn]
|
||||
= *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
|
||||
OptionsWindow :: run(void) throw ()
|
||||
{
|
||||
mainNotebook->setActivePage(2); // "Servers"
|
||||
property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS);
|
||||
show_all();
|
||||
Gtk::Main::run(*this);
|
||||
mainNotebook->set_current_page(2); // "Servers"
|
||||
mainWindow->property_window_position().set_value(
|
||||
Gtk::WIN_POS_CENTER_ALWAYS);
|
||||
mainWindow->show_all();
|
||||
Gtk::Main::run(*mainWindow);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1058,17 +779,12 @@ void
|
|||
OptionsWindow :: updateSchedulerStatus(void) throw ()
|
||||
{
|
||||
gLiveSupport->checkSchedulerClient();
|
||||
try {
|
||||
if (gLiveSupport->isSchedulerAvailable()) {
|
||||
schedulerStatusLabel->set_text(
|
||||
*getResourceUstring("schedulerRunningStatus"));
|
||||
} else {
|
||||
schedulerStatusLabel->set_text(
|
||||
*getResourceUstring("schedulerStoppedStatus"));
|
||||
}
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
if (gLiveSupport->isSchedulerAvailable()) {
|
||||
schedulerStatusLabel->set_text(
|
||||
*getResourceUstring("schedulerRunningStatus"));
|
||||
} else {
|
||||
schedulerStatusLabel->set_text(
|
||||
*getResourceUstring("schedulerStoppedStatus"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,26 +40,17 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/entry.h>
|
||||
#include <gtkmm/alignment.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/window.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/OptionsContainer.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/EntryBin.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
#include "LiveSupport/Widgets/Notebook.h"
|
||||
#include "LiveSupport/Widgets/ScrolledWindow.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "BasicWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
#include "MasterPanelUserInfoWidget.h"
|
||||
#include "BackupView.h"
|
||||
#include "RdsView.h"
|
||||
|
||||
|
@ -89,50 +80,31 @@ using namespace LiveSupport::Widgets;
|
|||
* | +-- currently ------------------+ |
|
||||
* | +-- selected tab ---------------+ |
|
||||
* | +-------------------------------+ |
|
||||
* +------------(Cancel)-(Apply)-(OK)--+
|
||||
* +------------(Apply)-(Cancel)-(OK)--+
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class OptionsWindow : public GuiWindow
|
||||
class OptionsWindow : public BasicWindow
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The notepad holding the different sections.
|
||||
*/
|
||||
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;
|
||||
Gtk::Notebook * mainNotebook;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
typedef std::vector<std::pair<OptionsContainer::OptionItemString,
|
||||
EntryBin*> > StringEntryListType;
|
||||
Gtk::Entry*> > StringEntryListType;
|
||||
|
||||
/**
|
||||
* The list of user entry fields of string type.
|
||||
|
@ -142,15 +114,17 @@ class OptionsWindow : public GuiWindow
|
|||
/**
|
||||
* 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.
|
||||
* 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
|
||||
* @return the newly created EntryBin
|
||||
* @param entryName the name of the Entry in the Glade file.
|
||||
* @param optionItem the name of the option item for this entry.
|
||||
* @return the text entry field just processed.
|
||||
*/
|
||||
EntryBin *
|
||||
createEntry(OptionsContainer::OptionItemString optionItem)
|
||||
Gtk::Entry *
|
||||
createEntry(const Glib::ustring & entryName,
|
||||
OptionsContainer::OptionItemString optionItem)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -216,59 +190,45 @@ class OptionsWindow : public GuiWindow
|
|||
|
||||
/**
|
||||
* Construct the "Sound" section.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructSoundSection(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the "Key bindings" section.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructKeyBindingsSection(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the "Servers" section.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructServersSection(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the "Scheduler" section.
|
||||
* 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 ();
|
||||
|
||||
/**
|
||||
* Construct the "Backup" section.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructBackupSection(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the "RDS" section.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructRdsSection(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the "About" section.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructAboutSection(void) throw ();
|
||||
|
||||
/**
|
||||
|
@ -279,6 +239,7 @@ class OptionsWindow : public GuiWindow
|
|||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Event handler for the Cancel button.
|
||||
*/
|
||||
|
@ -303,7 +264,6 @@ class OptionsWindow : public GuiWindow
|
|||
* @param needConfirm if true, we check if changes has been
|
||||
* made to the input fields, and if yes, then
|
||||
* a "save changes?" dialog is displayed
|
||||
* @see WhiteWindow::onCloseButtonClicked()
|
||||
*/
|
||||
virtual void
|
||||
onCloseButtonClicked(bool needConfirm = true) throw ();
|
||||
|
@ -316,7 +276,7 @@ class OptionsWindow : public GuiWindow
|
|||
* @see GLiveSupport::playTestSoundOnCue()
|
||||
*/
|
||||
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.
|
||||
|
@ -366,6 +326,7 @@ class OptionsWindow : public GuiWindow
|
|||
class ModelColumns : public ZebraTreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* The column for the name of the action.
|
||||
* 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.
|
||||
*/
|
||||
ZebraTreeView * keyBindingsView;
|
||||
ZebraTreeView * keyBindingsTreeView;
|
||||
|
||||
/**
|
||||
* The backup view shown in the backup section.
|
||||
*/
|
||||
BackupView * backupView;
|
||||
Ptr<BackupView>::Ref backupView;
|
||||
|
||||
/**
|
||||
* The RdsView shown in the RDS section.
|
||||
*/
|
||||
RdsView * rdsView;
|
||||
Ptr<RdsView>::Ref rdsView;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -445,10 +407,12 @@ class OptionsWindow : public GuiWindow
|
|||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param gladeDir the directory where the glade file is.
|
||||
*/
|
||||
OptionsWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -462,10 +426,11 @@ class OptionsWindow : public GuiWindow
|
|||
/**
|
||||
* Return the BackupList object shown by the widget.
|
||||
*/
|
||||
BackupList *
|
||||
Ptr<BackupList>::Ref
|
||||
getBackupList(void) throw ()
|
||||
{
|
||||
return backupView ? backupView->getBackupList() : 0;
|
||||
return backupView ? backupView->getBackupList()
|
||||
: Ptr<BackupList>::Ref();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,13 +38,12 @@
|
|||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
|
||||
#include "SimplePlaylistManagementWindow.h"
|
||||
#include "PlaylistWindow.h"
|
||||
|
||||
|
||||
using namespace Glib;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -54,10 +53,10 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc).
|
||||
*/
|
||||
const Glib::ustring windowName = "simplePlaylistManagementWindow";
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const Glib::ustring gladeFileName = "PlaylistWindow.glade";
|
||||
|
||||
}
|
||||
|
||||
|
@ -69,196 +68,116 @@ const Glib::ustring windowName = "simplePlaylistManagementWindow";
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
PlaylistWindow :: PlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton),
|
||||
: BasicWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton,
|
||||
gladeDir + gladeFileName),
|
||||
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 {
|
||||
set_title(*getResourceUstring("windowTitle"));
|
||||
nameLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("nameLabel")));
|
||||
saveButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("saveButtonLabel")));
|
||||
closeButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("closeButtonLabel")));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
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);
|
||||
|
||||
nameEntry = Gtk::manage(wf->createEntryBin());
|
||||
nameEntry->signal_changed().connect(sigc::mem_fun(
|
||||
*this, &SimplePlaylistManagementWindow::onTitleEdited ));
|
||||
entriesView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
||||
&PlaylistWindow::onEntryClicked));
|
||||
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());
|
||||
entriesModel = Gtk::ListStore::create(modelColumns);
|
||||
entriesView = Gtk::manage(wf->createTreeView(entriesModel));
|
||||
|
||||
// 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));
|
||||
// set up the status bar
|
||||
glade->get_widget("statusBar1", statusBar);
|
||||
statusBar->set_label("");
|
||||
|
||||
// create the right-click entry context menu
|
||||
rightClickMenu = Gtk::manage(new Gtk::Menu());
|
||||
Gtk::Menu::MenuList& rightClickMenuList = rightClickMenu->items();
|
||||
rightClickMenu.reset(new Gtk::Menu());
|
||||
Gtk::Menu::MenuList & rightClickMenuList = rightClickMenu->items();
|
||||
|
||||
try {
|
||||
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("upMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SimplePlaylistManagementWindow::onUpItem)));
|
||||
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("downMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SimplePlaylistManagementWindow::onDownItem)));
|
||||
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SimplePlaylistManagementWindow::onRemoveItem)));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
// 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 ));
|
||||
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("upMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&PlaylistWindow::onUpItem)));
|
||||
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("downMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&PlaylistWindow::onDownItem)));
|
||||
rightClickMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&PlaylistWindow::onRemoveItem)));
|
||||
|
||||
// set up the "lock fades" check button
|
||||
Gtk::CheckButton * lockFadesCheckButton;
|
||||
glade->get_widget("lockFadesCheckButton1", lockFadesCheckButton);
|
||||
lockFadesCheckButton->set_label(*getResourceUstring(
|
||||
"lockFadesCheckButtonLabel"));
|
||||
lockFadesCheckButton->set_active(true);
|
||||
areFadesLocked = true;
|
||||
lockFadesCheckButton->signal_toggled().connect(sigc::mem_fun(
|
||||
*this,
|
||||
&SimplePlaylistManagementWindow::onLockFadesCheckButtonClicked ));
|
||||
lockFadesCheckButton->signal_toggled().connect(sigc::mem_fun(*this,
|
||||
&PlaylistWindow::onLockFadesCheckButtonClicked));
|
||||
|
||||
// construct the "total time" display
|
||||
Gtk::Label * lengthTextLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("lengthLabel") ));
|
||||
lengthValueLabel = Gtk::manage(new Gtk::Label("00:00:00"));
|
||||
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 "total time" display
|
||||
Gtk::Label * lengthTextLabel;
|
||||
glade->get_widget("lengthTextLabel1", lengthTextLabel);
|
||||
lengthTextLabel->set_label(*getResourceUstring("lengthLabel"));
|
||||
|
||||
// set up the layout
|
||||
Gtk::VBox * mainBox = Gtk::manage(new Gtk::VBox);
|
||||
glade->get_widget("lengthValueLabel1", lengthValueLabel);
|
||||
lengthValueLabel->set_label("00:00:00");
|
||||
|
||||
Gtk::HBox * nameBox = Gtk::manage(new Gtk::HBox);
|
||||
nameBox->pack_start(*nameLabel, Gtk::PACK_SHRINK, 10);
|
||||
Gtk::Alignment * nameEntryAlignment = Gtk::manage(new Gtk::Alignment(
|
||||
Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
|
||||
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
|
||||
// register the signal handlers for the buttons
|
||||
Gtk::Button * closeButton;
|
||||
glade->get_widget("saveButton1", saveButton);
|
||||
glade->get_widget("closeButton1", closeButton);
|
||||
saveButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SimplePlaylistManagementWindow::onSaveButtonClicked));
|
||||
&PlaylistWindow::onSaveButtonClicked));
|
||||
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SimplePlaylistManagementWindow::onBottomCloseButtonClicked));
|
||||
&PlaylistWindow::onBottomCloseButtonClicked));
|
||||
|
||||
// show
|
||||
set_name(windowName);
|
||||
set_default_size(480, 350);
|
||||
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 ));
|
||||
// get notified when the playlist is modified outside of the window
|
||||
gLiveSupport->signalEditedPlaylistModified().connect(sigc::mem_fun(*this,
|
||||
&PlaylistWindow::onPlaylistModified ));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
SimplePlaylistManagementWindow :: ~SimplePlaylistManagementWindow (void)
|
||||
PlaylistWindow :: ~PlaylistWindow (void)
|
||||
throw ()
|
||||
{
|
||||
}
|
||||
|
@ -268,7 +187,7 @@ SimplePlaylistManagementWindow :: ~SimplePlaylistManagementWindow (void)
|
|||
* Save the edited playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
SimplePlaylistManagementWindow :: savePlaylist(bool reopen) throw ()
|
||||
PlaylistWindow :: savePlaylist(bool reopen) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<Playlist>::Ref playlist
|
||||
|
@ -308,7 +227,7 @@ SimplePlaylistManagementWindow :: savePlaylist(bool reopen) throw ()
|
|||
* Signal handler for the save button getting clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onSaveButtonClicked(void) throw ()
|
||||
PlaylistWindow :: onSaveButtonClicked(void) throw ()
|
||||
{
|
||||
savePlaylist(true);
|
||||
}
|
||||
|
@ -318,15 +237,15 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked(void) throw ()
|
|||
* Cancel the edited playlist, after asking for confirmation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
|
||||
PlaylistWindow :: cancelPlaylist(void) throw ()
|
||||
{
|
||||
if (gLiveSupport->getEditedPlaylist()) {
|
||||
if (!isPlaylistModified) {
|
||||
gLiveSupport->cancelEditedPlaylist();
|
||||
} else {
|
||||
DialogWindow::ButtonType result = dialogWindow->run();
|
||||
Gtk::ResponseType result = runConfirmationDialog();
|
||||
switch (result) {
|
||||
case DialogWindow::noButton:
|
||||
case Gtk::RESPONSE_NO:
|
||||
try {
|
||||
gLiveSupport->cancelEditedPlaylist();
|
||||
} catch (XmlRpcException &e) {
|
||||
|
@ -336,18 +255,18 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
|
|||
setPlaylistModified(false);
|
||||
break;
|
||||
|
||||
case DialogWindow::yesButton:
|
||||
case Gtk::RESPONSE_YES:
|
||||
if (!savePlaylist(false)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case DialogWindow::cancelButton:
|
||||
case Gtk::RESPONSE_CANCEL:
|
||||
return false;
|
||||
|
||||
default : return false;
|
||||
// can happen if window is closed
|
||||
} // with Alt-F4 -- treated as cancel
|
||||
default : // can happen if the window
|
||||
return false; // is closed with Alt-F4
|
||||
} // -- 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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: closeWindow(void) throw ()
|
||||
PlaylistWindow :: closeWindow(void) throw ()
|
||||
{
|
||||
statusBar->set_text("");
|
||||
nameEntry->set_text("");
|
||||
entriesModel->clear();
|
||||
setPlaylistModified(false);
|
||||
gLiveSupport->putWindowPosition(shared_from_this());
|
||||
hide();
|
||||
}
|
||||
|
||||
|
@ -374,7 +319,7 @@ SimplePlaylistManagementWindow :: closeWindow(void) throw ()
|
|||
* Signal handler for the save button getting clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onBottomCloseButtonClicked(void) throw ()
|
||||
PlaylistWindow :: onBottomCloseButtonClicked(void) throw ()
|
||||
{
|
||||
if (cancelPlaylist()) {
|
||||
closeWindow();
|
||||
|
@ -386,7 +331,7 @@ SimplePlaylistManagementWindow :: onBottomCloseButtonClicked(void) throw ()
|
|||
* Signal handler for the "lock fades" check button toggled.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onLockFadesCheckButtonClicked(void)
|
||||
PlaylistWindow :: onLockFadesCheckButtonClicked(void)
|
||||
throw ()
|
||||
{
|
||||
areFadesLocked = !areFadesLocked;
|
||||
|
@ -397,7 +342,7 @@ SimplePlaylistManagementWindow :: onLockFadesCheckButtonClicked(void)
|
|||
* Show the contents of the currently edited playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: showContents(void) throw ()
|
||||
PlaylistWindow :: showContents(void) throw ()
|
||||
{
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
Playlist::const_iterator it;
|
||||
|
@ -454,7 +399,7 @@ SimplePlaylistManagementWindow :: showContents(void) throw ()
|
|||
* Signal handler for the fade info being edited.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
|
||||
PlaylistWindow :: onTitleEdited(void) throw()
|
||||
{
|
||||
Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist();
|
||||
if (!playlist) {
|
||||
|
@ -463,7 +408,7 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
|
|||
playlist = gLiveSupport->getEditedPlaylist();
|
||||
|
||||
} catch (XmlRpcException &e) {
|
||||
std::cerr << "error in SimplePlaylistManagementWindow::"
|
||||
std::cerr << "error in PlaylistWindow::"
|
||||
"onTitleEdited(): "
|
||||
<< e.what() << std::endl;
|
||||
return;
|
||||
|
@ -484,7 +429,7 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
|
|||
* Signal handler for the fade info being edited.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onFadeInfoEdited(
|
||||
PlaylistWindow :: onFadeInfoEdited(
|
||||
const Glib::ustring & pathString,
|
||||
int columnId,
|
||||
const Glib::ustring & newText)
|
||||
|
@ -543,7 +488,7 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited(
|
|||
* Auxilliary function: set the fade in of a playlist element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: setFadeIn(
|
||||
PlaylistWindow :: setFadeIn(
|
||||
Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeIn)
|
||||
throw()
|
||||
|
@ -571,7 +516,7 @@ SimplePlaylistManagementWindow :: setFadeIn(
|
|||
* Auxilliary function: set the fade out of a playlist element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: setFadeOut(
|
||||
PlaylistWindow :: setFadeOut(
|
||||
Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeOut)
|
||||
throw()
|
||||
|
@ -599,7 +544,7 @@ SimplePlaylistManagementWindow :: setFadeOut(
|
|||
* Auxilliary function: check that fades are not longer than the whole clip.
|
||||
*----------------------------------------------------------------------------*/
|
||||
inline bool
|
||||
SimplePlaylistManagementWindow :: isLengthOkay(
|
||||
PlaylistWindow :: isLengthOkay(
|
||||
Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<FadeInfo>::Ref newFadeInfo)
|
||||
throw()
|
||||
|
@ -614,7 +559,7 @@ SimplePlaylistManagementWindow :: isLengthOkay(
|
|||
* Signal handler for the playlist being modified outside the window.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onPlaylistModified(void) throw()
|
||||
PlaylistWindow :: onPlaylistModified(void) throw()
|
||||
{
|
||||
setPlaylistModified(true);
|
||||
}
|
||||
|
@ -624,7 +569,7 @@ SimplePlaylistManagementWindow :: onPlaylistModified(void) throw()
|
|||
* Event handler for an entry being clicked in the list
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onEntryClicked(GdkEventButton * event)
|
||||
PlaylistWindow :: onEntryClicked(GdkEventButton * event)
|
||||
throw()
|
||||
{
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onUpItem(void) throw()
|
||||
PlaylistWindow :: onUpItem(void) throw()
|
||||
{
|
||||
if (currentItem && currentItem != entriesModel->children().begin()) {
|
||||
int rowNumber = (*currentItem)
|
||||
|
@ -670,7 +615,7 @@ SimplePlaylistManagementWindow :: onUpItem(void) throw()
|
|||
* Event handler for the Down menu item selected from the context menu.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onDownItem(void) throw()
|
||||
PlaylistWindow :: onDownItem(void) throw()
|
||||
{
|
||||
if (currentItem) {
|
||||
Gtk::TreeIter nextItem = currentItem;
|
||||
|
@ -691,7 +636,7 @@ SimplePlaylistManagementWindow :: onDownItem(void) throw()
|
|||
* Swap two playlist elements in the edited playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: swapPlaylistElements(
|
||||
PlaylistWindow :: swapPlaylistElements(
|
||||
Gtk::TreeIter firstIter,
|
||||
Gtk::TreeIter secondIter)
|
||||
throw()
|
||||
|
@ -769,7 +714,7 @@ SimplePlaylistManagementWindow :: swapPlaylistElements(
|
|||
* Event handler for the Remove menu item selected from the context menu.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onRemoveItem(void) throw()
|
||||
PlaylistWindow :: onRemoveItem(void) throw()
|
||||
{
|
||||
if (currentItem) {
|
||||
Ptr<Playlist>::Ref
|
||||
|
@ -791,12 +736,12 @@ SimplePlaylistManagementWindow :: onRemoveItem(void) throw()
|
|||
* Event handler for a key pressed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
SimplePlaylistManagementWindow :: onKeyPressed(GdkEventKey * event)
|
||||
PlaylistWindow :: onKeyPressed(GdkEventKey * event)
|
||||
throw ()
|
||||
{
|
||||
if (event->type == GDK_KEY_PRESS) {
|
||||
KeyboardShortcut::Action action = gLiveSupport->findAction(
|
||||
windowName,
|
||||
"playlistWindow",
|
||||
Gdk::ModifierType(event->state),
|
||||
event->keyval);
|
||||
switch (action) {
|
||||
|
@ -827,7 +772,7 @@ SimplePlaylistManagementWindow :: onKeyPressed(GdkEventKey * event)
|
|||
* Find (an iterator pointing to) the currently selected row.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: findCurrentItem(void) throw ()
|
||||
PlaylistWindow :: findCurrentItem(void) throw ()
|
||||
{
|
||||
Glib::RefPtr<Gtk::TreeView::Selection> selection
|
||||
= entriesView->get_selection();
|
||||
|
@ -839,7 +784,7 @@ SimplePlaylistManagementWindow :: findCurrentItem(void) throw ()
|
|||
* Select (highlight) the nth row.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: selectRow(int rowNumber) throw ()
|
||||
PlaylistWindow :: selectRow(int rowNumber) throw ()
|
||||
{
|
||||
Gtk::TreeModel::iterator iter = entriesModel->children().begin();
|
||||
for (; rowNumber > 0; --rowNumber) {
|
||||
|
@ -857,7 +802,7 @@ SimplePlaylistManagementWindow :: selectRow(int rowNumber) throw ()
|
|||
* Set the value of the isPlaylistModified variable.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: setPlaylistModified(bool newValue)
|
||||
PlaylistWindow :: setPlaylistModified(bool newValue)
|
||||
throw ()
|
||||
{
|
||||
isPlaylistModified = newValue;
|
|
@ -26,8 +26,8 @@
|
|||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef SimplePlaylistManagementWindow_h
|
||||
#define SimplePlaylistManagementWindow_h
|
||||
#ifndef PlaylistWindow_h
|
||||
#define PlaylistWindow_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
|
@ -41,17 +41,15 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
#include "LiveSupport/Widgets/DialogWindow.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "BasicWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -90,7 +88,7 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class SimplePlaylistManagementWindow : public GuiWindow
|
||||
class PlaylistWindow : public BasicWindow
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -119,24 +117,14 @@ class SimplePlaylistManagementWindow : public GuiWindow
|
|||
Gtk::TreeIter currentItem;
|
||||
|
||||
/**
|
||||
* The label for the name entry.
|
||||
* The input text field for the name of the playlist.
|
||||
*/
|
||||
Gtk::Label * nameLabel;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
Gtk::Entry * nameEntry;
|
||||
|
||||
/**
|
||||
* The entry tree view, now only showing rows.
|
||||
*/
|
||||
ZebraTreeView * entriesView;
|
||||
ZebraTreeView * entriesView;
|
||||
|
||||
/**
|
||||
* The entry tree model, as a GTK reference.
|
||||
|
@ -146,32 +134,23 @@ class SimplePlaylistManagementWindow : public GuiWindow
|
|||
/**
|
||||
* The label containing the length of the playlist.
|
||||
*/
|
||||
Gtk::Label * lengthValueLabel;
|
||||
/**
|
||||
* The save button.
|
||||
*/
|
||||
Button * saveButton;
|
||||
|
||||
/**
|
||||
* The close button.
|
||||
*/
|
||||
Button * closeButton;
|
||||
Gtk::Label * lengthValueLabel;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* a playlist element.
|
||||
*/
|
||||
Gtk::Menu * rightClickMenu;
|
||||
Ptr<Gtk::Menu>::Ref rightClickMenu;
|
||||
|
||||
/**
|
||||
* Find (an iterator pointing to) the currently selected row.
|
||||
|
@ -255,6 +234,14 @@ class SimplePlaylistManagementWindow : public GuiWindow
|
|||
void
|
||||
setPlaylistModified(bool newValue) throw ();
|
||||
|
||||
/**
|
||||
* Run the confirmation dialog.
|
||||
*
|
||||
* @return the response ID returned by the dialog.
|
||||
*/
|
||||
Gtk::ResponseType
|
||||
runConfirmationDialog(void) throw ();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -349,7 +336,7 @@ class SimplePlaylistManagementWindow : public GuiWindow
|
|||
* @param event the button event recieved
|
||||
*/
|
||||
void
|
||||
onEntryClicked(GdkEventButton * event) throw ();
|
||||
onEntryClicked(GdkEventButton * event) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for a key pressed at one of the entries.
|
||||
|
@ -403,6 +390,7 @@ class SimplePlaylistManagementWindow : public GuiWindow
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -410,20 +398,21 @@ class SimplePlaylistManagementWindow : public GuiWindow
|
|||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param gladeDir the directory where the glade file is.
|
||||
*/
|
||||
SimplePlaylistManagementWindow(
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
PlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~SimplePlaylistManagementWindow(void) throw ();
|
||||
~PlaylistWindow(void) throw ();
|
||||
|
||||
/**
|
||||
* Show / update the contents of the playlist management window.
|
||||
|
@ -455,5 +444,5 @@ class SimplePlaylistManagementWindow : public GuiWindow
|
|||
} // namespace GLiveSupport
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // SimplePlaylistManagementWindow_h
|
||||
#endif // PlaylistWindow_h
|
||||
|
|
@ -33,13 +33,11 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "RdsEntry.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -56,34 +54,21 @@ using namespace LiveSupport::GLiveSupport;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
RdsEntry :: RdsEntry(Ptr<ResourceBundle>::Ref bundle,
|
||||
const Glib::ustring & type,
|
||||
int width)
|
||||
RdsEntry :: RdsEntry(Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade,
|
||||
int index,
|
||||
const Glib::ustring & type,
|
||||
int width)
|
||||
throw ()
|
||||
: LocalizedObject(bundle)
|
||||
{
|
||||
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());
|
||||
|
||||
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);
|
||||
glade->get_widget(addIndex("rdsEntry", index), entry);
|
||||
entry->set_width_chars(width);
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,11 +79,11 @@ void
|
|||
RdsEntry :: setOptions(bool enabled,
|
||||
Ptr<const Glib::ustring>::Ref value) throw ()
|
||||
{
|
||||
checkBox->set_active(enabled);
|
||||
entryBin->set_text(*value);
|
||||
checkButton->set_active(enabled);
|
||||
entry->set_text(*value);
|
||||
|
||||
checkBoxSaved = enabled;
|
||||
entryBinSaved = value;
|
||||
checkButtonSaved = enabled;
|
||||
entrySaved = value;
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,17 +93,17 @@ RdsEntry :: setOptions(bool enabled,
|
|||
bool
|
||||
RdsEntry :: saveChanges(Ptr<GLiveSupport>::Ref gLiveSupport) throw ()
|
||||
{
|
||||
bool checkBoxNow = checkBox->get_active();
|
||||
bool checkButtonNow = checkButton->get_active();
|
||||
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
|
||||
|| *entryBinNow != *entryBinSaved) {
|
||||
if (!entrySaved || checkButtonNow != checkButtonSaved
|
||||
|| *entryNow != *entrySaved) {
|
||||
Ptr<OptionsContainer>::Ref optionsContainer =
|
||||
gLiveSupport->getOptionsContainer();
|
||||
optionsContainer->setRdsOptions(type, entryBinNow, checkBoxNow);
|
||||
checkBoxSaved = checkBoxNow;
|
||||
entryBinSaved = entryBinNow;
|
||||
optionsContainer->setRdsOptions(type, entryNow, checkButtonNow);
|
||||
checkButtonSaved = checkButtonNow;
|
||||
entrySaved = entryNow;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/checkbutton.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/EntryBin.h"
|
||||
#include "LiveSupport/Core/NumericTools.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
|
||||
|
@ -53,7 +53,6 @@ namespace LiveSupport {
|
|||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
@ -70,39 +69,42 @@ using namespace LiveSupport::GLiveSupport;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class RdsEntry : public Gtk::HBox,
|
||||
public LocalizedObject
|
||||
class RdsEntry : public LocalizedObject,
|
||||
private NumericTools
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The RDS type of the object (PS, PI, RT, etc).
|
||||
*/
|
||||
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:
|
||||
|
||||
/**
|
||||
* The enable/disable checkbox.
|
||||
*/
|
||||
Gtk::CheckButton * checkBox;
|
||||
Gtk::CheckButton * checkButton;
|
||||
|
||||
/**
|
||||
* The entry field.
|
||||
*/
|
||||
EntryBin * entryBin;
|
||||
Gtk::Entry * entry;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* 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
|
||||
* 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 width the width of the entry, in characters.
|
||||
*/
|
||||
RdsEntry(Ptr<ResourceBundle>::Ref bundle,
|
||||
const Glib::ustring & type,
|
||||
int width) throw ();
|
||||
RdsEntry(Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade,
|
||||
int index,
|
||||
const Glib::ustring & type,
|
||||
int width) throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -54,38 +53,27 @@ using namespace LiveSupport::GLiveSupport;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
RdsView :: RdsView (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
RdsView :: RdsView (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport)
|
||||
: gLiveSupport(gLiveSupport)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
Gtk::Label * deviceLabel;
|
||||
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<ResourceBundle>::Ref bundle = gLiveSupport->getBundle("rdsView");
|
||||
setBundle(bundle);
|
||||
|
||||
Ptr<RdsEntry>::Ref psEntry(new RdsEntry(getBundle(), "PS", 8));
|
||||
Ptr<RdsEntry>::Ref piEntry(new RdsEntry(getBundle(), "PI", 4));
|
||||
Ptr<RdsEntry>::Ref rtEntry(new RdsEntry(getBundle(), "RT", 32));
|
||||
Gtk::Label * deviceLabel;
|
||||
glade->get_widget("rdsDeviceLabel1", deviceLabel);
|
||||
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(piEntry);
|
||||
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();
|
||||
}
|
||||
|
@ -103,7 +91,7 @@ RdsView :: saveChanges(void) throw ()
|
|||
Ptr<const Glib::ustring>::Ref oldDevice = options->getOptionItem(
|
||||
OptionsContainer::serialDeviceName);
|
||||
Ptr<const Glib::ustring>::Ref newDevice(new const Glib::ustring(
|
||||
deviceEntryBin->get_text() ));
|
||||
deviceEntry->get_text() ));
|
||||
if (*oldDevice != *newDevice) {
|
||||
options->setOptionItem(OptionsContainer::serialDeviceName, newDevice);
|
||||
touched = true;
|
||||
|
@ -126,7 +114,7 @@ void
|
|||
RdsView :: reset(void) throw ()
|
||||
{
|
||||
Ptr<OptionsContainer>::Ref options = gLiveSupport->getOptionsContainer();
|
||||
deviceEntryBin->set_text(*options->getOptionItem(
|
||||
deviceEntry->set_text(*options->getOptionItem(
|
||||
OptionsContainer::serialDeviceName));
|
||||
|
||||
RdsEntryListType::const_iterator it;
|
||||
|
|
|
@ -40,13 +40,12 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/ScrolledWindow.h"
|
||||
#include "RdsEntry.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
|
@ -54,7 +53,6 @@ namespace LiveSupport {
|
|||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -90,10 +88,10 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class RdsView : public Gtk::VBox,
|
||||
public LocalizedObject
|
||||
class RdsView : public LocalizedObject
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The type for the list of entry widgets.
|
||||
*/
|
||||
|
@ -114,6 +112,7 @@ class RdsView : public Gtk::VBox,
|
|||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
EntryBin * deviceEntryBin;
|
||||
Gtk::Entry * deviceEntry;
|
||||
|
||||
|
||||
public:
|
||||
|
@ -131,11 +130,11 @@ class RdsView : public Gtk::VBox,
|
|||
*
|
||||
* @param gLiveSupport the gLiveSupport object, containing
|
||||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param glade the Glade file which specifies the visual
|
||||
* components for this class.
|
||||
*/
|
||||
RdsView(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
RdsView(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,10 +29,13 @@
|
|||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "RestoreBackupWindow.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -58,66 +61,34 @@ const unsigned int timerInterval = 10000;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
RestoreBackupWindow :: RestoreBackupWindow (
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Ptr<const Glib::ustring>::Ref fileName)
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade,
|
||||
Ptr<const Glib::ustring>::Ref fileName)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle),
|
||||
: gLiveSupport(gLiveSupport),
|
||||
fileName(fileName),
|
||||
currentState(AsyncState::pendingState)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
|
||||
"restoreBackupWindow");
|
||||
setBundle(bundle);
|
||||
|
||||
messageLabel = Gtk::manage(new Gtk::Label());
|
||||
try {
|
||||
set_title(*getResourceUstring("windowTitle"));
|
||||
cancelButton = Gtk::manage(wf->createButton(
|
||||
*gLiveSupport->getResourceUstring(
|
||||
"cancelButtonLabel")));
|
||||
okButton = Gtk::manage(wf->createButton(
|
||||
*gLiveSupport->getResourceUstring(
|
||||
"okButtonLabel")));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
// TODO: signal error
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
glade->get_widget("restoreBackupWindow1", mainWindow);
|
||||
mainWindow->set_title(*getResourceUstring("windowTitle"));
|
||||
|
||||
Gtk::Button * cancelButton;
|
||||
glade->get_widget("restoreBackupMessageLabel1", messageLabel);
|
||||
glade->get_widget("restoreBackupCancelButton1", cancelButton);
|
||||
glade->get_widget("restoreBackupOkButton1", okButton);
|
||||
|
||||
// pack the widgets
|
||||
Gtk::Box * messageBox = Gtk::manage(new Gtk::HBox());
|
||||
messageBox->pack_start(*messageLabel, Gtk::PACK_EXPAND_WIDGET, 10);
|
||||
|
||||
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,
|
||||
mainWindow->signal_delete_event().connect(sigc::mem_fun(*this,
|
||||
&RestoreBackupWindow::onDeleteEvent));
|
||||
cancelButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&RestoreBackupWindow::onCancelButtonClicked));
|
||||
okButton->signal_clicked().connect(sigc::mem_fun(
|
||||
*this,
|
||||
okButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&RestoreBackupWindow::onOkButtonClicked));
|
||||
|
||||
// start the restore backup operation
|
||||
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)
|
||||
throw ()
|
||||
{
|
||||
try {
|
||||
setLabelText(*getResourceUstring(messageKey));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
messageLabel->set_text(e.what());
|
||||
}
|
||||
setLabelText(*getResourceUstring(messageKey));
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,12 +132,7 @@ RestoreBackupWindow :: displayMessage(const Glib::ustring & messageKey,
|
|||
const Glib::ustring & argument)
|
||||
throw ()
|
||||
{
|
||||
try {
|
||||
setLabelText(*formatMessage(messageKey, argument));
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
messageLabel->set_text(e.what());
|
||||
}
|
||||
setLabelText(*formatMessage(messageKey, argument));
|
||||
}
|
||||
|
||||
|
||||
|
@ -220,7 +181,6 @@ RestoreBackupWindow :: restoreBackupCheck(void) throw ()
|
|||
{
|
||||
Ptr<StorageClientInterface>::Ref
|
||||
storage = gLiveSupport->getStorageClient();
|
||||
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
|
||||
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
try {
|
||||
|
@ -252,7 +212,6 @@ RestoreBackupWindow :: restoreBackupClose(void) throw ()
|
|||
if (token) {
|
||||
Ptr<StorageClientInterface>::Ref
|
||||
storage = gLiveSupport->getStorageClient();
|
||||
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
|
||||
|
||||
try {
|
||||
storage->restoreBackupClose(*token);
|
||||
|
@ -307,12 +266,33 @@ RestoreBackupWindow :: resetTimer(void) throw ()
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Detach the timer when the window is hidden.
|
||||
* Show the window.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RestoreBackupWindow :: on_hide(void) throw ()
|
||||
RestoreBackupWindow :: show(void) throw ()
|
||||
{
|
||||
restoreBackupClose();
|
||||
GuiWindow::on_hide();
|
||||
mainWindow->show();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,17 +40,20 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/StorageClient/StorageClientInterface.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -66,23 +69,29 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author: fgerlits $
|
||||
* @version $Revision$
|
||||
*/
|
||||
class RestoreBackupWindow : public GuiWindow
|
||||
class RestoreBackupWindow : public LocalizedObject
|
||||
{
|
||||
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.
|
||||
*/
|
||||
Gtk::Label * messageLabel;
|
||||
|
||||
/**
|
||||
* The cancel button.
|
||||
*/
|
||||
Button * cancelButton;
|
||||
|
||||
/**
|
||||
* The OK button.
|
||||
*/
|
||||
Button * okButton;
|
||||
Gtk::Button * okButton;
|
||||
|
||||
/**
|
||||
* The file name of the backup file to be uploaded.
|
||||
|
@ -106,6 +115,7 @@ class RestoreBackupWindow : public GuiWindow
|
|||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Event handler for the cancel button being clicked.
|
||||
*/
|
||||
|
@ -118,6 +128,12 @@ class RestoreBackupWindow : public GuiWindow
|
|||
virtual void
|
||||
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.
|
||||
*
|
||||
|
@ -197,32 +213,22 @@ class RestoreBackupWindow : public GuiWindow
|
|||
*/
|
||||
virtual void
|
||||
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:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, containing
|
||||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param glade the Glade object, which contains the
|
||||
* visual design.
|
||||
* @param fileName the file name of the backup to be restored.
|
||||
*/
|
||||
RestoreBackupWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Ptr<const Glib::ustring>::Ref fileName)
|
||||
RestoreBackupWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade,
|
||||
Ptr<const Glib::ustring>::Ref fileName)
|
||||
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 */
|
||||
|
|
|
@ -33,17 +33,14 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "SchedulePlaylistWindow.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace Glib;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
|
@ -52,6 +49,14 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
namespace {
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const Glib::ustring gladeFileName = "SchedulePlaylistWindow.glade";
|
||||
|
||||
}
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -63,69 +68,51 @@ using namespace LiveSupport::GLiveSupport;
|
|||
*----------------------------------------------------------------------------*/
|
||||
SchedulePlaylistWindow :: SchedulePlaylistWindow (
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
const Glib::ustring & gladeDir,
|
||||
Ptr<Playlist>::Ref playlist)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle),
|
||||
: gLiveSupport(gLiveSupport),
|
||||
playlist(playlist)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
|
||||
"schedulePlaylistWindow");
|
||||
setBundle(bundle);
|
||||
|
||||
try {
|
||||
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);
|
||||
}
|
||||
glade = Gnome::Glade::Xml::create(gladeDir + gladeFileName);
|
||||
|
||||
playlistLabel = Gtk::manage(new Gtk::Label(*playlist->getTitle()));
|
||||
calendar = Gtk::manage(new Gtk::Calendar());
|
||||
hourEntry = Gtk::manage(wf->createNumericComboBoxText(0, 23));
|
||||
minuteEntry = Gtk::manage(wf->createNumericComboBoxText(0, 59, 2));
|
||||
secondEntry = Gtk::manage(wf->createNumericComboBoxText(0, 59, 2));
|
||||
glade->get_widget("mainWindow1", mainWindow);
|
||||
mainWindow->set_title(*getResourceUstring("windowTitle"));
|
||||
|
||||
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);
|
||||
layout->attach(*calendar, 0, 6, 1, 2);
|
||||
layout->attach(*hourLabel, 0, 1, 2, 3);
|
||||
layout->attach(*hourEntry, 1, 2, 2, 3);
|
||||
layout->attach(*minuteLabel, 2, 3, 2, 3);
|
||||
layout->attach(*minuteEntry, 3, 4, 2, 3);
|
||||
layout->attach(*secondLabel, 4, 5, 2, 3);
|
||||
layout->attach(*secondEntry, 5, 6, 2, 3);
|
||||
layout->attach(*scheduleButton, 4, 6, 3, 4);
|
||||
layout->attach(*closeButton , 4, 6, 4, 5);
|
||||
Gtk::Label * hourLabel;
|
||||
Gtk::Label * minuteLabel;
|
||||
Gtk::Label * secondLabel;
|
||||
glade->get_widget("hourLabel1", hourLabel);
|
||||
glade->get_widget("minuteLabel1", minuteLabel);
|
||||
glade->get_widget("secondLabel1", secondLabel);
|
||||
hourLabel->set_label(*getResourceUstring("hourLabel"));
|
||||
hourLabel->set_label(*getResourceUstring("minuteLabel"));
|
||||
hourLabel->set_label(*getResourceUstring("secondLabel"));
|
||||
|
||||
// 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,
|
||||
&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
|
||||
SchedulePlaylistWindow :: onScheduleButtonClicked (void) throw ()
|
||||
{
|
||||
// get the date from the calendar
|
||||
guint year;
|
||||
guint month;
|
||||
guint day;
|
||||
|
||||
unsigned int year;
|
||||
unsigned int month;
|
||||
unsigned int 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
|
||||
// and construct an HH:MM:00.00 string from it
|
||||
Ptr<std::string>::Ref timeStr(new std::string(
|
||||
hourEntry->get_active_text()));
|
||||
*timeStr += ":";
|
||||
Glib::ustring minutes = minuteEntry->get_active_text();
|
||||
if (minutes == "") {
|
||||
minutes = "00";
|
||||
}
|
||||
*timeStr += minutes;
|
||||
*timeStr += ":";
|
||||
Glib::ustring seconds = secondEntry->get_active_text();
|
||||
if (seconds == "") {
|
||||
seconds = "00";
|
||||
}
|
||||
*timeStr += seconds;
|
||||
*timeStr += ".00";
|
||||
|
||||
Ptr<posix_time::ptime>::Ref selectedTime;
|
||||
int hours = hourEntry->get_value_as_int();
|
||||
int minutes = minuteEntry->get_value_as_int();
|
||||
int seconds = secondEntry->get_value_as_int();
|
||||
|
||||
Ptr<boost::posix_time::ptime>::Ref dateTime(new boost::posix_time::ptime(
|
||||
boost::gregorian::date(year,
|
||||
month,
|
||||
day),
|
||||
boost::posix_time::time_duration(
|
||||
hours,
|
||||
minutes,
|
||||
seconds) ));
|
||||
|
||||
try {
|
||||
gregorian::date date(year, month+1, day);
|
||||
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);
|
||||
gLiveSupport->schedulePlaylist(playlist, dateTime);
|
||||
} catch (XmlRpcException &e) {
|
||||
// TODO: notify user
|
||||
std::cerr << "scheduling problem: " << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
hide();
|
||||
mainWindow->hide();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,20 +41,15 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/EntryBin.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
||||
|
@ -89,90 +84,72 @@ using namespace LiveSupport::Core;
|
|||
* @author $Author$
|
||||
* @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.
|
||||
*/
|
||||
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;
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
* Event handler for the schedule button clicked.
|
||||
*/
|
||||
virtual void
|
||||
onScheduleButtonClicked(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, containing
|
||||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param gladeDir the directory where the Glade files are.
|
||||
* @param playlist the playlist to schedule.
|
||||
*/
|
||||
SchedulePlaylistWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
const Glib::ustring & gladeDir,
|
||||
Ptr<Playlist>::Ref playlist)
|
||||
throw ();
|
||||
|
||||
|
@ -180,8 +157,18 @@ class SchedulePlaylistWindow : public GuiWindow
|
|||
* Virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~SchedulePlaylistWindow(void) throw ();
|
||||
~SchedulePlaylistWindow(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying Gtk::Window.
|
||||
*/
|
||||
virtual Gtk::Window *
|
||||
getWindow(void) throw ()
|
||||
{
|
||||
return mainWindow;
|
||||
}
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/ScrolledNotebook.h"
|
||||
#include "SchedulerWindow.h"
|
||||
|
||||
|
||||
|
@ -54,10 +53,10 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc).
|
||||
*/
|
||||
const Glib::ustring windowName = "schedulerWindow";
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const Glib::ustring gladeFileName = "SchedulerWindow.glade";
|
||||
|
||||
}
|
||||
|
||||
|
@ -72,63 +71,28 @@ const Glib::ustring windowName = "schedulerWindow";
|
|||
SchedulerWindow :: SchedulerWindow (
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw (XmlRpcException)
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton)
|
||||
: BasicWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton,
|
||||
gladeDir + gladeFileName)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
constructScheduleView();
|
||||
constructStatusView();
|
||||
|
||||
Gtk::Box * scheduleView = constructScheduleView();
|
||||
Gtk::Box * statusView = constructStatusView();
|
||||
Gtk::Label * scheduleTabLabel;
|
||||
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);
|
||||
try {
|
||||
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);
|
||||
}
|
||||
glade->connect_clicked("closeButton1", sigc::mem_fun(*this,
|
||||
&SchedulerWindow::hide));
|
||||
|
||||
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();
|
||||
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox *
|
||||
void
|
||||
SchedulerWindow :: constructScheduleView(void) throw ()
|
||||
{
|
||||
calendar = Gtk::manage(new Gtk::Calendar());
|
||||
dateLabel = Gtk::manage(new Gtk::Label());
|
||||
glade->get_widget("calendar1", calendar);
|
||||
glade->get_widget("dateLabel1", dateLabel);
|
||||
|
||||
// create the tree view for the entries
|
||||
entryColumns.reset(new ModelColumns());
|
||||
entriesModel = Gtk::ListStore::create(*entryColumns);
|
||||
entriesView = Gtk::manage(new Gtk::TreeView());
|
||||
entriesView->set_model(entriesModel);
|
||||
entriesModel = Gtk::ListStore::create(entryColumns);
|
||||
glade->get_widget_derived("entriesTreeView1", entriesTreeView);
|
||||
entriesTreeView->set_model(entriesModel);
|
||||
entriesTreeView->connectModelSignals(entriesModel);
|
||||
|
||||
// Add the TreeView's view columns:
|
||||
try {
|
||||
entriesView->append_column(*getResourceUstring("startColumnLabel"),
|
||||
entryColumns->startColumn);
|
||||
entriesView->append_column(*getResourceUstring("titleColumnLabel"),
|
||||
entryColumns->titleColumn);
|
||||
entriesView->append_column(*getResourceUstring("endColumnLabel"),
|
||||
entryColumns->endColumn);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
entriesTreeView->append_column(*getResourceUstring("startColumnLabel"),
|
||||
entryColumns.startColumn);
|
||||
entriesTreeView->append_column(*getResourceUstring("titleColumnLabel"),
|
||||
entryColumns.titleColumn);
|
||||
entriesTreeView->append_column(*getResourceUstring("endColumnLabel"),
|
||||
entryColumns.endColumn);
|
||||
|
||||
// register the signal handler for entries view entries being clicked
|
||||
entriesView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onEntryClicked));
|
||||
entriesTreeView->signal_button_press_event().connect_notify(
|
||||
sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onEntryClicked));
|
||||
|
||||
// create the right-click entry context menu for audio clips
|
||||
entryMenu = Gtk::manage(new Gtk::Menu());
|
||||
// create the right-click entry context menu
|
||||
entryMenu.reset(new Gtk::Menu());
|
||||
Gtk::Menu::MenuList& menuList = entryMenu->items();
|
||||
// register the signal handlers for the popup menu
|
||||
try {
|
||||
menuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("deleteMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&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);
|
||||
menuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("deleteMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onDeleteItem)));
|
||||
entryMenu->accelerate(*mainWindow);
|
||||
|
||||
// register the signal handle for when a date is selected in the calendar
|
||||
calendar->signal_day_selected().connect(sigc::mem_fun(*this,
|
||||
|
@ -200,48 +146,26 @@ SchedulerWindow :: constructScheduleView(void) throw ()
|
|||
|
||||
// initialize the selected date for today
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox *
|
||||
void
|
||||
SchedulerWindow :: constructStatusView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Label * stopCurrentlyPlayingLabel;
|
||||
Button * stopCurrentlyPlayingButton;
|
||||
try {
|
||||
stopCurrentlyPlayingLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("stopCurrentlyPlayingText")));
|
||||
stopCurrentlyPlayingButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("stopCurrentlyPlayingButtonLabel")));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
stopCurrentlyPlayingButton->signal_clicked().connect(sigc::mem_fun(
|
||||
*this,
|
||||
Gtk::Button * stopCurrentlyPlayingButton;
|
||||
glade->get_widget("stopCurrentlyPlayingLabel1", stopCurrentlyPlayingLabel);
|
||||
glade->get_widget("stopCurrentlyPlayingButton1",
|
||||
stopCurrentlyPlayingButton);
|
||||
stopCurrentlyPlayingLabel->set_label(
|
||||
*getResourceUstring("stopCurrentlyPlayingText"));
|
||||
stopCurrentlyPlayingButton->set_label(
|
||||
*getResourceUstring("stopCurrentlyPlayingButtonLabel"));
|
||||
stopCurrentlyPlayingButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&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());
|
||||
|
||||
row[entryColumns->idColumn] = entry->getId();
|
||||
row[entryColumns->startColumn] =
|
||||
row[entryColumns.idColumn] = entry->getId();
|
||||
row[entryColumns.startColumn] =
|
||||
to_simple_string(*entry->getStartTime());
|
||||
row[entryColumns->titleColumn] = *playlist->getTitle();
|
||||
row[entryColumns->endColumn] = to_simple_string(*entry->getEndTime());
|
||||
row[entryColumns.titleColumn] = *playlist->getTitle();
|
||||
row[entryColumns.endColumn] = to_simple_string(*entry->getEndTime());
|
||||
|
||||
++it;
|
||||
}
|
||||
|
@ -349,7 +273,7 @@ SchedulerWindow :: onEntryClicked (GdkEventButton * event) throw ()
|
|||
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
|
||||
// only show the context menu, if something is already selected
|
||||
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
|
||||
entriesView->get_selection();
|
||||
entriesTreeView->get_selection();
|
||||
if (refSelection) {
|
||||
Gtk::TreeModel::iterator iter = refSelection->get_selected();
|
||||
if (iter) {
|
||||
|
@ -367,12 +291,12 @@ void
|
|||
SchedulerWindow :: onDeleteItem(void) throw ()
|
||||
{
|
||||
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
|
||||
entriesView->get_selection();
|
||||
entriesTreeView->get_selection();
|
||||
|
||||
if (refSelection) {
|
||||
Gtk::TreeModel::iterator iter = refSelection->get_selected();
|
||||
if (iter) {
|
||||
Ptr<const UniqueId>::Ref entryId = (*iter)[entryColumns->idColumn];
|
||||
Ptr<const UniqueId>::Ref entryId = (*iter)[entryColumns.idColumn];
|
||||
|
||||
try {
|
||||
gLiveSupport->removeFromSchedule(entryId);
|
||||
|
@ -396,16 +320,18 @@ SchedulerWindow :: onDeleteItem(void) throw ()
|
|||
void
|
||||
SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw ()
|
||||
{
|
||||
DialogWindow::ButtonType result = dialogWindow->run();
|
||||
Gtk::ResponseType result = runConfirmationDialog();
|
||||
switch (result) {
|
||||
case DialogWindow::yesButton: break;
|
||||
case Gtk::RESPONSE_YES:
|
||||
break;
|
||||
|
||||
case DialogWindow::noButton: return;
|
||||
break;
|
||||
case Gtk::RESPONSE_NO:
|
||||
return;
|
||||
break;
|
||||
|
||||
// can happen if the window is closed with Alt-F4 -- treated as No
|
||||
default : return;
|
||||
break;
|
||||
default : // can happen if the window
|
||||
return; // is closed with Alt-F4
|
||||
break; // -- treated as No
|
||||
}
|
||||
|
||||
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
|
||||
|
@ -416,10 +342,33 @@ SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw ()
|
|||
scheduler->stopCurrentlyPlaying(sessionId);
|
||||
|
||||
} catch (XmlRpcException &e) {
|
||||
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring(e.what()));
|
||||
gLiveSupport->displayMessageWindow(errorMessage);
|
||||
gLiveSupport->displayMessageWindow(e.what());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,17 +41,16 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/DialogWindow.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
|
||||
#include "BasicWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -71,7 +70,8 @@ using namespace LiveSupport::Core;
|
|||
* The Scheduler window, showing and allowing scheduling of playlists.
|
||||
*
|
||||
* 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:
|
||||
* <code><pre>
|
||||
|
@ -95,27 +95,32 @@ using namespace LiveSupport::Core;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class SchedulerWindow : public GuiWindow
|
||||
class SchedulerWindow : public BasicWindow
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Construct the Schedule view.
|
||||
* This displays the list of scheduled playlists.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructScheduleView(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the Status view.
|
||||
* 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 ();
|
||||
|
||||
/**
|
||||
* Run the confirmation dialog.
|
||||
*
|
||||
* @return the response ID returned by the dialog.
|
||||
*/
|
||||
Gtk::ResponseType
|
||||
runConfirmationDialog(void) throw ();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -126,7 +131,7 @@ class SchedulerWindow : public GuiWindow
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class ModelColumns : public Gtk::TreeModel::ColumnRecord
|
||||
class ModelColumns : public ZebraTreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -167,31 +172,26 @@ class SchedulerWindow : public GuiWindow
|
|||
*/
|
||||
Ptr<boost::gregorian::date>::Ref selectedDate;
|
||||
|
||||
/**
|
||||
* The main container in the window.
|
||||
*/
|
||||
Gtk::Table * layout;
|
||||
|
||||
/**
|
||||
* The calendar to select a specific date from.
|
||||
*/
|
||||
Gtk::Calendar * calendar;
|
||||
Gtk::Calendar * calendar;
|
||||
|
||||
/**
|
||||
* The label saying which day is being displayed.
|
||||
*/
|
||||
Gtk::Label * dateLabel;
|
||||
Gtk::Label * dateLabel;
|
||||
|
||||
/**
|
||||
* The column model.
|
||||
*/
|
||||
Ptr<ModelColumns>::Ref entryColumns;
|
||||
ModelColumns entryColumns;
|
||||
|
||||
/**
|
||||
* The tree view, now only showing rows, each scheduled entry for a
|
||||
* specific day.
|
||||
*/
|
||||
Gtk::TreeView * entriesView;
|
||||
ZebraTreeView * entriesTreeView;
|
||||
|
||||
/**
|
||||
* The tree model, as a GTK reference.
|
||||
|
@ -201,18 +201,7 @@ class SchedulerWindow : public GuiWindow
|
|||
/**
|
||||
* The right-click context menu for schedule entries.
|
||||
*/
|
||||
Gtk::Menu * 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;
|
||||
Ptr<Gtk::Menu>::Ref entryMenu;
|
||||
|
||||
/**
|
||||
* Signal handler for when a date is selected in the calendar.
|
||||
|
@ -244,6 +233,7 @@ class SchedulerWindow : public GuiWindow
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -253,10 +243,12 @@ class SchedulerWindow : public GuiWindow
|
|||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param gladeDir the directory where the glade file is.
|
||||
*/
|
||||
SchedulerWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,13 +37,10 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
|
||||
#include "ScratchpadWindow.h"
|
||||
|
||||
|
||||
using namespace Glib;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
@ -55,10 +52,10 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc).
|
||||
*/
|
||||
const Glib::ustring windowName = "scratchpadWindow";
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const Glib::ustring gladeFileName = "ScratchpadWindow.glade";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the user preference for storing Scratchpad contents
|
||||
|
@ -78,232 +75,109 @@ const Glib::ustring userPreferencesKeyName = "scratchpadContents";
|
|||
ScratchpadWindow :: ScratchpadWindow (
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton)
|
||||
: BasicWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton,
|
||||
gladeDir + gladeFileName),
|
||||
gladeDir(gladeDir)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
|
||||
|
||||
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));
|
||||
// create the tree view
|
||||
glade->get_widget_derived("treeView1", treeView);
|
||||
treeView->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
|
||||
treeView->set_reorderable(true);
|
||||
treeView->set_enable_search(false);
|
||||
|
||||
// Add the TreeView's view columns:
|
||||
try {
|
||||
treeView->appendColumn(*getResourceUstring("typeColumnLabel"),
|
||||
modelColumns.typeColumn, 20);
|
||||
treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn, 200);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
treeView->appendColumn("",
|
||||
modelColumns.typeColumn);
|
||||
treeView->appendColumn(*getResourceUstring("creatorColumnLabel"),
|
||||
modelColumns.creatorColumn);
|
||||
treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn);
|
||||
|
||||
// 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,
|
||||
&ScratchpadWindow::onEntryClicked));
|
||||
treeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onDoubleClick));
|
||||
|
||||
// register the signal handler for keyboard key presses
|
||||
treeView->signal_key_press_event().connect(sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onKeyPressed));
|
||||
|
||||
// Add the TreeView, inside a ScrolledWindow, with the button underneath:
|
||||
scrolledWindow.add(*treeView);
|
||||
|
||||
// Only show the scrollbars when they are necessary:
|
||||
scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
||||
|
||||
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 cue player widget
|
||||
cuePlayer.reset(new CuePlayer(gLiveSupport,
|
||||
treeView,
|
||||
modelColumns,
|
||||
glade));
|
||||
|
||||
// create the right-click entry context menu for audio clips
|
||||
audioClipMenu = Gtk::manage(new Gtk::Menu());
|
||||
Gtk::Menu::MenuList& audioClipMenuList = audioClipMenu->items();
|
||||
// register the signal handlers for the popup menu
|
||||
try {
|
||||
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cueMenuItem"),
|
||||
sigc::mem_fun(*cueAudioButtons,
|
||||
&CuePlayer::onPlayItem)));
|
||||
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToLiveModeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToLiveMode)));
|
||||
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToPlaylist)));
|
||||
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*treeView,
|
||||
&ZebraTreeView::onRemoveMenuOption)));
|
||||
audioClipMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("uploadToHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onUploadToHub)));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
audioClipMenu->accelerate(*this);
|
||||
audioClipMenu.reset(new Gtk::Menu());
|
||||
audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cueMenuItem"),
|
||||
sigc::mem_fun(*cuePlayer,
|
||||
&CuePlayer::onPlayItem)));
|
||||
audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToLiveModeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToLiveMode)));
|
||||
audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToPlaylist)));
|
||||
audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onRemoveMenuOption)));
|
||||
audioClipMenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
audioClipMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("uploadToHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onUploadToHub)));
|
||||
audioClipMenu->accelerate(*mainWindow);
|
||||
|
||||
// create the right-click entry context menu for playlists
|
||||
playlistMenu = Gtk::manage(new Gtk::Menu());
|
||||
Gtk::Menu::MenuList& playlistMenuList = playlistMenu->items();
|
||||
// register the signal handlers for the popup menu
|
||||
|
||||
try{
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cueMenuItem"),
|
||||
sigc::mem_fun(*cueAudioButtons,
|
||||
&CuePlayer::onPlayItem)));
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToLiveModeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToLiveMode)));
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToPlaylist)));
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*treeView,
|
||||
&ZebraTreeView::onRemoveMenuOption)));
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("editPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onEditPlaylist)));
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("schedulePlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onSchedulePlaylist)));
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("exportPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onExportPlaylist)));
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*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);
|
||||
playlistMenu.reset(new Gtk::Menu());
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cueMenuItem"),
|
||||
sigc::mem_fun(*cuePlayer,
|
||||
&CuePlayer::onPlayItem)));
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToLiveModeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToLiveMode)));
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onAddToPlaylist)));
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("removeMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onRemoveMenuOption)));
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("editPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onEditPlaylist)));
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("schedulePlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onSchedulePlaylist)));
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("exportPlaylistMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onExportPlaylist)));
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
|
||||
playlistMenu->items().push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("uploadToHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onUploadToHub)));
|
||||
playlistMenu->accelerate(*mainWindow);
|
||||
|
||||
// set the user preferences key
|
||||
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
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw ()
|
||||
ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw ()
|
||||
{
|
||||
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
|
||||
Gtk::TreePath currentPath;
|
||||
|
@ -353,7 +227,7 @@ ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw ()
|
|||
* Select the row which contains the playable specified.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw ()
|
||||
ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw ()
|
||||
{
|
||||
Gtk::TreeModel::const_iterator it;
|
||||
|
||||
|
@ -377,7 +251,7 @@ ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw ()
|
|||
* Remove an item from the Scratchpad
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw ()
|
||||
ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw ()
|
||||
{
|
||||
Gtk::TreeModel::const_iterator it;
|
||||
|
||||
|
@ -400,13 +274,13 @@ ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw ()
|
|||
* entry context menu
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onEditPlaylist(void) throw ()
|
||||
ScratchpadWindow :: onEditPlaylist(void) throw ()
|
||||
{
|
||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
||||
try {
|
||||
gLiveSupport->openPlaylistForEditing(playable->getId());
|
||||
} catch (XmlRpcException &e) {
|
||||
gLiveSupport->displayMessageWindow(getResourceUstring(
|
||||
gLiveSupport->displayMessageWindow(*getResourceUstring(
|
||||
"cannotEditPlaylistMsg" ));
|
||||
}
|
||||
}
|
||||
|
@ -417,12 +291,11 @@ ScratchpadWindow :: onEditPlaylist(void) throw ()
|
|||
* entry context menu
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onSchedulePlaylist(void) throw ()
|
||||
ScratchpadWindow :: onSchedulePlaylist(void) throw ()
|
||||
{
|
||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
||||
Ptr<UniqueId>::Ref uid = playable->getId();
|
||||
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
|
||||
try {
|
||||
|
@ -432,8 +305,6 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw ()
|
|||
|
||||
playlist = gLiveSupport->getPlaylist(uid);
|
||||
|
||||
bundle = gLiveSupport->getBundle("schedulePlaylistWindow");
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
|
@ -444,10 +315,10 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw ()
|
|||
}
|
||||
|
||||
schedulePlaylistWindow.reset(new SchedulePlaylistWindow(gLiveSupport,
|
||||
bundle,
|
||||
gladeDir,
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onExportPlaylist(void) throw ()
|
||||
ScratchpadWindow :: onExportPlaylist(void) throw ()
|
||||
{
|
||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
||||
Ptr<Playlist>::Ref playlist = playable->getPlaylist();
|
||||
|
@ -464,10 +335,10 @@ ScratchpadWindow :: onExportPlaylist(void) throw ()
|
|||
if (playlist) {
|
||||
exportPlaylistWindow.reset(new ExportPlaylistWindow(
|
||||
gLiveSupport,
|
||||
gLiveSupport->getBundle("exportPlaylistWindow"),
|
||||
gladeDir,
|
||||
playlist));
|
||||
exportPlaylistWindow->set_transient_for(*this);
|
||||
Gtk::Main::run(*exportPlaylistWindow);
|
||||
exportPlaylistWindow->getWindow()->set_transient_for(*mainWindow);
|
||||
Gtk::Main::run(*exportPlaylistWindow->getWindow());
|
||||
}
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
|
@ -480,7 +351,7 @@ ScratchpadWindow :: onExportPlaylist(void) throw ()
|
|||
* entry context menu
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onAddToPlaylist(void) throw ()
|
||||
ScratchpadWindow :: onAddToPlaylist(void) throw ()
|
||||
{
|
||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
||||
try {
|
||||
|
@ -498,7 +369,7 @@ ScratchpadWindow :: onAddToPlaylist(void) throw ()
|
|||
* entry context menu
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onAddToLiveMode(void) throw ()
|
||||
ScratchpadWindow :: onAddToLiveMode(void) throw ()
|
||||
{
|
||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
||||
gLiveSupport->addToLiveMode(playable);
|
||||
|
@ -509,20 +380,54 @@ ScratchpadWindow :: onAddToLiveMode(void) throw ()
|
|||
* Signal handler for "upload to hub" in the context menu.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onUploadToHub(void) throw ()
|
||||
ScratchpadWindow :: onUploadToHub(void) throw ()
|
||||
{
|
||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: onDoubleClick(const Gtk::TreeModel::Path & path,
|
||||
const Gtk::TreeViewColumn * column)
|
||||
throw ()
|
||||
throw ()
|
||||
{
|
||||
Gtk::TreeIter iter = treeModel->get_iter(path);
|
||||
if (iter) {
|
||||
|
@ -536,11 +441,11 @@ ScratchpadWindow :: onDoubleClick(const Gtk::TreeModel::Path & path,
|
|||
* Event handler for a key pressed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw ()
|
||||
ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw ()
|
||||
{
|
||||
if (event->type == GDK_KEY_PRESS) {
|
||||
KeyboardShortcut::Action action = gLiveSupport->findAction(
|
||||
windowName,
|
||||
"scratchpadWindow",
|
||||
Gdk::ModifierType(event->state),
|
||||
event->keyval);
|
||||
switch (action) {
|
||||
|
@ -559,7 +464,7 @@ ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw ()
|
|||
break;
|
||||
|
||||
case KeyboardShortcut::removeItem :
|
||||
onRemoveItemButtonClicked();
|
||||
onRemoveMenuOption();
|
||||
return true;
|
||||
|
||||
default : break;
|
||||
|
@ -574,7 +479,7 @@ ScratchpadWindow :: onKeyPressed(GdkEventKey * event) throw ()
|
|||
* Check whether exactly one row is selected.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
ScratchpadWindow :: isSelectionSingle(void) throw ()
|
||||
ScratchpadWindow :: isSelectionSingle(void) throw ()
|
||||
{
|
||||
Glib::RefPtr<Gtk::TreeView::Selection>
|
||||
selection = treeView->get_selection();
|
||||
|
@ -596,7 +501,7 @@ ScratchpadWindow :: isSelectionSingle(void) throw ()
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
|
||||
throw ()
|
||||
throw ()
|
||||
{
|
||||
// cache the item if it hasn't been cached yet
|
||||
if (!playable->getToken()) {
|
||||
|
@ -611,7 +516,7 @@ ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
|
|||
|
||||
removeItem(playable->getId());
|
||||
|
||||
Gtk::TreeModel::Row row = *treeModel->prepend();
|
||||
Gtk::TreeModel::Row row = *(treeModel->prepend());
|
||||
|
||||
row[modelColumns.playableColumn] = playable;
|
||||
|
||||
|
@ -629,6 +534,12 @@ ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
|
|||
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(
|
||||
*playable->getTitle());
|
||||
}
|
||||
|
@ -639,7 +550,7 @@ ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: addItem(Ptr<const UniqueId>::Ref id)
|
||||
throw ()
|
||||
throw ()
|
||||
{
|
||||
Ptr<Playable>::Ref playable;
|
||||
try {
|
||||
|
@ -658,7 +569,7 @@ ScratchpadWindow :: addItem(Ptr<const UniqueId>::Ref id)
|
|||
* Return the contents of the Scratchpad.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
ScratchpadWindow :: getContents(void) throw ()
|
||||
ScratchpadWindow :: getContents(void) throw ()
|
||||
{
|
||||
std::ostringstream contentsStream;
|
||||
Gtk::TreeModel::const_iterator it;
|
||||
|
@ -681,7 +592,7 @@ ScratchpadWindow :: getContents(void) throw ()
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: setContents(Ptr<const Glib::ustring>::Ref contents)
|
||||
throw ()
|
||||
throw ()
|
||||
{
|
||||
std::vector<UniqueId::IdType> contentsVector;
|
||||
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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ScratchpadWindow :: on_hide(void) throw ()
|
||||
ScratchpadWindow :: hide(void) throw ()
|
||||
{
|
||||
if (exportPlaylistWindow) {
|
||||
exportPlaylistWindow->hide();
|
||||
exportPlaylistWindow->getWindow()->hide();
|
||||
}
|
||||
if (schedulePlaylistWindow) {
|
||||
schedulePlaylistWindow->hide();
|
||||
schedulePlaylistWindow->getWindow()->hide();
|
||||
}
|
||||
|
||||
GuiWindow::on_hide();
|
||||
BasicWindow::hide();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,17 +41,14 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
|
||||
#include "BasicWindow.h"
|
||||
#include "CuePlayer.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "ContentsStorable.h"
|
||||
#include "ExportPlaylistWindow.h"
|
||||
#include "SchedulePlaylistWindow.h"
|
||||
|
@ -77,10 +74,21 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class ScratchpadWindow : public GuiWindow,
|
||||
class ScratchpadWindow : public BasicWindow,
|
||||
public ContentsStorable
|
||||
{
|
||||
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.
|
||||
*/
|
||||
|
@ -123,11 +131,6 @@ class ScratchpadWindow : public GuiWindow,
|
|||
void
|
||||
removeItem(Ptr<const UniqueId>::Ref id) throw ();
|
||||
|
||||
/**
|
||||
* The user preferences key.
|
||||
*/
|
||||
Ptr<const Glib::ustring>::Ref userPreferencesKey;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -147,6 +150,11 @@ class ScratchpadWindow : public GuiWindow,
|
|||
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> >
|
||||
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.
|
||||
*/
|
||||
|
@ -158,6 +166,7 @@ class ScratchpadWindow : public GuiWindow,
|
|||
ModelColumns(void) throw ()
|
||||
{
|
||||
add(typeColumn);
|
||||
add(creatorColumn);
|
||||
add(titleColumn);
|
||||
}
|
||||
};
|
||||
|
@ -166,7 +175,7 @@ class ScratchpadWindow : public GuiWindow,
|
|||
/**
|
||||
* The column model.
|
||||
*/
|
||||
ModelColumns modelColumns;
|
||||
ModelColumns modelColumns;
|
||||
|
||||
/**
|
||||
* The tree model, as a GTK reference.
|
||||
|
@ -176,87 +185,29 @@ class ScratchpadWindow : public GuiWindow,
|
|||
/**
|
||||
* The tree view, now only showing rows.
|
||||
*/
|
||||
ZebraTreeView * treeView;
|
||||
ZebraTreeView * treeView;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
Ptr<CuePlayer>::Ref cuePlayer;
|
||||
|
||||
/**
|
||||
* The right-click context menu for audio clips,
|
||||
* 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,
|
||||
* that comes up when right-clicking an entry in the entry list.
|
||||
*/
|
||||
Gtk::Menu * 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 ();
|
||||
Ptr<Gtk::Menu>::Ref playlistMenu;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
virtual void
|
||||
onEntryClicked(GdkEventButton * event) throw ();
|
||||
onEntryClicked(GdkEventButton * event) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the user double-clicking, or pressing Enter
|
||||
|
@ -334,16 +285,15 @@ class ScratchpadWindow : public GuiWindow,
|
|||
onUploadToHub(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.
|
||||
* Event handler for the Remove menu item selected from
|
||||
* the entry conext menu.
|
||||
*/
|
||||
virtual void
|
||||
on_hide(void) throw ();
|
||||
onRemoveMenuOption(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -351,12 +301,14 @@ class ScratchpadWindow : public GuiWindow,
|
|||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param gladeDir the directory where the glade file is.
|
||||
*/
|
||||
ScratchpadWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -422,8 +374,17 @@ class ScratchpadWindow : public GuiWindow,
|
|||
void
|
||||
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 */
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
|
||||
#include "SearchWindow.h"
|
||||
|
@ -60,14 +59,9 @@ using namespace LiveSupport::GLiveSupport;
|
|||
namespace {
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The 'search where' combo box key for local searches.
|
||||
* The name of the glade file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string searchWhereLocalKey = "searchWhereLocal";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The 'search where' combo box key for remote searches.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string searchWhereRemoteKey = "searchWhereRemote";
|
||||
const Glib::ustring gladeFileName = "SearchWindow.glade";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
throw ()
|
||||
: GuiWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ()
|
||||
: BasicWindow(gLiveSupport,
|
||||
bundle,
|
||||
windowOpenerButton,
|
||||
gladeDir + gladeFileName),
|
||||
gladeDir(gladeDir)
|
||||
{
|
||||
Gtk::Box * searchWhereBox = constructSearchWhereBox();
|
||||
|
||||
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);
|
||||
glade->get_widget("searchInputNoteBook1", searchInput);
|
||||
|
||||
// put them in one big box
|
||||
Gtk::VBox * bigBox = Gtk::manage(new Gtk::VBox);
|
||||
bigBox->pack_start(*searchWhereBox, Gtk::PACK_SHRINK);
|
||||
bigBox->pack_start(*searchInput, Gtk::PACK_SHRINK);
|
||||
bigBox->pack_start(*searchResultsView);
|
||||
add(*bigBox);
|
||||
Gtk::Label * simpleSearchTabLabel;
|
||||
Gtk::Label * advancedSearchTabLabel;
|
||||
Gtk::Label * browseTabLabel;
|
||||
Gtk::Label * transportsTabLabel;
|
||||
glade->get_widget("simpleSearchTabLabel1", simpleSearchTabLabel);
|
||||
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
|
||||
set_name("searchWindow");
|
||||
set_modal(false);
|
||||
property_window_position().set_value(Gtk::WIN_POS_NONE);
|
||||
constructSimpleSearchView();
|
||||
constructAdvancedSearchView();
|
||||
constructBrowseView();
|
||||
constructTransportsView();
|
||||
|
||||
show_all_children();
|
||||
constructSearchResultsView();
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,265 +126,130 @@ SearchWindow :: ~SearchWindow (void) throw ()
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the transport type selection box.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
SearchWindow :: constructSearchWhereBox(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Label * searchWhereLabel;
|
||||
try {
|
||||
searchWhereLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("searchWhereLabel") ));
|
||||
searchWhereEntry = Gtk::manage(wf->createComboBoxText());
|
||||
|
||||
Ptr<Glib::ustring>::Ref localKey(new Glib::ustring(
|
||||
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);
|
||||
}
|
||||
|
||||
glade->get_widget("searchWhereLabel1", searchWhereLabel);
|
||||
searchWhereLabel->set_label(*getResourceUstring("searchWhereLabel"));
|
||||
|
||||
glade->get_widget_derived("searchWhereEntry1", searchWhereEntry);
|
||||
searchWhereEntry->append_text(*getResourceUstring("searchWhereLocal"));
|
||||
searchWhereEntry->append_text(*getResourceUstring("searchWhereRemote"));
|
||||
searchWhereEntry->set_active(0);
|
||||
searchWhereEntry->signalSelectionChanged().connect(sigc::mem_fun(
|
||||
*this, &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;
|
||||
searchWhereEntry->signal_changed().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onSearchWhereChanged));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the simple search view.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
SearchWindow :: constructSimpleSearchView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
// set up the entry box
|
||||
simpleSearchEntry = Gtk::manage(wf->createEntryBin());
|
||||
glade->get_widget("simpleSearchEntry1", simpleSearchEntry);
|
||||
simpleSearchEntry->signal_activate().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onSimpleSearch));
|
||||
|
||||
Button * searchButton;
|
||||
try {
|
||||
searchButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("searchButtonLabel") ));
|
||||
} catch (std::invalid_argument &e) {
|
||||
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;
|
||||
Gtk::Button * simpleSearchButton;
|
||||
glade->get_widget("simpleSearchButton1", simpleSearchButton);
|
||||
simpleSearchButton->set_label(*getResourceUstring("searchButtonLabel"));
|
||||
simpleSearchButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onSimpleSearch));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the advanced search view.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
SearchWindow :: constructAdvancedSearchView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
// the two main components of the window
|
||||
advancedSearchEntry = Gtk::manage(new AdvancedSearchEntry(gLiveSupport));
|
||||
Gtk::Box * searchButtonBox = Gtk::manage(new Gtk::HButtonBox(
|
||||
Gtk::BUTTONBOX_END ));
|
||||
advancedSearchEntry.reset(new AdvancedSearchEntry(gLiveSupport, glade));
|
||||
advancedSearchEntry->connectCallback(sigc::mem_fun(*this,
|
||||
&SearchWindow::onAdvancedSearch ));
|
||||
|
||||
// set up the callback function for the entry field
|
||||
advancedSearchEntry->connectCallback(sigc::mem_fun(
|
||||
*this, &SearchWindow::onAdvancedSearch ));
|
||||
|
||||
// set up the search button box
|
||||
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;
|
||||
Gtk::Button * advancedSearchButton;
|
||||
glade->get_widget("advancedSearchButton1", advancedSearchButton);
|
||||
advancedSearchButton->set_label(*getResourceUstring("searchButtonLabel"));
|
||||
advancedSearchButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onAdvancedSearch));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the browse view.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
SearchWindow :: constructBrowseView(void) throw ()
|
||||
{
|
||||
// set up the browse input fields
|
||||
browseEntry = Gtk::manage(new BrowseEntry(gLiveSupport, getBundle()));
|
||||
|
||||
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;
|
||||
browseEntry.reset(new BrowseEntry(gLiveSupport, getBundle(), glade));
|
||||
browseEntry->signalChanged().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onBrowse));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the advanced search view.
|
||||
* Construct the transports view.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
SearchWindow :: constructTransportsView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
try {
|
||||
transportList = Gtk::manage(new TransportList(
|
||||
transportList.reset(new TransportList(
|
||||
gLiveSupport,
|
||||
gLiveSupport->getBundle("transportList") ));
|
||||
} catch (std::invalid_argument &e) {
|
||||
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;
|
||||
gLiveSupport->getBundle("transportList"),
|
||||
glade));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the search results display.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Box *
|
||||
void
|
||||
SearchWindow :: constructSearchResultsView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
localSearchResults = 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);
|
||||
|
||||
// add the TreeView's view columns
|
||||
try {
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("typeColumnLabel"),
|
||||
modelColumns.typeColumn, 20);
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn, 300);
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("creatorColumnLabel"),
|
||||
modelColumns.creatorColumn, 200);
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("sourceColumnLabel"),
|
||||
modelColumns.sourceColumn, 145);
|
||||
searchResultsTreeView->appendCenteredColumn(
|
||||
*getResourceUstring("lengthColumnLabel"),
|
||||
modelColumns.lengthColumn, 55);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("typeColumnLabel"),
|
||||
modelColumns.typeColumn, 20);
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn, 300);
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("creatorColumnLabel"),
|
||||
modelColumns.creatorColumn, 200);
|
||||
searchResultsTreeView->appendColumn(
|
||||
*getResourceUstring("sourceColumnLabel"),
|
||||
modelColumns.sourceColumn, 145);
|
||||
searchResultsTreeView->appendCenteredColumn(
|
||||
*getResourceUstring("lengthColumnLabel"),
|
||||
modelColumns.lengthColumn, 55);
|
||||
|
||||
// register the signal handler for treeview entries being clicked
|
||||
searchResultsTreeView->signal_button_press_event().connect_notify(
|
||||
sigc::mem_fun(
|
||||
*this, &SearchWindow::onEntryClicked));
|
||||
searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun(
|
||||
*this, &SearchWindow::onDoubleClick));
|
||||
sigc::mem_fun(*this,
|
||||
&SearchWindow::onEntryClicked));
|
||||
searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onDoubleClick));
|
||||
|
||||
// create the right-click context menus
|
||||
audioClipContextMenu = constructAudioClipContextMenu();
|
||||
playlistContextMenu = constructPlaylistContextMenu();
|
||||
remoteContextMenu = constructRemoteContextMenu();
|
||||
|
||||
// put the tree view inside a scrolled window
|
||||
ScrolledWindow * resultsWindow = Gtk::manage(new ScrolledWindow);
|
||||
resultsWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
||||
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);
|
||||
}
|
||||
glade->get_widget("searchResultsCountLabel1", searchResultsCountLabel);
|
||||
glade->get_widget("backwardButton1", backwardButton);
|
||||
glade->get_widget("forwardButton1", forwardButton);
|
||||
backwardButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onBackwardButtonClicked));
|
||||
forwardButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&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) {
|
||||
remoteSearchToken.reset();
|
||||
gLiveSupport->displayMessageWindow(formatMessage("longErrorMsg",
|
||||
*errorMessage ));
|
||||
gLiveSupport->displayMessageWindow(*formatMessage("longErrorMsg",
|
||||
*errorMessage ));
|
||||
displayMessage("shortErrorMsg", remoteSearchResults);
|
||||
}
|
||||
}
|
||||
|
@ -717,8 +559,8 @@ SearchWindow :: displayError(const XmlRpcException & error,
|
|||
Glib::RefPtr<Gtk::ListStore> treeModel)
|
||||
throw ()
|
||||
{
|
||||
gLiveSupport->displayMessageWindow(formatMessage("longErrorMsg",
|
||||
error.what() ));
|
||||
gLiveSupport->displayMessageWindow(*formatMessage("longErrorMsg",
|
||||
error.what() ));
|
||||
displayMessage("shortErrorMsg", treeModel);
|
||||
}
|
||||
|
||||
|
@ -814,7 +656,7 @@ SearchWindow :: onAddToScratchpad(void) throw ()
|
|||
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring(
|
||||
"error in SearchWindow::onAddToScratchpad(): "));
|
||||
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(
|
||||
"error in SearchWindow::onAddToPlaylist(): "));
|
||||
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(
|
||||
"error in SearchWindow::onAddToLiveMode(): "));
|
||||
errorMessage->append(e.what());
|
||||
gLiveSupport->displayMessageWindow(errorMessage);
|
||||
gLiveSupport->displayMessageWindow(*errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -895,8 +737,8 @@ SearchWindow :: onEditPlaylist(void) throw ()
|
|||
try {
|
||||
gLiveSupport->openPlaylistForEditing(playlist->getId());
|
||||
} catch (XmlRpcException &e) {
|
||||
gLiveSupport->displayMessageWindow(getResourceUstring(
|
||||
"cannotEditPlaylistMsg" ));
|
||||
gLiveSupport->displayMessageWindow(*getResourceUstring(
|
||||
"cannotEditPlaylistMsg" ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -921,10 +763,10 @@ SearchWindow :: onSchedulePlaylist(void) throw ()
|
|||
if (playlist) {
|
||||
schedulePlaylistWindow.reset(new SchedulePlaylistWindow(
|
||||
gLiveSupport,
|
||||
gLiveSupport->getBundle("schedulePlaylistWindow"),
|
||||
gladeDir,
|
||||
playlist));
|
||||
schedulePlaylistWindow->set_transient_for(*this);
|
||||
Gtk::Main::run(*schedulePlaylistWindow);
|
||||
schedulePlaylistWindow->getWindow()->set_transient_for(*mainWindow);
|
||||
Gtk::Main::run(*schedulePlaylistWindow->getWindow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -949,14 +791,14 @@ SearchWindow :: onExportPlaylist(void) throw ()
|
|||
try {
|
||||
exportPlaylistWindow.reset(new ExportPlaylistWindow(
|
||||
gLiveSupport,
|
||||
gLiveSupport->getBundle("exportPlaylistWindow"),
|
||||
gladeDir,
|
||||
playlist));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
exportPlaylistWindow->set_transient_for(*this);
|
||||
Gtk::Main::run(*exportPlaylistWindow);
|
||||
exportPlaylistWindow->getWindow()->set_transient_for(*mainWindow);
|
||||
Gtk::Main::run(*exportPlaylistWindow->getWindow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -991,12 +833,12 @@ bool
|
|||
SearchWindow :: uploadToHub(Ptr<Playable>::Ref playable) throw ()
|
||||
{
|
||||
try {
|
||||
searchInput->setActivePage(3);
|
||||
searchInput->set_current_page(3);
|
||||
transportList->addUpload(playable);
|
||||
|
||||
} catch (XmlRpcException &e) {
|
||||
gLiveSupport->displayMessageWindow(formatMessage("uploadToHubErrorMsg",
|
||||
e.what() ));
|
||||
gLiveSupport->displayMessageWindow(*formatMessage("uploadToHubErrorMsg",
|
||||
e.what() ));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1020,11 +862,11 @@ SearchWindow :: onDownloadFromHub(void) throw ()
|
|||
if (playable) {
|
||||
if (!gLiveSupport->existsPlayable(playable->getId())) {
|
||||
try {
|
||||
searchInput->setActivePage(3);
|
||||
searchInput->set_current_page(3);
|
||||
transportList->addDownload(playable);
|
||||
|
||||
} catch (XmlRpcException &e) {
|
||||
gLiveSupport->displayMessageWindow(formatMessage(
|
||||
gLiveSupport->displayMessageWindow(*formatMessage(
|
||||
"downloadFromHubErrorMsg", e.what() ));
|
||||
return;
|
||||
}
|
||||
|
@ -1056,16 +898,16 @@ SearchWindow :: onDoubleClick(const Gtk::TreeModel::Path & path,
|
|||
* Event handler called when the the window gets hidden.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SearchWindow :: on_hide(void) throw ()
|
||||
SearchWindow :: hide(void) throw ()
|
||||
{
|
||||
if (exportPlaylistWindow) {
|
||||
exportPlaylistWindow->hide();
|
||||
exportPlaylistWindow->getWindow()->hide();
|
||||
}
|
||||
if (schedulePlaylistWindow) {
|
||||
schedulePlaylistWindow->hide();
|
||||
schedulePlaylistWindow->getWindow()->hide();
|
||||
}
|
||||
|
||||
GuiWindow::on_hide();
|
||||
BasicWindow::hide();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1075,13 +917,20 @@ SearchWindow :: on_hide(void) throw ()
|
|||
bool
|
||||
SearchWindow :: searchIsLocal(void) throw ()
|
||||
{
|
||||
Ptr<const Glib::ustring>::Ref searchWhere
|
||||
= searchWhereEntry->getActiveKey();
|
||||
int searchWhere = searchWhereEntry->get_active_row_number();
|
||||
|
||||
if (*searchWhere == searchWhereLocalKey) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
switch (searchWhere) {
|
||||
case 0: return true;
|
||||
break;
|
||||
|
||||
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 ()
|
||||
{
|
||||
if (searchIsLocal()) {
|
||||
searchInput->setPageSensitive(2, true);
|
||||
searchInput->get_nth_page(2)->set_sensitive(true);
|
||||
searchResultsTreeView->set_model(localSearchResults);
|
||||
} else {
|
||||
if (searchInput->getActivePage() == 2) {
|
||||
searchInput->setActivePage(0);
|
||||
if (searchInput->get_current_page() == 2) {
|
||||
searchInput->set_current_page(0);
|
||||
}
|
||||
searchInput->setPageSensitive(2, false);
|
||||
searchInput->get_nth_page(2)->set_sensitive(false);
|
||||
searchResultsTreeView->set_model(remoteSearchResults);
|
||||
}
|
||||
|
||||
|
@ -1121,36 +970,31 @@ SearchWindow :: onTimer(void) throw ()
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the right-click context menu for local audio clips.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Menu *
|
||||
Ptr<Gtk::Menu>::Ref
|
||||
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();
|
||||
|
||||
try {
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*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("uploadToHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SearchWindow::onUploadToHub)));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*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("uploadToHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SearchWindow::onUploadToHub)));
|
||||
|
||||
contextMenu->accelerate(*this);
|
||||
contextMenu->accelerate(*mainWindow);
|
||||
return contextMenu;
|
||||
}
|
||||
|
||||
|
@ -1158,49 +1002,44 @@ SearchWindow :: constructAudioClipContextMenu(void) throw ()
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the right-click context menu for local playlists.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Menu *
|
||||
Ptr<Gtk::Menu>::Ref
|
||||
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();
|
||||
|
||||
try {
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("addToLiveModeMenuItem"),
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*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,
|
||||
&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,
|
||||
&SearchWindow::onEditPlaylist)));
|
||||
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);
|
||||
}
|
||||
&SearchWindow::onEditPlaylist)));
|
||||
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)));
|
||||
|
||||
contextMenu->accelerate(*this);
|
||||
contextMenu->accelerate(*mainWindow);
|
||||
return contextMenu;
|
||||
}
|
||||
|
||||
|
@ -1208,23 +1047,18 @@ SearchWindow :: constructPlaylistContextMenu(void) throw ()
|
|||
/*------------------------------------------------------------------------------
|
||||
* Construct the right-click context menu for remote audio clips & playlists.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::Menu *
|
||||
Ptr<Gtk::Menu>::Ref
|
||||
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();
|
||||
|
||||
try {
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("downloadFromHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SearchWindow::onDownloadFromHub)));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("downloadFromHubMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&SearchWindow::onDownloadFromHub)));
|
||||
|
||||
contextMenu->accelerate(*this);
|
||||
contextMenu->accelerate(*mainWindow);
|
||||
return contextMenu;
|
||||
}
|
||||
|
||||
|
@ -1302,25 +1136,12 @@ SearchWindow :: updatePagingToolbar(void) throw ()
|
|||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
backwardButton->setDisabled(offset == 0);
|
||||
forwardButton->setDisabled(offset + getSearchResultsSize() >= count);
|
||||
backwardButton->set_sensitive(offset == 0);
|
||||
forwardButton->set_sensitive(offset + getSearchResultsSize() >= count);
|
||||
} else {
|
||||
searchResultsCountLabel->set_text("");
|
||||
backwardButton->setDisabled(true);
|
||||
forwardButton->setDisabled(true);
|
||||
backwardButton->set_sensitive(false);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,17 +41,16 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm.h>
|
||||
|
||||
#include "BasicWindow.h"
|
||||
#include "LiveSupport/Core/NumericTools.h"
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
|
||||
#include "LiveSupport/Widgets/ScrolledWindow.h"
|
||||
#include "LiveSupport/Widgets/ScrolledNotebook.h"
|
||||
#include "GuiWindow.h"
|
||||
#include "AdvancedSearchEntry.h"
|
||||
#include "BrowseEntry.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
@ -80,10 +79,16 @@ using namespace LiveSupport::Widgets;
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
class SearchWindow : public GuiWindow
|
||||
class SearchWindow : public BasicWindow,
|
||||
private NumericTools
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The directory where the Glade files are.
|
||||
*/
|
||||
Glib::ustring gladeDir;
|
||||
|
||||
/**
|
||||
* The criteria for the last local search.
|
||||
*/
|
||||
|
@ -112,32 +117,32 @@ class SearchWindow : public GuiWindow
|
|||
/**
|
||||
* The simple search input field.
|
||||
*/
|
||||
EntryBin * simpleSearchEntry;
|
||||
Gtk::Entry * simpleSearchEntry;
|
||||
|
||||
/**
|
||||
* The box containing the advanced search input fields.
|
||||
*/
|
||||
AdvancedSearchEntry * advancedSearchEntry;
|
||||
Ptr<AdvancedSearchEntry>::Ref advancedSearchEntry;
|
||||
|
||||
/**
|
||||
* The box containing the browse input fields.
|
||||
*/
|
||||
BrowseEntry * browseEntry;
|
||||
Ptr<BrowseEntry>::Ref browseEntry;
|
||||
|
||||
/**
|
||||
* The list of transports in progress.
|
||||
*/
|
||||
TransportList * transportList;
|
||||
Ptr<TransportList>::Ref transportList;
|
||||
|
||||
/**
|
||||
* The button for paging in the search results backward.
|
||||
*/
|
||||
Button * backwardButton;
|
||||
Gtk::Button * backwardButton;
|
||||
|
||||
/**
|
||||
* The button for paging in the search results forward.
|
||||
*/
|
||||
Button * forwardButton;
|
||||
Gtk::Button * forwardButton;
|
||||
|
||||
/**
|
||||
* The Schedule Playlist pop-up window.
|
||||
|
@ -172,7 +177,7 @@ class SearchWindow : public GuiWindow
|
|||
/**
|
||||
* The notebook for the various tabs in the window.
|
||||
*/
|
||||
ScrolledNotebook * searchInput;
|
||||
Gtk::Notebook * searchInput;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Gtk::Menu * audioClipContextMenu;
|
||||
Ptr<Gtk::Menu>::Ref audioClipContextMenu;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Gtk::Menu * remoteContextMenu;
|
||||
Ptr<Gtk::Menu>::Ref remoteContextMenu;
|
||||
|
||||
/**
|
||||
* Construct the "search where" box.
|
||||
* This contains a combo box, where the user can choose between
|
||||
* local search or hub search.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructSearchWhereBox(void) throw ();
|
||||
|
||||
/**
|
||||
|
@ -212,67 +215,57 @@ class SearchWindow : public GuiWindow
|
|||
* items (both audio clips and playlists) where either the title
|
||||
* (dc:title), the creator (dc:creator) or the album (dc:source)
|
||||
* metadata fields contain this string.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructSimpleSearchView(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the advanced search view.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructAdvancedSearchView(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the browse view.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructBrowseView(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the advanced search view.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
void
|
||||
constructTransportsView(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the search results display.
|
||||
*
|
||||
* @return a pointer to the new view (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::Box *
|
||||
void
|
||||
constructSearchResultsView(void) throw ();
|
||||
|
||||
/**
|
||||
* 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 ();
|
||||
|
||||
/**
|
||||
* 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 ();
|
||||
|
||||
/**
|
||||
* Construct the right-click context menu for remote audio clips
|
||||
* 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 ();
|
||||
|
||||
/**
|
||||
|
@ -406,15 +399,6 @@ class SearchWindow : public GuiWindow
|
|||
displayRemoteSearchError(const XmlRpcException & error)
|
||||
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:
|
||||
|
||||
|
@ -610,15 +594,6 @@ class SearchWindow : public GuiWindow
|
|||
void
|
||||
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:
|
||||
|
||||
|
@ -629,12 +604,14 @@ class SearchWindow : public GuiWindow
|
|||
* all the vital info.
|
||||
* @param bundle the resource bundle holding the localized
|
||||
* resources for this window.
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* @param windowOpenerButton the button which was pressed to open
|
||||
* this window.
|
||||
* @param gladeDir the directory where the glade file is.
|
||||
*/
|
||||
SearchWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Button * windowOpenerButton)
|
||||
Gtk::ToggleButton * windowOpenerButton,
|
||||
const Glib::ustring & gladeDir)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
@ -660,6 +637,15 @@ class SearchWindow : public GuiWindow
|
|||
*/
|
||||
bool
|
||||
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 */
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::StorageClient;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -89,63 +88,52 @@ const Glib::ustring downloadSymbol = "⇩";
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
TransportList :: TransportList (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
TransportList :: TransportList(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle,
|
||||
Glib::RefPtr<Gnome::Glade::Xml> glade)
|
||||
throw ()
|
||||
: LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
|
||||
|
||||
// create the tree view
|
||||
treeModel = Gtk::ListStore::create(modelColumns);
|
||||
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel));
|
||||
treeView->set_enable_search(false);
|
||||
glade->get_widget_derived("transportsTreeView1", treeView);
|
||||
treeView->set_model(treeModel);
|
||||
treeView->connectModelSignals(treeModel);
|
||||
|
||||
// Add the TreeView's view columns:
|
||||
try {
|
||||
treeView->appendColumn("",
|
||||
modelColumns.directionColumn, 20);
|
||||
treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn, 300);
|
||||
treeView->appendColumn(*getResourceUstring("dateColumnLabel"),
|
||||
modelColumns.dateColumn, 180);
|
||||
treeView->appendColumn(*getResourceUstring("statusColumnLabel"),
|
||||
modelColumns.statusDisplayColumn, 50);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
treeView->appendColumn("",
|
||||
modelColumns.directionColumn, 20);
|
||||
treeView->appendColumn(*getResourceUstring("titleColumnLabel"),
|
||||
modelColumns.titleColumn, 300);
|
||||
treeView->appendColumn(*getResourceUstring("dateColumnLabel"),
|
||||
modelColumns.dateColumn, 180);
|
||||
treeView->appendColumn(*getResourceUstring("statusColumnLabel"),
|
||||
modelColumns.statusDisplayColumn, 50);
|
||||
|
||||
// register the signal handler for treeview entries being clicked
|
||||
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
||||
&TransportList::onEntryClicked));
|
||||
|
||||
// create the right-click entry context menu
|
||||
uploadMenu = Gtk::manage(new Gtk::Menu());
|
||||
downloadMenu = Gtk::manage(new Gtk::Menu());
|
||||
uploadMenu.reset(new Gtk::Menu());
|
||||
downloadMenu.reset(new Gtk::Menu());
|
||||
Gtk::Menu::MenuList& uploadMenuList = uploadMenu->items();
|
||||
Gtk::Menu::MenuList& downloadMenuList = downloadMenu->items();
|
||||
|
||||
try{
|
||||
uploadMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cancelUploadMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&TransportList::onCancelTransport)));
|
||||
downloadMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cancelDownloadMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&TransportList::onCancelTransport)));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
uploadMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cancelUploadMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&TransportList::onCancelTransport)));
|
||||
downloadMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
|
||||
*getResourceUstring("cancelDownloadMenuItem"),
|
||||
sigc::mem_fun(*this,
|
||||
&TransportList::onCancelTransport)));
|
||||
|
||||
uploadMenu->accelerate(*this);
|
||||
downloadMenu->accelerate(*this);
|
||||
|
||||
// add the tree view to this widget
|
||||
Gtk::VBox::pack_start(*treeView);
|
||||
Gtk::Window * mainWindow;
|
||||
glade->get_widget("mainWindow1", mainWindow);
|
||||
uploadMenu->accelerate(*mainWindow);
|
||||
downloadMenu->accelerate(*mainWindow);
|
||||
|
||||
userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName));
|
||||
}
|
||||
|
@ -486,7 +474,7 @@ TransportList :: onCancelTransport(void) throw ()
|
|||
removeSelected();
|
||||
|
||||
} catch (XmlRpcException &e) {
|
||||
gLiveSupport->displayMessageWindow(formatMessage(
|
||||
gLiveSupport->displayMessageWindow(*formatMessage(
|
||||
"cannotCancelTransportMsg",
|
||||
e.what() ));
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue