common: gdm-languages moved to gnome-desktop as gnome-languages
That code is useful for other core desktop modules. https://bugzilla.gnome.org/show_bug.cgi?id=692414
This commit is contained in:
parent
23cda5e6ff
commit
7221f9cd54
12 changed files with 37 additions and 1564 deletions
|
@ -102,7 +102,7 @@ GSD_REQUIRED_VERSION=3.7.3
|
|||
NETWORK_MANAGER_REQUIRED_VERSION=0.9.6.4
|
||||
NETWORK_MANAGER_APPLET_REQUIRED_VERSION=0.9.7
|
||||
LIBNOTIFY_REQUIRED_VERSION=0.7.3
|
||||
GNOME_DESKTOP_REQUIRED_VERSION=3.5.91
|
||||
GNOME_DESKTOP_REQUIRED_VERSION=3.7.5
|
||||
SCHEMAS_REQUIRED_VERSION=3.7.2.2
|
||||
LIBWACOM_REQUIRED_VERSION=0.7
|
||||
CLUTTER_REQUIRED_VERSION=1.11.3
|
||||
|
@ -280,12 +280,6 @@ case $host_os in
|
|||
esac
|
||||
AM_CONDITIONAL(BUILD_WACOM, [test x"$have_wacom" = x"yes"])
|
||||
|
||||
# This is a hard-dependency for the region and user-accounts panels
|
||||
PKG_CHECK_MODULES(ISOCODES, iso-codes)
|
||||
|
||||
AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
|
||||
ISO_CODES=iso-codes
|
||||
|
||||
# Kerberos kerberos support
|
||||
AC_PATH_PROG(KRB5_CONFIG, krb5-config, no)
|
||||
if test "$KRB5_CONFIG" = "no"; then
|
||||
|
|
|
@ -2,14 +2,10 @@
|
|||
cappletname = common
|
||||
|
||||
noinst_LTLIBRARIES = liblanguage.la
|
||||
noinst_PROGRAMS = list-languages
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
$(PANEL_CFLAGS) \
|
||||
$(LIBLANGUAGE_CFLAGS) \
|
||||
-DDATADIR=\""$(datadir)"\" \
|
||||
-DLIBLOCALEDIR=\""$(prefix)/lib/locale"\" \
|
||||
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
|
||||
$(LIBLANGUAGE_CFLAGS)
|
||||
|
||||
BUILT_SOURCES = \
|
||||
cc-common-resources.c \
|
||||
|
@ -17,9 +13,6 @@ BUILT_SOURCES = \
|
|||
|
||||
liblanguage_la_SOURCES = \
|
||||
$(BUILT_SOURCES) \
|
||||
gdm-languages.h \
|
||||
gdm-languages.c \
|
||||
locarchive.h \
|
||||
cc-common-language.c \
|
||||
cc-common-language.h \
|
||||
cc-language-chooser.c \
|
||||
|
@ -28,10 +21,6 @@ liblanguage_la_SOURCES = \
|
|||
liblanguage_la_LIBADD = \
|
||||
$(LIBLANGUAGE_LIBS)
|
||||
|
||||
list_languages_SOURCES = list-languages.c
|
||||
list_languages_LDADD = liblanguage.la
|
||||
list_languages_CFLAGS = $(LIBLANGUAGE_CFLAGS)
|
||||
|
||||
resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/common.gresource.xml)
|
||||
cc-common-resources.c: common.gresource.xml $(resource_files)
|
||||
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_common $<
|
||||
|
|
|
@ -30,9 +30,10 @@
|
|||
|
||||
#include <fontconfig/fontconfig.h>
|
||||
|
||||
#include "cc-common-language.h"
|
||||
#define GNOME_DESKTOP_USE_UNSTABLE_API
|
||||
#include <libgnome-desktop/gnome-languages.h>
|
||||
|
||||
#include "gdm-languages.h"
|
||||
#include "cc-common-language.h"
|
||||
|
||||
static char *get_lang_for_user_object_path (const char *path);
|
||||
|
||||
|
@ -112,13 +113,13 @@ iter_for_language (GtkTreeModel *model,
|
|||
g_free (l);
|
||||
} while (gtk_tree_model_iter_next (model, iter));
|
||||
|
||||
name = gdm_normalize_language_name (lang);
|
||||
name = gnome_normalize_language_name (lang);
|
||||
if (name != NULL) {
|
||||
if (region) {
|
||||
language = gdm_get_region_from_name (name, NULL);
|
||||
language = gnome_get_region_from_name (name, NULL);
|
||||
}
|
||||
else {
|
||||
language = gdm_get_language_from_name (name, NULL);
|
||||
language = gnome_get_language_from_name (name, NULL);
|
||||
}
|
||||
|
||||
gtk_list_store_insert_with_values (GTK_LIST_STORE (model),
|
||||
|
@ -166,7 +167,7 @@ cc_common_language_has_font (const gchar *locale)
|
|||
object_set = NULL;
|
||||
font_set = NULL;
|
||||
|
||||
if (!gdm_parse_language_name (locale, &language_code, NULL, NULL, NULL))
|
||||
if (!gnome_parse_language_name (locale, &language_code, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
charset = FcLangGetCharSet ((FcChar8 *) language_code);
|
||||
|
@ -241,7 +242,7 @@ add_one_language (gpointer d)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
name = gdm_normalize_language_name (data->languages[data->position]);
|
||||
name = gnome_normalize_language_name (data->languages[data->position]);
|
||||
if (g_hash_table_lookup (data->user_langs, name) != NULL) {
|
||||
g_free (name);
|
||||
goto next;
|
||||
|
@ -253,10 +254,10 @@ add_one_language (gpointer d)
|
|||
}
|
||||
|
||||
if (data->regions) {
|
||||
language = gdm_get_region_from_name (name, NULL);
|
||||
language = gnome_get_region_from_name (name, NULL);
|
||||
}
|
||||
else {
|
||||
language = gdm_get_language_from_name (name, NULL);
|
||||
language = gnome_get_language_from_name (name, NULL);
|
||||
}
|
||||
if (!language) {
|
||||
g_debug ("Ignoring '%s' as a locale, because we couldn't figure the language name", name);
|
||||
|
@ -291,7 +292,7 @@ cc_common_language_add_available_languages (GtkListStore *store,
|
|||
|
||||
data->store = g_object_ref (store);
|
||||
data->user_langs = g_hash_table_ref (user_langs);
|
||||
data->languages = gdm_get_all_language_names ();
|
||||
data->languages = gnome_get_all_language_names ();
|
||||
data->regions = regions;
|
||||
data->position = 0;
|
||||
|
||||
|
@ -313,7 +314,7 @@ cc_common_language_get_current_language (void)
|
|||
|
||||
locale = (const gchar *) setlocale (LC_MESSAGES, NULL);
|
||||
if (locale)
|
||||
language = gdm_normalize_language_name (locale);
|
||||
language = gnome_normalize_language_name (locale);
|
||||
else
|
||||
language = NULL;
|
||||
|
||||
|
@ -466,17 +467,17 @@ user_language_has_translations (const char *locale)
|
|||
char *name, *language_code, *territory_code;
|
||||
gboolean ret;
|
||||
|
||||
gdm_parse_language_name (locale,
|
||||
&language_code,
|
||||
&territory_code,
|
||||
NULL, NULL);
|
||||
gnome_parse_language_name (locale,
|
||||
&language_code,
|
||||
&territory_code,
|
||||
NULL, NULL);
|
||||
name = g_strdup_printf ("%s%s%s",
|
||||
language_code,
|
||||
territory_code != NULL? "_" : "",
|
||||
territory_code != NULL? territory_code : "");
|
||||
g_free (language_code);
|
||||
g_free (territory_code);
|
||||
ret = gdm_language_has_translations (name);
|
||||
ret = gnome_language_has_translations (name);
|
||||
g_free (name);
|
||||
|
||||
return ret;
|
||||
|
@ -556,9 +557,9 @@ add_other_users_language (GHashTable *ht)
|
|||
if (lang != NULL && *lang != '\0' &&
|
||||
cc_common_language_has_font (lang) &&
|
||||
user_language_has_translations (lang)) {
|
||||
name = gdm_normalize_language_name (lang);
|
||||
name = gnome_normalize_language_name (lang);
|
||||
if (!g_hash_table_lookup (ht, name)) {
|
||||
language = gdm_get_language_from_name (name, NULL);
|
||||
language = gnome_get_language_from_name (name, NULL);
|
||||
g_hash_table_insert (ht, name, language);
|
||||
}
|
||||
else {
|
||||
|
@ -587,9 +588,9 @@ insert_language (GHashTable *ht,
|
|||
char *label;
|
||||
char *key;
|
||||
|
||||
if (gdm_language_has_translations (long_lang))
|
||||
if (gnome_language_has_translations (long_lang))
|
||||
lang = long_lang;
|
||||
else if (short_lang != NULL && gdm_language_has_translations (short_lang))
|
||||
else if (short_lang != NULL && gnome_language_has_translations (short_lang))
|
||||
lang = short_lang;
|
||||
else {
|
||||
g_warning ("%s lacks translations, why is it default?", long_lang);
|
||||
|
@ -662,7 +663,7 @@ cc_common_language_get_user_languages (void)
|
|||
/* Add current locale */
|
||||
name = cc_common_language_get_current_language ();
|
||||
if (g_hash_table_lookup (ht, name) == NULL) {
|
||||
language = gdm_get_language_from_name (name, NULL);
|
||||
language = gnome_get_language_from_name (name, NULL);
|
||||
g_hash_table_insert (ht, name, language);
|
||||
} else {
|
||||
g_free (name);
|
||||
|
@ -690,14 +691,14 @@ cc_common_language_get_initial_regions (const gchar *lang)
|
|||
g_hash_table_insert (ht, g_strdup ("zh_CN.utf8"), g_strdup (_("China")));
|
||||
#endif
|
||||
|
||||
gdm_parse_language_name (lang, &language, NULL, NULL, NULL);
|
||||
langs = gdm_get_all_language_names ();
|
||||
gnome_parse_language_name (lang, &language, NULL, NULL, NULL);
|
||||
langs = gnome_get_all_language_names ();
|
||||
for (i = 0; langs[i]; i++) {
|
||||
gchar *l, *s;
|
||||
gdm_parse_language_name (langs[i], &l, NULL, NULL, NULL);
|
||||
gnome_parse_language_name (langs[i], &l, NULL, NULL, NULL);
|
||||
if (g_strcmp0 (language, l) == 0) {
|
||||
if (!g_hash_table_lookup (ht, langs[i])) {
|
||||
s = gdm_get_region_from_name (langs[i], NULL);
|
||||
s = gnome_get_region_from_name (langs[i], NULL);
|
||||
g_hash_table_insert (ht, g_strdup (langs[i]), s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "cc-language-chooser.h"
|
||||
#include "cc-common-language.h"
|
||||
#include "cc-common-resources.h"
|
||||
#include "gdm-languages.h"
|
||||
|
||||
gchar *
|
||||
cc_language_chooser_get_language (GtkWidget *chooser)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,44 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright 2008 Red Hat, Inc.
|
||||
* Copyright 2007 William Jon McCann <mccann@jhu.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Ray Strode
|
||||
* William Jon McCann
|
||||
*/
|
||||
|
||||
#ifndef __GDM_LANGUAGES_H
|
||||
#define __GDM_LANGUAGES_H
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
char * gdm_get_language_from_name (const char *name,
|
||||
const char *locale);
|
||||
char * gdm_get_region_from_name (const char *name,
|
||||
const char *locale);
|
||||
char ** gdm_get_all_language_names (void);
|
||||
gboolean gdm_parse_language_name (const char *name,
|
||||
char **language_codep,
|
||||
char **territory_codep,
|
||||
char **codesetp,
|
||||
char **modifierp);
|
||||
char * gdm_normalize_language_name (const char *name);
|
||||
gboolean gdm_language_has_translations (const char *language_name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDM_LANGUAGE_CHOOSER_WIDGET_H */
|
|
@ -1,43 +0,0 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <locale.h>
|
||||
#include <glib-object.h>
|
||||
#include "gdm-languages.h"
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
char **langs;
|
||||
guint i;
|
||||
|
||||
setlocale (LC_ALL, NULL);
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
|
||||
if (argc > 1) {
|
||||
guint i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
char *lang, *norm;
|
||||
norm = gdm_normalize_language_name (argv[i]);
|
||||
lang = gdm_get_language_from_name (norm, NULL);
|
||||
g_print ("%s (norm: %s) == %s\n", argv[i], norm, lang);
|
||||
g_free (norm);
|
||||
g_free (lang);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
langs = gdm_get_all_language_names ();
|
||||
if (langs == NULL) {
|
||||
g_warning ("No languages found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; langs[i] != NULL; i++)
|
||||
g_print ("%s == %s\n", langs[i], gdm_get_language_from_name (langs[i], NULL));
|
||||
|
||||
g_strfreev (langs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
/* Definitions for locale archive handling.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _LOCARCHIVE_H
|
||||
#define _LOCARCHIVE_H 1
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define AR_MAGIC 0xde020109
|
||||
|
||||
struct locarhead
|
||||
{
|
||||
uint32_t magic;
|
||||
/* Serial number. */
|
||||
uint32_t serial;
|
||||
/* Name hash table. */
|
||||
uint32_t namehash_offset;
|
||||
uint32_t namehash_used;
|
||||
uint32_t namehash_size;
|
||||
/* String table. */
|
||||
uint32_t string_offset;
|
||||
uint32_t string_used;
|
||||
uint32_t string_size;
|
||||
/* Table with locale records. */
|
||||
uint32_t locrectab_offset;
|
||||
uint32_t locrectab_used;
|
||||
uint32_t locrectab_size;
|
||||
/* MD5 sum hash table. */
|
||||
uint32_t sumhash_offset;
|
||||
uint32_t sumhash_used;
|
||||
uint32_t sumhash_size;
|
||||
};
|
||||
|
||||
|
||||
struct namehashent
|
||||
{
|
||||
/* Hash value of the name. */
|
||||
uint32_t hashval;
|
||||
/* Offset of the name in the string table. */
|
||||
uint32_t name_offset;
|
||||
/* Offset of the locale record. */
|
||||
uint32_t locrec_offset;
|
||||
};
|
||||
|
||||
|
||||
struct sumhashent
|
||||
{
|
||||
/* MD5 sum. */
|
||||
char sum[16];
|
||||
/* Offset of the file in the archive. */
|
||||
uint32_t file_offset;
|
||||
};
|
||||
|
||||
struct locrecent
|
||||
{
|
||||
uint32_t refs; /* # of namehashent records that point here */
|
||||
struct
|
||||
{
|
||||
uint32_t offset;
|
||||
uint32_t len;
|
||||
} record[__LC_LAST];
|
||||
};
|
||||
|
||||
|
||||
struct locarhandle
|
||||
{
|
||||
int fd;
|
||||
void *addr;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
|
||||
/* In memory data for the locales with their checksums. */
|
||||
typedef struct locale_category_data
|
||||
{
|
||||
off_t size;
|
||||
void *addr;
|
||||
char sum[16];
|
||||
} locale_data_t[__LC_LAST];
|
||||
|
||||
#endif /* locarchive.h */
|
|
@ -27,9 +27,11 @@
|
|||
#include <locale.h>
|
||||
#include <langinfo.h>
|
||||
#include <stdlib.h>
|
||||
#define GNOME_DESKTOP_USE_UNSTABLE_API
|
||||
#include <libgnome-desktop/gnome-languages.h>
|
||||
|
||||
#include "cc-common-language.h"
|
||||
#include "cc-language-chooser.h"
|
||||
#include "gdm-languages.h"
|
||||
#include "gnome-region-panel-formats.h"
|
||||
|
||||
static void
|
||||
|
@ -237,7 +239,7 @@ populate_regions (GtkBuilder *builder, const gchar *current_lang)
|
|||
current_region = g_strdup (current_lang);
|
||||
}
|
||||
else if (!g_hash_table_lookup (ht, current_region)) {
|
||||
name = gdm_get_region_from_name (current_region, NULL);
|
||||
name = gnome_get_region_from_name (current_region, NULL);
|
||||
g_hash_table_insert (ht, g_strdup (current_region), name);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <ibus.h>
|
||||
#endif
|
||||
|
||||
#include "gdm-languages.h"
|
||||
#include "gnome-region-panel-input.h"
|
||||
|
||||
#define WID(s) GTK_WIDGET(gtk_builder_get_object (builder, s))
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "gnome-region-panel-system.h"
|
||||
#include "cc-common-language.h"
|
||||
#include "cc-language-chooser.h"
|
||||
#include "gdm-languages.h"
|
||||
|
||||
static GDBusProxy *proxy = NULL;
|
||||
static GDBusProxy *sm_proxy = NULL;
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#define GNOME_DESKTOP_USE_UNSTABLE_API
|
||||
#include <libgnome-desktop/gnome-languages.h>
|
||||
#include <libgnome-desktop/gnome-xkb-info.h>
|
||||
|
||||
#include "cc-common-language.h"
|
||||
#include "gdm-languages.h"
|
||||
#include "gnome-region-panel-system.h"
|
||||
|
||||
#define WID(s) GTK_WIDGET(gtk_builder_get_object (dialog, s))
|
||||
|
@ -106,7 +106,7 @@ locale_settings_changed (GSettings *settings,
|
|||
region = g_strdup ((gchar*)g_object_get_data (G_OBJECT (label), "language"));
|
||||
}
|
||||
|
||||
display_region = gdm_get_region_from_name (region, NULL);
|
||||
display_region = gnome_get_region_from_name (region, NULL);
|
||||
label = WID ("user_format");
|
||||
gtk_label_set_text (GTK_LABEL (label), display_region);
|
||||
g_object_set_data_full (G_OBJECT (label), "region", g_strdup (region), g_free);
|
||||
|
@ -122,7 +122,7 @@ system_update_language (GtkBuilder *dialog, const gchar *language)
|
|||
gchar *display_language;
|
||||
GtkWidget *label;
|
||||
|
||||
display_language = gdm_get_language_from_name (language, NULL);
|
||||
display_language = gnome_get_language_from_name (language, NULL);
|
||||
label = WID ("user_display_language");
|
||||
gtk_label_set_text (GTK_LABEL (label), display_language);
|
||||
g_object_set_data_full (G_OBJECT (label), "language", g_strdup (language), g_free);
|
||||
|
@ -283,7 +283,7 @@ on_localed_properties_changed (GDBusProxy *proxy,
|
|||
}
|
||||
|
||||
if (messages) {
|
||||
name = gdm_get_language_from_name (messages, NULL);
|
||||
name = gnome_get_language_from_name (messages, NULL);
|
||||
label = WID ("system_display_language");
|
||||
gtk_label_set_text (GTK_LABEL (label), name);
|
||||
g_free (name);
|
||||
|
@ -291,7 +291,7 @@ on_localed_properties_changed (GDBusProxy *proxy,
|
|||
}
|
||||
|
||||
if (time) {
|
||||
name = gdm_get_region_from_name (time, NULL);
|
||||
name = gnome_get_region_from_name (time, NULL);
|
||||
label = WID ("system_format");
|
||||
gtk_label_set_text (GTK_LABEL (label), name);
|
||||
g_free (name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue