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/>.
22
#define __USE_XOPEN_EXTENDED
24
#include <glib/gstdio.h>
25
#include <glib/gi18n.h>
27
#include "cairo-dock-struct.h"
28
#include "cairo-dock-modules.h"
29
#include "cairo-dock-log.h"
30
#include "cairo-dock-gui-factory.h"
31
#include "cairo-dock-gui-callbacks.h"
32
#include "cairo-dock-keyfile-utilities.h"
33
#include "cairo-dock-animations.h"
34
#include "cairo-dock-dialogs.h"
35
#include "cairo-dock-dock-manager.h"
36
#include "cairo-dock-dock-factory.h"
37
#include "cairo-dock-launcher-factory.h"
38
#include "cairo-dock-internal-taskbar.h"
39
#include "cairo-dock-internal-accessibility.h"
40
#include "cairo-dock-internal-icons.h"
41
#include "cairo-dock-internal-views.h"
42
#include "cairo-dock-desktop-file-factory.h"
43
#include "cairo-dock-gui-simple.h"
45
#define CAIRO_DOCK_PREVIEW_WIDTH 200
46
#define CAIRO_DOCK_PREVIEW_HEIGHT 250
47
#define CAIRO_DOCK_SIMPLE_PANEL_WIDTH 1000
48
#define CAIRO_DOCK_SIMPLE_PANEL_HEIGHT 800
50
static GtkWidget *s_pSimpleConfigWindow = NULL;
51
static int s_iIconSize;
53
extern gchar *g_cConfFile;
54
extern gchar *g_cCurrentThemePath;
55
extern CairoDock *g_pMainDock;
56
extern int g_iXScreenWidth[2], g_iXScreenHeight[2];
57
extern gchar *g_cCairoDockDataDir;
59
#define cd_reload(module_name) do {\
60
pInternalModule = cairo_dock_find_internal_module_from_name (module_name);\
61
if (pInternalModule != NULL) \
62
cairo_dock_reload_internal_module_from_keyfile (pInternalModule, pKeyFile);\
65
static gboolean on_apply_config_simple (gpointer data)
69
//\_____________ On actualise le fichier de conf principal.
70
// on ouvre les 2 fichiers (l'un en lecture, l'autre en ecriture).
71
gchar *cConfFilePath = g_strdup_printf ("%s/%s", g_cCurrentThemePath, CAIRO_DOCK_SIMPLE_CONF_FILE);
72
GKeyFile* pSimpleKeyFile = cairo_dock_open_key_file (cConfFilePath);
73
g_free (cConfFilePath);
74
g_return_val_if_fail (pSimpleKeyFile != NULL, TRUE);
75
GKeyFile* pKeyFile = cairo_dock_open_key_file (g_cConfFile);
76
g_return_val_if_fail (pKeyFile != NULL, TRUE);
79
CairoDockPositionType iScreenBorder = g_key_file_get_integer (pSimpleKeyFile, "Behavior", "screen border", NULL);
80
g_key_file_set_integer (pKeyFile, "Position", "screen border", iScreenBorder);
82
int iVisibility = g_key_file_get_integer (pSimpleKeyFile, "Behavior", "visibility", NULL);
83
g_key_file_set_integer (pKeyFile, "Accessibility", "visibility", iVisibility);
85
gboolean bShowOnClick = g_key_file_get_boolean (pSimpleKeyFile, "Behavior", "show on click", NULL);
86
g_key_file_set_boolean (pKeyFile, "Accessibility", "show on click", bShowOnClick);
88
int iTaskbarType = g_key_file_get_integer (pSimpleKeyFile, "Behavior", "taskbar", NULL);
89
gboolean bShowAppli = TRUE, bHideVisible, bCurrentDesktopOnly, bMixLauncherAppli, bGroupAppliByClass;
96
bMixLauncherAppli = TRUE;
98
bGroupAppliByClass = FALSE;
99
bCurrentDesktopOnly = FALSE;
102
bMixLauncherAppli = TRUE;
103
bGroupAppliByClass = TRUE;
104
bHideVisible = FALSE;
105
bCurrentDesktopOnly = FALSE;
109
bCurrentDesktopOnly = TRUE;
110
bMixLauncherAppli = FALSE;
111
bGroupAppliByClass = FALSE;
112
bHideVisible = FALSE;
115
g_key_file_set_boolean (pKeyFile, "TaskBar", "show applications", bShowAppli);
116
if (bShowAppli) // sinon on inutile de modifier les autres parametres.
118
g_key_file_set_boolean (pKeyFile, "TaskBar", "hide visible", bHideVisible);
119
g_key_file_set_boolean (pKeyFile, "TaskBar", "current desktop only", bCurrentDesktopOnly);
120
g_key_file_set_boolean (pKeyFile, "TaskBar", "mix launcher appli", bMixLauncherAppli);
121
g_key_file_set_boolean (pKeyFile, "TaskBar", "group by class", bGroupAppliByClass);
125
gchar *cIconTheme = g_key_file_get_string (pSimpleKeyFile, "Appearance", "default icon directory", NULL);
126
g_key_file_set_string (pKeyFile, "Icons", "default icon directory", cIconTheme);
129
int iIconSize = g_key_file_get_integer (pSimpleKeyFile, "Appearance", "icon size", NULL);
130
if (iIconSize != s_iIconSize)
132
int iLauncherSize, iIconGap;
133
double fMaxScale, fReflectSize;
136
case 0: // tres petites
161
case 4: // tres grandes
169
gint tab[2] = {iLauncherSize, iLauncherSize};
170
g_key_file_set_integer_list (pKeyFile, "Icons", "launcher size", tab, 2);
171
g_key_file_set_integer_list (pKeyFile, "Icons", "appli size", tab, 2);
172
g_key_file_set_integer_list (pKeyFile, "Icons", "applet size", tab, 2);
173
/// hauteur des separateurs ?...
174
g_key_file_set_double (pKeyFile, "Icons", "zoom max", fMaxScale);
175
g_key_file_set_double (pKeyFile, "Icons", "field depth", fReflectSize);
176
g_key_file_set_integer (pKeyFile, "Icons", "icon gap", iIconGap);
177
s_iIconSize = iIconSize;
180
gchar *cIconOrder = g_key_file_get_string (pSimpleKeyFile, "Appearance", "icon's type order", NULL);
181
g_key_file_set_string (pKeyFile, "Icons", "icon's type order", cIconOrder);
184
gboolean bMixAppletsAndLaunchers = g_key_file_get_boolean (pSimpleKeyFile, "Appearance", "mix applets with launchers", NULL);
185
g_key_file_set_boolean (pKeyFile, "Icons", "mix applets with launchers", bMixAppletsAndLaunchers);
187
gchar *cMainDockDefaultRendererName = g_key_file_get_string (pSimpleKeyFile, "Appearance", "main dock view", NULL);
188
g_key_file_set_string (pKeyFile, "Views", "main dock view", cMainDockDefaultRendererName);
189
g_free (cMainDockDefaultRendererName);
191
gchar *cSubDockDefaultRendererName = g_key_file_get_string (pSimpleKeyFile, "Appearance", "sub-dock view", NULL);
192
g_key_file_set_string (pKeyFile, "Views", "sub-dock view", cSubDockDefaultRendererName);
193
g_free (cSubDockDefaultRendererName);
197
cairo_dock_write_keys_to_file (pKeyFile, g_cConfFile);
199
//\_____________ On recharge les modules concernes.
200
CairoDockInternalModule *pInternalModule;
201
cd_reload ("Position");
202
cd_reload ("Accessibility");
203
cd_reload ("TaskBar");
207
/// recharger aussi les plug-ins d'animation...
213
static void on_destroy_config_simple (gpointer data)
216
s_pSimpleConfigWindow = NULL;
220
GtkWidget *cairo_dock_build_simplified_ihm ()
222
if (s_pSimpleConfigWindow != NULL)
224
gtk_window_present (GTK_WINDOW (s_pSimpleConfigWindow));
225
return s_pSimpleConfigWindow;
228
//\_____________ On actualise le fichier de conf simple.
229
// on cree le fichier au besoin, et on l'ouvre.
230
gchar *cConfFilePath = g_strdup_printf ("%s/%s", g_cCurrentThemePath, CAIRO_DOCK_SIMPLE_CONF_FILE);
231
if (! g_file_test (cConfFilePath, G_FILE_TEST_EXISTS))
233
gchar *cCommand = g_strdup_printf ("cp \"%s/%s\" \"%s\"", CAIRO_DOCK_SHARE_DATA_DIR, CAIRO_DOCK_SIMPLE_CONF_FILE, cConfFilePath);
234
int r = system (cCommand);
238
GKeyFile* pSimpleKeyFile = cairo_dock_open_key_file (cConfFilePath);
239
g_return_val_if_fail (pSimpleKeyFile != NULL, NULL);
242
CairoDockPositionType iScreenBorder = ((! g_pMainDock->container.bIsHorizontal) << 1) | (! g_pMainDock->container.bDirectionUp);
243
g_key_file_set_integer (pSimpleKeyFile, "Behavior", "screen border", iScreenBorder);
245
gboolean iVisibility;
246
if (myAccessibility.bReserveSpace)
248
else if (myAccessibility.bPopUp)
250
else if (myAccessibility.bAutoHide)
252
else if (myAccessibility.bAutoHideOnMaximized)
254
else if (myAccessibility.cRaiseDockShortcut)
258
g_key_file_set_integer (pSimpleKeyFile, "Behavior", "visibility", iVisibility);
260
g_key_file_set_boolean (pSimpleKeyFile, "Behavior", "show on click", myAccessibility.bShowSubDockOnClick);
263
if (! myTaskBar.bShowAppli)
265
else if (myTaskBar.bHideVisibleApplis)
267
else if (myTaskBar.bGroupAppliByClass)
271
g_key_file_set_integer (pSimpleKeyFile, "Behavior", "taskbar", iTaskbarType);
274
g_key_file_set_string (pSimpleKeyFile, "Appearance", "default icon directory", myIcons.cIconTheme);
277
if (myIcons.tIconAuthorizedWidth[CAIRO_DOCK_LAUNCHER] <= 42) // icones toutes petites.
279
else if (myIcons.tIconAuthorizedWidth[CAIRO_DOCK_LAUNCHER] >= 54) // icones tres grandes.
281
else if (myIcons.tIconAuthorizedWidth[CAIRO_DOCK_LAUNCHER] <= 48)
283
if (myIcons.fAmplitude >= 2) // icones petites.
286
iIconSize = 3; // moyennes.
291
g_key_file_set_integer (pSimpleKeyFile, "Appearance", "icon size", iIconSize);
292
s_iIconSize = iIconSize;
294
g_key_file_set_integer_list (pSimpleKeyFile, "Appearance", "icon's type order", myIcons.iIconsTypesList, 3);
296
g_key_file_set_boolean (pSimpleKeyFile, "Appearance", "mix applets with launchers", myIcons.bMixAppletsAndLaunchers);
298
g_key_file_set_string (pSimpleKeyFile, "Appearance", "main dock view", myViews.cMainDockDefaultRendererName);
300
g_key_file_set_string (pSimpleKeyFile, "Appearance", "sub-dock view", myViews.cSubDockDefaultRendererName);
304
cairo_dock_write_keys_to_file (pSimpleKeyFile, cConfFilePath);
306
//\_____________ On construit la fenetre.
307
cairo_dock_build_normal_gui (cConfFilePath,
311
(CairoDockApplyConfigFunc) on_apply_config_simple,
313
(GFreeFunc) on_destroy_config_simple,
314
&s_pSimpleConfigWindow);