* Some aesthetic changes
authorSergio Villar Senin <svillar@igalia.com>
Wed, 26 Sep 2007 12:12:09 +0000 (12:12 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 26 Sep 2007 12:12:09 +0000 (12:12 +0000)
* Removed an invalid g_warning
* Fixed a problem when changing the name of the device, the details widget was showing the %s after a device name change because it was using another different function than the one used for creating the widget
* Changed some ModestConf functions
* Modest now listens for changes in the keys without needing a folder view

pmo-trunk-r3421

src/maemo/modest-main-window.c
src/modest-conf.c
src/modest-conf.h
src/modest-ui-actions.h
src/widgets/modest-account-view.c
src/widgets/modest-folder-view.c

index 097776b..697be5e 100644 (file)
@@ -122,9 +122,8 @@ on_account_removed (TnyAccountStore *accoust_store,
                     TnyAccount *account,
                     gpointer user_data);
 
-static void
-on_default_account_changed (ModestAccountMgr* mgr,
-                           gpointer user_data);
+static void on_default_account_changed (ModestAccountMgr* mgr,
+                                       gpointer user_data);
 
 static gboolean on_inner_widgets_key_pressed  (GtkWidget *widget,
                                               GdkEventKey *event,
@@ -803,15 +802,19 @@ connect_signals (ModestMainWindow *self)
 
        /* folder view */
        
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
-                                                      G_OBJECT(priv->folder_view), "key-press-event",
-                                                      G_CALLBACK(on_inner_widgets_key_pressed), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), "folder_selection_changed",
-                                                      G_CALLBACK (modest_main_window_on_folder_selection_changed), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), "folder-display-name-changed",
-                                                      G_CALLBACK (modest_ui_actions_on_folder_display_name_changed), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->folder_view), "focus-in-event", 
-                                                      G_CALLBACK (on_folder_view_focus_in), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,
+                                          G_OBJECT(priv->folder_view), "key-press-event",
+                                          G_CALLBACK(on_inner_widgets_key_pressed), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), "folder_selection_changed",
+                                          G_CALLBACK (modest_main_window_on_folder_selection_changed), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), "folder-display-name-changed",
+                                          G_CALLBACK (modest_ui_actions_on_folder_display_name_changed), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->folder_view), "focus-in-event", 
+                                          G_CALLBACK (on_folder_view_focus_in), self);
 
        /* Folder view CSM */
        menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/FolderViewCSM");
@@ -820,18 +823,24 @@ connect_signals (ModestMainWindow *self)
                                                       G_CALLBACK(_folder_view_csm_menu_activated),
                                                       self);
        /* header view */
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "header_selected",
-                                                      G_CALLBACK(modest_ui_actions_on_header_selected), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "header_activated",
-                                                      G_CALLBACK(modest_ui_actions_on_header_activated), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "item_not_found",
-                                                      G_CALLBACK(modest_ui_actions_on_item_not_found), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "key-press-event",
-                                                      G_CALLBACK(on_inner_widgets_key_pressed), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "msg_count_changed",
-                                                      G_CALLBACK(on_msg_count_changed), self);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->header_view), "focus-in-event",
-                                                      G_CALLBACK (on_header_view_focus_in), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "header_selected",
+                                          G_CALLBACK(modest_ui_actions_on_header_selected), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "header_activated",
+                                          G_CALLBACK(modest_ui_actions_on_header_activated), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "item_not_found",
+                                          G_CALLBACK(modest_ui_actions_on_item_not_found), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "key-press-event",
+                                          G_CALLBACK(on_inner_widgets_key_pressed), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "msg_count_changed",
+                                          G_CALLBACK(on_msg_count_changed), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->header_view), "focus-in-event",
+                                          G_CALLBACK (on_header_view_focus_in), self);
        
        /* Header view CSM */
        menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/HeaderViewCSM");
@@ -1465,18 +1474,14 @@ create_empty_view (void)
        return GTK_WIDGET(align);
 }
 
