~cairo-dock-team/ubuntu/precise/cairo-dock-plug-ins/984054

« back to all changes in this revision

Viewing changes to mail/src/cd-mail-applet-config.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-10 00:05:57 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810000557-pfxoz5w7hbyclcqh
Tags: 2.2.0~0beta4-0ubuntu1
* New Upstream Version (LP: #614625)
* Fixed a few bugs on LP:
 - LP: #483963: Dustbin applet does not display trashes on all volumes
 - LP: #485159: Some apps have problem with Systray
 - LP: #500677: ~/.xsession-errors is too much used by CD
 - LP: #500979: Shortcuts: the order gets messed up
 - LP: #521531: Mail: crashes on Maildir
 - LP: #519915: GTG: create a new applet to control GTG
 - LP: #526138: GMenu doesn't handle desktop file exec strings properly
 - LP: #531317: CMake: Added an error if the prefix of 'cairo-dock-plugins'
                 is not the same 'cairo-dock-core'
 - LP: #531319: CMake: check the version of 'cairo-dock' when building
                 'cairo-dock-plugins'
 - LP: #537115: Click at the position where icon lavel was, the icon
                 and dock still receive the event
 - LP: #537943: Terminal applet shortkey behaviour
 - LP: #538637: Trash applet doesn't create .trashinfo files on XFCE
 - More details on the 'ChangeLog' file
* debian/rules:
 - Autotools has been replaced by CMake
 - cdbs is now used.
* debian/copyright:
 - Updated with the new applets
* debian/control:
 - Autotools has been replaced by CMake
 - Added libcurl4-gnutls-dev, libindicator-dev, libdbusmenu-glib-dev
   libido-0.1-dev, libical-dev, libdbusmenu-gtk-dev as Build-deps
 - Bump Standard-Version to 3.9.1
 - Wget is required for dnd2share applet
 - Added the exact realease for 'cairo-dock-dev' in order to prevent any
    build error if this package is not already available (thx to didrocks)
* debian/cairo-dock-plug-ins*.install:
 - All sonames are now installed into lib32 or lib64 (lib*)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "cd-mail-applet-accounts.h"
26
26
#include "cd-mail-applet-etpan.h"
27
27
 
 
28
typedef void (*cd_mail_fill_account)(CDMailAccount *mailaccount, GKeyFile *pKeyFile, const gchar *mailbox_name);
 
29
typedef void (*cd_mail_create_account)( GKeyFile *pKeyFile, const gchar *pMailAccountName );
28
30
 
29
31
struct storage_type_def {
30
 
  char * name;
31
 
  char * description;
 
32
  const gchar * name;
 
33
  const gchar * description;
32
34
  cd_mail_fill_account pfillFunc;
33
35
  cd_mail_create_account pcreateFunc;
34
36
};
35
37
 
36
38
static struct storage_type_def storage_tab[] = {
37
 
  {"pop3", "POP3", cd_mail_retrieve_pop3_params, cd_mail_create_pop3_params },
38
 
  {"imap", "IMAP", cd_mail_retrieve_imap_params, cd_mail_create_imap_params },
39
 
  {"mbox", "MBox", cd_mail_retrieve_mbox_params, cd_mail_create_mbox_params },
40
 
  {"mh", "MH", cd_mail_retrieve_mh_params, cd_mail_create_mh_params },
41
 
  {"maildir", "MailDir", cd_mail_retrieve_maildir_params , cd_mail_create_maildir_params},
42
 
  {"gmail", "GMail", cd_mail_retrieve_gmail_params, cd_mail_create_gmail_params },
 
39
        {"pop3", "POP3", cd_mail_retrieve_pop3_params, cd_mail_create_pop3_params },
 
40
        {"imap", "IMAP", cd_mail_retrieve_imap_params, cd_mail_create_imap_params },
 
41
        {"mbox", "MBox", cd_mail_retrieve_mbox_params, cd_mail_create_mbox_params },
 
42
        {"mh", "MH", cd_mail_retrieve_mh_params, cd_mail_create_mh_params },
 
43
        {"maildir", "MailDir", cd_mail_retrieve_maildir_params , cd_mail_create_maildir_params},
 
44
        {"gmail", "GMail", cd_mail_retrieve_gmail_params, cd_mail_create_gmail_params }
43
45
#if ( __WORDSIZE == 64 )
44
46
/* in 64bit libetpan crashes with RSS, so... avoid it. */
45
47
#warning "Compilation 64bits: avoiding RSS accounts"
46
48
#else
47
 
  {"feed", "RSS/Feed", cd_mail_retrieve_feed_params, cd_mail_create_feed_params },
 
49
        ,{"feed", "RSS/Feed", cd_mail_retrieve_feed_params, cd_mail_create_feed_params }
48
50
#endif
49
51
};
50
52
 
51
 
const int MAIL_NB_STORAGE_TYPES = sizeof(storage_tab) / sizeof(struct storage_type_def);
 
53
const guint MAIL_NB_STORAGE_TYPES = sizeof(storage_tab) / sizeof(struct storage_type_def);
52
54
 
53
55
static void _get_mail_accounts (GKeyFile *pKeyFile, CairoDockModuleInstance *myApplet)
54
56
{
73
75
        //\_______________ On recupere les comptes mail dans le fichier de conf.
74
76
        CDMailAccount *pMailAccount;
75
77
        gchar *cMailAccountName;
76
 
        int j, account_type;
 
78
        guint j;
77
79
        gsize i, length = 0;
78
 
        gchar **pGroupList = g_key_file_get_groups (pKeyFile, &length);
 
80
        gboolean bFlushConfFileNeeded = FALSE;
 
81
                gchar **pGroupList = g_key_file_get_groups (pKeyFile, &length);
79
82
        myData.pMailAccounts = g_ptr_array_sized_new (length - 3);
80
83
        
81
 
        g_print ("recuperons les comptes ...\n");
 
84
        cd_debug ("recuperons les comptes ...\n");
82
85
        for (i = 3; i < length; i ++)  // Icon, Desklet, Configuration + mail groups
83
86
        {
84
87
                cMailAccountName = pGroupList[i];
85
 
                g_print ("+ on recupere le compte '%s'\n", cMailAccountName);
 
88
                cd_debug ("+ on recupere le compte '%s'\n", cMailAccountName);
86
89
                
87
 
                /* Get the type of the account */
 
90
                // Get the type of the account.
88
91
                if (! g_key_file_has_key (pKeyFile, cMailAccountName, "type", NULL))
89
92
                        continue ;
90
93
                
91
94
                gchar *cMailAccountType = g_key_file_get_string (pKeyFile, cMailAccountName, "type", NULL);
92
 
 
 
95
                if (cMailAccountType == NULL)
 
96
                        continue;
 
97
                
93
98
                for( j = 0; j < MAIL_NB_STORAGE_TYPES; j++ )
94
99
                {
95
100
                        if (g_strcasecmp(storage_tab[j].name, cMailAccountType) == 0)
96
101
                        {
97
 
                                account_type = j;
98
102
                                break;
99
103
                        }
100
104
                }
101
 
                /* in case the account type is unknown, just ignore... */
 
105
                g_free (cMailAccountType);
 
106
                
 
107
                // in case the account type is unknown, just ignore.
102
108
                if( j >= MAIL_NB_STORAGE_TYPES )
103
109
                        continue;
104
 
                g_print ("  mail type : %d\n", j);
 
110
                cd_debug ("  mail type : %d\n", j);
105
111
                
 
112
                // create a new mail account.
106
113
                pMailAccount = g_new0 (CDMailAccount, 1);
107
114
                g_ptr_array_add (myData.pMailAccounts, pMailAccount);
108
115
 
109
116
                pMailAccount->name = g_strdup (cMailAccountName);
110
 
                
 
117
                pMailAccount->timeout = CD_CONFIG_GET_INTEGER_WITH_DEFAULT (cMailAccountName, "timeout mn", 10);
111
118
                pMailAccount->pAppletInstance = myApplet;
112
 
                (storage_tab[account_type].pfillFunc)( pMailAccount, pKeyFile, cMailAccountName );
113
 
 
114
 
                /* get a specific mail application to launch for this account, if any */
115
 
                pMailAccount->cMailApp = g_strdup(g_key_file_get_string (pKeyFile, cMailAccountName, "mail application", NULL));
 
119
                pMailAccount->cMailApp = g_key_file_get_string (pKeyFile, cMailAccountName, "mail application", NULL);  // a specific mail application to launch for this account, if any.
 
120
                (storage_tab[j].pfillFunc)( pMailAccount, pKeyFile, cMailAccountName );
116
121
        }
117
122
        g_strfreev (pGroupList);
118
123
}
126
131
        path = CD_CONFIG_GET_STRING ("Configuration", "has mail image");
127
132
        myConfig.cHasMailUserImage = (path?cairo_dock_generate_file_path (path):NULL);
128
133
        g_free (path);
 
134
        myConfig.bPlaySound = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "play sound", TRUE);
