~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to src/cairo-dock.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
**    great deal by sending me additional tweaked and optimized versions. I've
57
57
**    now merged all that with my recent additions.
58
58
**
59
 
*********************** VERSION 0.1.0 and above (2007-2009)*********************
 
59
*********************** VERSION 0.1.0 and above (2007-2010)*********************
60
60
**
61
61
** author(s) :
62
 
**     Fabrice Rey <fabounet@users.berlios.de>
 
62
**     Fabrice Rey <fabounet@glx-dock.org>
63
63
**
64
64
** notes :
65
65
**     I've completely rewritten the calculation part, and the callback system.
88
88
 
89
89
#include <gtk/gtkgl.h>
90
90
 
 
91
#include "config.h"
91
92
#include "cairo-dock-icons.h"
92
93
#include "cairo-dock-applications-manager.h"
93
94
#include "cairo-dock-callbacks.h"
95
96
#include "cairo-dock-dock-manager.h"
96
97
#include "cairo-dock-menu.h"
97
98
#include "cairo-dock-themes-manager.h"
98
 
#include "cairo-dock-dialogs.h"
 
99
#include "cairo-dock-dialog-manager.h"
99
100
#include "cairo-dock-notifications.h"
100
101
#include "cairo-dock-keyfile-utilities.h"
101
102
#include "cairo-dock-config.h"
102
103
#include "cairo-dock-file-manager.h"
103
 
#include "cairo-dock-renderer-manager.h"
 
104
#include "cairo-dock-backends-manager.h"
104
105
#include "cairo-dock-keybinder.h"
105
106
#include "cairo-dock-log.h"
106
107
#include "cairo-dock-draw.h"
108
109
#include "cairo-dock-X-utilities.h"
109
110
#include "cairo-dock-gui-manager.h"
110
111
#include "cairo-dock-gui-launcher.h"
 
112
#include "cairo-dock-gui-switch.h"
 
113
#include "cairo-dock-launcher-manager.h"
111
114
#include "cairo-dock-dbus.h"
112
115
#include "cairo-dock-load.h"
113
116
#include "cairo-dock-internal-icons.h"
114
 
#include "cairo-dock-desklet.h"
 
117
#include "cairo-dock-desklet-manager.h"
115
118
#include "cairo-dock-flying-container.h"
116
119
#include "cairo-dock-animations.h"
117
120
#include "cairo-dock-gauge.h"
118
121
#include "cairo-dock-graph.h"
119
122
#include "cairo-dock-default-view.h"
 
123
#include "cairo-dock-X-manager.h"
120
124
#include "cairo-dock-internal-system.h"
121
 
 
122
 
CairoDock *g_pMainDock;  // pointeur sur le dock principal.
123
 
GdkWindowTypeHint g_iWmHint = GDK_WINDOW_TYPE_HINT_DOCK;  // hint pour la fenetre du dock principal.
124
 
 
125
 
gchar *g_cCairoDockDataDir = NULL;  // le repertoire racine contenant tout.
126
 
gchar *g_cCurrentThemePath = NULL;  // le chemin vers le repertoire du theme courant.
127
 
gchar *g_cCurrentLaunchersPath = NULL;  // le chemin vers le repertoire des lanceurs du theme courant.
128
 
gchar *g_cCurrentIconsPath = NULL;  // le chemin vers le repertoire des icones du theme courant.
129
 
gchar *g_cConfFile = NULL;  // le chemin du fichier de conf.
130
 
int g_iMajorVersion, g_iMinorVersion, g_iMicroVersion;  // version de la lib.
131
 
 
132
 
int g_iScreenWidth[2];  // dimensions de l'ecran physique sur lequel reside le dock
133
 
int g_iScreenHeight[2];
134
 
int g_iXScreenWidth[2];  // dimensions de l'ecran logique X.
135
 
int g_iXScreenHeight[2];
136
 
int g_iNbDesktops;  // nombre de bureaux.
137
 
int g_iNbViewportX, g_iNbViewportY;  // nombre de "faces du cube".
138
 
int g_iNbNonStickyLaunchers = 0;
139
 
 
140
 
CairoDockImageBuffer g_pDockBackgroundBuffer;
141
 
CairoDockImageBuffer g_pIndicatorBuffer;
142
 
CairoDockImageBuffer g_pActiveIndicatorBuffer;
143
 
CairoDockImageBuffer g_pClassIndicatorBuffer;
144
 
CairoDockImageBuffer g_pIconBackgroundBuffer;
145
 
CairoDockImageBuffer g_pVisibleZoneBuffer;
146
 
CairoDockImageBuffer g_pBoxAboveBuffer;
147
 
CairoDockImageBuffer g_pBoxBelowBuffer;
148
 
 
149
 
gboolean g_bKeepAbove = FALSE;
150
 
gboolean g_bSkipPager = TRUE;
151
 
gboolean g_bSkipTaskbar = TRUE;
152
 
gboolean g_bSticky = TRUE;
153
 
 
154
 
gboolean g_bUseGlitz = FALSE;
155
 
gboolean g_bVerbose = FALSE;
156
 
 
157
 
CairoDockDesktopEnv g_iDesktopEnv = CAIRO_DOCK_UNKNOWN_ENV;
158
 
 
159
 
CairoDockDesktopBackground *g_pFakeTransparencyDesktopBg = NULL;
 
125
#include "cairo-dock-internal-dialogs.h"
 
126
#include "cairo-dock-indicator-manager.h"
 
127
#include "cairo-dock-internal-accessibility.h"
 
128
#include "cairo-dock-user-interaction.h"
 
129
#include "cairo-dock-hiding-effect.h"
 
130
#include "cairo-dock-icon-container.h"
 
131
#include "cairo-dock-data-renderer.h"
 
132
 
 
133
#define CAIRO_DOCK_THEME_SERVER "http://themes.glx-dock.org"  // "http://themes.cairo-dock.vef.fr"
 
134
#define CAIRO_DOCK_BACKUP_THEME_SERVER "http://fabounet03.free.fr"
 
135
 
 
136
extern gchar *g_cCairoDockDataDir;
 
137
extern gchar *g_cCurrentThemePath;
 
138
 
 
139
extern gchar *g_cConfFile;
 
140
extern int g_iMajorVersion, g_iMinorVersion, g_iMicroVersion;
 
141
 
 
142
extern CairoDock *g_pMainDock;
 
143
 
 
144
extern gboolean g_bKeepAbove;
 
145
extern gboolean g_bSticky;
 
146
 
 
147
extern gboolean g_bUseGlitz;
 
148
extern gboolean g_bUseOpenGL;
 
149
extern CairoDockDesktopEnv g_iDesktopEnv;
 
150
extern gboolean g_bEasterEggs;
 
151
 
 
152
extern CairoDockGLConfig g_openglConfig;
 
153
extern CairoDockHidingEffect *g_pKeepingBelowBackend;
 
154
extern CairoDockModuleInstance *g_pCurrentModule;
160
155
//int g_iDamageEvent = 0;
161
156
 
162
 
gchar *g_cThemeServerAdress = NULL;
163
 
gboolean g_bEasterEggs = FALSE;
164
 
gboolean g_bLocked = FALSE;
165
 
 
166
 
CairoDockGLConfig g_openglConfig;
167
 
gboolean g_bUseOpenGL = FALSE;
168
157
gboolean g_bForceCairo = FALSE;
169
 
GLuint g_iBackgroundTexture=0;
170
 
GLuint g_pGradationTexture[2]={0, 0};
171
 
 
172
 
CairoDockModuleInstance *g_pCurrentModule = NULL;
 
158
gboolean g_bLocked;
173
159
 
174
160
static gchar *s_cLaunchCommand = NULL;
 
161
static gchar *s_cLastVersion = NULL;
 
162
gboolean g_bEnterHelpOnce = FALSE;
 
163
static gchar *s_cDefaulBackend = NULL;
 
164
static gboolean s_bTestComposite = TRUE;
 