-static GtkWidget *
-create_details_widget (GtkWidget *styled_widget, TnyAccount *account)
+/*
+ * Free the returned string
+ */
+static gchar *
+get_gray_color_markup (GtkWidget *styled_widget)
 {
-       /* TODO: Clean up this function. It's a mess, with lots of copy/paste. murrayc. */
-       
-       GtkWidget *vbox;
-       GtkWidget *label_w;
-       gchar *label;
        gchar *gray_color_markup;
 
-       vbox = gtk_vbox_new (FALSE, 0);
-
        /* Obtain the secondary text color. We need a realized widget, that's why 
           we get styled_widget from outside */
 #ifndef MODEST_HAVE_HILDON0_WIDGETS
@@ -1484,15 +1489,51 @@ create_details_widget (GtkWidget *styled_widget, TnyAccount *account)
        gtk_style_lookup_color (styled_widget->style, "SecondaryTextColor", &color);
        gray_color_markup = modest_text_utils_get_color_string (&color);
 #else
-       // gray_color_markup is freed below
        gray_color_markup = g_strdup ("#BBBBBB");
 #endif 
-       /* Account description: */
+       return gray_color_markup;
+}
+
+/*
+ * Free the returned string
+ */
+static gchar*
+create_device_name_visual_string (const gchar *device_name,
+                                 const gchar *gray_color_markup)
+{
+       gchar *tmp, *label;
+
+       /* We have to use "" to fill the %s of the translation. We can
+          not just use the device name because the device name is
+          shown in a different color, so it could not be included
+          into the <span> tag */
+       tmp = g_strdup_printf (_("mcen_fi_localroot_description"), "");
+       label = g_markup_printf_escaped ("<span color='%s'>%s</span>%s", 
+                                        gray_color_markup, 
+                                        tmp, 
+                                        device_name);
+       g_free (tmp);
+
+       return label;
+}
+
+static GtkWidget *
+create_details_widget (GtkWidget *styled_widget, TnyAccount *account)
+{
+       /* TODO: Clean up this function. It's a mess, with lots of copy/paste. murrayc. */
        
+       GtkWidget *vbox;
+       GtkWidget *label_w;
+       gchar *label;
+       gchar *gray_color_markup;
+
+       vbox = gtk_vbox_new (FALSE, 0);
+
+       gray_color_markup = get_gray_color_markup (styled_widget);
+
+       /* Account description: */
        if (modest_tny_account_is_virtual_local_folders (account)
                || (modest_tny_account_is_memory_card_account (account))) {
-               gchar *tmp;
-               /* Local folders: */
        
                /* Get device name */
                gchar *device_name = NULL;
@@ -1501,11 +1542,9 @@ create_details_widget (GtkWidget *styled_widget, TnyAccount *account)
                                                      MODEST_CONF_DEVICE_NAME, NULL);
                else
                        device_name = g_strdup (tny_account_get_name (account));
-                                                     
-               tmp = g_strdup_printf (_("mcen_fi_localroot_description"), ""); //TODO: Why the ""?
-               label = g_markup_printf_escaped ("<span color='%s'>%s</span>%s",
-                                                gray_color_markup, tmp, device_name);
-               g_free (tmp);
+
+               label = create_device_name_visual_string ((const gchar *) device_name, 
+                                                         (const gchar *) gray_color_markup);
                label_w = gtk_label_new (NULL);
                gtk_label_set_markup (GTK_LABEL (label_w), label);
                gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
@@ -1816,7 +1855,7 @@ on_configuration_key_changed (ModestConf* conf,
                GList *children;
                GtkLabel *label;
                const gchar *device_name;
-               gchar *new_text;
+               gchar *new_text, *gray_color_markup;
                
                /* Get label */
                children = gtk_container_get_children (GTK_CONTAINER (priv->details_widget));
@@ -1824,14 +1863,14 @@ on_configuration_key_changed (ModestConf* conf,
                
                device_name = modest_conf_get_string (modest_runtime_get_conf(),
                                                      MODEST_CONF_DEVICE_NAME, NULL);
+
+               gray_color_markup = get_gray_color_markup (GTK_WIDGET (self));          
+               new_text = create_device_name_visual_string (device_name, gray_color_markup);
                
-               new_text = g_strdup_printf ("%s: %s",
-                                           _("mcen_fi_localroot_description"),
-                                           device_name);
-               
-               gtk_label_set_text (label, new_text);
+               gtk_label_set_markup (label, new_text);
                gtk_widget_show (GTK_WIDGET (label));
                
+               g_free (gray_color_markup);
                g_free (new_text);
                g_list_free (children);
        }
index 55452f4..90946b9 100644 (file)
@@ -114,6 +114,7 @@ static void
 modest_conf_init (ModestConf *obj)
 {
        GConfClient *conf = NULL;
+       GError *error = NULL;
        ModestConfPrivate *priv = MODEST_CONF_GET_PRIVATE(obj);
 
        priv->gconf_client = NULL;
@@ -124,7 +125,22 @@ modest_conf_init (ModestConf *obj)
                return;
        }
 
-       priv->gconf_client = conf;      /* all went well! */
+       priv->gconf_client = conf;
+
+       /* All the tree will be listened */
+       gconf_client_add_dir (priv->gconf_client,
+                             "/apps/modest",
+                             GCONF_CLIENT_PRELOAD_NONE,
+                             &error);
+
+       /* Notify every change under namespace */
+       if (!error)
+               gconf_client_notify_add (priv->gconf_client,
+                                        "/apps/modest",
+                                        modest_conf_on_change,
+                                        obj,
+                                        NULL,
+                                        &error);
 }
 
 static void
@@ -454,16 +470,15 @@ modest_conf_type_to_gconf_type (ModestConfValueType value_type, GError **err)
        return gconf_type;
 }
 
