Index: src/yelp-main.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-main.c,v retrieving revision 1.43 diff -p -u -u -p -r1.43 yelp-main.c --- src/yelp-main.c 3 Feb 2006 05:41:57 -0000 1.43 +++ src/yelp-main.c 11 Feb 2006 16:26:44 -0000 @@ -43,6 +43,7 @@ #include "yelp-window.h" #include "yelp-base.h" #include "yelp-html.h" +#include "yelp-gecko-utils.h" #define YELP_FACTORY_OAFIID "OAFIID:GNOME_Yelp_Factory" @@ -408,7 +409,11 @@ main (int argc, char **argv) gnome_vfs_init (); - yelp_html_initialize (); + if (!yelp_gecko_init ()) + { + g_print ("Couldn't initialize gecko!\n"); + exit (1); + }; /* Commandline parsing is done here */ g_object_get (G_OBJECT (program), @@ -463,6 +468,8 @@ main (int argc, char **argv) } else { main_start (url); } + + yelp_gecko_shutdown (); return 0; } Index: src/yelp-gecko-utils.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-gecko-utils.h,v retrieving revision 1.8 diff -p -u -u -p -r1.8 yelp-gecko-utils.h --- src/yelp-gecko-utils.h 16 May 2005 21:02:33 -0000 1.8 +++ src/yelp-gecko-utils.h 11 Feb 2006 16:26:44 -0000 @@ -33,6 +33,8 @@ void yelp_gecko_set_color ( const gchar *color); void yelp_gecko_set_font (YelpFontType font_type, const gchar *fontname); +gboolean yelp_gecko_init (void); +void yelp_gecko_shutdown (void); G_END_DECLS Index: src/yelp-gecko-utils.cpp =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-gecko-utils.cpp,v retrieving revision 1.16 diff -p -u -u -p -r1.16 yelp-gecko-utils.cpp --- src/yelp-gecko-utils.cpp 22 Jan 2006 18:06:35 -0000 1.16 +++ src/yelp-gecko-utils.cpp 11 Feb 2006 16:26:44 -0000 @@ -28,9 +28,46 @@ #include #include #include +#include +#include #include #include "yelp-gecko-utils.h" +#include "yelp-gecko-services.h" + +static nsIPrefBranch* gPrefBranch; + +static const char *font_languages[] = { + "x-western" +#ifdef HAVE_GECKO_1_8 + , + "ar", + "el", + "he", + "ja", + "ko", + "th", + "tr", + "x-armn", + "x-baltic", + "x-beng", + "x-cans", + "x-central-euro", + "x-cyrillic", + "x-devanagari", + "x-ethi", + "x-geor", + "x-gujr", + "x-guru", + "x-khmr", + "x-mlym", + "x-tamil", + "x-unicode", + "zh-CN", + "zh-HK", + "zh-TW" +#endif /* HAVE_GECKO_1_8 */ +}; static gboolean yelp_util_split_font_string (const gchar *font_name, gchar **name, gint *size) @@ -39,6 +76,8 @@ yelp_util_split_font_string (const gchar PangoFontMask mask = (PangoFontMask) (PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE); gboolean retval = FALSE; + if (!font_name) return FALSE; + desc = pango_font_description_from_string (font_name); if (!desc) return FALSE; @@ -56,49 +95,25 @@ yelp_util_split_font_string (const gchar static gboolean gecko_prefs_set_bool (const gchar *key, gboolean value) { - nsresult rv; - nsCOMPtr prefService (do_GetService (NS_PREFSERVICE_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS (rv, FALSE); + NS_ENSURE_TRUE (gPrefBranch, FALSE); - nsCOMPtr pref; - rv = prefService->GetBranch ("", getter_AddRefs (pref)); - NS_ENSURE_SUCCESS (rv, FALSE); - - rv = pref->SetBoolPref (key, value); - - return NS_SUCCEEDED (rv) != PR_FALSE; + return NS_SUCCEEDED(gPrefBranch->SetBoolPref (key, value)); } static gboolean gecko_prefs_set_string (const gchar *key, const gchar *value) { - nsresult rv; - nsCOMPtr prefService (do_GetService (NS_PREFSERVICE_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS (rv, FALSE); - - nsCOMPtr pref; - rv = prefService->GetBranch ("", getter_AddRefs (pref)); - NS_ENSURE_SUCCESS (rv, FALSE); + NS_ENSURE_TRUE (gPrefBranch, FALSE); - rv = pref->SetCharPref (key, value); - - return NS_SUCCEEDED (rv) != PR_FALSE; + return NS_SUCCEEDED(gPrefBranch->SetCharPref (key, value)); } static gboolean gecko_prefs_set_int (const gchar *key, gint value) { - nsresult rv; - nsCOMPtr prefService (do_GetService (NS_PREFSERVICE_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS (rv, FALSE); - - nsCOMPtr pref; - rv = prefService->GetBranch ("", getter_AddRefs (pref)); - NS_ENSURE_SUCCESS (rv, FALSE); + NS_ENSURE_TRUE (gPrefBranch, FALSE); - rv = pref->SetIntPref (key, value); - - return NS_SUCCEEDED (rv) != PR_FALSE; + return NS_SUCCEEDED(gPrefBranch->SetIntPref (key, value)); } extern "C" void @@ -130,14 +145,14 @@ yelp_gecko_set_color (YelpColorType type } extern "C" void -yelp_gecko_set_font (YelpFontType font_type, const gchar *fontname) +yelp_gecko_set_font (YelpFontType font_type, + const gchar *fontname) { - gchar *name; - gint size = 0; - - g_return_if_fail (fontname != NULL); + char *name = NULL; + char pref[128]; + int size = 0; + guint i; - name = NULL; if (!yelp_util_split_font_string (fontname, &name, &size)) { g_free (name); return; @@ -147,22 +162,32 @@ yelp_gecko_set_font (YelpFontType font_t switch (font_type) { case YELP_FONT_VARIABLE: - gecko_prefs_set_string ("font.name.variable.x-western", - name); - gecko_prefs_set_int ("font.size.variable.x-western", - size); - gecko_prefs_set_int ("font.minimum-size.x-western", - 8); + for (i = 0; i < G_N_ELEMENTS (font_languages); ++i) + { + g_snprintf (pref, sizeof (pref), "font.name.variable.%s", + font_languages[i]); + gecko_prefs_set_string (pref, name); + + g_snprintf (pref, sizeof (pref), "font.size.variable.%s", + font_languages[i]); + gecko_prefs_set_int (pref, size); + + g_snprintf (pref, sizeof (pref), "font.minimum-size.%s", + font_languages[i]); + gecko_prefs_set_int (pref, 8); + } break; case YELP_FONT_FIXED: - gecko_prefs_set_string ("font.name.monospace.x-western", - name); - gecko_prefs_set_int ("font.size.monospace.x-western", - size); - gecko_prefs_set_string ("font.name.fixed.x-western", - name); - gecko_prefs_set_int ("font.size.fixed.x-western", - size); + for (i = 0; i < G_N_ELEMENTS (font_languages); ++i) + { + g_snprintf (pref, sizeof (pref), "font.name.monospace.%s", + font_languages[i]); + gecko_prefs_set_string (pref, name); + + g_snprintf (pref, sizeof (pref), "font.size.monospace.%s", + font_languages[i]); + gecko_prefs_set_int (pref, size); + } break; default: break; @@ -170,3 +195,31 @@ yelp_gecko_set_font (YelpFontType font_t g_free (name); } + +extern "C" gboolean +yelp_gecko_init (void) +{ + gtk_moz_embed_set_comp_path (MOZILLA_HOME); + + gtk_moz_embed_push_startup (); + + yelp_register_printing (); + + nsresult rv; + nsCOMPtr prefService (do_GetService (NS_PREFSERVICE_CONTRACTID, &rv)); + NS_ENSURE_SUCCESS (rv, FALSE); + + rv = CallQueryInterface (prefService, &gPrefBranch); + NS_ENSURE_SUCCESS (rv, FALSE); + + return TRUE; +} + +extern "C" void +yelp_gecko_shutdown (void) +{ + NS_IF_RELEASE (gPrefBranch); + gPrefBranch = nsnull; + + gtk_moz_embed_pop_startup (); +} Index: src/yelp-html.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.h,v retrieving revision 1.32 diff -p -u -u -p -r1.32 yelp-html.h --- src/yelp-html.h 7 Jan 2006 19:08:37 -0000 1.32 +++ src/yelp-html.h 11 Feb 2006 16:26:44 -0000 @@ -113,7 +113,6 @@ void yelp_html_print void yelp_html_preview_end (YelpHtml *html); void yelp_html_preview_navigate (YelpHtml *html, gint page_no); -void yelp_html_initialize (void); G_END_DECLS Index: src/yelp-html.cpp =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.cpp,v retrieving revision 1.6 diff -p -u -u -p -r1.6 yelp-html.cpp --- src/yelp-html.cpp 29 Jan 2006 21:56:05 -0000 1.6 +++ src/yelp-html.cpp 11 Feb 2006 16:26:44 -0000 @@ -485,17 +485,3 @@ html_set_a11y (void) caret = yelp_settings_get_caret (); yelp_gecko_set_caret (caret); } - -void -yelp_html_initialize (void) -{ - static gboolean initialized = FALSE; - - if (initialized) - return; - initialized = TRUE; - - gtk_moz_embed_set_comp_path (MOZILLA_HOME); - -} - Index: src/Makefile.am =================================================================== RCS file: /cvs/gnome/yelp/src/Makefile.am,v retrieving revision 1.89 diff -p -u -u -p -r1.89 Makefile.am --- src/Makefile.am 19 Jan 2006 19:01:20 -0000 1.89 +++ src/Makefile.am 11 Feb 2006 16:26:44 -0000 @@ -50,6 +50,7 @@ YELP_DEFINES = \ -DIMAGEDIR=\""$(datadir)/images/yelp"\" \ -DSERVERDIR=\"$(libexecdir)\" \ -DBINDIR=\""$(bindir)"\" \ + -DSHAREDIR=\""$(pkgdatadir)"\" \ -DMOZILLA_HOME=\""$(MOZILLA_HOME)\"" mozilla_include_subdirs = \