~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to Xgamma/src/applet-notifications.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/******************************************************************************
 
21
 
 
22
This file is a part of the cairo-dock program, 
 
23
released under the terms of the GNU General Public License.
 
24
 
 
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
 
26
 
 
27
******************************************************************************/
 
28
 
 
29
#include <stdlib.h>
 
30
#include <string.h>
 
31
#include <glib/gi18n.h>
 
32
#include <cairo-dock.h>
 
33
 
 
34
#include "applet-struct.h"
 
35
#include "applet-xgamma.h"
 
36
#include "applet-notifications.h"
 
37
 
 
38
 
 
39
CD_APPLET_ON_CLICK_BEGIN
 
40
        if (myDock)
 
41
        {
 
42
                double fGamma = xgamma_get_gamma (&myData.Xgamma);
 
43
                if (fGamma > 0)
 
44
                {
 
45
                        fGamma = cairo_dock_show_value_and_wait (D_("Set up gamma :"), myIcon, myContainer, fGamma, GAMMA_MAX);
 
46
                        if (fGamma > 0)
 
47
                        {
 
48
                                fGamma = MAX (fGamma, GAMMA_MIN);
 
49
                                
 
50
                                myData.Xgamma.red = fGamma;
 
51
                                myData.Xgamma.blue = fGamma;
 
52
                                myData.Xgamma.green = fGamma;
 
53
                                xgamma_set_gamma (&myData.Xgamma);
 
54
                        }
 
55
                }
 
56
        }
 
57
CD_APPLET_ON_CLICK_END
 
58
 
 
59
static void _cd_xgamma_remember_current_gamma (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
 
60
{
 
61
        double fGamma = xgamma_get_gamma (&myData.Xgamma);
 
62
        g_return_if_fail (fGamma > 0);
 
63
        
 
64
        cairo_dock_update_conf_file (myApplet->cConfFilePath,
 
65
                G_TYPE_DOUBLE, "Configuration", "initial gamma", fGamma,
 
66
                G_TYPE_INVALID);
 
67
}
 
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
 
73
 
 
74
 
 
75
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
 
76
        if (myDock)
 
77
        {
 
78
                double fGamma = xgamma_get_gamma (&myData.Xgamma);
 
79
                if (fGamma > 0)
 
80
                {
 
81
                        //\___________________ On construit notre widget si c'est la 1ere fois.
 
82
                        if (myData.pWidget == NULL)
 
83
                        {
 
84
                                xgamma_build_and_show_widget ();
 
85
                        }
 
86
                        else
 
87
                        {
 
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);
 
93
                                
 
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;
 
99
                                
 
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);
 
104
                                
 
105
                                if (myData.pDialog != NULL)
 
106
                                {
 
107
                                        cairo_dock_unhide_dialog (myData.pDialog);
 
108
                                }
 
109
                        }
 
110
                }
 
111
        }
 
112
CD_APPLET_ON_MIDDLE_CLICK_END
 
113
 
 
114
 
 
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);
 
118
        double f;
 
119
        if (CD_APPLET_SCROLL_UP)
 
120
        {
 
121
                f = (1. - myConfig.iScrollVariation/100.);
 
122
                myData.Xgamma.red *= f;
 
123
                myData.Xgamma.green *= f;
 
124
                myData.Xgamma.blue *= f;
 
125
        }
 
126
        else
 
127
        {
 
128
                f = (1. + myConfig.iScrollVariation/100.);
 
129
                myData.Xgamma.red *= f;
 
130
                myData.Xgamma.green *= f;
 
131
                myData.Xgamma.blue *= f;
 
132
        }
 
133
        
 
134
        xgamma_set_gamma (&myData.Xgamma);
 
135
CD_APPLET_ON_SCROLL_END