Exemplo n.º 1
0
GSList *
soli_encoding_items_get (void)
{
	const GtkSourceEncoding *current_encoding;
	GSList *encodings;
	GSList *items = NULL;
	GSList *l;

	encodings = soli_settings_get_candidate_encodings (NULL);

	current_encoding = gtk_source_encoding_get_current ();

	for (l = encodings; l != NULL; l = l->next)
	{
		const GtkSourceEncoding *enc = l->data;
		gchar *name;

		if (enc == current_encoding)
		{
			name = g_strdup_printf (_("Current Locale (%s)"),
						gtk_source_encoding_get_charset (enc));
		}
		else
		{
			name = gtk_source_encoding_to_string (enc);
		}

		items = g_slist_prepend (items, soli_encoding_item_new (enc, name));
	}

	g_slist_free (encodings);

	return g_slist_reverse (items);
}
Exemplo n.º 2
0
static void
print_all_encodings (void)
{
	GSList *all_encodings;
	GSList *l;

	all_encodings = gtk_source_encoding_get_all ();

	for (l = all_encodings; l != NULL; l = l->next)
	{
		const GtkSourceEncoding *encoding = l->data;
		g_print ("%s\n", gtk_source_encoding_get_charset (encoding));
	}

	g_slist_free (all_encodings);
}
Exemplo n.º 3
0
static void
save_encoding_metadata (GeditDocument *doc)
{
	const GtkSourceEncoding *encoding;
	const gchar *charset;

	gedit_debug (DEBUG_DOCUMENT);

	encoding = gtk_source_file_get_encoding (doc->priv->file);

	if (encoding == NULL)
	{
		encoding = gtk_source_encoding_get_utf8 ();
	}

	charset = gtk_source_encoding_get_charset (encoding);

	gedit_document_set_metadata (doc,
				     GEDIT_METADATA_ATTRIBUTE_ENCODING, charset,
				     NULL);
}