165
static gint s_iGuiMode = 0;  // 0 = simple mode, 1 = advanced mode
175
166
 
 
167
static void _accept_metacity_composition (int iClickedButton, GtkWidget *pInteractiveWidget, gpointer data, CairoDialog *pDialog)
 
168
{
 
169
        if (iClickedButton == 1)  // clic explicite sur "cancel"
 
170
        {
 
171
                int r = system ("gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool false");
 
172
        }
 
173
}
 
174
static void _toggle_remember_choice (GtkCheckButton *pButton, GtkWidget *pDialog)
 
175
{
 
176
        g_object_set_data (G_OBJECT (pDialog), "remember", GINT_TO_POINTER (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pButton))));
 
177
}
176
178
static gboolean _cairo_dock_successful_launch (gpointer data)
177
179
{
178
180
        if (g_str_has_suffix (s_cLaunchCommand, " -m"))
179
181
                s_cLaunchCommand[strlen (s_cLaunchCommand)-3] = '\0';  // on enleve le mode maintenance.
 
182
        
 
183
        //\___________________ On teste le composite maintenant (au demarrage, le composite manager peut ne pas etre lance).
 
184
        if (s_bTestComposite)
 
185
        {
 
186
                GdkScreen *pScreen = gdk_screen_get_default ();
 
187
                if (! mySystem.bUseFakeTransparency && ! gdk_screen_is_composited (pScreen))
 
188
                {
 
189
                        cd_warning ("no composite manager found");
 
190
                        // Si l'utilisateur utilise Metacity, on lui propose d'activer le composite.
 
191
                        gchar *cPsef = cairo_dock_launch_command_sync ("pgrep metacity");  // 'ps' ne marche pas, il faut le lancer dans un script :-/
 
192
                        if (cPsef != NULL && *cPsef != '\0')  // "metacity" a ete trouve.
 
193
                        {
 
194
                                Icon *pIcon = cairo_dock_get_dialogless_icon ();
 
195
                                GtkWidget *pAskBox = gtk_hbox_new (FALSE, 3);
 
196
                                GtkWidget *label = gtk_label_new (_("Don't ask me any more"));
 
197
                                GtkWidget *pCheckBox = gtk_check_button_new ();
 
198
                                gtk_box_pack_end (GTK_BOX (pAskBox), pCheckBox, FALSE, FALSE, 0);
 
199
                                gtk_box_pack_end (GTK_BOX (pAskBox), label, FALSE, FALSE, 0);
 
200
                                g_signal_connect (G_OBJECT (pCheckBox), "toggled", G_CALLBACK(_toggle_remember_choice), pAskBox);
 
201
                                int iClickedButton = cairo_dock_show_dialog_and_wait (_("To remove the black rectangle around the dock, you will need to activate a composite manager.\nFor instance, this can be done by activating desktop effects, launching Compiz, or activating the composition in Metacity.\nI can perform this last operation for you. Do you want to proceed ?"), pIcon, CAIRO_CONTAINER (g_pMainDock), 0., NULL, pAskBox);
 
202
                                
 
203
                                gboolean bRememberChoice = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pAskBox), "remember"));
 
204
                                gtk_widget_destroy (pAskBox);
 
205
                                if (bRememberChoice)
 
206
                                {
 
207
                                        s_bTestComposite = FALSE;
 
208
                                }
 
209
                                ///int iAnswer= cairo_dock_ask_question_and_wait (_("To remove the black rectangle around the dock, you will need to activate a composite manager.\nFor instance, this can be done by activating desktop effects, launching Compiz, or activating the composition in Metacity.\nI can perform this last operation for you. Do you want to proceed ?"), pIcon, CAIRO_CONTAINER (g_pMainDock));
 
210
                                if (iClickedButton == 0 || iClickedButton == -1)
 
211
                                {
 
212
                                        int r = system ("gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true");
 
213
                                        cairo_dock_show_dialog_with_question (_("Do you want to keep this setting?"), pIcon, CAIRO_CONTAINER (g_pMainDock), NULL, (CairoDockActionOnAnswerFunc) _accept_metacity_composition, NULL, NULL);
 
214
                                }
 
215
                                
 
216
                        }
 
217
                        else  // sinon il a droit a un "message a caractere informatif".
 
218
                        {
 
219
                                cairo_dock_show_general_message (_("To remove the black rectangle around the dock, you will need to activate a composite manager.\nFor instance, this can be done by activating desktop effects, launching Compiz, or activating the composition in Metacity.\nIf your machine can't support composition, Cairo-Dock can emulate it. This option is in the 'System' module of the configuration, at the bottom of the page."), 0);
 
220
                        }
 
221
                        g_free (cPsef);
 
222
                }
 
223
                else  // a priori peu utile de le retester, surtout que le composite risque de ne pas etre actif tout de suite au demarrage.
 
224
                {
 
225
                        s_bTestComposite = FALSE;
 
226
                }
 
227
                
 
228
                if (! s_bTestComposite)
 
229
                {
 
230
                        gchar *cConfFilePath = g_strdup_printf ("%s/.cairo-dock", g_cCairoDockDataDir);
 
231
                        cairo_dock_update_conf_file (cConfFilePath,
 
232
                                G_TYPE_BOOLEAN, "Launch", "test composite", s_bTestComposite,
 
233
                                G_TYPE_INVALID);
 
234
                        g_free (cConfFilePath);
 
235
                }
 
236
        }
180
237
        return FALSE;
181
238
}
182
239
static void _cairo_dock_intercept_signal (int signal)
205
262
        signal (SIGABRT, _cairo_dock_intercept_signal);  // Abort
206
263
}
207
264
 
208
 
static void _accept_metacity_composition (int iClickedButton, GtkWidget *pInteractiveWidget, gpointer data, CairoDialog *pDialog)
209
 
{
210
 
        if (iClickedButton == 1)  // clic explicite sur "cancel"
211
 
        {
212
 
                int r = system ("gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool false");
213
 
        }
214
 
}
215
 
 
216
265
static gboolean on_delete_maintenance_gui (GtkWidget *pWidget, GdkEvent *event, GMainLoop *pBlockingLoop)
217
266
{
218
267
        g_print ("%s ()\n", __func__);
223
272
        return FALSE;  // TRUE <=> ne pas detruire la fenetre.
224
273
}
225
274
 
226
 
#define _create_dir_or_die(cDirPath) do {\
227
 
        if (g_mkdir (cDirPath, 7*8*8+7*8+7) != 0) {\
228
 
                cd_warning ("couldn't create directory %s", cDirPath);\
229
 
                return 1; } } while (0)
 
275
static void _entered_help_once (CairoDockModuleInstance *pInstance, GKeyFile *pKeyFile)
 
276
{
 
277
        if (!g_bEnterHelpOnce)
 
278
        {
 
279
                g_bEnterHelpOnce = TRUE;
 
280
                gchar *cConfFilePath = g_strdup_printf ("%s/.cairo-dock", g_cCairoDockDataDir);
 
281
                cairo_dock_update_conf_file (cConfFilePath,
 
282
                        G_TYPE_BOOLEAN, "Help", "entered once", g_bEnterHelpOnce,
 
283
                        G_TYPE_INVALID);
 
284
                g_free (cConfFilePath);
 
285
        }
 
286
}
 
287
static void _register_help_module (void)
 
