| 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-notifications.h" |
| 25 |
#include "applet-draw.h" |
| 26 |
#include "applet-session.h" |
| 27 |
#include "applet-appli-finder.h" |
| 28 |
#include "applet-listing.h" |
| 29 |
#include "applet-search.h" |
| 30 |
#include "applet-config.h" |
| 31 |
|
| 32 |
static const gchar *s_DefaultApplis[26+1] = { |
| 33 |
"abiword", |
| 34 |
"gnome-background-properties", |
| 35 |
"gnome-calculator", |
| 36 |
"gnome-dictionary", |
| 37 |
"evince", |
| 38 |
"firefox", |
| 39 |
"gjiten", |
| 40 |
"", |
| 41 |
"inkscape", |
| 42 |
"", |
| 43 |
"kate", |
| 44 |
"", |
| 45 |
"", |
| 46 |
"nautilus --browser", |
| 47 |
"ooffice", |
| 48 |
"pan", |
| 49 |
"", |
| 50 |
"rhythmbox", |
| 51 |
"synaptic", |
| 52 |
"gnome-terminal", |
| 53 |
"", |
| 54 |
"vlc", |
| 55 |
"", |
| 56 |
"", |
| 57 |
"yast", |
| 58 |
"", |
| 59 |
NULL}; |
| 60 |
|
| 61 |
//\_________________ 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. |
| 62 |
CD_APPLET_GET_CONFIG_BEGIN |
| 63 |
myConfig.cShortkeySearch = CD_CONFIG_GET_STRING ("Configuration", "shortkey search"); |
| 64 |
myConfig.iAppearanceDuration = CD_CONFIG_GET_INTEGER ("Configuration", "appear duration"); |
| 65 |
myConfig.iCloseDuration = CD_CONFIG_GET_INTEGER ("Configuration", "stop duration"); |
| 66 |
myConfig.cIconAnimation = CD_CONFIG_GET_STRING ("Configuration", "animation"); |
| 67 |
CD_CONFIG_GET_COLOR_RGBA ("Configuration", "frame color", myConfig.pFrameColor); |
| 68 |
|
| 69 |
myConfig.fFontSizeRatio = CD_CONFIG_GET_DOUBLE ("Configuration", "font size"); |
| 70 |
myConfig.bTextOnTop = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "text on top", TRUE); |
| 71 |
|
| 72 |
myConfig.labelDescription.cFont = CD_CONFIG_GET_STRING_WITH_DEFAULT ("Configuration", "font", "Monospace 16"); |
| 73 |
myConfig.labelDescription.bOutlined = CD_CONFIG_GET_BOOLEAN ("Configuration", "text outlined"); |
| 74 |
CD_CONFIG_GET_COLOR ("Configuration", "text color", &myConfig.labelDescription.fColorStart); |
| 75 |
myConfig.labelDescription.iMargin = 2; |
| 76 |
CD_CONFIG_GET_COLOR ("Configuration", "bg color", &myConfig.labelDescription.fBackgroundColor); |
| 77 |
|
| 78 |
myConfig.iNbResultMax = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "nb results", 50); |
| 79 |
myConfig.iNbLinesInListing = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "nb lines", 10); |
| 80 |
|
| 81 |
myConfig.infoDescription.cFont = g_strdup ("Sans 14"); |
| 82 |
myConfig.infoDescription.iSize = 14; |
| 83 |
myConfig.infoDescription.bOutlined = FALSE; |
| 84 |
myConfig.infoDescription.fColorStart.rgba.red = 1; |
| 85 |
myConfig.infoDescription.fColorStart.rgba.green = 0; |
| 86 |
myConfig.infoDescription.fColorStart.rgba.blue = 0; |
| 87 |
myConfig.infoDescription.fColorStart.rgba.alpha = 0; |
| 88 |
myConfig.infoDescription.fBackgroundColor.rgba.red = 1; |
| 89 |
myConfig.infoDescription.fBackgroundColor.rgba.green = 0; |
| 90 |
myConfig.infoDescription.fBackgroundColor.rgba.blue = 0; |
| 91 |
myConfig.infoDescription.fBackgroundColor.rgba.alpha = 0.33; |
| 92 |
myConfig.infoDescription.iMargin = 8; |
| 93 |
|
| 94 |
myConfig.cPreferredApplis = g_new0 (gchar *, 26+1); // NULL-terminated |
| 95 |
gchar key[2]; |
| 96 |
int i; |
| 97 |
for (i = 0; i < 26; i ++) |
| 98 |
{ |
| 99 |
sprintf (key, "%c", 'a'+i); |
| 100 |
myConfig.cPreferredApplis[i] = CD_CONFIG_GET_STRING_WITH_DEFAULT ("Configuration", key, s_DefaultApplis[i]); |
| 101 |
} |
| 102 |
|
| 103 |
myConfig.bUseFiles = CD_CONFIG_GET_BOOLEAN ("Search Engines", "files"); |
| 104 |
myConfig.bUseFirefox = CD_CONFIG_GET_BOOLEAN ("Search Engines", "firefox"); |
| 105 |
myConfig.bUseRecent = CD_CONFIG_GET_BOOLEAN ("Search Engines", "recent"); |
| 106 |
myConfig.bUseWeb = CD_CONFIG_GET_BOOLEAN ("Search Engines", "web"); |
| 107 |
myConfig.bUseCommand = CD_CONFIG_GET_BOOLEAN ("Search Engines", "cmd"); |
| 108 |
CD_APPLET_GET_CONFIG_END |
| 109 |
|
| 110 |
|
| 111 |
//\_________________ 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. |
| 112 |
CD_APPLET_RESET_CONFIG_BEGIN |
| 113 |
g_free (myConfig.cShortkeySearch); |
| 114 |
g_free (myConfig.cIconAnimation); |
| 115 |
g_free (myConfig.labelDescription.cFont); |
| 116 |
g_strfreev (myConfig.cPreferredApplis); |
| 117 |
CD_APPLET_RESET_CONFIG_END |
| 118 |
|
| 119 |
|
| 120 |
//\_________________ 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. |
| 121 |
CD_APPLET_RESET_DATA_BEGIN |
| 122 |
cd_do_close_session (); |
| 123 |
cd_do_exit_session (); |
| 124 |
|
| 125 |
cd_do_free_all_backends (); |
| 126 |
|
| 127 |
cd_do_reset_applications_list (); |
| 128 |
|
| 129 |
cd_do_destroy_listing (myData.pListing); |
| 130 |
|
| 131 |
if (myData.pPromptSurface != NULL) |
| 132 |
cairo_surface_destroy (myData.pPromptSurface); |
| 133 |
if (myData.iPromptTexture != 0) |
| 134 |
_cairo_dock_delete_texture (myData.iPromptTexture); |
| 135 |
if (myData.pScoobySurface != NULL) |
| 136 |
cairo_surface_destroy (myData.pScoobySurface); |
| 137 |
if (myData.pActiveButtonSurface != NULL) |
| 138 |
cairo_surface_destroy (myData.pActiveButtonSurface); |
| 139 |
if (myData.pInactiveButtonSurface != NULL) |
| 140 |
cairo_surface_destroy (myData.pInactiveButtonSurface); |
| 141 |
CD_APPLET_RESET_DATA_END |