diff options
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-account-widget.c | 113 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 90 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-dialogs.c | 3 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-menu.c | 7 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-store.c | 14 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-store.h | 1 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 51 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-view.h | 3 | ||||
-rw-r--r-- | libempathy-gtk/empathy-spell.c | 91 | ||||
-rw-r--r-- | libempathy-gtk/empathy-spell.h | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-tls-dialog.c | 38 |
11 files changed, 289 insertions, 126 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index d32a16563..0bb918e1a 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -121,6 +121,49 @@ static guint signals[LAST_SIGNAL] = { 0 }; #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget) #define CHANGED_TIMEOUT 300 +#define DIGIT "0-9" +#define DIGITS "(["DIGIT"]+)" +#define ALPHA "a-zA-Z" +#define ALPHAS "(["ALPHA"]+)" +#define ALPHADIGIT ALPHA DIGIT +#define ALPHADIGITS "(["ALPHADIGIT"]+)" +#define ALPHADIGITDASH ALPHA DIGIT "-" +#define ALPHADIGITDASHS "(["ALPHADIGITDASH"]*)" + +#define HOSTNUMBER "("DIGITS"\\."DIGITS"\\."DIGITS"\\."DIGITS")" +#define TOPLABEL ALPHAS"|(["ALPHA"]" ALPHADIGITDASHS "["ALPHADIGIT"])" +#define DOMAINLABEL ALPHADIGITS"|(["ALPHADIGIT"]" ALPHADIGITDASHS \ + "["ALPHADIGIT"])" +#define HOSTNAME "((" DOMAINLABEL "\\.)+" TOPLABEL ")" +/* Based on http://www.ietf.org/rfc/rfc1738.txt (section 5) */ +#define HOST "("HOSTNAME "|" HOSTNUMBER")" +/* Based on http://www.ietf.org/rfc/rfc0822.txt (appendix D) */ +#define EMAIL_LOCALPART "([^\\(\\)<>@,;:\\\\\"\\[\\]\\s]+)" + +/* UIN is digital according to the unofficial specification: + * http://iserverd.khstu.ru/docum_ext/icqv5.html#CTS + * 5 digits minimun according to http://en.wikipedia.org/wiki/ICQ#UIN */ +#define ICQ_USER_NAME "(["DIGIT"]{5,})" +/* Based on http://www.ietf.org/rfc/rfc2812.txt (section 2.3.1) */ +#define IRC_SPECIAL "_\\[\\]{}\\\\|`^" +#define IRC_USER_NAME "(["ALPHA IRC_SPECIAL"]["ALPHADIGITDASH IRC_SPECIAL"]*)" +/* Based on http://www.ietf.org/rfc/rfc4622.txt (section 2.2) + * We just exclude invalid characters to avoid ucschars and other redundant + * complexity */ +#define JABBER_USER_NAME "([^@:'\"<>&\\s]+)" +/* ID is an email according to the unofficial specification: + * http://www.hypothetic.org/docs/msn/general/names.php */ +#define MSN_USER_NAME EMAIL_LOCALPART +/* Based on the official help: + * http://help.yahoo.com/l/us/yahoo/edit/registration/edit-01.html */ +#define YAHOO_USER_NAME "(["ALPHA"]["ALPHADIGIT"_\\.]{3,31})" + +#define ACCOUNT_REGEX_ICQ "^"ICQ_USER_NAME"$" +#define ACCOUNT_REGEX_IRC "^"IRC_USER_NAME"$" +#define ACCOUNT_REGEX_JABBER "^"JABBER_USER_NAME"@"HOST"$" +#define ACCOUNT_REGEX_MSN "^"MSN_USER_NAME"@"HOST"$" +#define ACCOUNT_REGEX_YAHOO "^"YAHOO_USER_NAME"$" + static void account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self, gboolean sensitive) @@ -141,6 +184,35 @@ account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self, } static void +account_widget_set_entry_highlighting (GtkEntry *entry, gboolean highlight) +{ + GdkColor color; + GtkStyle *style; + + g_return_if_fail (GTK_IS_ENTRY (entry)); + + style = gtk_widget_get_style (GTK_WIDGET (entry)); + + if (highlight) + { + color = style->bg[GTK_STATE_SELECTED]; + + /* Here we take the current theme colour and add it to + * the colour for white and average the two. This + * gives a colour which is inline with the theme but + * slightly whiter. + */ + color.red = (color.red + (style->white).red) / 2; + color.green = (color.green + (style->white).green) / 2; + color.blue = (color.blue + (style->white).blue) / 2; + + gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, &color); + } + else + gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL); +} + +static void account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self) { EmpathyAccountWidgetPriv *priv = GET_PRIV (self); @@ -161,9 +233,13 @@ account_widget_entry_changed_common (EmpathyAccountWidget *self, const gchar *str; const gchar *param_name; EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + gboolean prev_status; + gboolean curr_status; str = gtk_entry_get_text (entry); param_name = g_object_get_data (G_OBJECT (entry), "param_name"); + prev_status = empathy_account_settings_parameter_is_valid (priv->settings, + param_name); if (EMP_STR_EMPTY (str)) { @@ -185,6 +261,11 @@ account_widget_entry_changed_common (EmpathyAccountWidget *self, tp_strdiff (param_name, "password") ? str : "***"); empathy_account_settings_set_string (priv->settings, param_name, str); } + + curr_status = empathy_account_settings_parameter_is_valid (priv->settings, + param_name); + if (curr_status != prev_status) + account_widget_set_entry_highlighting (entry, !curr_status); } static void @@ -196,6 +277,21 @@ account_widget_entry_changed_cb (GtkEditable *entry, } static void +account_widget_entry_map_cb (GtkEntry *entry, + EmpathyAccountWidget *self) +{ + EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + const gchar *param_name; + gboolean is_valid; + + /* need to initialize input highlighting */ + param_name = g_object_get_data (G_OBJECT (entry), "param_name"); + is_valid = empathy_account_settings_parameter_is_valid (priv->settings, + param_name); + account_widget_set_entry_highlighting (entry, !is_valid); +} + +static void account_widget_int_changed_cb (GtkWidget *widget, EmpathyAccountWidget *self) { @@ -456,6 +552,8 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self, g_signal_connect (widget, "changed", G_CALLBACK (account_widget_entry_changed_cb), self); + g_signal_connect (widget, "map", + G_CALLBACK (account_widget_entry_map_cb), self); } else if (GTK_IS_TOGGLE_BUTTON (widget)) { @@ -1047,6 +1145,9 @@ account_widget_build_irc (EmpathyAccountWidget *self, { EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + empathy_account_settings_set_regex (priv->settings, "account", + ACCOUNT_REGEX_IRC); + if (priv->simple) { priv->irc_network_chooser = empathy_account_widget_irc_build_simple (self, @@ -1074,6 +1175,9 @@ account_widget_build_msn (EmpathyAccountWidget *self, { EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + empathy_account_settings_set_regex (priv->settings, "account", + ACCOUNT_REGEX_MSN); + if (priv->simple) { self->ui_details->gui = empathy_builder_get_file (filename, @@ -1203,6 +1307,9 @@ account_widget_build_jabber (EmpathyAccountWidget *self, is_gtalk = account_widget_is_gtalk (self); is_facebook = account_widget_is_facebook (self); + empathy_account_settings_set_regex (priv->settings, "account", + ACCOUNT_REGEX_JABBER); + if (priv->simple && !is_gtalk && !is_facebook) { /* Simple widget for XMPP */ @@ -1327,6 +1434,9 @@ account_widget_build_icq (EmpathyAccountWidget *self, EmpathyAccountWidgetPriv *priv = GET_PRIV (self); GtkWidget *spinbutton_port; + empathy_account_settings_set_regex (priv->settings, "account", + ACCOUNT_REGEX_ICQ); + if (priv->simple) { self->ui_details->gui = empathy_builder_get_file (filename, @@ -1405,6 +1515,9 @@ account_widget_build_yahoo (EmpathyAccountWidget *self, { EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + empathy_account_settings_set_regex (priv->settings, "account", + ACCOUNT_REGEX_YAHOO); + if (priv->simple) { self->ui_details->gui = empathy_builder_get_file (filename, diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 295ee6af1..fb8d538ef 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -1763,33 +1763,79 @@ chat_spelling_menu_activate_cb (GtkMenuItem *menu_item, gtk_menu_item_get_label (menu_item)); } + +static GtkWidget * +chat_spelling_build_suggestions_menu (const gchar *code, + EmpathyChatSpell *chat_spell) +{ + GList *suggestions, *l; + GtkWidget *menu, *menu_item; + + suggestions = empathy_spell_get_suggestions (code, chat_spell->word); + if (suggestions == NULL) + return NULL; + + menu = gtk_menu_new (); + for (l = suggestions; l; l = l->next) { + menu_item = gtk_menu_item_new_with_label (l->data); + g_signal_connect (G_OBJECT (menu_item), "activate", + G_CALLBACK (chat_spelling_menu_activate_cb), + chat_spell); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + } + empathy_spell_free_suggestions (suggestions); + + gtk_widget_show_all (menu); + + return menu; +} + static GtkWidget * chat_spelling_build_menu (EmpathyChatSpell *chat_spell) { - GtkWidget *menu, *menu_item; - GList *suggestions, *l; - - menu = gtk_menu_new (); - suggestions = empathy_spell_get_suggestions (chat_spell->word); - if (suggestions == NULL) { - menu_item = gtk_menu_item_new_with_label (_("(No Suggestions)")); - gtk_widget_set_sensitive (menu_item, FALSE); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - } else { - for (l = suggestions; l; l = l->next) { - menu_item = gtk_menu_item_new_with_label (l->data); - g_signal_connect (G_OBJECT (menu_item), - "activate", - G_CALLBACK (chat_spelling_menu_activate_cb), - chat_spell); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - } - } - empathy_spell_free_suggestions (suggestions); + GtkWidget *menu, *submenu, *item; + GList *codes, *l; - gtk_widget_show_all (menu); + codes = empathy_spell_get_enabled_language_codes (); + g_assert (codes != NULL); - return menu; + if (g_list_length (codes) > 1) { + menu = gtk_menu_new (); + + for (l = codes; l; l = l->next) { + const gchar *code, *name; + + code = l->data; + name = empathy_spell_get_language_name (code); + if (!name) + continue; + + item = gtk_image_menu_item_new_with_label (name); + + submenu = chat_spelling_build_suggestions_menu ( + code, chat_spell); + if (submenu == NULL) + gtk_widget_set_sensitive (item, FALSE); + else + gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), + submenu); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); + } + } else { + menu = chat_spelling_build_suggestions_menu (codes->data, + chat_spell); + if (menu == NULL) { + menu = gtk_menu_new (); + item = gtk_menu_item_new_with_label (_("(No Suggestions)")); + gtk_widget_set_sensitive (item, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + } + } + g_list_free (codes); + + gtk_widget_show_all (menu); + + return menu; } static void diff --git a/libempathy-gtk/empathy-individual-dialogs.c b/libempathy-gtk/empathy-individual-dialogs.c index edfb3fd48..85ed7d1d4 100644 --- a/libempathy-gtk/empathy-individual-dialogs.c +++ b/libempathy-gtk/empathy-individual-dialogs.c @@ -56,8 +56,7 @@ can_add_contact_to_account (TpAccount *account, return FALSE; individual_manager = empathy_individual_manager_dup_singleton (); - result = empathy_individual_manager_get_flags_for_connection ( - individual_manager, connection) & EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD; + result = empathy_connection_can_add_personas (connection); g_object_unref (individual_manager); return result; diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c index b1237cf8b..e3159b401 100644 --- a/libempathy-gtk/empathy-individual-menu.c +++ b/libempathy-gtk/empathy-individual-menu.c @@ -822,15 +822,12 @@ empathy_individual_edit_menu_item_new (FolksIndividual *individual) if (empathy_individual_manager_initialized ()) { TpConnection *connection; - EmpathyIndividualManagerFlags flags; manager = empathy_individual_manager_dup_singleton (); connection = empathy_contact_get_connection (contact); - flags = empathy_individual_manager_get_flags_for_connection ( - manager, connection); - enable = (flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS || - flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP); + enable = (empathy_connection_can_alias_personas (connection) && + empathy_connection_can_group_personas (connection)); g_object_unref (manager); } diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c index 77f3016ec..c9159463c 100644 --- a/libempathy-gtk/empathy-individual-store.c +++ b/libempathy-gtk/empathy-individual-store.c @@ -158,8 +158,7 @@ static void add_individual_to_store (GtkTreeStore *self, GtkTreeIter *iter, GtkTreeIter *parent, - FolksIndividual *individual, - EmpathyIndividualManagerFlags flags) + FolksIndividual *individual) { gboolean can_audio_call, can_video_call; @@ -172,7 +171,6 @@ add_individual_to_store (GtkTreeStore *self, EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, individual, EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, FALSE, EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE, - EMPATHY_INDIVIDUAL_STORE_COL_FLAGS, flags, EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL, can_audio_call, EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL, can_video_call, -1); @@ -376,7 +374,6 @@ individual_store_add_individual (EmpathyIndividualStore *self, GList *groups = NULL, *l; EmpathyContact *contact; TpConnection *connection; - EmpathyIndividualManagerFlags flags = 0; gchar *protocol_name; priv = GET_PRIV (self); @@ -392,8 +389,6 @@ individual_store_add_individual (EmpathyIndividualStore *self, contact = empathy_contact_dup_from_folks_individual (individual); connection = empathy_contact_get_connection (contact); - flags = empathy_individual_manager_get_flags_for_connection (priv->manager, - connection); tp_connection_parse_object_path (connection, &protocol_name, NULL); @@ -420,7 +415,7 @@ individual_store_add_individual (EmpathyIndividualStore *self, } add_individual_to_store (GTK_TREE_STORE (self), &iter, parent, - individual, flags); + individual); } g_free (protocol_name); @@ -434,7 +429,7 @@ individual_store_add_individual (EmpathyIndividualStore *self, FALSE); add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group, - individual, flags); + individual); } g_list_free (groups); if (group_set != NULL) @@ -450,7 +445,7 @@ individual_store_add_individual (EmpathyIndividualStore *self, &iter_group, NULL, NULL, TRUE); add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group, - individual, flags); + individual); } individual_store_contact_update (self, individual); @@ -1493,7 +1488,6 @@ individual_store_setup (EmpathyIndividualStore *self) G_TYPE_BOOLEAN, /* Is separator */ G_TYPE_BOOLEAN, /* Can make audio calls */ G_TYPE_BOOLEAN, /* Can make video calls */ - EMPATHY_TYPE_INDIVIDUAL_MANAGER_FLAGS, /* Flags */ G_TYPE_BOOLEAN, /* Is a fake group */ }; diff --git a/libempathy-gtk/empathy-individual-store.h b/libempathy-gtk/empathy-individual-store.h index 4c99610d6..debb218ad 100644 --- a/libempathy-gtk/empathy-individual-store.h +++ b/libempathy-gtk/empathy-individual-store.h @@ -63,7 +63,6 @@ typedef enum EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL, EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL, - EMPATHY_INDIVIDUAL_STORE_COL_FLAGS, EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, EMPATHY_INDIVIDUAL_STORE_COL_COUNT, } EmpathyIndividualStoreCol; diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c index ebc71a10a..2f2aae90a 100644 --- a/libempathy-gtk/empathy-individual-view.c +++ b/libempathy-gtk/empathy-individual-view.c @@ -2132,29 +2132,6 @@ empathy_individual_view_dup_selected (EmpathyIndividualView *view) return individual; } -EmpathyIndividualManagerFlags -empathy_individual_view_get_flags (EmpathyIndividualView *view) -{ - EmpathyIndividualViewPriv *priv; - GtkTreeSelection *selection; - GtkTreeIter iter; - GtkTreeModel *model; - EmpathyIndividualFeatureFlags flags; - - g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (view), 0); - - priv = GET_PRIV (view); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return 0; - - gtk_tree_model_get (model, &iter, - EMPATHY_INDIVIDUAL_STORE_COL_FLAGS, &flags, -1); - - return flags; -} - gchar * empathy_individual_view_get_selected_group (EmpathyIndividualView *view, gboolean *is_fake_group) @@ -2355,7 +2332,8 @@ empathy_individual_view_get_individual_menu (EmpathyIndividualView *view) GtkWidget *menu = NULL; GtkWidget *item; GtkWidget *image; - EmpathyIndividualManagerFlags flags; + gboolean can_remove = FALSE; + GList *l; g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (view), NULL); @@ -2363,16 +2341,31 @@ empathy_individual_view_get_individual_menu (EmpathyIndividualView *view) if (individual == NULL) return NULL; - flags = empathy_individual_view_get_flags (view); + /* If any of the Individual's personas can be removed, add an option to + * remove. This will act as a best-effort option. If any Personas cannot be + * removed from the server, then this option will just be inactive upon + * subsequent menu openings */ + for (l = folks_individual_get_personas (individual); l != NULL; l = l->next) + { + FolksPersona *persona = FOLKS_PERSONA (l->data); + FolksPersonaStore *store = folks_persona_get_store (persona); + FolksMaybeBool maybe_can_remove = + folks_persona_store_get_can_remove_personas (store); + + if (maybe_can_remove == FOLKS_MAYBE_BOOL_TRUE) + { + can_remove = TRUE; + break; + } + } menu = empathy_individual_menu_new (individual, priv->individual_features); /* Remove contact */ - if (priv->view_features & - EMPATHY_INDIVIDUAL_VIEW_FEATURE_INDIVIDUAL_REMOVE && - flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE) + if ((priv->view_features & + EMPATHY_INDIVIDUAL_VIEW_FEATURE_INDIVIDUAL_REMOVE) && + can_remove) { - /* create the menu if required, or just add a separator */ if (menu == NULL) menu = gtk_menu_new (); diff --git a/libempathy-gtk/empathy-individual-view.h b/libempathy-gtk/empathy-individual-view.h index 51a487d94..94ec8ccfd 100644 --- a/libempathy-gtk/empathy-individual-view.h +++ b/libempathy-gtk/empathy-individual-view.h @@ -98,9 +98,6 @@ EmpathyIndividualView *empathy_individual_view_new ( FolksIndividual *empathy_individual_view_dup_selected ( EmpathyIndividualView *view); -EmpathyIndividualManagerFlags empathy_individual_view_get_flags ( - EmpathyIndividualView *view); - gchar *empathy_individual_view_get_selected_group (EmpathyIndividualView *view, gboolean * is_fake_group); diff --git a/libempathy-gtk/empathy-spell.c b/libempathy-gtk/empathy-spell.c index ff94bb053..b9abcd5f7 100644 --- a/libempathy-gtk/empathy-spell.c +++ b/libempathy-gtk/empathy-spell.c @@ -48,8 +48,11 @@ typedef struct { #define ISO_CODES_DATADIR ISO_CODES_PREFIX "/share/xml/iso-codes" #define ISO_CODES_LOCALESDIR ISO_CODES_PREFIX "/share/locale" +/* Language code (gchar *) -> language name (gchar *) */ static GHashTable *iso_code_names = NULL; -static GList *languages = NULL; +/* Contains only _enabled_ languages + * Language code (gchar *) -> language (SpellLanguage *) */ +static GHashTable *languages = NULL; static void spell_iso_codes_parse_start_tag (GMarkupParseContext *ctx, @@ -162,24 +165,22 @@ spell_notify_languages_cb (GSettings *gsettings, const gchar *key, gpointer user_data) { - GList *l; - DEBUG ("Resetting languages due to config change"); /* We just reset the languages list. */ - for (l = languages; l; l = l->next) { - SpellLanguage *lang; - - lang = l->data; - - enchant_broker_free_dict (lang->config, lang->speller); - enchant_broker_free (lang->config); - - g_slice_free (SpellLanguage, lang); + if (languages != NULL) { + g_hash_table_destroy (languages); + languages = NULL; } +} + +static void +empathy_spell_free_language (SpellLanguage *lang) +{ + enchant_broker_free_dict (lang->config, lang->speller); + enchant_broker_free (lang->config); - g_list_free (languages); - languages = NULL; + g_slice_free (SpellLanguage, lang); } static void @@ -201,6 +202,9 @@ spell_setup_languages (void) return; } + languages = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, (GDestroyNotify) empathy_spell_free_language); + str = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES); @@ -224,7 +228,9 @@ spell_setup_languages (void) if (lang->speller == NULL) { DEBUG ("language '%s' has no valid dict", strv[i]); } else { - languages = g_list_append (languages, lang); + g_hash_table_insert (languages, + g_strdup (strv[i]), + lang); } i++; @@ -294,6 +300,13 @@ empathy_spell_get_language_codes (void) return list_langs; } +GList * +empathy_spell_get_enabled_language_codes (void) +{ + spell_setup_languages (); + return g_hash_table_get_keys (languages); +} + void empathy_spell_free_language_codes (GList *codes) { @@ -309,7 +322,8 @@ empathy_spell_check (const gchar *word) gboolean digit; gunichar c; gint len; - GList *l; + GHashTableIter iter; + SpellLanguage *lang; g_return_val_if_fail (word != NULL, FALSE); @@ -332,11 +346,8 @@ empathy_spell_check (const gchar *word) } len = strlen (word); - for (l = languages; l; l = l->next) { - SpellLanguage *lang; - - lang = l->data; - + g_hash_table_iter_init (&iter, languages); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &lang)) { enchant_result = enchant_dict_check (lang->speller, word, len); if (enchant_result == 0) { @@ -348,36 +359,40 @@ empathy_spell_check (const gchar *word) } GList * -empathy_spell_get_suggestions (const gchar *word) +empathy_spell_get_suggestions (const gchar *code, const gchar *word) { gint len; - GList *l1; GList *suggestion_list = NULL; + SpellLanguage *lang; + gchar **suggestions; + gsize i, number_of_suggestions; + g_return_val_if_fail (code != NULL, NULL); g_return_val_if_fail (word != NULL, NULL); spell_setup_languages (); - len = strlen (word); + if (!languages) { + return NULL; + } - for (l1 = languages; l1; l1 = l1->next) { - SpellLanguage *lang; - gchar **suggestions; - gsize i, number_of_suggestions; + len = strlen (word); - lang = l1->data; + lang = g_hash_table_lookup (languages, code); + if (!lang) { + return NULL; + } - suggestions = enchant_dict_suggest (lang->speller, word, len, - &number_of_suggestions); + suggestions = enchant_dict_suggest (lang->speller, word, len, + &number_of_suggestions); - for (i = 0; i < number_of_suggestions; i++) { - suggestion_list = g_list_append (suggestion_list, - g_strdup (suggestions[i])); - } + for (i = 0; i < number_of_suggestions; i++) { + suggestion_list = g_list_append (suggestion_list, + g_strdup (suggestions[i])); + } - if (suggestions) { - enchant_dict_free_string_list (lang->speller, suggestions); - } + if (suggestions) { + enchant_dict_free_string_list (lang->speller, suggestions); } return suggestion_list; diff --git a/libempathy-gtk/empathy-spell.h b/libempathy-gtk/empathy-spell.h index 65dbb131d..aa2a3e51e 100644 --- a/libempathy-gtk/empathy-spell.h +++ b/libempathy-gtk/empathy-spell.h @@ -31,9 +31,11 @@ G_BEGIN_DECLS gboolean empathy_spell_supported (void); const gchar *empathy_spell_get_language_name (const gchar *code); GList *empathy_spell_get_language_codes (void); +GList *empathy_spell_get_enabled_language_codes (void); void empathy_spell_free_language_codes (GList *codes); gboolean empathy_spell_check (const gchar *word); -GList * empathy_spell_get_suggestions (const gchar *word); +GList * empathy_spell_get_suggestions (const gchar *code, + const gchar *word); void empathy_spell_free_suggestions (GList *suggestions); G_END_DECLS diff --git a/libempathy-gtk/empathy-tls-dialog.c b/libempathy-gtk/empathy-tls-dialog.c index 39d02ff65..9213ac458 100644 --- a/libempathy-gtk/empathy-tls-dialog.c +++ b/libempathy-gtk/empathy-tls-dialog.c @@ -148,47 +148,48 @@ reason_to_string (EmpathyTLSDialog *self) details = priv->details; g_string_append (str, _("The identity provided by the chat server cannot be " - "verified.\n")); + "verified.")); + g_string_append (str, "\n\n"); switch (reason) { case EMP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED: reason_str = _("The certificate is not signed by a Certification " - "Authority"); + "Authority."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED: - reason_str = _("The certificate has expired"); + reason_str = _("The certificate has expired."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED: - reason_str = _("The certificate hasn't yet been activated"); + reason_str = _("The certificate hasn't yet been activated."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_FINGERPRINT_MISMATCH: - reason_str = _("The certificate does not have the expected fingerprint"); + reason_str = _("The certificate does not have the expected fingerprint."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH: reason_str = _("The hostname verified by the certificate doesn't match " - "the server name"); + "the server name."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED: - reason_str = _("The certificate is self-signed"); + reason_str = _("The certificate is self-signed."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_REVOKED: reason_str = _("The certificate has been revoked by the issuing " - "Certification Authority"); + "Certification Authority."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_INSECURE: - reason_str = _("The certificate is cryptographically weak"); + reason_str = _("The certificate is cryptographically weak."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_LIMIT_EXCEEDED: - reason_str = _("The certificate length exceeds verifiable limits"); + reason_str = _("The certificate length exceeds verifiable limits."); break; case EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN: default: - reason_str = _("The certificate is malformed"); + reason_str = _("The certificate is malformed."); break; } - g_string_append_printf (str, "%s.", reason_str); + g_string_append (str, reason_str); /* add more information in case of HOSTNAME_MISMATCH */ if (reason == EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH) @@ -201,7 +202,7 @@ reason_to_string (EmpathyTLSDialog *self) if (expected_hostname != NULL && certificate_hostname != NULL) { - g_string_append (str, "\n"); + g_string_append (str, "\n\n"); g_string_append_printf (str, _("Expected hostname: %s"), expected_hostname); g_string_append (str, "\n"); @@ -216,10 +217,11 @@ reason_to_string (EmpathyTLSDialog *self) static GtkWidget * build_gcr_widget (EmpathyTLSDialog *self) { - GcrCertificateBasicsWidget *widget; + GcrCertificateWidget *widget; GcrCertificate *certificate; GPtrArray *cert_chain = NULL; GArray *first_cert; + int height; EmpathyTLSDialogPriv *priv = GET_PRIV (self); g_object_get (priv->certificate, @@ -229,7 +231,13 @@ build_gcr_widget (EmpathyTLSDialog *self) certificate = gcr_simple_certificate_new ((const guchar *) first_cert->data, first_cert->len); - widget = gcr_certificate_basics_widget_new (certificate); + widget = gcr_certificate_widget_new (certificate); + + /* FIXME: make this widget bigger by default -- GTK+ should really handle + * this sort of thing for us */ + gtk_widget_get_preferred_height (GTK_WIDGET (widget), NULL, &height); + /* force the widget to at least 150 pixels high */ + gtk_widget_set_size_request (GTK_WIDGET (widget), -1, MAX (height, 150)); g_object_unref (certificate); g_ptr_array_unref (cert_chain); |