[dia] Get rid of obsolete GNOME stuff
- From: Hans Breuer <hans src gnome org>
- To: svn-commits-list gnome org
- Subject: [dia] Get rid of obsolete GNOME stuff
- Date: Sat, 13 Jun 2009 14:00:21 -0400 (EDT)
commit 89571335316f879d624baec6013c01264c73c462
Author: Hans Breuer <hans breuer org>
Date: Sat Jun 13 19:18:55 2009 +0200
Get rid of obsolete GNOME stuff
* use #ifdef HAVE_GNOME rather than #ifdef GNOME
* use g_get_language_names() ratehr than copied stuff from gnome-i18n.c
* remove obsolete gnome.h includes
app/Makefile.am | 22 +--
app/app_procs.c | 13 +-
app/commands.c | 4 +-
app/dia_embedd.c | 411 -----------------------------------------
app/disp_callbacks.c | 4 -
app/display.c | 5 -
app/interface.c | 14 +-
app/sheets_dialog_callbacks.c | 4 -
configure.in | 19 +-
lib/intl.c | 293 ++----------------------------
lib/intl.h | 28 +--
11 files changed, 46 insertions(+), 771 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index 2d87c7b..ef57ba2 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -22,15 +22,7 @@ noinst_PROGRAMS = run_dia.sh
run_dia_sh_SOURCES =
-if HAVE_BONOBO
-dia_embedd = dia-embedd
-dia_oafinfo = GNOME_Dia.oaf
-else
-dia_embedd =
-dia_oafinfo =
-endif
-
-bin_PROGRAMS = dia $(dia_embedd)
+bin_PROGRAMS = dia
ICON_PNG_PAIRS= \
dia_connectable_icon $(srcdir)/pixmaps/connectable.png \
@@ -92,9 +84,6 @@ dia-app-icons.h: $(ICON_PNGS)
BUILT_SOURCES = dia-app-icons.h
-oafinfodir = $(datadir)/oaf
-oafinfo_DATA = $(dia_oafinfo)
-
dia_core_files = \
confirm.h \
confirm.c \
@@ -232,15 +221,6 @@ dia_LDADD = ../lib/libdia.la \
## Bonobo embeddable dia. Commented out, because it's a bit raw.
## Especially the configure/make parts.
-dia_embedd_SOURCES = \
- $(dia_core_files) \
- dia_embedd.c
-
-dia_embedd_LDADD = ../lib/libdia.la \
- $(EFENCE) \
- $(APP_LIBS) $(PNG_LIBS) $(GTK_LIBS) $(INTLLIBS)
-#$(BONOBO_LIBS)
-
if HAVE_GCC
# OS X would like += rather than =, but Linux automake no like that. Grrr.
dia_LDFLAGS = -export-dynamic
diff --git a/app/app_procs.c b/app/app_procs.c
index e0649eb..dccbbe1 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -34,7 +34,7 @@
#include <png.h> /* just for the version stuff */
#endif
-#ifdef GNOME
+#ifdef HAVE_GNOME
#undef GTK_DISABLE_DEPRECATED
/* /usr/include/libgnomeui-2.0/libgnomeui/gnome-entry.h:58: error: expected specifier-qualifier-list before 'GtkCombo' */
#include <gnome.h>
@@ -101,7 +101,7 @@ static void print_credits(gboolean credits);
static gboolean dia_is_interactive = FALSE;
-#ifdef GNOME
+#ifdef HAVE_GNOME
static void
session_die (gpointer client_data)
@@ -415,12 +415,9 @@ dump_dependencies(void)
#ifdef HAVE_CAIRO
"cairo "
#endif
-#ifdef GNOME
+#ifdef HAVE_GNOME
"gnome "
#endif
-#ifdef HAVE_GNOMEPRINT
- "gnomeprint "
-#endif
#ifdef HAVE_LIBART
"libart "
#endif
@@ -621,7 +618,7 @@ app_init (int argc, char **argv)
static gboolean version = FALSE;
static gboolean verbose = FALSE;
static gboolean log_to_stderr = FALSE;
-#ifdef GNOME
+#ifdef HAVE_GNOME
GnomeClient *client;
#endif
static char *export_file_name = NULL;
@@ -725,7 +722,7 @@ app_init (int argc, char **argv)
textdomain(GETTEXT_PACKAGE);
if (argv && dia_is_interactive && !version) {
-#ifdef GNOME
+#ifdef HAVE_GNOME
GnomeProgram *program =
gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
argc, argv,
diff --git a/app/commands.c b/app/commands.c
index f81d6ac..46e2d79 100644
--- a/app/commands.c
+++ b/app/commands.c
@@ -27,7 +27,7 @@
#include <math.h>
#include <glib.h>
-#ifdef GNOME
+#ifdef HAVE_GNOME
#undef GTK_DISABLE_DEPRECATED
# include <gnome.h>
#endif
@@ -632,7 +632,7 @@ edit_redo_callback (GtkAction *action)
void
help_manual_callback (GtkAction *action)
{
-#ifdef GNOME
+#ifdef HAVE_GNOME
gnome_help_display("dia", NULL, NULL);
#else
char *helpdir, *helpindex = NULL, *command;
diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c
index 51e09cc..afaa6f0 100644
--- a/app/disp_callbacks.c
+++ b/app/disp_callbacks.c
@@ -23,10 +23,6 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
-#ifdef GNOME
-#undef GTK_DISABLE_DEPRECATED
-#include <gnome.h>
-#endif
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
diff --git a/app/display.c b/app/display.c
index 6aca06a..343eafd 100644
--- a/app/display.c
+++ b/app/display.c
@@ -24,11 +24,6 @@
#include <stdio.h>
#include <math.h>
-#ifdef GNOME
-#undef GTK_DISABLE_DEPRECATED
-#include <gnome.h>
-#endif
-
#include <gdk/gdkkeysyms.h>
#include "intl.h"
diff --git a/app/interface.c b/app/interface.c
index 3ee5b70..6ec68f1 100644
--- a/app/interface.c
+++ b/app/interface.c
@@ -18,7 +18,7 @@
#include <config.h>
-#ifdef GNOME
+#ifdef HAVE_GNOME
#undef GTK_DISABLE_DEPRECATED /* gnome */
#include <gnome.h>
#else
@@ -1625,7 +1625,7 @@ create_integrated_ui (void)
GtkWidget *layer_view;
-#ifdef GNOME
+#ifdef HAVE_GNOME
window = gnome_app_new ("Dia", _("Diagram Editor"));
#else
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -1651,7 +1651,7 @@ create_integrated_ui (void)
main_vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
-#ifdef GNOME
+#ifdef HAVE_GNOME
gnome_app_set_contents (GNOME_APP(window), main_vbox);
#else
gtk_container_add (GTK_CONTAINER (window), main_vbox);
@@ -1704,7 +1704,7 @@ create_integrated_ui (void)
* uses the tool buttons*/
menus_get_integrated_ui_menubar(&menubar, &toolbar, &accel_group);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
-#ifdef GNOME
+#ifdef HAVE_GNOME
gnome_app_set_menus (GNOME_APP (window), GTK_MENU_BAR (menubar));
#else
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
@@ -1749,7 +1749,7 @@ create_toolbox ()
GtkWidget *menubar;
GtkAccelGroup *accel_group;
-#ifdef GNOME
+#ifdef HAVE_GNOME
window = gnome_app_new ("Dia", _("Diagram Editor"));
#else
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -1778,7 +1778,7 @@ create_toolbox ()
main_vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
-#ifdef GNOME
+#ifdef HAVE_GNOME
gnome_app_set_contents(GNOME_APP(window), main_vbox);
#else
gtk_container_add (GTK_CONTAINER (window), main_vbox);
@@ -1814,7 +1814,7 @@ create_toolbox ()
* uses the tool buttons*/
menus_get_toolbox_menubar(&menubar, &accel_group);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
-#ifdef GNOME
+#ifdef HAVE_GNOME
gnome_app_set_menus(GNOME_APP(window), GTK_MENU_BAR(menubar));
#else
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
diff --git a/app/sheets_dialog_callbacks.c b/app/sheets_dialog_callbacks.c
index 55efbab..1272314 100644
--- a/app/sheets_dialog_callbacks.c
+++ b/app/sheets_dialog_callbacks.c
@@ -48,11 +48,7 @@
#include <gmodule.h>
#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu */
-#ifdef GNOME
-#include <gnome.h>
-#else
#include <gtk/gtk.h>
-#endif
#include <libxml/tree.h>
#include <libxml/parser.h>
diff --git a/configure.in b/configure.in
index 266789d..8718f51 100644
--- a/configure.in
+++ b/configure.in
@@ -110,17 +110,18 @@ if test "$have_libart" = "yes" ; then
fi
AC_MSG_CHECKING([whether GNOME specific code should be used])
-AC_ARG_ENABLE(gnome,[ --enable-gnome enable gnome code],
- GNOME=$enableval, GNOME=no)
-if test "$GNOME" = "yes" ; then
+AC_ARG_ENABLE(gnome,
+ AC_HELP_STRING([--enable-gnome],[enable gnome code]),,
+ enable_gnome=no)
+if test x"$enable_gnome" = "xyes" ; then
GTK_MODULES="$GTK_MODULES libgnome-2.0 libgnomeui-2.0"
- AC_DEFINE(GNOME,1,[Define if building with GNOME support])
+ AC_DEFINE(HAVE_GNOME,1,[Define if building with GNOME support])
AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [GNOME icon directory])
- have_gnome=true
+ have_gnome=yes
else
- have_gnome=false
+ have_gnome=no
fi
-AM_CONDITIONAL(HAVE_GNOME, $have_gnome)
+AM_CONDITIONAL(HAVE_GNOME, [test "x$have_gnome" != "xno"])
AC_MSG_RESULT($GNOME)
dnl GTK2: libgnomecanvas-2.0 ?
@@ -129,7 +130,7 @@ PKG_CHECK_MODULES(GTK,$GTK_MODULES)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
-AM_CONDITIONAL(HAVE_BONOBO,false)
+AM_CONDITIONAL(HAVE_BONOBO,[test "true" = "false"])
dnl Look for Cairo
AC_ARG_WITH(cairo,
@@ -627,7 +628,7 @@ Configuration:
Source code location: ${srcdir}
Compiler: ${CC}
- Gnome support: ${GNOME}
+ Gnome support: ${have_gnome}
Python support: ${with_python}
Libart support (PNG export): ${have_libart}
Cairo support (PNG, PDF, print): ${with_cairo}
diff --git a/lib/intl.c b/lib/intl.c
index 7af95a3..774a3d8 100644
--- a/lib/intl.c
+++ b/lib/intl.c
@@ -6,294 +6,25 @@
#include <stdlib.h>
#include <string.h>
-#ifndef GNOME
-/* taken from gnome-libs/libgnome/gnome-i18n.c ... */
-/* FIXME: is this still necessary, or has gtk2.0 swallowed this ? */
-
-static GHashTable *alias_table = NULL;
-
-/*read an alias file for the locales*/
-static void
-read_aliases (char *file)
-{
- FILE *fp;
- char buf[256];
-
- if (!alias_table)
- alias_table = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, g_free);
- fp = fopen (file,"r");
- if (!fp)
- return;
- while (fgets (buf,256,fp)) {
- char *p;
- g_strstrip(buf);
- if(buf[0]=='#' || buf[0]=='\0')
- continue;
- p = strtok(buf,"\t ");
- if(!p) continue;
- p = strtok(NULL,"\t ");
- if(!p) continue;
- g_hash_table_insert (alias_table, g_strdup(buf), g_strdup(p));
- }
- fclose (fp);
-}
-
-static void
-free_alias_table(void)
-{
- if (!alias_table)
- return;
- g_hash_table_destroy(alias_table);
- alias_table = NULL;
-}
-
-/*return the un-aliased language as a newly allocated string*/
-static char *
-unalias_lang (char *lang)
-{
- char *p;
-
- if(!alias_table) {
- read_aliases ("/usr/share/locale/locale.alias");
- read_aliases ("/usr/local/share/locale/locale.alias");
- read_aliases ("/usr/lib/X11/locale/locale.alias");
- read_aliases ("/usr/openwin/lib/locale/locale.alias");
- }
- while((p=g_hash_table_lookup(alias_table,lang)) && strcmp(p, lang))
- lang = p;
- return lang;
-}
-
-/* Mask for components of locale spec. The ordering here is from
- * least significant to most significant
- */
-enum
-{
- COMPONENT_CODESET = 1 << 0,
- COMPONENT_TERRITORY = 1 << 1,
- COMPONENT_MODIFIER = 1 << 2
-};
-
-/* Break an X/Open style locale specification into components
- */
-static guint
-explode_locale (const gchar *locale,
- gchar **language,
- gchar **territory,
- gchar **codeset,
- gchar **modifier)
-{
- const gchar *uscore_pos;
- const gchar *at_pos;
- const gchar *dot_pos;
-
- guint mask = 0;
-
- uscore_pos = strchr (locale, '_');
- dot_pos = strchr (uscore_pos ? uscore_pos : locale, '.');
- at_pos = strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@');
-
- if (at_pos) {
- mask |= COMPONENT_MODIFIER;
- *modifier = g_strdup (at_pos);
- } else
- at_pos = locale + strlen (locale);
-
- if (dot_pos) {
- mask |= COMPONENT_CODESET;
- *codeset = g_new (gchar, 1 + at_pos - dot_pos);
- strncpy (*codeset, dot_pos, at_pos - dot_pos);
- (*codeset)[at_pos - dot_pos] = '\0';
- } else
- dot_pos = at_pos;
-
- if (uscore_pos) {
- mask |= COMPONENT_TERRITORY;
- *territory = g_new (gchar, 1 + dot_pos - uscore_pos);
- strncpy (*territory, uscore_pos, dot_pos - uscore_pos);
- (*territory)[dot_pos - uscore_pos] = '\0';
- } else
- uscore_pos = dot_pos;
-
- *language = g_new (gchar, 1 + uscore_pos - locale);
- strncpy (*language, locale, uscore_pos - locale);
- (*language)[uscore_pos - locale] = '\0';
-
- return mask;
-}
-
-/*
- * Compute all interesting variants for a given locale name -
- * by stripping off different components of the value.
- *
- * For simplicity, we assume that the locale is in
- * X/Open format: language[_territory][ codeset][ modifier]
- *
- * TODO: Extend this to handle the CEN format (see the GNUlibc docs)
- * as well. We could just copy the code from glibc wholesale
- * but it is big, ugly, and complicated, so I'm reluctant
- * to do so when this should handle 99% of the time...
- */
-static GList *
-compute_locale_variants (const gchar *locale)
-{
- GList *retval = NULL;
-
- gchar *language;
- gchar *territory=NULL;
- gchar *codeset=NULL;
- gchar *modifier=NULL;
-
- guint mask;
- guint i;
-
- g_return_val_if_fail (locale != NULL, NULL);
-
- mask = explode_locale (locale, &language, &territory, &codeset, &modifier);
-
- /* Iterate through all possible combinations, from least attractive
- * to most attractive.
- */
- for (i=0; i<=mask; i++)
- if ((i & ~mask) == 0)
- {
- gchar *val = g_strconcat(language,
- (i & COMPONENT_TERRITORY) ? territory : "",
- (i & COMPONENT_CODESET) ? codeset : "",
- (i & COMPONENT_MODIFIER) ? modifier : "",
- NULL);
- retval = g_list_prepend (retval, val);
- }
-
- g_free (language);
- if (mask & COMPONENT_CODESET)
- g_free (codeset);
- if (mask & COMPONENT_TERRITORY)
- g_free (territory);
- if (mask & COMPONENT_MODIFIER)
- g_free (modifier);
-
- return retval;
-}
-
-/* The following is (partly) taken from the gettext package.
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. */
-
-static const gchar *
-guess_category_value (const gchar *categoryname)
-{
- const gchar *retval;
-
- /* The highest priority value is the `LANGUAGE' environment
- variable. This is a GNU extension. */
- retval = getenv ("LANGUAGE");
- if (retval != NULL && retval[0] != '\0')
- return retval;
-
- /* `LANGUAGE' is not set. So we have to proceed with the POSIX
- methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some
- systems this can be done by the `setlocale' function itself. */
-
- /* Setting of LC_ALL overwrites all other. */
- retval = getenv ("LC_ALL");
- if (retval != NULL && retval[0] != '\0')
- return retval;
-
- /* Next comes the name of the desired category. */
- retval = getenv (categoryname);
- if (retval != NULL && retval[0] != '\0')
- return retval;
-
- /* Last possibility is the LANG environment variable. */
- retval = getenv ("LANG");
- if (retval != NULL && retval[0] != '\0')
- return retval;
-
- return NULL;
-}
-
-static GList *
-get_language_list(const gchar *category_name)
-{
- GList *list = NULL;
- gint c_locale_defined= FALSE;
-
- const gchar *category_value;
- gchar *category_memory, *orig_category_memory;
-
- if (!category_name)
- category_name= "LC_ALL";
-
- category_value = guess_category_value (category_name);
- if (! category_value)
- category_value = "C";
- orig_category_memory = category_memory =
- g_malloc (strlen (category_value)+1);
-
- while (category_value[0] != '\0') {
- while (category_value[0] != '\0' && category_value[0] == ':')
- ++category_value;
-
- if (category_value[0] != '\0') {
- char *cp= category_memory;
-
- while (category_value[0] != '\0' && category_value[0] != ':')
- *category_memory++= *category_value++;
-
- category_memory[0]= '\0';
- category_memory++;
-
- cp = unalias_lang(cp);
-
- if (strcmp (cp, "C") == 0)
- c_locale_defined= TRUE;
-
- list= g_list_concat (list, compute_locale_variants (cp));
- }
- }
-
- g_free (orig_category_memory);
-
- if (!c_locale_defined)
- list= g_list_append (list, "C");
-
- return list;
-}
-
-#endif
-
-const GList *
-intl_get_language_list(void)
-{
- static const GList *list = NULL;
-
- if (!list) {
-#ifdef GNOME
- list = gnome_i18n_get_language_list("LC_MESSAGES");
-#else
- list = get_language_list("LC_MESSAGES");
- free_alias_table();
-#endif
- }
- return list;
-}
-
/* low numbers are better */
int
intl_score_locale(const gchar *locale)
{
- const GList *list = intl_get_language_list();
- const GList *tmp;
- int i;
+ const gchar * const *names = g_get_language_names ();
+ int i = 0;
/* NULL is same as C locale */
- if (!locale)
- return g_list_length((GList*)list) - 1;
- for (tmp = list, i = 0; tmp; tmp = tmp->next, i++)
- if (!strcmp((const char *)tmp->data, locale))
+ if (!locale) {
+ while (names[i] != NULL)
+ ++i;
+ return i;
+ }
+ while (names[i] != NULL) {
+ if (strcmp(names[i], locale) == 0)
break;
- if (!tmp) /* not found */
+ ++i;
+ }
+ if (!names[i] != NULL) /* not found */
i = G_MAXINT;
return i;
}
diff --git a/lib/intl.h b/lib/intl.h
index 390879b..b19b8ab 100644
--- a/lib/intl.h
+++ b/lib/intl.h
@@ -2,27 +2,17 @@
#define INTL_H
#include <glib.h>
-#ifdef GNOME
-# include <libgnome/gnome-i18n.h>
-#else
-# ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(String) gettext(String)
-# ifdef gettext_noop
-# define N_(String) gettext_noop(String)
-# else
-# define N_(String) (String)
-# endif
-# else /* NLS is disabled */
-# define _(String) (String)
-# define N_(String) (String)
-# define gettext(String) (String)
-# define textdomain(Domain)
-# define bindtextdomain(Package, Directory)
-# endif
+
+#ifdef ENABLE_NLS
+# include <glib/gi18n.h>
+#else /* NLS is disabled */
+# define _(String) (String)
+# define N_(String) (String)
+# define gettext(String) (String)
+# define textdomain(Domain)
+# define bindtextdomain(Package, Directory)
#endif
-const GList *intl_get_language_list (void);
int intl_score_locale (const gchar *locale);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]