2007-07-31 Philip Van Hoof <pvanhoof@gnome.org>
[modest] / src / maemo / modest-platform.c
index 3fec988..73d4c1f 100644 (file)
 
 static osso_context_t *osso_context = NULL;
 
-static void  folder_name_insensitive_press (GtkWidget *widget, 
-                                           ModestWindow *window);
-       
 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 = 
@@ -143,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",
@@ -152,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)) {
@@ -518,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) {
@@ -529,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,
@@ -604,24 +611,28 @@ 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);
+       if (strlen (chars) == 0 || strchr (chars, '/')) 
                gtk_widget_set_sensitive (ok_button, FALSE);
-
-               g_list_free (buttons);
-       } else if (g_utf8_strlen (chars,-1) >= 21)
+               
+       else 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 /* explicitely enable it, because with a previous entry_changed, it might have been turned off */
+               gtk_widget_set_sensitive (ok_button, TRUE);
+               
        /* Free */
+       g_list_free (buttons);
        g_free (chars);
 }
 
@@ -781,10 +792,6 @@ modest_platform_run_folder_name_dialog (GtkWindow *parent_window,
        /* Add accept button (with unsensitive handler) */
        buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area));
        accept_btn = GTK_WIDGET (buttons->next->data);
-       g_signal_connect (G_OBJECT (accept_btn), "insensitive-press", 
-                         G_CALLBACK (folder_name_insensitive_press), 
-                         parent_window);
-
        /* Create label and entry */
        label = gtk_label_new (label_text);
        /* TODO: check that the suggested name does not exist */
@@ -831,12 +838,6 @@ modest_platform_run_folder_name_dialog (GtkWindow *parent_window,
        return result;
 }
 
-static void  
-folder_name_insensitive_press (GtkWidget *widget, ModestWindow *window)
-{
-       hildon_banner_show_information (NULL, NULL, _CS("ckdg_ib_enter_name"));
-}
-
 gint
 modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
                                       TnyFolderStore *parent_folder,
@@ -1345,10 +1346,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),