GHashTable * terminal_encodings_get_builtins (void) { GHashTable *encodings_hashtable; guint i; TerminalEncoding *encoding; encodings_hashtable = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) terminal_encoding_unref); /* Placeholder entry for the current locale's charset */ encoding = terminal_encoding_new ("current", _("Current Locale"), FALSE, TRUE); g_hash_table_insert (encodings_hashtable, (gpointer) terminal_encoding_get_id (encoding), encoding); for (i = 0; i < G_N_ELEMENTS (encodings); ++i) { encoding = terminal_encoding_new (encodings[i].charset, _(encodings[i].name), FALSE, FALSE); g_hash_table_insert (encodings_hashtable, (gpointer) terminal_encoding_get_id (encoding), encoding); } return encodings_hashtable; }
static void update_active_encodings_gsettings (void) { GSList *list, *l; GArray *strings; const gchar *id_string; GSettings *settings; list = terminal_app_get_active_encodings (terminal_app_get ()); strings = g_array_new (TRUE, TRUE, sizeof (gchar *)); for (l = list; l != NULL; l = l->next) { TerminalEncoding *encoding = (TerminalEncoding *) l->data; id_string = terminal_encoding_get_id (encoding); strings = g_array_append_val (strings, id_string); } settings = g_settings_new (CONF_GLOBAL_SCHEMA); g_settings_set_strv (settings, "active-encodings", (const gchar **) strings->data); g_object_unref (settings); g_array_free (strings, TRUE); g_slist_foreach (list, (GFunc) terminal_encoding_unref, NULL); g_slist_free (list); }
/** * terminal_app_ensure_encoding: * @app: * @charset: (allow-none): a charset, or %NULL * * Ensures there's a #TerminalEncoding for @charset available. If @charset * is %NULL, returns the #TerminalEncoding for the locale's charset. If * @charset is not a known charset, returns a #TerminalEncoding for a * custom charset. * * Returns: (transfer none): a #TerminalEncoding */ TerminalEncoding * terminal_app_ensure_encoding (TerminalApp *app, const char *charset) { TerminalEncoding *encoding; encoding = g_hash_table_lookup (app->encodings, charset ? charset : "current"); if (encoding == NULL) { encoding = terminal_encoding_new (charset, _("User Defined"), TRUE, TRUE /* scary! */); g_hash_table_insert (app->encodings, (gpointer) terminal_encoding_get_id (encoding), encoding); } return encoding; }