add more Theme wrapper functions
TODO: wrap Eina_List functions, but before enhance Eina::List wrapper SVN revision: 79354
This commit is contained in:
parent
04dd63f9e7
commit
e23711d0ac
|
@ -12,17 +12,13 @@
|
|||
|
||||
namespace Elmxx {
|
||||
|
||||
/*!
|
||||
* smart callbacks called:
|
||||
* "changed" - the user toggled the state
|
||||
*/
|
||||
class Theme
|
||||
{
|
||||
public:
|
||||
Theme ();
|
||||
Theme (bool default_theme = true);
|
||||
~Theme ();
|
||||
Theme (const Theme &th); // specific copy constructor
|
||||
|
||||
|
||||
/**
|
||||
* Prepends a theme overlay to the list of overlays
|
||||
*
|
||||
|
@ -86,6 +82,96 @@ public:
|
|||
* @ingroup Theme
|
||||
*/
|
||||
void delExtension (const std::string& item);
|
||||
|
||||
/**
|
||||
* Set the theme search order for the given theme
|
||||
*
|
||||
* @param theme Theme search string
|
||||
*
|
||||
* This sets the search string for the theme in path-notation from first
|
||||
* theme to search, to last, delimited by the : character. Example:
|
||||
*
|
||||
* "shiny:/path/to/file.edj:default"
|
||||
*
|
||||
* See the ELM_THEME environment variable for more information.
|
||||
*
|
||||
* @see getTheme()
|
||||
* @see getThemeList()
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
void setTheme (const std::string &theme);
|
||||
|
||||
/**
|
||||
* Return the theme search order
|
||||
*
|
||||
* @return The internal search order path
|
||||
*
|
||||
* This function returns a colon separated string of theme elements as
|
||||
* returned by elm_theme_list_get().
|
||||
*
|
||||
* @see elm_theme_set()
|
||||
* @see elm_theme_list_get()
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
std::string getTheme ();
|
||||
|
||||
/**
|
||||
* Return the full path for a theme element
|
||||
*
|
||||
* @param f The theme element name
|
||||
* @param in_search_path Reference to a boolean to indicate if item is in the search path or not
|
||||
* @return The full path to the file found.
|
||||
*
|
||||
* This returns a string you should free with free() on success, NULL on
|
||||
* failure. This will search for the given theme element, and if it is a
|
||||
* full or relative path element or a simple search-able name. The returned
|
||||
* path is the full path to the file, if searched, and the file exists, or it
|
||||
* is simply the full path given in the element or a resolved path if
|
||||
* relative to home. The @p in_search_path boolean pointed to is set to
|
||||
* EINA_TRUE if the file was a search-able file and is in the search path,
|
||||
* and EINA_FALSE otherwise.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
static std::string getItemListPath (const std::string &f, bool &in_search_path);
|
||||
|
||||
/**
|
||||
* Flush the current theme.
|
||||
*
|
||||
*
|
||||
* This flushes caches that let elementary know where to find theme elements
|
||||
* in the given theme. If @p th is NULL, then the default theme is flushed.
|
||||
* Call this function if source theme data has changed in such a way as to
|
||||
* make any caches Elementary kept invalid.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
void flush ();
|
||||
|
||||
/**
|
||||
* This flushes all themes (default and specific ones).
|
||||
*
|
||||
* This will flush all themes in the current application context, by calling
|
||||
* flush() on each of them.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
static void flushFull ();
|
||||
|
||||
/**
|
||||
* Get a data item from a theme
|
||||
*
|
||||
* @param key The data key to search with
|
||||
* @return The data value, or NULL on failure
|
||||
*
|
||||
* This function is used to return data items from edc in @p th, an overlay, or an extension.
|
||||
* It works the same way as edje_file_data_get() except that the return is stringshared.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
std::string getData (const std::string &key);
|
||||
|
||||
private:
|
||||
Elm_Theme *mTheme;
|
||||
|
@ -122,18 +208,6 @@ EAPI void elm_theme_ref_set(Elm_Theme *th, Elm_Theme *thref);
|
|||
*/
|
||||
EAPI Elm_Theme *elm_theme_ref_get(Elm_Theme *th);
|
||||
|
||||
/**
|
||||
* Return the default theme
|
||||
*
|
||||
* @return The default theme handle
|
||||
*
|
||||
* This returns the internal default theme setup handle that all widgets
|
||||
* use implicitly unless a specific theme is set. This is also often use
|
||||
* as a shorthand of NULL.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
EAPI Elm_Theme *elm_theme_default_get(void);
|
||||
|
||||
/**
|
||||
* Get the list of registered overlays for the given theme
|
||||
|
@ -160,41 +234,7 @@ EAPI const Eina_List *elm_theme_overlay_list_get(const Elm_Theme *th);
|
|||
*/
|
||||
EAPI const Eina_List *elm_theme_extension_list_get(const Elm_Theme *th);
|
||||
|
||||
/**
|
||||
* Set the theme search order for the given theme
|
||||
*
|
||||
* @param th The theme to set the search order, or if NULL, the default theme
|
||||
* @param theme Theme search string
|
||||
*
|
||||
* This sets the search string for the theme in path-notation from first
|
||||
* theme to search, to last, delimited by the : character. Example:
|
||||
*
|
||||
* "shiny:/path/to/file.edj:default"
|
||||
*
|
||||
* See the ELM_THEME environment variable for more information.
|
||||
*
|
||||
* @see elm_theme_get()
|
||||
* @see elm_theme_list_get()
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
EAPI void elm_theme_set(Elm_Theme *th, const char *theme);
|
||||
|
||||
/**
|
||||
* Return the theme search order
|
||||
*
|
||||
* @param th The theme to get the search order, or if NULL, the default theme
|
||||
* @return The internal search order path
|
||||
*
|
||||
* This function returns a colon separated string of theme elements as
|
||||
* returned by elm_theme_list_get().
|
||||
*
|
||||
* @see elm_theme_set()
|
||||
* @see elm_theme_list_get()
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
EAPI const char *elm_theme_get(Elm_Theme *th);
|
||||
|
||||
/**
|
||||
* Return a list of theme elements to be used in a theme.
|
||||
|
@ -219,49 +259,9 @@ EAPI const char *elm_theme_get(Elm_Theme *th);
|
|||
*/
|
||||
EAPI const Eina_List *elm_theme_list_get(const Elm_Theme *th);
|
||||
|
||||
/**
|
||||
* Return the full path for a theme element
|
||||
*
|
||||
* @param f The theme element name
|
||||
* @param in_search_path Pointer to a boolean to indicate if item is in the search path or not
|
||||
* @return The full path to the file found.
|
||||
*
|
||||
* This returns a string you should free with free() on success, NULL on
|
||||
* failure. This will search for the given theme element, and if it is a
|
||||
* full or relative path element or a simple search-able name. The returned
|
||||
* path is the full path to the file, if searched, and the file exists, or it
|
||||
* is simply the full path given in the element or a resolved path if
|
||||
* relative to home. The @p in_search_path boolean pointed to is set to
|
||||
* EINA_TRUE if the file was a search-able file and is in the search path,
|
||||
* and EINA_FALSE otherwise.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
EAPI char *elm_theme_list_item_path_get(const char *f, Eina_Bool *in_search_path);
|
||||
|
||||
/**
|
||||
* Flush the current theme.
|
||||
*
|
||||
* @param th Theme to flush
|
||||
*
|
||||
* This flushes caches that let elementary know where to find theme elements
|
||||
* in the given theme. If @p th is NULL, then the default theme is flushed.
|
||||
* Call this function if source theme data has changed in such a way as to
|
||||
* make any caches Elementary kept invalid.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
EAPI void elm_theme_flush(Elm_Theme *th);
|
||||
|
||||
/**
|
||||
* This flushes all themes (default and specific ones).
|
||||
*
|
||||
* This will flush all themes in the current application context, by calling
|
||||
* elm_theme_flush() on each of them.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
EAPI void elm_theme_full_flush(void);
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of theme elements in the theme search path
|
||||
|
@ -322,19 +322,7 @@ EAPI void elm_object_theme_set(Evas_Object *obj, Elm_Theme *th);
|
|||
*/
|
||||
EAPI Elm_Theme *elm_object_theme_get(const Evas_Object *obj);
|
||||
|
||||
/**
|
||||
* Get a data item from a theme
|
||||
*
|
||||
* @param th The theme, or NULL for default theme
|
||||
* @param key The data key to search with
|
||||
* @return The data value, or NULL on failure
|
||||
*
|
||||
* This function is used to return data items from edc in @p th, an overlay, or an extension.
|
||||
* It works the same way as edje_file_data_get() except that the return is stringshared.
|
||||
*
|
||||
* @ingroup Theme
|
||||
*/
|
||||
EAPI const char *elm_theme_data_get(Elm_Theme *th, const char *key);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,14 +8,24 @@ using namespace std;
|
|||
|
||||
namespace Elmxx {
|
||||
|
||||
Theme::Theme () :
|
||||
mTheme (NULL) // elm_theme_new ()
|
||||
Theme::Theme (bool default_theme)
|
||||
{
|
||||
if (default_theme)
|
||||
{
|
||||
mTheme = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
mTheme = elm_theme_new ();
|
||||
}
|
||||
}
|
||||
|
||||
Theme::~Theme ()
|
||||
{
|
||||
//elm_theme_free (mTheme);
|
||||
if (mTheme)
|
||||
{
|
||||
elm_theme_free (mTheme);
|
||||
}
|
||||
}
|
||||
|
||||
Theme::Theme (const Theme &th)
|
||||
|
@ -43,5 +53,39 @@ void Theme::delExtension (const std::string& item)
|
|||
elm_theme_extension_del(mTheme, item.c_str());
|
||||
}
|
||||
|
||||
void Theme::setTheme (const std::string &theme)
|
||||
{
|
||||
elm_theme_set(mTheme, theme.c_str());
|
||||
}
|
||||
|
||||
std::string Theme::getTheme ()
|
||||
{
|
||||
return elm_theme_get(mTheme);
|
||||
}
|
||||
|
||||
std::string Theme::getItemListPath (const std::string &f, bool &in_search_path)
|
||||
{
|
||||
Eina_Bool b;
|
||||
|
||||
const char *ret = elm_theme_list_item_path_get(f.c_str(), &b);
|
||||
in_search_path = b;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Theme::flush ()
|
||||
{
|
||||
elm_theme_flush(mTheme);
|
||||
}
|
||||
|
||||
void Theme::flushFull ()
|
||||
{
|
||||
elm_theme_full_flush();
|
||||
}
|
||||
|
||||
std::string Theme::getData (const std::string &key)
|
||||
{
|
||||
return elm_theme_data_get(mTheme, key.c_str());
|
||||
}
|
||||
|
||||
} // end namespace Elmxx
|
||||
|
|
Loading…
Reference in New Issue