288
{
 
289
        //\________________ ceci est un vilain hack ...Ā mais je trouvais ca lourd de compiler un truc qui n'a aucun code, et puis comme ca on a l'aide meme sans les plug-ins.
 
290
        CairoDockModule *pHelpModule = g_new0 (CairoDockModule, 1);
 
291
        CairoDockVisitCard *pVisitCard = g_new0 (CairoDockVisitCard, 1);
 
292
        pHelpModule->pVisitCard = pVisitCard;
 
293
        pVisitCard->cModuleName = "Help";
 
294
        pVisitCard->cTitle = _("Help");
 
295
        pVisitCard->iMajorVersionNeeded = 2;
 
296
        pVisitCard->iMinorVersionNeeded = 0;
 
297
        pVisitCard->iMicroVersionNeeded = 0;
 
298
        pVisitCard->cPreviewFilePath = NULL;
 
299
        pVisitCard->cGettextDomain = NULL;
 
300
        pVisitCard->cDockVersionOnCompilation = CAIRO_DOCK_VERSION;
 
301
        pVisitCard->cUserDataDir = "help";
 
302
        pVisitCard->cShareDataDir = CAIRO_DOCK_SHARE_DATA_DIR;
 
303
        pVisitCard->cConfFileName = "help.conf";
 
304
        pVisitCard->cModuleVersion = "0.1.1";
 
305
        pVisitCard->iCategory = CAIRO_DOCK_CATEGORY_BEHAVIOR;
 
306
        pVisitCard->cIconFilePath = CAIRO_DOCK_SHARE_DATA_DIR"/icon-help.svg";
 
307
        pVisitCard->iSizeOfConfig = 0;
 
308
        pVisitCard->iSizeOfData = 0;
 
309
        pVisitCard->cDescription = N_("A useful FAQ which also contains a lot of hints.\nRoll your mouse over a sentence to make helpful popups appear.");
 
310
        pVisitCard->cAuthor = "Fabounet";
 
311
        pHelpModule->pInterface = g_new0 (CairoDockModuleInterface, 1);
 
312
        pHelpModule->pInterface->load_custom_widget = _entered_help_once;
 
313
        cairo_dock_register_module (pHelpModule);
 
314
        cairo_dock_activate_module (pHelpModule, NULL);
 
315
        pHelpModule->fLastLoadingTime = time (NULL) + 1e7;  // pour ne pas qu'il soit desactive lors d'un reload general, car il n'est pas dans la liste des modules actifs du fichier de conf.
 
316
}
 
317
 
 
318
static void _cairo_dock_get_global_config (void)
 
319
{
 
320
        gchar *cConfFilePath = g_strdup_printf ("%s/.cairo-dock", g_cCairoDockDataDir);
 
321
        GKeyFile *pKeyFile = g_key_file_new ();
 
322
        if (g_file_test (cConfFilePath, G_FILE_TEST_EXISTS))
 
323
        {
 
324
                g_key_file_load_from_file (pKeyFile, cConfFilePath, 0, NULL);
 
325
                s_cLastVersion = g_key_file_get_string (pKeyFile, "Launch", "last version", NULL);
 
326
                s_cDefaulBackend = g_key_file_get_string (pKeyFile, "Launch", "default backend", NULL);
 
327
                if (s_cDefaulBackend && *s_cDefaulBackend == '\0')
 
328
                {
 
329
                        g_free (s_cDefaulBackend);
 
330
                        s_cDefaulBackend = NULL;
 
331
                }
 
332
                s_bTestComposite = g_key_file_get_boolean (pKeyFile, "Launch", "test composite", NULL);
 
333
                g_bEnterHelpOnce = g_key_file_get_boolean (pKeyFile, "Help", "entered once", NULL);
 
334
                s_iGuiMode = g_key_file_get_integer (pKeyFile, "Gui", "mode", NULL);  // 0 si la cle n'est pas presente.
 
335
        }
 
336
        else  // ancienne methode.
 
337
        {
 
338
                gchar *cLastVersionFilePath = g_strdup_printf ("%s/.cairo-dock-last-version", g_cCairoDockDataDir);
 
339
                if (g_file_test (cLastVersionFilePath, G_FILE_TEST_EXISTS))
 
340
                {
 
341
                        gsize length = 0;
 
342
                        g_file_get_contents (cLastVersionFilePath,
 
343
                                &s_cLastVersion,
 
344
                                &length,
 
345
                                NULL);
 
346
                }
 
347
                g_remove (cLastVersionFilePath);
 
348
                g_free (cLastVersionFilePath);
 
349
                g_key_file_set_string (pKeyFile, "Launch", "last version", s_cLastVersion);
 
350
                
 
351
                g_key_file_set_string (pKeyFile, "Launch", "default backend", "");
 
352
                g_key_file_set_boolean (pKeyFile, "Launch", "test composite", TRUE);
 
353
                
 
354
                gchar *cHelpHistory = g_strdup_printf ("%s/.help/entered-once", g_cCairoDockDataDir);
 
355
                if (g_file_test (cHelpHistory, G_FILE_TEST_EXISTS))
 
356
                {
 
357
                        g_bEnterHelpOnce = TRUE;
 
358
                }
 
359
                gchar *cCommand = g_strdup_printf ("rm -rf \"%s/.help\"", g_cCairoDockDataDir);
 
360
                int r = system (cCommand);
 
361
                g_free (cCommand);
 
362
                g_free (cHelpHistory);
 
363
                g_key_file_set_boolean (pKeyFile, "Help", "entered once", g_bEnterHelpOnce);
 
364
                
 
365
                s_iGuiMode = 0;
 
366
                g_key_file_set_integer (pKeyFile, "Gui", "mode", s_iGuiMode);
 
367
                
 
368
                cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
 
369
        }
 
370
        g_key_file_free (pKeyFile);
 
371
        g_free (cConfFilePath);
 
372
}
230
373
 
231
374
int main (int argc, char** argv)
232
375
{
256
399
        
257
400
        gtk_init (&argc, &argv);
258
401
        
259
 
        memset (&g_pDockBackgroundBuffer, 0, sizeof (CairoDockImageBuffer));
260
 
        memset (&g_pIndicatorBuffer, 0, sizeof (CairoDockImageBuffer));
261
 
        memset (&g_pActiveIndicatorBuffer, 0, sizeof (CairoDockImageBuffer));
262
 
        memset (&g_pClassIndicatorBuffer, 0, sizeof (CairoDockImageBuffer));
263
 
        memset (&g_pIconBackgroundBuffer, 0, sizeof (CairoDockImageBuffer));
264
 
        memset (&g_pVisibleZoneBuffer, 0, sizeof (CairoDockImageBuffer));
265
 
        memset (&g_pBoxAboveBuffer, 0, sizeof (CairoDockImageBuffer));
266
 
        memset (&g_pBoxBelowBuffer, 0, sizeof (CairoDockImageBuffer));
267
 
        
268
402
        GError *erreur = NULL;
269
403
        
270
404
        //\___________________ On recupere quelques options.
271
 
        gboolean bSafeMode = FALSE, bMaintenance = FALSE, bNoSkipPager = FALSE, bNoSkipTaskbar = FALSE, bNoSticky = FALSE, bToolBarHint = FALSE, bNormalHint = FALSE, bCappuccino = FALSE, bExpresso = FALSE, bCafeLatte = FALSE, bPrintVersion = FALSE, bTesting = FALSE, bForceIndirectRendering = FALSE, bForceOpenGL = FALSE, bToggleIndirectRendering = FALSE;
272
 
        gchar *cEnvironment = NULL, *cUserDefinedDataDir = NULL, *cVerbosity = 0, *cUserDefinedModuleDir = NULL, *cExcludeModule = NULL;
 
405
        gboolean bSafeMode = FALSE, bMaintenance = FALSE, bNoSticky = FALSE, bNormalHint = FALSE, bCappuccino = FALSE, bPrintVersion = FALSE, bTesting = FALSE, bForceIndirectRendering = FALSE, bForceOpenGL = FALSE, bToggleIndirectRendering = FALSE;
 
406
        gchar *cEnvironment = NULL, *cUserDefinedDataDir = NULL, *cVerbosity = 0, *cUserDefinedModuleDir = NULL, *cExcludeModule = NULL, *cThemeServerAdress = NULL;
273
407
        GOptionEntry TableDesOptions[] =
274
408
        {
275
409
                {"log", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
276
410
                        &cVerbosity,
277
 
                        "log verbosity (debug,message,warning,critical,error) default is warning", NULL},
 
411
                        "log verbosity (debug,message,warning,critical,error); default is warning", NULL},
278
412
#ifdef HAVE_GLITZ
279
413
                {"glitz", 'g', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
280
414
                        &g_bUseGlitz,
288
422
                        "use OpenGL backend", NULL},
289
423
                {"indirect-opengl", 'O', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
290
424
                        &bToggleIndirectRendering,
291
 
                        "use OpenGL backend and toggle On/Off indirect rendering. Use this instead of -o if you have some drawing artifacts, like invisible icons.", NULL},
 
425
                        "use OpenGL backend with indirect rendering. There are very few case where this option should be used.", NULL},
