* src/modest-text-utils.[ch]:
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 26 Feb 2008 13:10:56 +0000 (13:10 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Tue, 26 Feb 2008 13:10:56 +0000 (13:10 +0000)
        * Added a new method to escape mnemonics
* src/maemo/modest-main-window.c:
        * Now we escape mnemonics on account names in menus and toolbar
          (fixes NB#81327).

pmo-trunk-r4227

src/maemo/modest-main-window.c
src/modest-text-utils.c
src/modest-text-utils.h

index 843d499..99efb7f 100644 (file)
@@ -651,6 +651,8 @@ update_menus (ModestMainWindow* self)
                        display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_mailbox_n"), 
                                                        modest_account_settings_get_display_name (settings));
                }
                        display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_mailbox_n"), 
                                                        modest_account_settings_get_display_name (settings));
                }
+
+               
                
                /* Create action and add it to the action group. The
                   action name must be the account name, this way we
                
                /* Create action and add it to the action group. The
                   action name must be the account name, this way we
@@ -659,9 +661,13 @@ update_menus (ModestMainWindow* self)
                        gchar* item_name, *refresh_action_name;
                        guint8 merge_id = 0;
                        GtkAction *view_account_action, *refresh_account_action;
                        gchar* item_name, *refresh_action_name;
                        guint8 merge_id = 0;
                        GtkAction *view_account_action, *refresh_account_action;
+                       gchar *escaped_display_name;
+
+                       escaped_display_name = modest_text_utils_escape_mnemonics (display_name);
 
                        view_account_action = GTK_ACTION (gtk_radio_action_new (account_name,
 
                        view_account_action = GTK_ACTION (gtk_radio_action_new (account_name,
-                                                                               display_name, NULL, NULL, 0));
+                                                                               escaped_display_name, NULL, NULL, 0));
+                       g_free (escaped_display_name);
                        gtk_action_group_add_action (priv->view_additions_group, view_account_action);
                        gtk_radio_action_set_group (GTK_RADIO_ACTION (view_account_action), radio_group);
                        radio_group = gtk_radio_action_get_group (GTK_RADIO_ACTION (view_account_action));
                        gtk_action_group_add_action (priv->view_additions_group, view_account_action);
                        gtk_radio_action_set_group (GTK_RADIO_ACTION (view_account_action), radio_group);
                        radio_group = gtk_radio_action_get_group (GTK_RADIO_ACTION (view_account_action));
index 94d822e..01e70d3 100644 (file)
@@ -1687,3 +1687,23 @@ modest_text_utils_buffer_selection_is_valid (GtkTextBuffer *buffer)
 
        return result;
 }
 
        return result;
 }
+
+gchar *
+modest_text_utils_escape_mnemonics (const gchar *text)
+{
+       const gchar *p;
+       GString *result = NULL;
+
+       if (text == NULL)
+               return NULL;
+
+       result = g_string_new ("");
+       for (p = text; *p != '\0'; p++) {
+               if (*p == '_')
+                       result = g_string_append (result, "__");
+               else
+                       result = g_string_append_c (result, *p);
+       }
+       
+       return g_string_free (result, FALSE);
+}
index 3a9c975..4443876 100644 (file)
@@ -446,5 +446,15 @@ gboolean     modest_text_utils_is_forbidden_char (const gchar character,
  */
 gboolean     modest_text_utils_buffer_selection_is_valid (GtkTextBuffer *buffer);
 
  */
 gboolean     modest_text_utils_buffer_selection_is_valid (GtkTextBuffer *buffer);
 
+/**
+ * modest_text_utils_escape_mnemonics:
+ * @text: a string
+ *
+ * obtains the representation of text, but escaping mnemonics (we duplicate _)
+ *
+ * Returns: a newly allocated string
+ */
+gchar *modest_text_utils_escape_mnemonics (const gchar *text);
+
 
 #endif /* __MODEST_TEXT_UTILS_H__ */
 
 #endif /* __MODEST_TEXT_UTILS_H__ */