2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef __CAIRO_DOCK_THEMES_MANAGER__
22
#define __CAIRO_DOCK_THEMES_MANAGER__
28
/**@file cairo-dock-themes-manager.h This class provides a convenient way to use themes.
30
* local (installed as root in a sub-folder of /usr/share/cairo-dock)
31
* user (located in a sub-folder of ~/.config/cairo-dock)
32
* distant (located on the cairo-dock's server)
33
* The class offers a high level of abstraction that allows to manipulate themes without having to care their location, version, etc.
38
CAIRO_DOCK_LOCAL_THEME=0,
39
CAIRO_DOCK_USER_THEME,
40
CAIRO_DOCK_DISTANT_THEME,
42
CAIRO_DOCK_UPDATED_THEME,
44
CAIRO_DOCK_NB_TYPE_THEME
47
/// Definition of a generic theme.
48
struct _CairoDockTheme {
49
/// complete path of the theme.
56
gchar *cDisplayedName;
57
/// type of theme : installed, user, distant.
58
CairoDockThemeType iType;
59
/// rating of the theme, between 1 and 5.
61
/// gint sobriety/simplicity of the theme, between 1 and 5.
63
/// date of creation of the theme.
65
/// date of latest changes in the theme.
69
/** Destroy a theme and free all its allocated memory.
70
*@param pTheme the theme.
72
void cairo_dock_free_theme (CairoDockTheme *pTheme);
75
gchar *cairo_dock_uncompress_file (const gchar *cArchivePath, const gchar *cExtractTo, const gchar *cRealArchiveName);
77
/** Download a distant file into a given folder, possibly extracting it.
78
*@param cServerAdress adress of the server.
79
*@param cDistantFilePath path of the file on the server.
80
*@param cDistantFileName name of the file.
81
*@param cExtractTo a local path where to extract the file, if this one is a .tar.gz/.tar.bz2/.tgz archive, or NULL.
82
*@param erreur an error.
83
*@return the local path of the downloaded file. If it was an archive, the path of the extracted file. Free the string after using it.
85
gchar *cairo_dock_download_file (const gchar *cServerAdress, const gchar *cDistantFilePath, const gchar *cDistantFileName, const gchar *cExtractTo, GError **erreur);
87
/** Asynchronously download a distant file into a given folder, possibly extracting it. This function is non-blocking, you'll get a CairoTask that you can discard at any time, and you'll get the path of the downloaded file as the first argument of the callback (the second being the data you passed to this function).
88
*@param cServerAdress adress of the server.
89
*@param cDistantFilePath path of the file on the server.
90
*@param cDistantFileName name of the file.
91
*@param cExtractTo a local path where to extract the file, if this one is a .tar.gz/.tar.bz2/.tgz archive, or NULL.
92
*@param pCallback function called when the download is finished. It takes the path of the downloaded file (it belongs to the task so don't free it) and the data you've set here.
93
*@param data data to be passed to the callback.
94
*@return the Task that is doing the job. Keep it and use \ref cairo_dock_discard_task whenever you want to discard the download (for instance if the user cancels it).
96
CairoDockTask *cairo_dock_download_file_async (const gchar *cServerAdress, const gchar *cDistantFilePath, const gchar *cDistantFileName, const gchar *cExtractTo, GFunc pCallback, gpointer data);
98
/** Retrieve the content of a distant text file.
99
*@param cServerAdress adress of the server.
100
*@param cDistantFilePath path of the file on the server.
101
*@param cDistantFileName name of the file.
102
*@param erreur an error.
103
*@return the content of the file. Free the string after using it.
105
gchar *cairo_dock_get_distant_file_content (const gchar *cServerAdress, const gchar *cDistantFilePath, const gchar *cDistantFileName, GError **erreur);
107
/** Asynchronously retrieve the content of a distant text file. This function is non-blocking, you'll get a CairoTask that you can discard at any time, and you'll get the content of the downloaded file as the first argument of the callback (the second being the data you passed to this function).
108
*@param cServerAdress adress of the server.
109
*@param cDistantFilePath path of the file on the server.
110
*@param cDistantFileName name of the file.
111
*@param pCallback function called when the download is finished. It takes the content of the downloaded file (it belongs to the task so don't free it) and the data you've set here.
112
*@param data data to be passed to the callback.
113
*@return the Task that is doing the job. Keep it and use \ref cairo_dock_discard_task whenever you want to discard the download (for instance if the user cancels it).
115
CairoDockTask *cairo_dock_get_distant_file_content_async (const gchar *cServerAdress, const gchar *cDistantFilePath, const gchar *cDistantFileName, GFunc pCallback, gpointer data);
118
GHashTable *cairo_dock_list_local_themes (const gchar *cThemesDir, GHashTable *hProvidedTable, gboolean bUpdateThemeValidity, GError **erreur);
120
GHashTable *cairo_dock_list_net_themes (const gchar *cServerAdress, const gchar *cDirectory, const gchar *cListFileName, GHashTable *hProvidedTable, GError **erreur);
122
/** Get a list of themes from differente sources.
123
*@param cShareThemesDir path of a local folder containg themes or NULL.
124
*@param cUserThemesDir path of a user folder containg themes or NULL.
125
*@param cDistantThemesDir path of a distant folder containg themes or NULL.
126
*@return a hash table of (name, #_CairoDockTheme).
128
GHashTable *cairo_dock_list_themes (const gchar *cShareThemesDir, const gchar *cUserThemesDir, const gchar *cDistantThemesDir);
130
/** Asynchronously get a list of themes from differente sources. This function is non-blocking, you'll get a CairoTask that you can discard at any time, and you'll get a hash-table of the themes as the first argument of the callback (the second being the data you passed to this function).
131
*@param cShareThemesDir path of a local folder containg themes or NULL.
132
*@param cUserThemesDir path of a user folder containg themes or NULL.
133
*@param cDistantThemesDir path of a distant folder containg themes or NULL.
134
*@param pCallback function called when the listing is finished. It takes the hash-table of the found themes (it belongs to the task so don't free it) and the data you've set here.
135
*@param data data to be passed to the callback.
136
*@return the Task that is doing the job. Keep it and use \ref cairo_dock_discard_task whenever you want to discard the download (for instance if the user cancels it).*/
137
CairoDockTask *cairo_dock_list_themes_async (const gchar *cShareThemesDir, const gchar *cUserThemesDir, const gchar *cDistantThemesDir, GFunc pCallback, gpointer data);
140
/** Look for a theme with a given name into differente sources. If the theme is found on the server and is not present on the disk, or is not up to date, then it is downloaded and the local path is returned.
141
*@param cThemeName name of the theme.
142
*@param cShareThemesDir path of a local folder containg themes or NULL.
143
*@param cUserThemesDir path of a user folder containg themes or NULL.
144
*@param cDistantThemesDir path of a distant folder containg themes or NULL.
145
*@param iGivenType type of theme, or CAIRO_DOCK_ANY_THEME if any type of theme should be considered.
146
*@return a newly allocated string containing the complete local path of the theme. If the theme is distant, it is downloaded and extracted into this folder.
148
gchar *cairo_dock_get_theme_path (const gchar *cThemeName, const gchar *cShareThemesDir, const gchar *cUserThemesDir, const gchar *cDistantThemesDir, CairoDockThemeType iGivenType);
151
void cairo_dock_mark_theme_as_modified (gboolean bModified);
152
gboolean cairo_dock_theme_need_save (void);
155
CairoDockThemeType cairo_dock_extract_theme_type_from_name (const gchar *cThemeName);
157
/** Export the current theme to a given name. Exported themes can be imported directly from the Theme Manager.
158
* @param cNewThemeName name to export the theme to.
159
* @param bSaveBehavior whether to save the behavior paremeters too.
160
* @param bSaveLaunchers whether to save the launchers too.
161
* @return TRUE if the theme could be exported succefuly.
163
gboolean cairo_dock_export_current_theme (const gchar *cNewThemeName, gboolean bSaveBehavior, gboolean bSaveLaunchers);
165
/** Create a package of the current theme. Packages can be distributed easily, and imported into the dock by a mere drag and drop into the Theme Manager. The package is placed in the Home.
166
* @param cThemeName name of the package.
167
* @return TRUE if the theme could be packaged succefuly.
169
gboolean cairo_dock_package_current_theme (const gchar *cThemeName);
171
/** Extract a package into the themes folder. Does not load it.
172
* @param cPackagePath path of a package. If the package is distant, it is first downoladed.
173
* @return the path of the theme folder, or NULL if anerror occured.
175
gchar * cairo_dock_depackage_theme (const gchar *cPackagePath);
177
/** Remove some exported themes from the hard-disk.
178
* @param cThemesList a list of theme names, NULL-terminated.
179
* @return TRUE if the themes has been succefuly deleted.
181
gboolean cairo_dock_delete_themes (gchar **cThemesList);
183
/** Import a theme, which can be : a local theme, a user theme, a distant theme, or even the path to a packaged theme.
184
* @param cThemeName name of the theme to import.
185
* @param bLoadBehavior whether to import the behavior parameters too.
186
* @param bLoadLaunchers whether to import the launchers too.
187
* @return TRUE if the theme could be imported succefuly.
189
gboolean cairo_dock_import_theme (const gchar *cThemeName, gboolean bLoadBehavior, gboolean bLoadLaunchers);
191
/** Asynchronously import a theme, which can be : a local theme, a user theme, a distant theme, or even the path to a packaged theme. This function is non-blocking, you'll get a CairoTask that you can discard at any time, and you'll get the result of the import as the first argument of the callback (the second being the data you passed to this function).
192
* @param cThemeName name of the theme to import.
193
* @param bLoadBehavior whether to import the behavior parameters too.
194
* @param bLoadLaunchers whether to import the launchers too.
195
* @param pCallback function called when the download is finished. It takes the result of the import (TRUE for a successful import) and the data you've set here.
196
* @param data data to be passed to the callback.
197
* @return the Task that is doing the job. Keep it and use \ref cairo_dock_discard_task whenever you want to discard the download (for instance if the user cancels it).
200
CairoDockTask *cairo_dock_import_theme_async (const gchar *cThemeName, gboolean bLoadBehavior, gboolean bLoadLaunchers, GFunc pCallback, gpointer data);
202
/** Load the current theme. This will (re)load all the parameters of Cairo-Dock and all the plug-ins, as if you just started the dock.
204
void cairo_dock_load_current_theme (void);
205
#define cairo_dock_load_theme(...) cairo_dock_load_current_theme ()
208
/* Build and show the Theme Manager window.
210
void cairo_dock_manage_themes (void);