292
426
                {"indirect", 'i', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
293
427
                        &bForceIndirectRendering,
294
428
                        "deprecated - see -O", NULL},
295
429
                {"keep-above", 'a', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
296
430
                        &g_bKeepAbove,
297
431
                        "keep the dock above other windows whatever", NULL},
298
 
                {"no-skip-pager", 'p', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
299
 
                        &bNoSkipPager,
300
 
                        "show the dock in pager", NULL},
301
 
                {"no-skip-taskbar", 'b', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
302
 
                        &bNoSkipTaskbar,
303
 
                        "show the dock in taskbar", NULL},
304
432
                {"no-sticky", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
305
433
                        &bNoSticky,
306
434
                        "don't make the dock appear on all desktops", NULL},
307
 
                {"toolbar-hint", 't', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
308
 
                        &bToolBarHint,
309
 
                        "force the window manager to consider cairo-dock as a toolbar instead of a dock", NULL},
310
 
                {"normal-hint", 'n', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
311
 
                        &bNormalHint,
312
 
                        "force the window manager to consider cairo-dock as a normal appli instead of a dock", NULL},
313
435
                {"env", 'e', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
314
436
                        &cEnvironment,
315
 
                        "force the dock to consider this environnement - it may crash the dock if not set properly.", NULL},
 
437
                        "force the dock to consider this environnement - use it with care.", NULL},
316
438
                {"dir", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
317
439
                        &cUserDefinedDataDir,
318
 
                        "force the dock to load this directory, instead of ~/.config/cairo-dock.", NULL},
 
440
                        "force the dock to load from this directory, instead of ~/.config/cairo-dock.", NULL},
319
441
                {"maintenance", 'm', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
320
442
                        &bMaintenance,
321
443
                        "allow to edit the config before the dock is started and show the config panel on start", NULL},
328
450
                {"capuccino", 'C', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
329
451
                        &bCappuccino,
330
452
                        "Cairo-Dock makes anything, including coffee !", NULL},
331
 
                {"expresso", 'X', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
332
 
                        &bExpresso,
333
 
                        "Cairo-Dock makes anything, including coffee !", NULL},
334
 
                {"cafe-latte", 'L', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
335
 
                        &bCafeLatte,
336
 
                        "Cairo-Dock makes anything, including coffee !", NULL},
337
453
                {"version", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
338
454
                        &bPrintVersion,
339
455
                        "print version and quit.", NULL},
347
463
                        &g_bEasterEggs,
348
464
                        "for debugging purpose only. Some hidden and still unstable options will be activated.", NULL},
349
465
                {"server", 'S', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
350
 
                        &g_cThemeServerAdress,
 
466
                        &cThemeServerAdress,
351
467
                        "address of a server containing additional themes. This will overwrite the default server address.", NULL},
352
468
                {"locked", 'k', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
353
469
                        &g_bLocked,
354
470
                        "lock the dock so that any modification is impossible for users.", NULL},
355
 
                {NULL}
 
471
                {NULL, 0, 0, 0,
 
472
                        NULL,
 
473
                        NULL, NULL}
356
474
        };
357
475
 
358
476
        GOptionContext *context = g_option_context_new ("Cairo-Dock");
385
503
        cd_log_set_level_from_name (cVerbosity);
386
504
        g_free (cVerbosity);
387
505
 
388
 
        g_bSkipPager = ! bNoSkipPager;
389
 
        g_bSkipTaskbar = ! bNoSkipTaskbar;
390
506
        g_bSticky = ! bNoSticky;
391
507
 
392
 
        if (bToolBarHint)
393
 
                g_iWmHint = GDK_WINDOW_TYPE_HINT_TOOLBAR;
394
 
        if (bNormalHint)
395
 
                g_iWmHint = GDK_WINDOW_TYPE_HINT_NORMAL;
396
508
        if (cEnvironment != NULL)
397
509
        {
398
510
                if (strcmp (cEnvironment, "gnome") == 0)
413
525
        
414
526
        if (bCappuccino)
415
527
        {
416
 
                g_print ("Please insert one coin into your PC.\n");
417
 
                return 0;
418
 
        }
419
 
        if (bExpresso)
420
 
        {
421
 
                g_print ("Sorry, no more sugar; please try again later.\n");
422
 
                return 0;
423
 
        }
424
 
        if (bCafeLatte)
425
 
        {
426
 
                g_print ("Honestly, you trust someone who includes such options in his code ?\n");
 
528
                g_print ("Cairo-Dock does anything, including coffee !.\n");
427
529
                return 0;
428
530
        }
429
531
        
432
534
        bind_textdomain_codeset (CAIRO_DOCK_GETTEXT_PACKAGE, "UTF-8");
433
535
        textdomain (CAIRO_DOCK_GETTEXT_PACKAGE);
434
536
 
435
 
        //\___________________ On teste l'existence du repertoire des donnees ~/.config/cairo-dock.
436
 
        gboolean bFirstLaunch = FALSE;
437
 
        int r;
 
537
        //\___________________ On definit les repertoires des donnees.
 
538
        gchar *cRootDataDirPath;
438
539
        if (cUserDefinedDataDir != NULL)
439
540
        {
440
 
                g_cCairoDockDataDir = cUserDefinedDataDir;
 
541
                cRootDataDirPath = cUserDefinedDataDir;
441
542
                cUserDefinedDataDir = NULL;
442
 
                if (! g_file_test (g_cCairoDockDataDir, G_FILE_TEST_IS_DIR))
443
 
                {
444
 
                        _create_dir_or_die (g_cCairoDockDataDir);
445
 
                }
446
543
        }
447
544
        else
448
545
        {
449
 
                g_cCairoDockDataDir = g_strdup_printf ("%s/.config/%s", getenv("HOME"), CAIRO_DOCK_DATA_DIR);
450
 
                if (! g_file_test (g_cCairoDockDataDir, G_FILE_TEST_IS_DIR))
451
 
                {
452
 
                        _create_dir_or_die (g_cCairoDockDataDir);
453
 
                        bFirstLaunch = TRUE;
454
 
                }
455
 
        }
456
 
        gchar *cThemesDir = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, CAIRO_DOCK_THEMES_DIR);
457
 
        if (! g_file_test (cThemesDir, G_FILE_TEST_IS_DIR))
458
 
        {
459
 
                _create_dir_or_die (cThemesDir);
460
 
        }
461
 
        g_free (cThemesDir);
462
 
        gchar *cExtrasDir = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, CAIRO_DOCK_EXTRAS_DIR);
463
 
        if (! g_file_test (cExtrasDir, G_FILE_TEST_IS_DIR))
464
 
        {
465
 
                _create_dir_or_die (cExtrasDir);
466
 
        }
467
 
        g_free (cExtrasDir);
468
 
        g_cCurrentThemePath = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, CAIRO_DOCK_CURRENT_THEME_NAME);
469
 
        if (! g_file_test (g_cCurrentThemePath, G_FILE_TEST_IS_DIR))
470
 
        {
471
 
                _create_dir_or_die (g_cCurrentThemePath);
472
 
        }
473
 
        
474
 
        g_cCurrentLaunchersPath = g_strdup_printf ("%s/%s", g_cCurrentThemePath, CAIRO_DOCK_LAUNCHERS_DIR);
475
 
        if (! g_file_test (g_cCurrentLaunchersPath, G_FILE_TEST_IS_DIR))
476
 
        {
477
 
                _create_dir_or_die (g_cCurrentLaunchersPath);
478
 
        }
479
 
        g_cCurrentIconsPath = g_strdup_printf ("%s/%s", g_cCurrentThemePath, CAIRO_DOCK_LOCAL_ICONS_DIR);
