* check for a valid foldername
[modest] / src / maemo / modest-platform.c
index 602a175..b1a8227 100644 (file)
 static osso_context_t *osso_context = NULL;
 
 static void    
-on_modest_conf_update_interval_changed (ModestConf* self, const gchar *key, 
-       ModestConfEvent event, gpointer user_data)
+on_modest_conf_update_interval_changed (ModestConf* self, 
+                                       const gchar *key, 
+                                       ModestConfEvent event,
+                                       ModestConfNotificationId id, 
+                                       gpointer user_data)
 {
        if (strcmp (key, MODEST_CONF_UPDATE_INTERVAL) == 0) {
                const guint update_interval_minutes = 
@@ -140,7 +143,13 @@ modest_platform_init (int argc, char *argv[])
        
 
        /* Make sure that the update interval is changed whenever its gconf key 
-        * is changed: */
+        * is changed */
+       /* CAUTION: we're not using here the
+          modest_conf_listen_to_namespace because we know that there
+          are other parts of Modest listening for this namespace, so
+          we'll receive the notifications anyway. We basically do not
+          use it because there is no easy way to do the
+          modest_conf_forget_namespace */
        ModestConf *conf = modest_runtime_get_conf ();
        g_signal_connect (G_OBJECT(conf),
                          "key_changed",
@@ -149,7 +158,7 @@ modest_platform_init (int argc, char *argv[])
                          
        /* Get the initial update interval from gconf: */
        on_modest_conf_update_interval_changed(conf, MODEST_CONF_UPDATE_INTERVAL,
-               MODEST_CONF_EVENT_KEY_CHANGED, NULL);
+                                              MODEST_CONF_EVENT_KEY_CHANGED, 0, NULL);
 
        /* initialize the addressbook */
        if (!osso_abook_init (&argc, &argv, osso_context)) {
@@ -515,7 +524,8 @@ modest_platform_get_icon (const gchar *name)
        GtkIconTheme *current_theme = NULL;
 
        g_return_val_if_fail (name, NULL);
-       
+
+#if 0 /* do we still need this? */
        if (g_str_has_suffix (name, ".png")) { /*FIXME: hack*/
                pixbuf = gdk_pixbuf_new_from_file (name, &err);
                if (!pixbuf) {
@@ -526,7 +536,7 @@ modest_platform_get_icon (const gchar *name)
                }
                return pixbuf;
        }
-
+#endif /* */
        current_theme = gtk_icon_theme_get_default ();
        pixbuf = gtk_icon_theme_load_icon (current_theme, name, 26,
                                           GTK_ICON_LOOKUP_NO_SVG,
@@ -563,28 +573,16 @@ entry_insert_text (GtkEditable *editable,
                hildon_banner_show_information  (gtk_widget_get_parent (GTK_WIDGET (data)), NULL,
                                                 _CS("ckdg_ib_maximum_characters_reached"));
        } else {
-               gboolean is_valid = FALSE;
-
-               if (!text)
-                       is_valid = FALSE;
-               else if (strlen(text) == 0 && g_str_has_prefix (chars, " "))
-                       is_valid = FALSE;
-               else
-                       is_valid = !g_str_has_prefix(text, " ");
+               GtkWidget *ok_button;
+               GList *buttons;
                
-               /* A blank space is not valid as first character */
-               if (is_valid) {
-                       GtkWidget *ok_button;
-                       GList *buttons;
-                       
-                       /* Show OK button */
-                       buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (data)->action_area));
-                       ok_button = GTK_WIDGET (buttons->next->data);
-                               gtk_widget_set_sensitive (ok_button, TRUE);
-                               g_list_free (buttons);
+               buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (data)->action_area));
+               ok_button = GTK_WIDGET (buttons->next->data);
+               
+               gtk_widget_set_sensitive (ok_button,
+                                         modest_text_utils_validate_folder_name (chars));      
+               g_list_free (buttons);
                
-               }
-
                /* Write the text in the entry */
                g_signal_handlers_block_by_func (editable,
                                                 (gpointer) entry_insert_text, data);
@@ -601,24 +599,24 @@ entry_changed (GtkEditable *editable,
               gpointer     user_data)
 {
        gchar *chars;
+       GtkWidget *ok_button;
+       GList *buttons;
 
+       buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (user_data)->action_area));
+       ok_button = GTK_WIDGET (buttons->next->data);
+       
        chars = gtk_editable_get_chars (editable, 0, -1);
        g_return_if_fail (chars != NULL);
 
-       /* Dimm OK button. Do not allow also the "/" */
-       if (strlen (chars) == 0 || strchr (chars, '/')) {
-               GtkWidget *ok_button;
-               GList *buttons;
-
-               buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (user_data)->action_area));
-               ok_button = GTK_WIDGET (buttons->next->data);
-               gtk_widget_set_sensitive (ok_button, FALSE);
-
-               g_list_free (buttons);
-       } else if (g_utf8_strlen (chars,-1) >= 21)
+       
+       if (g_utf8_strlen (chars,-1) >= 21)
                hildon_banner_show_information  (gtk_widget_get_parent (GTK_WIDGET (user_data)), NULL,
-                                                _CS("ckdg_ib_maximum_characters_reached"));            
+                                                _CS("ckdg_ib_maximum_characters_reached"));
+       else
+               gtk_widget_set_sensitive (ok_button, modest_text_utils_validate_folder_name(chars));
+               
        /* Free */
+       g_list_free (buttons);
        g_free (chars);
 }
 
@@ -1332,10 +1330,11 @@ modest_platform_create_folder_view (TnyFolderStoreQuery *query)
 {
        GtkWidget *widget = modest_folder_view_new (query);
 
-       /* Show all accounts by default */
+       /* Show one account by default */
        modest_folder_view_set_style (MODEST_FOLDER_VIEW (widget),
                                      MODEST_FOLDER_VIEW_STYLE_SHOW_ONE);
 
+
        /* Restore settings */
        modest_widget_memory_restore (modest_runtime_get_conf(), 
                                      G_OBJECT (widget),