2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
******************************************************************************/
31
#include <glib/gi18n.h>
32
#include <cairo-dock.h>
34
#include "applet-struct.h"
35
#include "applet-xgamma.h"
36
#include "applet-notifications.h"
39
CD_APPLET_ON_CLICK_BEGIN
42
double fGamma = xgamma_get_gamma (&myData.Xgamma);
45
fGamma = cairo_dock_show_value_and_wait (D_("Set up gamma :"), myIcon, myContainer, fGamma, GAMMA_MAX);
48
fGamma = MAX (fGamma, GAMMA_MIN);
50
myData.Xgamma.red = fGamma;
51
myData.Xgamma.blue = fGamma;
52
myData.Xgamma.green = fGamma;
53
xgamma_set_gamma (&myData.Xgamma);
57
CD_APPLET_ON_CLICK_END
59
static void _cd_xgamma_remember_current_gamma (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
61
double fGamma = xgamma_get_gamma (&myData.Xgamma);
62
g_return_if_fail (fGamma > 0);
64
cairo_dock_update_conf_file (myApplet->cConfFilePath,
65
G_TYPE_DOUBLE, "Configuration", "initial gamma", fGamma,
68
CD_APPLET_ON_BUILD_MENU_BEGIN
69
GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
70
CD_APPLET_ADD_IN_MENU (D_("Apply current luminosity on startup"), _cd_xgamma_remember_current_gamma, pSubMenu);
71
CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
72
CD_APPLET_ON_BUILD_MENU_END
75
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
78
double fGamma = xgamma_get_gamma (&myData.Xgamma);
81
//\___________________ On construit notre widget si c'est la 1ere fois.
82
if (myData.pWidget == NULL)
84
xgamma_build_and_show_widget ();
88
//\___________________ On lui met les valeurs a jour, sans appeler les callbacks.
89
g_signal_handler_block (myData.pGlobalScale, myData.iGloalScaleSignalID);
90
g_signal_handler_block (myData.pRedScale, myData.iRedScaleSignalID);
91
g_signal_handler_block (myData.pGreenScale, myData.iGreenScaleSignalID);
92
g_signal_handler_block (myData.pBlueScale, myData.iBlueScaleSignalID);
94
gtk_range_set_value (GTK_RANGE (myData.pGlobalScale), fGamma);
95
gtk_range_set_value (GTK_RANGE (myData.pRedScale), myData.Xgamma.red);
96
gtk_range_set_value (GTK_RANGE (myData.pGreenScale), myData.Xgamma.green);
97
gtk_range_set_value (GTK_RANGE (myData.pBlueScale), myData.Xgamma.blue);
98
myData.XoldGamma = myData.Xgamma;
100
g_signal_handler_unblock (myData.pGlobalScale, myData.iGloalScaleSignalID);
101
g_signal_handler_unblock (myData.pRedScale, myData.iRedScaleSignalID);
102
g_signal_handler_unblock (myData.pGreenScale, myData.iGreenScaleSignalID);
103
g_signal_handler_unblock (myData.pBlueScale, myData.iBlueScaleSignalID);
105
if (myData.pDialog != NULL)
107
cairo_dock_unhide_dialog (myData.pDialog);
112
CD_APPLET_ON_MIDDLE_CLICK_END
115
CD_APPLET_ON_SCROLL_BEGIN
116
double fGamma = xgamma_get_gamma (&myData.Xgamma);
117
g_print ("%.2f;%.2f;%.2f\n", myData.Xgamma.red, myData.Xgamma.green, myData.Xgamma.blue);
119
if (CD_APPLET_SCROLL_UP)
121
f = (1. - myConfig.iScrollVariation/100.);
122
myData.Xgamma.red *= f;
123
myData.Xgamma.green *= f;
124
myData.Xgamma.blue *= f;
128
f = (1. + myConfig.iScrollVariation/100.);
129
myData.Xgamma.red *= f;
130
myData.Xgamma.green *= f;
131
myData.Xgamma.blue *= f;
134
xgamma_set_gamma (&myData.Xgamma);
135
CD_APPLET_ON_SCROLL_END