480
 
        if (! g_file_test (g_cCurrentIconsPath, G_FILE_TEST_IS_DIR))
481
 
        {
482
 
                _create_dir_or_die (g_cCurrentIconsPath);
483
 
                if (! bFirstLaunch)
484
 
                {
485
 
                        cd_warning ("Cairo-Dock's local icons are now located in the 'icons' folder, they will be moved there");
486
 
                        gchar *cCommand = g_strdup_printf ("cd \"%s\" && mv *.svg *.png *.xpm *.jpg *.bmp *.gif \"%s\" > /dev/null", g_cCurrentLaunchersPath, g_cCurrentIconsPath);
487
 
                        cd_message (cCommand);
488
 
                        r = system (cCommand);
489
 
                        g_free (cCommand);
490
 
                }
491
 
        }
492
 
        
493
 
        //\___________________ On initialise les numeros de version.
494
 
        cairo_dock_get_version_from_string (CAIRO_DOCK_VERSION, &g_iMajorVersion, &g_iMinorVersion, &g_iMicroVersion);
495
 
 
 
546
                cRootDataDirPath = g_strdup_printf ("%s/.config/%s", getenv("HOME"), CAIRO_DOCK_DATA_DIR);
 
547
        }
 
548
        gboolean bFirstLaunch = ! g_file_test (cRootDataDirPath, G_FILE_TEST_IS_DIR);
 
549
        
 
550
        gchar *cExtraDirPath = g_strconcat (cRootDataDirPath, "/"CAIRO_DOCK_EXTRAS_DIR, NULL);
 
551
        gchar *cThemesDirPath = g_strconcat (cRootDataDirPath, "/"CAIRO_DOCK_THEMES_DIR, NULL);
 
552
        gchar *cCurrentThemeDirPath = g_strconcat (cRootDataDirPath, "/"CAIRO_DOCK_CURRENT_THEME_NAME, NULL);
 
553
        cairo_dock_set_paths (cRootDataDirPath, cExtraDirPath, cThemesDirPath, cCurrentThemeDirPath, cThemeServerAdress ? cThemeServerAdress : g_strdup (CAIRO_DOCK_THEME_SERVER));
 
554
        
 
555
          /////////////
 
556
         //// LIB ////
 
557
        /////////////
 
558
        
496
559
        //\___________________ On initialise le gestionnaire de docks (a faire en 1er).
497
 
        cairo_dock_initialize_dock_manager ();
 
560
        cairo_dock_init_dock_manager ();
498
561
        
499
562
        //\___________________ On initialise le gestionnaire de desklets.
500
563
        cairo_dock_init_desklet_manager ();
501
564
        
502
 
        //\___________________ On initialise le gestionnaire de vues.
503
 
        cairo_dock_initialize_renderer_manager ();
 
565
        //\___________________ On initialise le gestionnaire de dialogues.
 
566
        cairo_dock_init_dialog_manager ();
 
567
        
 
568
        //\___________________ On initialise le gestionnaire de backends (vues, etc).
 
569
        cairo_dock_init_backends_manager ();
 
570
        
 
571
        //\___________________ On initialise le gestionnaire des indicateurs.
 
572
        cairo_dock_init_indicator_manager ();
504
573
        
505
574
        //\___________________ On initialise le multi-threading.
506
575
        if (!g_thread_supported ())
507
576
                g_thread_init (NULL);
508
577
        
509
 
        //\___________________ On initialise le support de X.
510
 
        cairo_dock_initialize_X_support ();
511
 
        cairo_dock_start_listening_X_events ();
 
578
        //\___________________ On demarre le support de X.
 
579
        cairo_dock_start_X_manager ();
512
580
        
513
581
        //\___________________ On initialise le keybinder.
514
582
        cd_keybinder_init();
515
583
        
516
 
        //\___________________ On detecte l'environnement de bureau (apres les applis et avant les modules).
 
584
        //\___________________ On detecte l'environnement de bureau (apres X et avant les modules).
517
585
        if (g_iDesktopEnv == CAIRO_DOCK_UNKNOWN_ENV)
518
586
                g_iDesktopEnv = cairo_dock_guess_environment ();
519
587
        cd_debug ("environnement de bureau : %d", g_iDesktopEnv);
520
588
        
521
 
        //\___________________ On enregistre les rendus de donnees.
522
 
        cairo_dock_register_data_renderer_entry_point ("gauge", (CairoDataRendererNewFunc) cairo_dock_new_gauge);
523
 
        cairo_dock_register_data_renderer_entry_point ("graph", (CairoDataRendererNewFunc) cairo_dock_new_graph);
 
589
        //\___________________ On enregistre les implementations.
 
590
        cairo_dock_register_built_in_data_renderers ();
 
591
        cairo_dock_register_hiding_effects ();
 
592
        g_pKeepingBelowBackend = cairo_dock_get_hiding_effect ("Fade out");
 
593
        
 
594
        cairo_dock_register_icon_container_renderers ();
 
595
        
 
596
        //\___________________ On enregistre les notifications de base (avant les modules).
 
597
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_ICON,
 
598
                (CairoDockNotificationFunc) cairo_dock_render_icon_notification,
 
599
                CAIRO_DOCK_RUN_FIRST, NULL);
 
600
        cairo_dock_register_notification (CAIRO_DOCK_INSERT_ICON,
 
601
                (CairoDockNotificationFunc) cairo_dock_on_insert_remove_icon_notification,
 
602
                CAIRO_DOCK_RUN_AFTER, NULL);
 
603
        cairo_dock_register_notification (CAIRO_DOCK_REMOVE_ICON,
 
604
                (CairoDockNotificationFunc) cairo_dock_on_insert_remove_icon_notification,
 
605
                CAIRO_DOCK_RUN_AFTER, NULL);
 
606
        cairo_dock_register_notification (CAIRO_DOCK_UPDATE_ICON,
 
607
                (CairoDockNotificationFunc) cairo_dock_update_inserting_removing_icon_notification,
 
608
                CAIRO_DOCK_RUN_AFTER, NULL);
 
609
        cairo_dock_register_notification (CAIRO_DOCK_STOP_ICON,
 
610
                (CairoDockNotificationFunc) cairo_dock_stop_inserting_removing_icon_notification,
 
611
                CAIRO_DOCK_RUN_AFTER, NULL);
 
612
        cairo_dock_register_notification (CAIRO_DOCK_UPDATE_FLYING_CONTAINER,
 
613
                (CairoDockNotificationFunc) cairo_dock_update_flying_container_notification,
 
614
                CAIRO_DOCK_RUN_AFTER, NULL);
 
615
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_FLYING_CONTAINER,
 
616
                (CairoDockNotificationFunc) cairo_dock_render_flying_container_notification,
 
617
                CAIRO_DOCK_RUN_AFTER, NULL);
 
618
        
 
619
          /////////////
 
620
         //// APP ////
 
621
        /////////////
 
622
        
 
623
        //\___________________ On lit la config globale de l'appli.
 
624
        _cairo_dock_get_global_config ();
524
625
        
525
626
        //\___________________ On initialise le support d'OpenGL.
526
627
        gboolean bOpenGLok = FALSE;
527
628
        if (bForceOpenGL || (! g_bForceCairo && ! g_bUseGlitz))
528
629
                bOpenGLok = cairo_dock_initialize_opengl_backend (bToggleIndirectRendering, bForceOpenGL);
529
 
        if (bOpenGLok && ! bForceOpenGL && ! cairo_dock_opengl_is_safe ())  // opengl disponible sans l'avoir force mais pas safe => on demande confirmation.
 
630
        if (bOpenGLok && ! bForceOpenGL && ! bToggleIndirectRendering && ! cairo_dock_opengl_is_safe ())  // opengl disponible sans l'avoir force mais pas safe => on demande confirmation.
530
631
        {
531
 
                GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Use OpenGL in Cairo-Dock ?"),
532
 
                        NULL,
533
 
                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
534
 
                        GTK_STOCK_YES,
535
 
                        GTK_RESPONSE_YES,
536
 
                        GTK_STOCK_NO,
537
 
                        GTK_RESPONSE_NO,
538
 
                        NULL);