129
135
        path = CD_CONFIG_GET_STRING ("Configuration", "new mail sound");
130
136
        myConfig.cNewMailUserSound = (path?cairo_dock_generate_file_path (path):NULL);
131
137
        g_free (path);
132
138
 
133
139
        myConfig.cMailApplication = CD_CONFIG_GET_STRING ("Configuration", "mail application");
134
 
        myConfig.cMailClass = CD_CONFIG_GET_STRING ("Configuration", "mail class");
135
 
        myConfig.bStealTaskBarIcon = myConfig.cMailApplication && CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "inhibate appli", TRUE);
 
140
        /**myConfig.cMailClass = CD_CONFIG_GET_STRING ("Configuration", "mail class");
 
141
        myConfig.bStealTaskBarIcon = myConfig.cMailApplication && CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "inhibate appli", TRUE);*/
136
142
        myConfig.bShowMessageContent = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "show content", TRUE);
137
 
        myConfig.iNbMaxShown = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "max shown mails", -1);
 
143
        myConfig.iNbMaxShown = MIN (30, CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "max shown mails", 10));
138
144
        myConfig.bAlwaysShowMailCount = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "show zero mail", TRUE);
139
145
        //myConfig.bShowMessageContent = FALSE;
140
146
        
157
163
        g_free( myConfig.cHasMailUserImage );
