~cairo-dock-team/ubuntu/natty/cairo-dock-plug-ins/2.3.0-2.1

« back to all changes in this revision

Viewing changes to clock/src/applet-backend-default.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Didier Roche
  • Date: 2010-09-18 14:20:27 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100918142027-b0zsay70mqxv63l0
Tags: 2.2.0~2-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New Upstream Version (LP: #638529)
* Fixed a few bugs on LP:
 - Fixed a crash in rainbow view when the cone is completely opened
 - Fixed a crash in rainbow view if the subdock is empty
 - Installed in lib directory by default even in 64bits arch
 - Status-Notifier: fixed few bugs
 - Clock applet:
   - Notify of missed tasks (moved some functions to a new file)
   - Fixed a little memory leak
 - Removed some 'g_print' (LP: #500677: xsession-errors log)
* Updated translations
* debian/control
 - Updated the version of cairo-dock-dev and cairo-dock-core

[ Didier Roche ]
* debian/control: depends on latest libindicator-dev (LP: #637692)

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        }
46
46
        gchar *cFile = g_strdup_printf ("%s/%s", cDirPath, "tasks.conf");
47
47
        GKeyFile *pKeyFile = cairo_dock_open_key_file (cFile);
48
 
        g_free (cFile);
 
48
        
49
49
        g_free (cDirPath);
50
50
        if (pKeyFile == NULL)  // encore aucune taches.
 
51
        {
 
52
                g_free (cFile);
51
53
                return NULL;
 
54
        }
52
55
        
53
56
        gsize length=0;
54
57
        gchar **pGroupList = g_key_file_get_groups (pKeyFile, &length);
55
58
        if (pGroupList == NULL)
56
59
        {
57
60
                g_key_file_free (pKeyFile);
 
61
                g_free (cFile);
58
62
                return NULL;
59
63
        }
60
64
        
61
65
        CDClockTask *pTask;
62
66
        gchar *cTaskID;
63
67
        GList *pTaskList = NULL;
 
68
        guint iMonth = myData.currentTime.tm_mon;
 
69
        guint iYear = myData.currentTime.tm_year + 1900;
 
70
        guint y, m, freq;
 
71
        gboolean bUpdateFile = FALSE;
64
72
        guint i;
65
73
        for (i = 0; i < length; i ++)
66
74
        {
67
75
                cTaskID = pGroupList[i];
 
76
                
 
77
                // discard tasks older than 1 year (clean the file too).
 
78
                y = g_key_file_get_integer (pKeyFile, cTaskID, "year", NULL);
 
79
                m = g_key_file_get_integer (pKeyFile, cTaskID, "month", NULL);
 
80
                freq = g_key_file_get_integer (pKeyFile, cTaskID, "freq", NULL);
 
81
                if (freq == CD_TASK_DONT_REPEAT && (iYear < y -1 || iYear == y - 1 && iMonth < m))
 
82
                {
 
83
                        g_key_file_remove_group (pKeyFile, cTaskID, NULL);
 
84
                        bUpdateFile = TRUE;
 
85
                        g_free (cTaskID);
 
86
                        continue;
 
87
                }
 
88
                
 
89
                // append the task.
68
90
                pTask = g_new0 (CDClockTask, 1);
69
 
                //g_print ("+ task %s\n", cTaskID);
70
 
                
71
91
                pTask->cID = cTaskID;
72
92
                pTask->iDay = g_key_file_get_integer (pKeyFile, cTaskID, "day", NULL);
73
 
                pTask->iMonth = g_key_file_get_integer (pKeyFile, cTaskID, "month", NULL);
74
 
                pTask->iYear = g_key_file_get_integer (pKeyFile, cTaskID, "year", NULL);
 
93
                pTask->iMonth = m;
 
94
                pTask->iYear = y;
75
95
                pTask->cTitle = g_key_file_get_string (pKeyFile, cTaskID, "title", NULL);
76
96
                pTask->cText = g_key_file_get_string (pKeyFile, cTaskID, "text", NULL);
77
97
                pTask->cTags = g_key_file_get_string (pKeyFile, cTaskID, "tags", NULL);
78
98
                pTask->iHour = g_key_file_get_integer (pKeyFile, cTaskID, "hour", NULL);
79
99
                pTask->iMinute = g_key_file_get_integer (pKeyFile, cTaskID, "minute", NULL);
80
 
                pTask->iFrequency = g_key_file_get_integer (pKeyFile, cTaskID, "freq", NULL);
 
100
                pTask->iFrequency = freq;
 
101
                pTask->bAcknowledged = g_key_file_get_boolean (pKeyFile, cTaskID, "ack", NULL);
81
102
                
82
103
                pTaskList = g_list_prepend (pTaskList, pTask);
83
104
                s_iCounter = MAX (s_iCounter, atoi (cTaskID));
84
105
        }
85
106
        
86
107
        g_free (pGroupList);  // les elements sont les IDs et sont integres dans les taches.
 
108
        
 
109
        if (bUpdateFile)
 
110
                cairo_dock_write_keys_to_file (pKeyFile, cFile);
 
111
        
87
112
        g_key_file_free (pKeyFile);
 
113
        g_free (cFile);
88
114
        return pTaskList;
89
115
}
90
116
 
107
133
        g_key_file_set_integer (pKeyFile, pTask->cID, "hour", pTask->iHour);
108
134
        g_key_file_set_integer (pKeyFile, pTask->cID, "minute", pTask->iMinute);
109
135
        g_key_file_set_integer (pKeyFile, pTask->cID, "freq", pTask->iFrequency);
 
136
        g_key_file_set_boolean (pKeyFile, pTask->cID, "ack", pTask->bAcknowledged);
110
137
        
111
138
        cairo_dock_write_keys_to_file (pKeyFile, cFile);
112
139
        g_free (cFile);
143
170
        g_key_file_set_integer (pKeyFile, pTask->cID, "hour", pTask->iHour);
144
171
        g_key_file_set_integer (pKeyFile, pTask->cID, "minute", pTask->iMinute);
145
172
        g_key_file_set_integer (pKeyFile, pTask->cID, "freq", pTask->iFrequency);
 
173
        g_key_file_set_boolean (pKeyFile, pTask->cID, "ack", pTask->bAcknowledged);
146
174
        
147
175
        cairo_dock_write_keys_to_file (pKeyFile, cFile);
148
176
        g_free (cFile);