539
 
                GtkWidget *label = gtk_label_new (_("OpenGL allows you to use the hardware acceleration, reducing the CPU load to the minimum.\nIt also allows some pretty visual effects similar to Compiz.\nHowever, some cards and/or their drivers don't fully support it, which may prevent the dock from running correctly.\nDo you want to activate OpenGL ?\n (To not show this dialog, launch the dock from the Application menu,\n  or with the -o option to force OpenGL and -c to force cairo.)"));
540
 
                gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label);
541
 
                gtk_widget_show_all (dialog);
542
 
                
543
 
                gint iAnswer = gtk_dialog_run (GTK_DIALOG (dialog));  // lance sa propre main loop, c'est pourquoi on peut le faire avant le gtk_main().
544
 
                gtk_widget_destroy (dialog);
545
 
                if (iAnswer == GTK_RESPONSE_NO)
 
632
                if (s_cDefaulBackend == NULL) // pas de backend par defaut defini.
 
633
                {
 
634
                        GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Use OpenGL in Cairo-Dock"),
 
635
                                NULL,
 
636
                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 
637
                                GTK_STOCK_YES,
 
638
                                GTK_RESPONSE_YES,
 
639
                                GTK_STOCK_NO,
 
640
                                GTK_RESPONSE_NO,
 
641
                                NULL);
 
642
                        GtkWidget *label = gtk_label_new (_("OpenGL allows you to use the hardware acceleration, reducing the CPU load to the minimum.\nIt also allows some pretty visual effects similar to Compiz.\nHowever, some cards and/or their drivers don't fully support it, which may prevent the dock from running correctly.\nDo you want to activate OpenGL ?\n (To not show this dialog, launch the dock from the Application menu,\n  or with the -o option to force OpenGL and -c to force cairo.)"));
 
643
                        gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0);
 
644
                        
 
645
                        GtkWidget *pAskBox = gtk_hbox_new (FALSE, 3);
 
646
                        gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), pAskBox, FALSE, FALSE, 0);
 
647
                        label = gtk_label_new (_("Remember this choice"));
 
648
                        GtkWidget *pCheckBox = gtk_check_button_new ();
 
649
                        gtk_box_pack_end (GTK_BOX (pAskBox), pCheckBox, FALSE, FALSE, 0);
 
650
                        gtk_box_pack_end (GTK_BOX (pAskBox), label, FALSE, FALSE, 0);
 
651
                        g_signal_connect (G_OBJECT (pCheckBox), "toggled", G_CALLBACK(_toggle_remember_choice), dialog);
 
652
                        
 
653
                        gtk_widget_show_all (dialog);
 
654
                        
 
655
                        gint iAnswer = gtk_dialog_run (GTK_DIALOG (dialog));  // lance sa propre main loop, c'est pourquoi on peut le faire avant le gtk_main().
 
656
                        gboolean bRememberChoice = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "remember"));
 
657
                        gtk_widget_destroy (dialog);
 
658
                        if (iAnswer == GTK_RESPONSE_NO)
 
659
                        {
 
660
                                cairo_dock_deactivate_opengl ();
 
661
                        }
 
662
                        
 
663
                        if (bRememberChoice)  // l'utilisateur a defini le choix par defaut.
 
664
                        {
 
665
                                s_cDefaulBackend = g_strdup (iAnswer == GTK_RESPONSE_NO ? "cairo" : "opengl");
 
666
                                gchar *cConfFilePath = g_strdup_printf ("%s/.cairo-dock", g_cCairoDockDataDir);
 
667
                                cairo_dock_update_conf_file (cConfFilePath,
 
668
                                        G_TYPE_STRING, "Launch", "default backend", s_cDefaulBackend,
 
669
                                        G_TYPE_INVALID);
 
670
                                g_free (cConfFilePath);
 
671
                        }
 
672
                }
 
673
                else if (strcmp (s_cDefaulBackend, "opengl") != 0)  // un backend par defaut qui n'est pas OpenGL.
546
674
                {
547
675
                        cairo_dock_deactivate_opengl ();
548
676
                }
555
683
        //\___________________ On initialise le gestionnaire de modules et on pre-charge les modules existant (il faut le faire apres savoir si on utilise l'OpenGL).
556
684
        if (g_module_supported () && ! bSafeMode)
557
685
        {
558
 
                cairo_dock_initialize_module_manager (CAIRO_DOCK_MODULES_DIR);
 
686
                cairo_dock_initialize_module_manager (cairo_dock_get_modules_dir ());
559
687
                
560
688
                if (cUserDefinedModuleDir != NULL)
561
689
                {
568
696
                cairo_dock_initialize_module_manager (NULL);
569
697
        
570
698
        //\___________________ On definit le backend des GUI.
571
 
        cairo_dock_load_user_gui_backend ();
 
699
        cairo_dock_load_user_gui_backend (s_iGuiMode);
572
700
        cairo_dock_register_default_launcher_gui_backend ();
573
701
        
574
702
        //\___________________ On enregistre la vue par defaut.
575
703
        cairo_dock_register_default_renderer ();
576
704
        
577
705
        //\___________________ On enregistre nos notifications.
578
 
        cairo_dock_register_notification (CAIRO_DOCK_BUILD_CONTAINER_MENU,
579
 
                (CairoDockNotificationFunc) cairo_dock_notification_build_container_menu,
580
 
                CAIRO_DOCK_RUN_FIRST, NULL);
581
 
        
582
 
        cairo_dock_register_notification (CAIRO_DOCK_BUILD_ICON_MENU,
583
 
                (CairoDockNotificationFunc) cairo_dock_notification_build_icon_menu,
584
 
                CAIRO_DOCK_RUN_AFTER, NULL);
585
706
        cairo_dock_register_notification (CAIRO_DOCK_DROP_DATA,
586
707
                (CairoDockNotificationFunc) cairo_dock_notification_drop_data,
587
708
                CAIRO_DOCK_RUN_AFTER, NULL);
594
715
        cairo_dock_register_notification (CAIRO_DOCK_SCROLL_ICON,
595
716
                (CairoDockNotificationFunc) cairo_dock_notification_scroll_icon,
596
717
                CAIRO_DOCK_RUN_AFTER, NULL);
597
 
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_DOCK,
598
 
                (CairoDockNotificationFunc) cairo_dock_render_dock_notification,
599
 
                CAIRO_DOCK_RUN_FIRST, NULL);
600
 
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_ICON,
601
 
                (CairoDockNotificationFunc) cairo_dock_render_icon_notification,
602
 
                CAIRO_DOCK_RUN_FIRST, NULL);
603
 
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_DESKLET,
604
 
                (CairoDockNotificationFunc) cairo_dock_render_desklet_notification,
605
 
                CAIRO_DOCK_RUN_FIRST, NULL);
606
 
        cairo_dock_register_notification (CAIRO_DOCK_INSERT_ICON,
607
 
                (CairoDockNotificationFunc) cairo_dock_on_insert_remove_icon_notification,
608
 
                CAIRO_DOCK_RUN_AFTER, NULL);
609
 
        cairo_dock_register_notification (CAIRO_DOCK_REMOVE_ICON,
610
 
                (CairoDockNotificationFunc) cairo_dock_on_insert_remove_icon_notification,
611
 
                CAIRO_DOCK_RUN_AFTER, NULL);
612
 
        cairo_dock_register_notification (CAIRO_DOCK_UPDATE_ICON,
613
 
                (CairoDockNotificationFunc) cairo_dock_update_inserting_removing_icon_notification,
614
 
                CAIRO_DOCK_RUN_AFTER, NULL);
615
 
        cairo_dock_register_notification (CAIRO_DOCK_STOP_ICON,
616
 
                (CairoDockNotificationFunc) cairo_dock_stop_inserting_removing_icon_notification,
617
 
                CAIRO_DOCK_RUN_AFTER, NULL);
