Index: 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 --- yelp-gecko-utils.h 16 May 2005 21:02:33 -0000 1.8 +++ yelp-gecko-utils.h 5 Feb 2006 22:25:04 -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: 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 --- yelp-gecko-utils.cpp 22 Jan 2006 18:06:35 -0000 1.16 +++ yelp-gecko-utils.cpp 5 Feb 2006 22:25:04 -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,39 @@ 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); + + nsCOMPtr file; + rv = NS_NewNativeLocalFile (nsEmbedCString (SHAREDIR "/default-prefs.js"), + PR_TRUE, getter_AddRefs (file)); + NS_ENSURE_SUCCESS (rv, FALSE); + + rv = prefService->ReadUserPrefs (file); + 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: 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 --- yelp-main.c 3 Feb 2006 05:41:57 -0000 1.43 +++ yelp-main.c 5 Feb 2006 22:25:05 -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" @@ -382,7 +383,6 @@ main (int argc, char **argv) if (local_id != NULL && *local_id != '\0') { startup_id = g_strdup (local_id); - putenv ("DESKTOP_STARTUP_ID="); } gtk_window_set_auto_startup_notification(FALSE); @@ -408,7 +408,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 +467,8 @@ main (int argc, char **argv) } else { main_start (url); } + + yelp_gecko_shutdown (); return 0; } Index: 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 --- yelp-html.h 7 Jan 2006 19:08:37 -0000 1.32 +++ yelp-html.h 5 Feb 2006 22:25:05 -0000 @@ -99,6 +99,9 @@ void yelp_html_set_find_props (YelpHtml gboolean match_case, gboolean wrap); +void yelp_html_set_selection (YelpHtml *html, + gboolean attention); + void yelp_html_jump_to_anchor (YelpHtml *html, gchar *anchor); @@ -113,7 +116,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: 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 --- yelp-html.cpp 29 Jan 2006 21:56:05 -0000 1.6 +++ yelp-html.cpp 5 Feb 2006 22:25:05 -0000 @@ -338,8 +338,6 @@ void yelp_html_frames (YelpHtml *html, gboolean enable) { html->priv->frames_enabled = enable; - - } void @@ -405,14 +403,17 @@ yelp_html_set_find_props (YelpHtml *h } void +yelp_html_set_selection (YelpHtml *html, + gboolean attention) +{ + html->priv->yelper->SetSelectionAttention ((PRBool) attention); +} + +void yelp_html_jump_to_anchor (YelpHtml *html, gchar *anchor) { - YelpHtmlPriv *priv; - - g_return_if_fail (html != NULL); - - priv = html->priv; + YelpHtmlPriv *priv = html->priv; g_free (priv->anchor); priv->anchor = g_strdup (anchor); @@ -485,17 +486,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); - -} -