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

« back to all changes in this revision

Viewing changes to clock/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 clock applet, 
 
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
#include <stdlib.h>
 
29
#include <math.h>
 
30
#define __USE_POSIX
 
31
#include <signal.h>
 
32
 
 
33
#include "applet-struct.h"
 
34
#include "applet-draw.h"
 
35
#include "applet-notifications.h"
 
36
 
 
37
 
 
38
static void _cd_clock_launch_time_admin (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
 
39
{
 
40
        if (myConfig.cSetupTimeCommand != NULL)
 
41
        {
 
42
                cairo_dock_launch_command (myConfig.cSetupTimeCommand);
 
43
        }
 
44
        else
 
45
        {
 
46
                if (! cairo_dock_fm_setup_time ())
 
47
                {
 
48
                        if (g_iDesktopEnv == CAIRO_DOCK_KDE)
 
49
                        {
 
50
                                cairo_dock_launch_command ("kcmshell kde-clock.desktop");
 
51
                        }
 
52
                        else
 
53
                        {
 
54
                                cd_warning ("couldn't guess what to do to set up time.");
 
55
                        }
 
56
                }
 
57
        }
 
58
}
 
59
 
 
60
 
 
61
 
 
62
 
 
63
CD_APPLET_ON_CLICK_BEGIN
 
64
        if (myData.pCalendarDialog != NULL)
 
65
        {
 
66
                cairo_dock_dialog_unreference (myData.pCalendarDialog);
 
67
                myData.pCalendarDialog = NULL;
 
68
        }
 
69
        else
 
70
        {
 
71
                GtkWidget *pCalendar = gtk_calendar_new ();
 
72
                myData.pCalendarDialog = cairo_dock_show_dialog_full (_("Calendar"),
 
73
                        myIcon, myContainer,
 
74
                        0,
 
75
                        MY_APPLET_SHARE_DATA_DIR"/dates.svg",
 
76
                        pCalendar,
 
77
                        NULL, NULL, NULL);
 
78
        }
 
79
CD_APPLET_ON_CLICK_END
 
80
 
 
81
 
 
82
CD_APPLET_ON_BUILD_MENU_BEGIN
 
83
        GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
 
84
                CD_APPLET_ADD_IN_MENU (D_("Set up time and date"), _cd_clock_launch_time_admin, pSubMenu);
 
85
                CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
 
86
CD_APPLET_ON_BUILD_MENU_END
 
87
 
 
88
 
 
89
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
 
90
        if (myData.iAlarmPID > 0)
 
91
        {
 
92
                kill (myData.iAlarmPID, 1);
 
93
                myData.iAlarmPID = 0;
 
94
        }
 
95
        cairo_dock_remove_dialog_if_any (myIcon);
 
96
        myData.pCalendarDialog = NULL;
 
97
CD_APPLET_ON_MIDDLE_CLICK_END
 
98
 
 
99
 
 
100
CD_APPLET_ON_UPDATE_ICON_BEGIN
 
101
        myData.iSmoothAnimationStep ++;
 
102
        int iDetlaT = cairo_dock_get_slow_animation_delta_t (myContainer);
 
103
        int iNbSteps = 1.*myConfig.iSmoothAnimationDuration / iDetlaT;  // on anime l'aiguille sur 500ms.
 
104
        if (myData.iSmoothAnimationStep > iNbSteps)
 
105
                CD_APPLET_SKIP_UPDATE_ICON;
 
106
        
 
107
        // taille de la texture.
 
108
        int iWidth, iHeight;
 
109
        CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
 
110
        
 
111
        // render to texture
 
112
        cd_clock_render_analogic_to_texture (myApplet, iWidth, iHeight, &myData.currentTime, 1.*myData.iSmoothAnimationStep / iNbSteps);
 
113
CD_APPLET_ON_UPDATE_ICON_END