618
 
        cairo_dock_register_notification (CAIRO_DOCK_UPDATE_FLYING_CONTAINER,
619
 
                (CairoDockNotificationFunc) cairo_dock_update_flying_container_notification,
620
 
                CAIRO_DOCK_RUN_AFTER, NULL);
621
 
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_FLYING_CONTAINER,
622
 
                (CairoDockNotificationFunc) cairo_dock_render_flying_container_notification,
 
718
        cairo_dock_register_notification (CAIRO_DOCK_BUILD_CONTAINER_MENU,
 
719
                (CairoDockNotificationFunc) cairo_dock_notification_build_container_menu,
 
720
                CAIRO_DOCK_RUN_FIRST, NULL);
 
721
        cairo_dock_register_notification (CAIRO_DOCK_BUILD_ICON_MENU,
 
722
                (CairoDockNotificationFunc) cairo_dock_notification_build_icon_menu,
623
723
                CAIRO_DOCK_RUN_AFTER, NULL);
624
724
        
625
725
        //\___________________ On initialise la gestion des crash.
626
726
        if (! bTesting)
627
727
                _cairo_dock_set_signal_interception ();
628
728
        
629
 
        //\___________________ On charge le dernier theme ou on demande a l'utilisateur d'en choisir un.
630
 
        g_cConfFile = g_strdup_printf ("%s/%s", g_cCurrentThemePath, CAIRO_DOCK_CONF_FILE);
631
 
        
 
729
        //\___________________ mode maintenance.
632
730
        if (bMaintenance)