158
164
        g_free( myConfig.cNewMailUserSound );
159
165
        g_free( myConfig.cMailApplication );
160
 
        g_free( myConfig.cMailClass );
 
166
        ///g_free( myConfig.cMailClass );
161
167
        g_free (myConfig.cThemePath);
162
168
        g_free (myConfig.cRenderer);
163
169
 
193
199
        cd_debug ("");
194
200
        
195
201
        //\____________ On recupere le type et le nom du nouveau compte.
196
 
        gint iChosenAccountType = gtk_combo_box_get_active(pMailTypesCombo);
197
 
        if( iChosenAccountType < 0 || iChosenAccountType >= MAIL_NB_STORAGE_TYPES )
 
202
        guint iChosenAccountType = gtk_combo_box_get_active(pMailTypesCombo);
 
203
        if( iChosenAccountType >= MAIL_NB_STORAGE_TYPES )
198
204
        {
199
205
                cd_warning ("while trying get chosen account type (%d) : out of range.", iChosenAccountType);
200
206
                cairo_dock_show_temporary_dialog_with_icon (D_("Please choose an account type."), myIcon, myContainer, 3000, "same icon");
321
327
{
322
328
        cd_debug ("");
323
329
        //\____________ On recupere notre widget personnalise (un simple container vide qu'on va remplir avec nos trucs).
324
 
        GtkWidget *pCustomWidgetBox = cairo_dock_get_widget_from_name ("Configuration", "add account");
325
 
        g_return_if_fail (pCustomWidgetBox != NULL);
 
330
        CairoDockGroupKeyWidget *pGroupKeyWidget = cairo_dock_get_group_key_widget_from_name ("Configuration", "add account");
 
331
        g_return_if_fail (pGroupKeyWidget != NULL);
 
332
        
 
333
        GtkWidget *pCustomWidgetBox = gtk_hbox_new (FALSE, 3);
 
334
        gtk_box_pack_end (GTK_BOX (pGroupKeyWidget->pKeyBox),
 
335
                pCustomWidgetBox,
 
336
                FALSE,
 
337
                FALSE,
 
338
                0);
326
339
        
327
340
        //\____________ On cree un combo pour selectionner le type de compte mail qu'on voudrait ajouter
328
341
        GtkWidget *pMailTypesCombo = gtk_combo_box_new_text();
329
342
        if( pMailTypesCombo )
330
343
        {
331
 
        for( int j = 0; j < MAIL_NB_STORAGE_TYPES; j++ )
 
344
       guint j;
 
345
        for( j = 0; j < MAIL_NB_STORAGE_TYPES; j++ )
332
346
        {
333
347
          gtk_combo_box_append_text( GTK_COMBO_BOX (pMailTypesCombo), storage_tab[j].description );
334
348
          //gtk_widget_set_tooltip_text (pMenuItem, D_("description du type de compte"));
382
396
                //pMailAccount = g_ptr_array_index (myData.pMailAccounts, i);  // i-3
383
397
                //cMailAccountName = pMailAccount->name;
384
398
                cMailAccountName = pGroupList[i];
385
 
                g_print ("- on ajoute le bouton remove au compte '%s'\n", cMailAccountName);
 
399
                cd_debug ("- on ajoute le bouton remove au compte '%s'\n", cMailAccountName);
386
400
                if (! g_key_file_has_group (pKeyFile, cMailAccountName))
387
401
                {
388
402
                        cd_warning ("mail : no group for mail account '%s'", cMailAccountName);
390
404
                }
391
405
                
392
406
                //\____________ On recupere notre widget personnalise (un simple container vide qu'on va remplir avec nos trucs).
393
 
                GtkWidget *pCustomWidgetBox = cairo_dock_get_widget_from_name (cMailAccountName, "remove account");
394
 
                if( pCustomWidgetBox == NULL )
 
407
                CairoDockGroupKeyWidget *pGroupKeyWidget = cairo_dock_get_group_key_widget_from_name (cMailAccountName, "remove account");
 
408
                if( pGroupKeyWidget == NULL )
395
409
                {
396
410
                        cd_warning ("mail : oups, there is a problem in the conf file");
397
411
                        continue;
404
418
                        "clicked",
405
419
                        G_CALLBACK (_cd_mail_remove_account),
406
420
                        myApplet);
407
 
                gtk_box_pack_start (GTK_BOX (pCustomWidgetBox),
 
421
                gtk_box_pack_start (GTK_BOX (pGroupKeyWidget->pKeyBox),
408
422
                        pButton,
409
423
                        FALSE,
410
424
                        FALSE,
416
430
 
417
431
void cd_mail_save_custom_widget (CairoDockModuleInstance *myApplet, GKeyFile *pKeyFile)
418
432
{
419
 
        g_print ("%s (%s)\n", __func__, myIcon->cName);
 
433
        cd_debug ("%s (%s)\n", __func__, myIcon->cName);
420
434
        // ca c'est si on avait des valeurs a recuperer dans nos widgets personnalises, et a stocker dans le pKeyFile. mais ici ils sont simple, et donc tous pris en charge par le dock.
421
435
}