[gnome-terminal] Add accessor functions for TerminalEncoding
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] Add accessor functions for TerminalEncoding
- Date: Tue, 10 Aug 2010 16:16:28 +0000 (UTC)
commit ea10e6046fd0a8136af9d5da5c91d4cb78e52c3a
Author: Christian Persch <chpe gnome org>
Date: Tue Aug 10 17:44:01 2010 +0200
Add accessor functions for TerminalEncoding
src/terminal-app.c | 4 +++-
src/terminal-encoding.c | 33 +++++++++++++++++++++++++--------
src/terminal-encoding.h | 4 ++++
src/terminal-window.c | 6 +++---
4 files changed, 35 insertions(+), 12 deletions(-)
---
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 84ee27a..691be12 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -964,7 +964,9 @@ terminal_app_encoding_list_notify_cb (GConfClient *client,
_("User Defined"),
TRUE,
TRUE /* scary! */);
- g_hash_table_insert (app->encodings, encoding->charset, encoding);
+ g_hash_table_insert (app->encodings,
+ (gpointer) terminal_encoding_get_charset (encoding),
+ encoding);
}
if (!terminal_encoding_is_valid (encoding))
diff --git a/src/terminal-encoding.c b/src/terminal-encoding.c
index 2d85f2e..f70bbc6 100644
--- a/src/terminal-encoding.c
+++ b/src/terminal-encoding.c
@@ -48,7 +48,6 @@ static const struct {
const char *charset;
const char *name;
} encodings[] = {
-// { "UTF-8", N_("Current Locale") },
{ "ISO-8859-1", N_("Western") },
{ "ISO-8859-2", N_("Central European") },
{ "ISO-8859-3", N_("South European") },
@@ -183,6 +182,22 @@ terminal_encoding_unref (TerminalEncoding *encoding)
g_slice_free (TerminalEncoding, encoding);
}
+const char *
+terminal_encoding_get_id (TerminalEncoding *encoding)
+{
+ g_return_val_if_fail (encoding != NULL, NULL);
+
+ return encoding->charset;
+}
+
+const char *
+terminal_encoding_get_charset (TerminalEncoding *encoding)
+{
+ g_return_val_if_fail (encoding != NULL, NULL);
+
+ return encoding->charset;
+}
+
gboolean
terminal_encoding_is_valid (TerminalEncoding *encoding)
{
@@ -202,7 +217,7 @@ terminal_encoding_is_valid (TerminalEncoding *encoding)
* which the underlying GIConv implementation can't support.
*/
converted = g_convert (ascii_sample, sizeof (ascii_sample) - 1,
- encoding->charset, "UTF-8",
+ terminal_encoding_get_charset (encoding), "UTF-8",
&bytes_read, &bytes_written, &error);
/* The encoding is only valid if ASCII passes through cleanly. */
@@ -217,7 +232,7 @@ terminal_encoding_is_valid (TerminalEncoding *encoding)
{
_terminal_debug_print (TERMINAL_DEBUG_ENCODINGS,
"Rejecting encoding %s as invalid:\n",
- encoding->charset);
+ terminal_encoding_get_charset (encoding));
_terminal_debug_print (TERMINAL_DEBUG_ENCODINGS,
" input \"%s\"\n",
ascii_sample);
@@ -232,7 +247,7 @@ terminal_encoding_is_valid (TerminalEncoding *encoding)
else
_terminal_debug_print (TERMINAL_DEBUG_ENCODINGS,
"Encoding %s is valid\n\n",
- encoding->charset);
+ terminal_encoding_get_charset (encoding));
}
#endif
@@ -269,7 +284,7 @@ update_active_encodings_gconf (void)
{
TerminalEncoding *encoding = (TerminalEncoding *) l->data;
- strings = g_slist_prepend (strings, encoding->charset);
+ strings = g_slist_prepend (strings, (gpointer) terminal_encoding_get_id (encoding));
}
conf = gconf_client_get_default ();
@@ -375,7 +390,7 @@ liststore_insert_encoding (gpointer key,
return;
gtk_list_store_insert_with_values (store, &iter, -1,
- COLUMN_CHARSET, encoding->charset,
+ COLUMN_CHARSET, terminal_encoding_get_charset (encoding),
COLUMN_NAME, encoding->name,
COLUMN_DATA, encoding,
-1);
@@ -574,7 +589,7 @@ terminal_encodings_get_builtins (void)
_("Current Locale"),
FALSE,
TRUE);
- g_hash_table_insert (encodings_hashtable, encoding->charset, encoding);
+ g_hash_table_insert (encodings_hashtable, (gpointer) terminal_encoding_get_id (encoding), encoding);
}
for (i = 0; i < G_N_ELEMENTS (encodings); ++i)
@@ -585,7 +600,9 @@ terminal_encodings_get_builtins (void)
_(encodings[i].name),
FALSE,
FALSE);
- g_hash_table_insert (encodings_hashtable, encoding->charset, encoding);
+ g_hash_table_insert (encodings_hashtable,
+ (gpointer) terminal_encoding_get_id (encoding),
+ encoding);
}
return encodings_hashtable;
diff --git a/src/terminal-encoding.h b/src/terminal-encoding.h
index e0986a3..63740c9 100644
--- a/src/terminal-encoding.h
+++ b/src/terminal-encoding.h
@@ -50,6 +50,10 @@ void terminal_encoding_unref (TerminalEncoding *encoding);
gboolean terminal_encoding_is_valid (TerminalEncoding *encoding);
+const char *terminal_encoding_get_id (TerminalEncoding *encoding);
+
+const char *terminal_encoding_get_charset (TerminalEncoding *encoding);
+
GHashTable *terminal_encodings_get_builtins (void);
void terminal_encoding_dialog_show (GtkWindow *transient_parent);
diff --git a/src/terminal-window.c b/src/terminal-window.c
index f330066..2f73e50 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -804,8 +804,8 @@ terminal_window_update_encoding_menu (TerminalWindow *window)
char name[128];
char *display_name;
- g_snprintf (name, sizeof (name), SET_ENCODING_ACTION_NAME_PREFIX "%s", e->charset);
- display_name = g_strdup_printf ("%s (%s)", e->name, e->charset);
+ g_snprintf (name, sizeof (name), SET_ENCODING_ACTION_NAME_PREFIX "%s", terminal_encoding_get_id (e));
+ display_name = g_strdup_printf ("%s (%s)", e->name, terminal_encoding_get_charset (e));
encoding_action = gtk_radio_action_new (name,
display_name,
@@ -817,7 +817,7 @@ terminal_window_update_encoding_menu (TerminalWindow *window)
gtk_radio_action_set_group (encoding_action, group);
group = gtk_radio_action_get_group (encoding_action);
- if (charset && strcmp (e->charset, charset) == 0)
+ if (charset && strcmp (terminal_encoding_get_charset (e), charset) == 0)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (encoding_action), TRUE);
g_signal_connect (encoding_action, "toggled",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]