633
731
        {
634
732
                if (cExcludeModule != NULL)
659
757
        
660
758
        if (cExcludeModule != NULL)
661
759
        {
662
 
                g_print ("on enleve %s de '%s'\n", cExcludeModule, s_cLaunchCommand);
 
760
                //g_print ("on enleve %s de '%s'\n", cExcludeModule, s_cLaunchCommand);
663
761
                gchar *str = g_strstr_len (s_cLaunchCommand, -1, " -x ");
664
762
                if (str)
665
763
                {
673
771
                }
674
772
        }
675
773
        
 
774
        //\___________________ On charge le dernier theme.
676
775
        cd_message ("loading theme ...");
677
776
        if (! g_file_test (g_cConfFile, G_FILE_TEST_EXISTS))
678
777
        {
679
 
                gchar *cCommand = g_strdup_printf ("/bin/cp -r \"%s\"/* \"%s/%s\"", CAIRO_DOCK_SHARE_DATA_DIR"/themes/_default_", g_cCairoDockDataDir, CAIRO_DOCK_CURRENT_THEME_NAME);
 
778
                gchar *cCommand = g_strdup_printf ("/bin/cp -r \"%s\"/* \"%s\"", CAIRO_DOCK_SHARE_DATA_DIR"/themes/_default_", g_cCurrentThemePath);
680
779
                cd_message (cCommand);
681
 
                r = system (cCommand);
 
780
                int r = system (cCommand);
682
781
                g_free (cCommand);
683
782
                
684
 
                cairo_dock_mark_theme_as_modified (FALSE);  // on ne proposera pas de sauvegarder ce theme.
 
783
                cairo_dock_mark_current_theme_as_modified (FALSE);  // on ne proposera pas de sauvegarder ce theme.
685
784
                cairo_dock_load_current_theme ();
686
785
        }
687
786
        else
688
787
                cairo_dock_load_current_theme ();
689
788
        
690
 
        //\___________________ On affiche un petit message de bienvenue.
691
 
        if (bFirstLaunch)
692
 
        {
693
 
                cairo_dock_show_general_message (_("Welcome in Cairo-Dock2 !\nA default and simple theme has been loaded.\nYou can either familiarize yourself with the dock or choose another theme with right-click -> Cairo-Dock -> Manage themes.\nA useful help is available by right-click -> Cairo-Dock -> Help.\nIf you have any question/request/remark, please pay us a visit at http://glx-dock.org.\nHope you will enjoy this soft !\n  (you can now click on this dialog to close it)"), 0);
694
 
                
695
 
                GdkScreen *pScreen = gdk_screen_get_default ();
696
 
                if (! mySystem.bUseFakeTransparency && ! gdk_screen_is_composited (pScreen))
697
 
                {
698
 
                        cd_warning ("no composite manager found");
699
 
                        // Si l'utilisateur utilise Metacity, on lui propose d'activer le composite.
700
 
                        gchar *cPsef = cairo_dock_launch_command_sync ("pgrep metacity");  // 'ps' ne marche pas, il faut le lancer dans un script :-/
701
 
                        if (cPsef != NULL && *cPsef != '\0')  // "metacity" a ete trouve.
702
 
                        {
703
 
                                Icon *pIcon = cairo_dock_get_dialogless_icon ();
704
 
                                
705
 
                                int iAnswer= cairo_dock_ask_question_and_wait (_("To remove the black rectangle around the dock, you need to activate a composite manager.\nFor instance, it can be done by activating the desktop effects, launching Compiz, or activating the composition in Metacity.\nI can do this lattest operation for you, do you want to proceed ?"), pIcon, CAIRO_CONTAINER (g_pMainDock));
706
 
                                if (iAnswer == GTK_RESPONSE_YES)
707
 
                                {
708
 
                                        int r = system ("gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true");
709
 
                                        cairo_dock_show_dialog_with_question (_("Do you want to keep this setting ?"), pIcon, CAIRO_CONTAINER (g_pMainDock), NULL, (CairoDockActionOnAnswerFunc) _accept_metacity_composition, NULL, NULL);
710
 
                                }
711
 
                        }
712
 
                        else  // sinon il a droit a un "message a caractere informatif".
713
 
                        {
714
 
                                cairo_dock_show_general_message (_("To remove the black rectangle around the dock, you need to activate a composite manager.\nFor instance, it can be done by activating the desktop effects, launching Compiz, or activating the composition in Metacity.\nIf your machine can't support composition, Cairo-Dock can emulate it; this option is in the 'System' module of the configuration, at the bottom of the page."), 0);
715
 
                        }
716
 
                        g_free (cPsef);
717
 
                }
718
 
        }
719
 
        else if (cExcludeModule != NULL && ! bMaintenance)
720
 
        {
721
 
                gchar *cMessage = g_strdup_printf (_("The module '%s' may have encountered a problem.\nIt has been restared successfully, but if it happens again, thanks to report it to us at http://glx-dock.org"), cExcludeModule);
722
 
                
723
 
                CairoDockModule *pModule = cairo_dock_find_module_from_name (cExcludeModule);
724
 
                Icon *icon = cairo_dock_get_dialogless_icon ();
725
 
                cairo_dock_show_temporary_dialog_with_icon (cMessage, icon, CAIRO_CONTAINER (g_pMainDock), 15000., (pModule ? pModule->pVisitCard->cIconFilePath : NULL));
726
 
                g_free (cMessage);
 
789
        if (g_bLocked)
 
790
        {
 
791
                myAccessibility.bLockIcons = TRUE;
 
792
                myAccessibility.bLockAll = TRUE;
727
793
        }
728
794
        
729
 
        if (cairo_dock_get_nb_modules () <= 1)  // le module Help est inclus de base.
 
795
        if (!bSafeMode && cairo_dock_get_nb_modules () == 0)
730
796
        {
731
797
                Icon *pIcon = cairo_dock_get_dialogless_icon ();
732
798
                cairo_dock_ask_question_and_wait (("No plug-in were found.\nPlug-ins provide most of the functionnalities of Cairo-Dock (animations, applets, views, etc).\nSee http://glx-dock.org for more information.\nSince there is almost no meaning in running the dock without them, the application will quit now."), pIcon, CAIRO_CONTAINER (g_pMainDock));
733
799
                exit (0);
734
800
        }
735
801
        
736
 
        //\___________________ On affiche le changelog en cas de nouvelle version.
737
 
        gchar *cLastVersionFilePath = g_strdup_printf ("%s/.cairo-dock-last-version", g_cCairoDockDataDir);
738
 
        gboolean bWriteChangeLog;
739
 
        if (! g_file_test (cLastVersionFilePath, G_FILE_TEST_EXISTS))
740
 
        {
741
 
                bWriteChangeLog = TRUE;
742
 
        }
743
 
        else
744
 
        {
745
 
                gsize length = 0;
746
 
                gchar *cContent = NULL;
747
 
                g_file_get_contents (cLastVersionFilePath,
748
 
                        &cContent,
749
 
                        &length,
750
 
                        NULL);
751
 
                if (length > 0 && strcmp (cContent, CAIRO_DOCK_VERSION) == 0)
752
 
                        bWriteChangeLog = FALSE;
753
 
                else
754
 
                        bWriteChangeLog = TRUE;
755
 
                g_free (cContent);
756
 
        }
757
 
 
758
 
        g_file_set_contents (cLastVersionFilePath,
759
 
                CAIRO_DOCK_VERSION,
760
 
                -1,
761
 
                NULL);
762
 
        g_free (cLastVersionFilePath);
763
 
 
764
 
        if (bWriteChangeLog && ! bFirstLaunch)
 
802
        _register_help_module ();
 
803
        
 
804
        
 
805
        //\___________________ On affiche un petit message de bienvenue ou de changelog ou d'erreur.
 
806
        gboolean bNewVersion = (s_cLastVersion == NULL || strcmp (s_cLastVersion, CAIRO_DOCK_VERSION) != 0);
 
807
        if (bNewVersion)
 
808
        {
 
809
                gchar *cConfFilePath = g_strdup_printf ("%s/.cairo-dock", g_cCairoDockDataDir);
 
810
                cairo_dock_update_conf_file (cConfFilePath,
 
811
                        G_TYPE_STRING, "Launch", "last version", CAIRO_DOCK_VERSION,
 
812
                        G_TYPE_INVALID);
 
813
                g_free (cConfFilePath);
 
814
        }
 
815
        
 
816
        if (bFirstLaunch)  // tout premier lancement -> bienvenue !
 
817
        {
 
818
                cairo_dock_show_general_message (_("Welcome in Cairo-Dock2 !\nA default and simple theme has been loaded.\nYou can either familiarize yourself with the dock or choose another theme with right-click -> Cairo-Dock -> Manage themes.\nA useful help is available by right-click -> Cairo-Dock -> Help.\nIf you have any question/request/remark, please pay us a visit at http://glx-dock.org.\nHope you will enjoy this soft !\n  (you can now click on this dialog to close it)"), 0);
 
819
        }
 
820
        else if (bNewVersion)  // nouvelle version -> changelog (si c'est le 1er lancement, inutile de dire ce qui est nouveau, et de plus on a deja le message de bienvenue).
765
821
        {
766
822
                gchar *cChangeLogFilePath = g_strdup_printf ("%s/ChangeLog.txt", CAIRO_DOCK_SHARE_DATA_DIR);
767
 
                GKeyFile *pKeyFile = g_key_file_new ();
 
823
                GKeyFile *pKeyFile = cairo_dock_open_key_file (cChangeLogFilePath);
768
824
                g_key_file_load_from_file (pKeyFile, cChangeLogFilePath, 0, &erreur);  // pas de commentaire utile.
769
 
                if (erreur != NULL)
770
 
                {
771
 
                        cd_warning (erreur->message);
772
 
                        g_error_free (erreur);
773
 
                        erreur = NULL;
774
 
                }
775
 
                else
 
825
                if (pKeyFile != NULL)
776
826
                {
777
827
                        gchar *cKeyName = g_strdup_printf ("%d.%d.%d", g_iMajorVersion, g_iMinorVersion, g_iMicroVersion);  // version sans les "alpha", "beta", "rc", etc.
778
 
                        gchar *cChangeLogMessage = g_key_file_get_string (pKeyFile, "ChangeLog", cKeyName, &erreur);
 
828
                        gchar *cChangeLogMessage = g_key_file_get_string (pKeyFile, "ChangeLog", cKeyName, NULL);
779
829
                        g_free (cKeyName);
780
 
                        if (erreur != NULL)
781
 
                        {
782
 
                                g_error_free (erreur);
783
 
                                erreur = NULL;
784
 
                        }
785
 
                        else
 
830
                        if (cChangeLogMessage != NULL)
786
831
                        {
787
832
                                Icon *pFirstIcon = cairo_dock_get_first_icon (g_pMainDock->icons);
 
833
                                myDialogs.dialogTextDescription.bUseMarkup = TRUE;
788
834
                                cairo_dock_show_temporary_dialog_with_default_icon (gettext (cChangeLogMessage), pFirstIcon, CAIRO_CONTAINER (g_pMainDock), 0);
 
835
                                myDialogs.dialogTextDescription.bUseMarkup = FALSE;
 
836
                                g_free (cChangeLogMessage);
789
837
                        }
790
 
                        g_free (cChangeLogMessage);
791
838
                }
792
839
        }
 
840
        else if (cExcludeModule != NULL && ! bMaintenance)
 
841
        {
 
842
                gchar *cMessage = g_strdup_printf (_("The module '%s' may have encountered a problem.\nIt has been restored successfully, but if it happens again, please report it at http://glx-dock.org"), cExcludeModule);
 
843
                
 
844
                CairoDockModule *pModule = cairo_dock_find_module_from_name (cExcludeModule);
 
845
                Icon *icon = cairo_dock_get_dialogless_icon ();
 
846
                cairo_dock_show_temporary_dialog_with_icon (cMessage, icon, CAIRO_CONTAINER (g_pMainDock), 15000., (pModule ? pModule->pVisitCard->cIconFilePath : NULL));
 
847
                g_free (cMessage);
 
848
        }
793
849
        
794
850
        if (! bTesting)
795
851
                g_timeout_add_seconds (5, _cairo_dock_successful_launch, NULL);
796
852
        
797
 
        /*g_print ("\n2eme DOCK PRINCIPAL AVEC 1 ICONE : BORD TRONQUE EN VERTICAL\n\n");
798
 
        g_print ("\nPLAN 3D NE PREND PAS TOUT L'ECRAN\n\n");
799
 
        g_print ("\nBATTERIE VERS 100%% (?)\n\n");
800
 
        
801
 
        g_print ("\nINDICATEURS EN HAUT (RETOURNES) ET CAIRO\n\n");
802
 
        g_print ("=> AUTO-HIDE WHEN SWITCHING DESKTOP IN CAIRO MODE\n");
803
 
        g_print ("PREVUE EN VUE PARABOLIQUE\n");
804
 
        g_print ("MP AVEC CERTAINS NOMS D'ALBUM/ARTISTE (ACCENT?)\n");
805
 
        
806
 
        g_print ("\nTEXTURE FROM PIXMAP\n\n");
807
 
        g_print ("\nNOUVELLE INSTANCE COPIEE SUR LA 1ERE\n\n");
808
 
        g_print ("\nJAUGES : LOGO\n\n");*/
809
 
        
810
 
        /*if (strcmp((cairo_dock_launch_command_sync ("date +%m%d")), "0101") == 0)
811
 
        {
812
 
                Icon *pFirstIcon = cairo_dock_get_first_icon (g_pMainDock->icons);
813
 
                cairo_dock_show_temporary_dialog_with_default_icon ("Happy New Year every body !\n\tThe Cairo-Dock Team", pFirstIcon, CAIRO_CONTAINER (g_pMainDock), 0);
814
 
        }*/
815
 
        
816
853
        gtk_main ();
817
854
        
818
855
        signal (SIGSEGV, NULL);  // Segmentation violation
819
856
        signal (SIGFPE, NULL);  // Floating-point exception
820
857
        signal (SIGILL, NULL);  // Illegal instruction
821
858
        signal (SIGABRT, NULL);
822
 
        cairo_dock_free_all_docks ();
 
859
        cairo_dock_free_all ();
823
860
        
824
861
        rsvg_term ();
 
862
        xmlCleanupParser ();
825
863
        
826
864
        cd_message ("Bye bye !");
827
865
        g_print ("\033[0m\n");