-ModestConfNotificationId
+void
 modest_conf_listen_to_namespace (ModestConf *self,
                                 const gchar *namespace)
 {
        ModestConfPrivate *priv;
        GError *error = NULL;
-       ModestConfNotificationId notification_id;
 
-       g_return_val_if_fail (MODEST_IS_CONF (self), 0);
-       g_return_val_if_fail (namespace, 0);
+       g_return_if_fail (MODEST_IS_CONF (self));
+       g_return_if_fail (namespace);
        
        priv = MODEST_CONF_GET_PRIVATE(self);
 
@@ -473,30 +488,11 @@ modest_conf_listen_to_namespace (ModestConf *self,
                              namespace,
                              GCONF_CLIENT_PRELOAD_NONE,
                              &error);
-
-       if (error) {
-               return 0;
-       }
-
-       /* Notify every change under namespace */
-       notification_id = gconf_client_notify_add (priv->gconf_client,
-                                                  namespace,
-                                                  modest_conf_on_change,
-                                                  self,
-                                                  NULL,
-                                                  &error);
-
-       if (error) {
-               return 0;
-       } else {
-               return notification_id;
-       }
 }
 
 void 
 modest_conf_forget_namespace (ModestConf *self,
-                             const gchar *namespace,
-                             ModestConfNotificationId id)
+                             const gchar *namespace)
 {
        ModestConfPrivate *priv;
 
@@ -508,7 +504,4 @@ modest_conf_forget_namespace (ModestConf *self,
        /* Remove the namespace to the list of the namespaces that will
           be observed */
        gconf_client_remove_dir (priv->gconf_client, namespace, NULL);
-
-       /* Notify every change under namespace */
-       gconf_client_notify_remove (priv->gconf_client, id);
 }
index b3ac8c9..c681549 100644 (file)
@@ -300,12 +300,11 @@ gchar* modest_conf_key_escape (const gchar* str);
 gchar* modest_conf_key_unescape (const gchar* str);
 
 
-ModestConfNotificationId modest_conf_listen_to_namespace (ModestConf *self,
-                                                         const gchar *namespace);
+void modest_conf_listen_to_namespace (ModestConf *self,
+                                     const gchar *namespace);
 
-void modest_conf_forget_namespace (ModestConf *self,
-                                  const gchar *namespace,
-                                  ModestConfNotificationId id);
+void modest_conf_forget_namespace    (ModestConf *self,
+                                     const gchar *namespace);
 G_END_DECLS
 
 #endif /* __MODEST_CONF_H__ */
index 0254434..2979779 100644 (file)
@@ -240,11 +240,6 @@ void     modest_ui_actions_on_delete_folder            (GtkAction *action,
 void     modest_ui_actions_on_move_folder_to_trash_folder     (GtkAction *action,
                                                               ModestMainWindow *main_window);
 
-/*
-void     modest_ui_actions_on_connection_changed    (TnyDevice *device, gboolean online,
-                                                    ModestMainWindow *main_window);
-*/
-
 void     modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                                  const gchar* server_account_name,
                                                  gchar **username, gchar **password, gboolean *cancel, 
index f50d502..fa52d07 100644 (file)
@@ -326,8 +326,6 @@ on_account_changed (TnyAccountStore *account_store,
        self = MODEST_ACCOUNT_VIEW (user_data);
        priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
        
-       g_warning ("account changed: %s", tny_account_get_id(account));
-       
        /* Update account view */
 /*     update_account_view (priv->account_mgr, self); */
 }
index b476479..01594b2 100644 (file)
@@ -161,8 +161,6 @@ struct _ModestFolderViewPrivate {
 
        TnyFolder            *folder_to_select; /* folder to select after the next update */
 
-       ModestConfNotificationId notification_id;
-
        gulong                changed_signal;
        gulong                account_inserted_signal;
        gulong                account_removed_signal;
@@ -673,9 +671,6 @@ modest_folder_view_init (ModestFolderView *obj)
         * Track changes in the local account name (in the device it
         * will be the device name)
         */
-       priv->notification_id = modest_conf_listen_to_namespace (conf,
-                                                                MODEST_CONF_NAMESPACE);
-
        priv->conf_key_signal = g_signal_connect (G_OBJECT(conf), 
                                                  "key_changed",
                                                  G_CALLBACK(on_configuration_key_changed), 
@@ -702,12 +697,6 @@ modest_folder_view_finalize (GObject *obj)
        
        priv =  MODEST_FOLDER_VIEW_GET_PRIVATE(obj);
 
-       if (priv->notification_id) {
-               modest_conf_forget_namespace (modest_runtime_get_conf (),
-                                             MODEST_CONF_NAMESPACE,
-                                             priv->notification_id);
-       }
-
        if (priv->timer_expander != 0) {
                g_source_remove (priv->timer_expander);
                priv->timer_expander = 0;
@@ -2089,10 +2078,6 @@ on_configuration_key_changed (ModestConf* conf,
        g_return_if_fail (MODEST_IS_FOLDER_VIEW (self));
        priv = MODEST_FOLDER_VIEW_GET_PRIVATE(self);
 
-       /* Do not listen for changes in other namespaces */
-       if (priv->notification_id != id)
-                return;
-        
        if (!strcmp (key, MODEST_CONF_DEVICE_NAME)) {
                g_free (priv->local_account_name);