Debian Codegraph @

musicPlayer/src/applet-config.c

raw
1 /**
2 * This file is a part of the Cairo-Dock project
3 *
4 * Copyright : (C) see the 'copyright' file.
5 * E-mail : see the 'copyright' file.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <string.h>
21 #include <cairo-dock.h>
22
23 #include "applet-struct.h"
24 #include "applet-config.h"
25 #include "applet-musicplayer.h"
26 #include "3dcover-draw.h"
27
28 //\_________________ Here you have to get all your parameters from the conf file. Use the macros CD_CONFIG_GET_BOOLEAN, CD_CONFIG_GET_INTEGER, CD_CONFIG_GET_STRING, etc. myConfig has been reseted to 0 at this point. This function is called at the beginning of init and reload.
29 CD_APPLET_GET_CONFIG_BEGIN
30 myConfig.iQuickInfoType = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "quick-info_type", MY_APPLET_TIME_ELAPSED);
31
32 myConfig.cMusicPlayer = CD_CONFIG_GET_STRING ("Configuration", "current-player"); // NULL by default
33 myConfig.cLastKnownDesktopFile = CD_CONFIG_GET_STRING ("Configuration", "desktop-entry"); // see applet-struct.h
34 myConfig.cDefaultTitle = CD_CONFIG_GET_STRING ("Icon", "name");
35
36 myConfig.bEnableDialogs = CD_CONFIG_GET_BOOLEAN ("Configuration", "enable_dialogs");
37 myConfig.iDialogDuration = 1000 * CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "time_dialog", 4);
38
39 myConfig.cChangeAnimation = CD_CONFIG_GET_STRING_WITH_DEFAULT ("Configuration", "change_animation", "wobbly");
40 myConfig.bEnableCover = CD_CONFIG_GET_BOOLEAN ("Configuration", "enable_cover");
41 myConfig.bOpenglThemes = g_bUseOpenGL && CD_CONFIG_GET_BOOLEAN ("Configuration", "enable_opengl_themes");
42 myConfig.bStealTaskBarIcon = CD_CONFIG_GET_BOOLEAN ("Configuration", "inhibate appli");
43
44 myConfig.cUserImage[PLAYER_NONE] = CD_CONFIG_GET_STRING ("Configuration", "default icon");
45 myConfig.cUserImage[PLAYER_PLAYING] = CD_CONFIG_GET_STRING ("Configuration", "play icon");
46 myConfig.cUserImage[PLAYER_PAUSED] = CD_CONFIG_GET_STRING ("Configuration", "pause icon");
47 myConfig.cUserImage[PLAYER_STOPPED] = CD_CONFIG_GET_STRING ("Configuration", "stop icon");
48 myConfig.cUserImage[PLAYER_BROKEN] = CD_CONFIG_GET_STRING ("Configuration", "broken icon");
49
50 myConfig.bDownload = CD_CONFIG_GET_BOOLEAN ("Configuration", "DOWNLOAD");
51 myConfig.bPauseOnClick = (CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "pause on click", 1) == 0); // c'est une liste numerotee de 2 elements.
52 if (!myConfig.bPauseOnClick) // pour pouvoir agir sur la fenetre, il faut voler l'appli (plus tellement vrai avec MPRIS2...).
53 myConfig.bStealTaskBarIcon = TRUE;
54 myConfig.bNextPrevOnScroll = (CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "scrolling", 0) == 0); // c'est une liste numerotee de 2 elements.
55
56 //\_______________ On on recupere le theme choisi.
57 if (myConfig.bOpenglThemes)
58 myConfig.cThemePath = CD_CONFIG_GET_THEME_PATH ("Configuration", "theme", "themes", "cd_box_3d");
59 CD_APPLET_GET_CONFIG_END
60
61
62 //\_________________ Here you have to free all ressources allocated for myConfig. This one will be reseted to 0 at the end of this function. This function is called right before you get the applet's config, and when your applet is stopped, in the end.
63 CD_APPLET_RESET_CONFIG_BEGIN
64
65 g_free (myConfig.cDefaultTitle);
66 g_free (myConfig.cMusicPlayer);
67 g_free (myConfig.cLastKnownDesktopFile);
68
69 int i;
70 for (i = 0; i < PLAYER_NB_STATUS; i ++) {
71 g_free (myConfig.cUserImage[i]);
72 }
73
74 g_free (myConfig.cThemePath);
75
76 CD_APPLET_RESET_CONFIG_END
77
78
79 //\_________________ Here you have to free all ressources allocated for myData. This one will be reseted to 0 at the end of this function. This function is called when your applet is stopped, in the very end.
80 CD_APPLET_RESET_DATA_BEGIN
81 int i;
82 for (i = 0; i < PLAYER_NB_STATUS; i ++) {
83 if (myData.pSurfaces[i] != NULL)
84 cairo_surface_destroy (myData.pSurfaces[i]);
85 }
86
87 if (myData.pCover != NULL)
88 cairo_surface_destroy (myData.pCover);
89
90 g_free (myData.cRawTitle);
91 g_free (myData.cTitle);
92 g_free (myData.cArtist);
93 g_free (myData.cAlbum);
94 g_free (myData.cCoverPath);
95 g_free (myData.cPreviousCoverPath);
96 g_free (myData.cPreviousRawTitle);
97
98 // On s'occupe des handlers.
99 g_list_foreach (myData.pHandlers, (GFunc) cd_musicplayer_free_handler, NULL);
100 g_list_free (myData.pHandlers);
101
102 // Bye bye pauvres textures opengl
103 cd_opengl_reset_opengl_datas (myApplet);
104
105 CD_APPLET_RESET_DATA_END