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"
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.
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.
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;
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;
149
gboolean g_bKeepAbove = FALSE;
150
gboolean g_bSkipPager = TRUE;
151
gboolean g_bSkipTaskbar = TRUE;
152
gboolean g_bSticky = TRUE;
154
gboolean g_bUseGlitz = FALSE;
155
gboolean g_bVerbose = FALSE;
157
CairoDockDesktopEnv g_iDesktopEnv = CAIRO_DOCK_UNKNOWN_ENV;
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"
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"
136
extern gchar *g_cCairoDockDataDir;
137
extern gchar *g_cCurrentThemePath;
139
extern gchar *g_cConfFile;
140
extern int g_iMajorVersion, g_iMinorVersion, g_iMicroVersion;
142
extern CairoDock *g_pMainDock;
144
extern gboolean g_bKeepAbove;
145
extern gboolean g_bSticky;
147
extern gboolean g_bUseGlitz;
148
extern gboolean g_bUseOpenGL;
149
extern CairoDockDesktopEnv g_iDesktopEnv;
150
extern gboolean g_bEasterEggs;
152
extern CairoDockGLConfig g_openglConfig;
153
extern CairoDockHidingEffect *g_pKeepingBelowBackend;
154
extern CairoDockModuleInstance *g_pCurrentModule;
160
155
//int g_iDamageEvent = 0;
162
gchar *g_cThemeServerAdress = NULL;
163
gboolean g_bEasterEggs = FALSE;
164
gboolean g_bLocked = FALSE;
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};
172
CairoDockModuleInstance *g_pCurrentModule = NULL;
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
167
static void _accept_metacity_composition (int iClickedButton, GtkWidget *pInteractiveWidget, gpointer data, CairoDialog *pDialog)
169
if (iClickedButton == 1) // clic explicite sur "cancel"
171
int r = system ("gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool false");
174
static void _toggle_remember_choice (GtkCheckButton *pButton, GtkWidget *pDialog)
176
g_object_set_data (G_OBJECT (pDialog), "remember", GINT_TO_POINTER (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pButton))));
176
178
static gboolean _cairo_dock_successful_launch (gpointer data)
178
180
if (g_str_has_suffix (s_cLaunchCommand, " -m"))
179
181
s_cLaunchCommand[strlen (s_cLaunchCommand)-3] = '\0'; // on enleve le mode maintenance.
183
//\___________________ On teste le composite maintenant (au demarrage, le composite manager peut ne pas etre lance).
184
if (s_bTestComposite)
186
GdkScreen *pScreen = gdk_screen_get_default ();
187
if (! mySystem.bUseFakeTransparency && ! gdk_screen_is_composited (pScreen))
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.
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);
203
gboolean bRememberChoice = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pAskBox), "remember"));
204
gtk_widget_destroy (pAskBox);
207
s_bTestComposite = FALSE;
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)
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);
217
else // sinon il a droit a un "message a caractere informatif".
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);
223
else // a priori peu utile de le retester, surtout que le composite risque de ne pas etre actif tout de suite au demarrage.
225
s_bTestComposite = FALSE;
228
if (! s_bTestComposite)
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,
234
g_free (cConfFilePath);
182
239
static void _cairo_dock_intercept_signal (int signal)
223
272
return FALSE; // TRUE <=> ne pas detruire la fenetre.
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)
277
if (!g_bEnterHelpOnce)
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,
284
g_free (cConfFilePath);
287
static void _register_help_module (void)
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.
318
static void _cairo_dock_get_global_config (void)
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))
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')
329
g_free (s_cDefaulBackend);
330
s_cDefaulBackend = NULL;
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.
336
else // ancienne methode.
338
gchar *cLastVersionFilePath = g_strdup_printf ("%s/.cairo-dock-last-version", g_cCairoDockDataDir);
339
if (g_file_test (cLastVersionFilePath, G_FILE_TEST_EXISTS))
342
g_file_get_contents (cLastVersionFilePath,
347
g_remove (cLastVersionFilePath);
348
g_free (cLastVersionFilePath);
349
g_key_file_set_string (pKeyFile, "Launch", "last version", s_cLastVersion);
351
g_key_file_set_string (pKeyFile, "Launch", "default backend", "");
352
g_key_file_set_boolean (pKeyFile, "Launch", "test composite", TRUE);
354
gchar *cHelpHistory = g_strdup_printf ("%s/.help/entered-once", g_cCairoDockDataDir);
355
if (g_file_test (cHelpHistory, G_FILE_TEST_EXISTS))
357
g_bEnterHelpOnce = TRUE;
359
gchar *cCommand = g_strdup_printf ("rm -rf \"%s/.help\"", g_cCairoDockDataDir);
360
int r = system (cCommand);
362
g_free (cHelpHistory);
363
g_key_file_set_boolean (pKeyFile, "Help", "entered once", g_bEnterHelpOnce);
366
g_key_file_set_integer (pKeyFile, "Gui", "mode", s_iGuiMode);
368
cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
370
g_key_file_free (pKeyFile);
371
g_free (cConfFilePath);
231
374
int main (int argc, char** argv)
257
400
gtk_init (&argc, &argv);
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));
268
402
GError *erreur = NULL;
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[] =
275
409
{"log", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
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,
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,
297
431
"keep the dock above other windows whatever", NULL},
298
{"no-skip-pager", 'p', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
300
"show the dock in pager", NULL},
301
{"no-skip-taskbar", 'b', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
303
"show the dock in taskbar", NULL},
304
432
{"no-sticky", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
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,
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,
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,
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,
321
443
"allow to edit the config before the dock is started and show the config panel on start", NULL},
432
534
bind_textdomain_codeset (CAIRO_DOCK_GETTEXT_PACKAGE, "UTF-8");
433
535
textdomain (CAIRO_DOCK_GETTEXT_PACKAGE);
435
//\___________________ On teste l'existence du repertoire des donnees ~/.config/cairo-dock.
436
gboolean bFirstLaunch = FALSE;
537
//\___________________ On definit les repertoires des donnees.
538
gchar *cRootDataDirPath;
438
539
if (cUserDefinedDataDir != NULL)
440
g_cCairoDockDataDir = cUserDefinedDataDir;
541
cRootDataDirPath = cUserDefinedDataDir;
441
542
cUserDefinedDataDir = NULL;
442
if (! g_file_test (g_cCairoDockDataDir, G_FILE_TEST_IS_DIR))
444
_create_dir_or_die (g_cCairoDockDataDir);
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))
452
_create_dir_or_die (g_cCairoDockDataDir);
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))
459
_create_dir_or_die (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))
465
_create_dir_or_die (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))
471
_create_dir_or_die (g_cCurrentThemePath);
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))
477
_create_dir_or_die (g_cCurrentLaunchersPath);
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))
482
_create_dir_or_die (g_cCurrentIconsPath);
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);
493
//\___________________ On initialise les numeros de version.
494
cairo_dock_get_version_from_string (CAIRO_DOCK_VERSION, &g_iMajorVersion, &g_iMinorVersion, &g_iMicroVersion);
546
cRootDataDirPath = g_strdup_printf ("%s/.config/%s", getenv("HOME"), CAIRO_DOCK_DATA_DIR);
548
gboolean bFirstLaunch = ! g_file_test (cRootDataDirPath, G_FILE_TEST_IS_DIR);
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));
496
559
//\___________________ On initialise le gestionnaire de docks (a faire en 1er).
497
cairo_dock_initialize_dock_manager ();
560
cairo_dock_init_dock_manager ();
499
562
//\___________________ On initialise le gestionnaire de desklets.
500
563
cairo_dock_init_desklet_manager ();
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 ();
568
//\___________________ On initialise le gestionnaire de backends (vues, etc).
569
cairo_dock_init_backends_manager ();
571
//\___________________ On initialise le gestionnaire des indicateurs.
572
cairo_dock_init_indicator_manager ();
505
574
//\___________________ On initialise le multi-threading.
506
575
if (!g_thread_supported ())
507
576
g_thread_init (NULL);
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 ();
513
581
//\___________________ On initialise le keybinder.
514
582
cd_keybinder_init();
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);
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");
594
cairo_dock_register_icon_container_renderers ();
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);
623
//\___________________ On lit la config globale de l'appli.
624
_cairo_dock_get_global_config ();
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.
531
GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Use OpenGL in Cairo-Dock ?"),
533
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
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);
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.
634
GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Use OpenGL in Cairo-Dock"),
636
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
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);
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);
653
gtk_widget_show_all (dialog);
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)
660
cairo_dock_deactivate_opengl ();
663
if (bRememberChoice) // l'utilisateur a defini le choix par defaut.
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,
670
g_free (cConfFilePath);
673
else if (strcmp (s_cDefaulBackend, "opengl") != 0) // un backend par defaut qui n'est pas OpenGL.
547
675
cairo_dock_deactivate_opengl ();
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);
625
725
//\___________________ On initialise la gestion des crash.
627
727
_cairo_dock_set_signal_interception ();
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);
729
//\___________________ mode maintenance.
632
730
if (bMaintenance)
634
732
if (cExcludeModule != NULL)
774
//\___________________ On charge le dernier theme.
676
775
cd_message ("loading theme ...");
677
776
if (! g_file_test (g_cConfFile, G_FILE_TEST_EXISTS))
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);
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 ();
688
787
cairo_dock_load_current_theme ();
690
//\___________________ On affiche un petit message de bienvenue.
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);
695
GdkScreen *pScreen = gdk_screen_get_default ();
696
if (! mySystem.bUseFakeTransparency && ! gdk_screen_is_composited (pScreen))
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.
703
Icon *pIcon = cairo_dock_get_dialogless_icon ();
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)
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);
712
else // sinon il a droit a un "message a caractere informatif".
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);
719
else if (cExcludeModule != NULL && ! bMaintenance)
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);
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));
791
myAccessibility.bLockIcons = TRUE;
792
myAccessibility.bLockAll = TRUE;
729
if (cairo_dock_get_nb_modules () <= 1) // le module Help est inclus de base.
795
if (!bSafeMode && cairo_dock_get_nb_modules () == 0)
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));
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))
741
bWriteChangeLog = TRUE;
746
gchar *cContent = NULL;
747
g_file_get_contents (cLastVersionFilePath,
751
if (length > 0 && strcmp (cContent, CAIRO_DOCK_VERSION) == 0)
752
bWriteChangeLog = FALSE;
754
bWriteChangeLog = TRUE;
758
g_file_set_contents (cLastVersionFilePath,
762
g_free (cLastVersionFilePath);
764
if (bWriteChangeLog && ! bFirstLaunch)
802
_register_help_module ();
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);
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,
813
g_free (cConfFilePath);
816
if (bFirstLaunch) // tout premier lancement -> bienvenue !
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);
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).
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.
771
cd_warning (erreur->message);
772
g_error_free (erreur);
825
if (pKeyFile != NULL)
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);
782
g_error_free (erreur);
830
if (cChangeLogMessage != NULL)
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);
790
g_free (cChangeLogMessage);
840
else if (cExcludeModule != NULL && ! bMaintenance)
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);
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));
795
851
g_timeout_add_seconds (5, _cairo_dock_successful_launch, NULL);
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");
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");
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");*/
810
/*if (strcmp((cairo_dock_launch_command_sync ("date +%m%d")), "0101") == 0)
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);
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 ();
826
864
cd_message ("Bye bye !");
827
865
g_print ("\033[0m\n");