summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@src.gnome.org>2004-10-18 06:49:58 +0000
committerShaun McCance <shaunm@src.gnome.org>2004-10-18 06:49:58 +0000
commitecbb0fa95f3442c72591be37e8665b1cdfd0cb5d (patch)
tree8e8cfe1c4cafb90caed424df37c0189ffc93f71a
parentdca56f74162e337ecb79ec590cd8e10d01e3efec (diff)
downloadyelp-ecbb0fa95f3442c72591be37e8665b1cdfd0cb5d.tar.gz
- Minor changes
* configure.in: - Minor changes * data/default.css: - Some CSS changes * data/Makefile.am: * data/ui/yelp-ui.xml: * data/ui/yelp.glade: * src/Makefile.am: * src/yelp-base.c: * src/yelp-gecko-utils.cpp: * src/yelp-gecko-utils.h: * src/yelp-html-gecko.c: * src/yelp-html.h: * src/yelp-window.c: - Added font preference and all the Gecko wonder that goes with - Moved theme stuff to settings * src/yelp-man-pager.c: * src/yelp-toc-pager.c: * src/yelp-window.c: - Moved theme stuff to settings * src/yelp-db-pager.c: * src/yelp-pager.c: * src/yelp-utils.c: - Changed debug statements to use g_print
-rw-r--r--ChangeLog31
-rw-r--r--configure.in8
-rw-r--r--data/Makefile.am27
-rw-r--r--data/default.css18
-rw-r--r--data/ui/yelp-ui.xml2
-rw-r--r--data/ui/yelp.glade237
-rw-r--r--src/Makefile.am4
-rw-r--r--src/yelp-base.c4
-rw-r--r--src/yelp-db-pager.c16
-rw-r--r--src/yelp-gecko-utils.cpp88
-rw-r--r--src/yelp-gecko-utils.h17
-rw-r--r--src/yelp-html-gecko.c48
-rw-r--r--src/yelp-html.h13
-rw-r--r--src/yelp-man-pager.c6
-rw-r--r--src/yelp-pager.c4
-rw-r--r--src/yelp-settings.c429
-rw-r--r--src/yelp-settings.h69
-rw-r--r--src/yelp-theme.c186
-rw-r--r--src/yelp-theme.h48
-rw-r--r--src/yelp-toc-pager.c22
-rw-r--r--src/yelp-utils.c22
-rw-r--r--src/yelp-window.c103
22 files changed, 1045 insertions, 357 deletions
diff --git a/ChangeLog b/ChangeLog
index f5652a51..8c7e4288 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2004-10-18 Shaun McCance <shaunm@gnome.org>
+
+ * configure.in:
+ - Minor changes
+
+ * data/default.css:
+ - Some CSS changes
+
+ * data/Makefile.am:
+ * data/ui/yelp-ui.xml:
+ * data/ui/yelp.glade:
+ * src/Makefile.am:
+ * src/yelp-base.c:
+ * src/yelp-gecko-utils.cpp:
+ * src/yelp-gecko-utils.h:
+ * src/yelp-html-gecko.c:
+ * src/yelp-html.h:
+ * src/yelp-window.c:
+ - Added font preference and all the Gecko wonder that goes with
+ - Moved theme stuff to settings
+
+ * src/yelp-man-pager.c:
+ * src/yelp-toc-pager.c:
+ * src/yelp-window.c:
+ - Moved theme stuff to settings
+
+ * src/yelp-db-pager.c:
+ * src/yelp-pager.c:
+ * src/yelp-utils.c:
+ - Changed debug statements to use g_print
+
2004-10-12 Shaun McCance <shaunm@gnome.org>
* data/ui/yelp-ui.xml:
diff --git a/configure.in b/configure.in
index e147ad9a..21a00dc3 100644
--- a/configure.in
+++ b/configure.in
@@ -1,10 +1,14 @@
AC_INIT(src/yelp-main.c)
-AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(yelp, 2.6.0)
+AM_CONFIG_HEADER(config.h)
+
+AM_SANITY_CHECK
+AM_MAINTAINER_MODE
AC_PROG_INTLTOOL
+AC_PATH_PROG(GCONFTOOL, gconftool-2)
-AM_MAINTAINER_MODE
+AM_GCONF_SOURCE_2
AC_PROG_CC
AC_PROG_CXX
diff --git a/data/Makefile.am b/data/Makefile.am
index 2552dc50..71781e84 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,14 +1,27 @@
SUBDIRS = icons ui
@INTLTOOL_XML_RULE@
+@INTLTOOL_SCHEMAS_RULE@
-cssdir = $(datadir)/yelp
-tocdir = $(datadir)/yelp
+schemasdir = $(GCONF_SCHEMA_FILE_DIR)
+schemas_DATA = yelp.schemas
-css_DATA = default.css
+tocdir = $(datadir)/yelp
toc_DATA = toc.xml
-EXTRA_DIST = \
- default.css \
- toc.xml.in \
- toc.xml
+cssdir = $(datadir)/yelp
+css_DATA = default.css
+
+EXTRA_DIST = \
+ yelp.schemas yelp.schemas.in \
+ toc.xml toc.xml.in \
+ default.css
+
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+ if test -z "$(DESTDIR)"; then \
+ GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/yelp.schemas ; \
+ fi
+else
+install-data-local:
+endif
diff --git a/data/default.css b/data/default.css
index b57011c7..f52329a5 100644
--- a/data/default.css
+++ b/data/default.css
@@ -2,20 +2,18 @@ h1 { font-size: 1.6em; font-weight: bold; }
h2 { font-size: 1.4em; font-weight: bold; }
h3 { font-size: 1.2em; font-weight: bold; }
-body { margin: 0em; padding: 0em; }
-div[class="body"] {
- margin-left: 0.8em;
- margin-right: 0.8em;
- margin-bottom: 1.6em;
+body {
+ padding-left: 8px;
+ padding-right: 12px;
}
p, div { margin: 0em; }
p + p, p + div, div + p, div + div { margin-top: 0.8em; }
-dl { margin: 0em; }
-ol { margin: 0em; }
-ul { margin: 0em; }
-ul li { padding-left: 0.4em; }
-dd + dt { margin-top: 1.6em; }
+dl { margin: 0px; }
+ol { margin: 0px; }
+ul { margin: 0px; }
+ol li { padding-left: 12px; }
+ul li { padding-left: 12px; }
li[class="menu-folder"] + li[class="menu-file"] { margin-top: 0.8em; }
diff --git a/data/ui/yelp-ui.xml b/data/ui/yelp-ui.xml
index 5f81d7c2..430d94ef 100644
--- a/data/ui/yelp-ui.xml
+++ b/data/ui/yelp-ui.xml
@@ -9,6 +9,8 @@
<menuitem action="Copy"/>
<separator/>
<menuitem action="Find"/>
+ <separator/>
+ <menuitem action="Preferences"/>
</menu>
<menu action="GoMenu">
<menuitem action="GoBack"/>
diff --git a/data/ui/yelp.glade b/data/ui/yelp.glade
index e349faa7..8055722d 100644
--- a/data/ui/yelp.glade
+++ b/data/ui/yelp.glade
@@ -447,4 +447,241 @@
</child>
</widget>
+<widget class="GtkDialog" id="prefs_dialog">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Preferences</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox7">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area7">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="closebutton1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox133">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1226">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Fonts&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment11">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="use_system_fonts">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Use system fonts</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment12">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkTable" id="font_table">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1227">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Variable width:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">variable_font</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label1228">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Fixed width:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">fixed_font</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkFontButton" id="variable_font">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_style">True</property>
+ <property name="show_size">True</property>
+ <property name="use_font">False</property>
+ <property name="use_size">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkFontButton" id="fixed_font">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_style">True</property>
+ <property name="show_size">True</property>
+ <property name="use_font">False</property>
+ <property name="use_size">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index bc5608fe..83af6b0c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@ INCLUDES = \
-I$(MOZILLA_INCLUDE_ROOT) \
-I$(MOZILLA_INCLUDE_ROOT)/dom \
-I$(MOZILLA_INCLUDE_ROOT)/find \
+ -I$(MOZILLA_INCLUDE_ROOT)/pref \
-I$(MOZILLA_INCLUDE_ROOT)/webbrwsr \
-I$(MOZILLA_INCLUDE_ROOT)/string \
-include $(MOZILLA_INCLUDE_ROOT)/mozilla-config.h \
@@ -63,7 +64,6 @@ test_pager_SOURCES = \
yelp-man-pager.c yelp-man-pager.h \
yelp-man-parser.c yelp-man-parser.h \
yelp-pager.c yelp-pager.h \
- yelp-theme.c yelp-theme.h \
yelp-toc-pager.c yelp-toc-pager.h \
yelp-utils.c yelp-utils.h \
yelp-marshal-main.c test-pager.c
@@ -88,8 +88,8 @@ yelp_SOURCES = \
yelp-man-pager.c yelp-man-pager.h \
yelp-man-parser.c yelp-man-parser.h \
yelp-pager.c yelp-pager.h \
+ yelp-settings.c yelp-settings.h \
yelp-toc-pager.c yelp-toc-pager.h \
- yelp-theme.c yelp-theme.h \
yelp-window.c yelp-window.h \
yelp-uri.c yelp-uri.h \
yelp-utils.c yelp-utils.h \
diff --git a/src/yelp-base.c b/src/yelp-base.c
index fa689ea2..43783ba3 100644
--- a/src/yelp-base.c
+++ b/src/yelp-base.c
@@ -29,7 +29,7 @@
#include "yelp-cache.h"
#include "yelp-window.h"
-#include "yelp-theme.h"
+#include "yelp-settings.h"
#include "yelp-pager.h"
#include "yelp-toc-pager.h"
#include "yelp-base.h"
@@ -110,7 +110,7 @@ yelp_base_init (YelpBase *base)
base->priv = priv;
yelp_cache_init ();
- yelp_theme_init ();
+ yelp_settings_init ();
}
static void
diff --git a/src/yelp-db-pager.c b/src/yelp-db-pager.c
index a662f4be..55809a0d 100644
--- a/src/yelp-db-pager.c
+++ b/src/yelp-db-pager.c
@@ -39,7 +39,7 @@
#include "yelp-error.h"
#include "yelp-db-pager.h"
#include "yelp-toc-pager.h"
-#include "yelp-theme.h"
+#include "yelp-settings.h"
#ifdef YELP_DEBUG
#define d(x) x
@@ -55,8 +55,6 @@
#define BOOK_CHUNK_DEPTH 2
#define ARTICLE_CHUNK_DEPTH 1
-#define d(x)
-
struct _YelpDBPagerPriv {
GtkTreeModel *sects;
@@ -221,7 +219,7 @@ db_pager_process (YelpPager *pager)
gchar *db_chunk_basename, *db_chunk_basename_q;
const gchar *params[40];
- d (printf ("db_pager_process\n"));
+ d (g_print ("db_pager_process\n"));
doc_info = yelp_pager_get_doc_info (pager);
@@ -309,9 +307,9 @@ db_pager_process (YelpPager *pager)
params[i++] = p_doc_path;
*/
params[i++] = "color_gray_background";
- params[i++] = yelp_theme_get_gray_background ();
+ params[i++] = yelp_settings_get_color (YELP_COLOR_GRAY_BACKGROUND);
params[i++] = "color_gray_border";
- params[i++] = yelp_theme_get_gray_border ();
+ params[i++] = yelp_settings_get_color (YELP_COLOR_GRAY_BORDER);
params[i++] = "admon_graphics_path";
params[i++] = "\"file://" DATADIR "/yelp/icons/\"";
params[i++] = NULL;
@@ -379,7 +377,7 @@ db_pager_process (YelpPager *pager)
static void
db_pager_error (YelpPager *pager)
{
- d (printf ("db_pager_error\n"));
+ d (g_print ("db_pager_error\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_ERROR);
yelp_toc_pager_unpause (yelp_toc_pager_get ());
}
@@ -387,7 +385,7 @@ db_pager_error (YelpPager *pager)
static void
db_pager_cancel (YelpPager *pager)
{
- d (printf ("db_pager_cancel\n"));
+ d (g_print ("db_pager_cancel\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_INVALID);
yelp_toc_pager_unpause (yelp_toc_pager_get ());
// FIXME: actually cancel
@@ -396,7 +394,7 @@ db_pager_cancel (YelpPager *pager)
static void
db_pager_finish (YelpPager *pager)
{
- d (printf ("db_pager_finish\n"));
+ d (g_print ("db_pager_finish\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_FINISHED);
yelp_toc_pager_unpause (yelp_toc_pager_get ());
}
diff --git a/src/yelp-gecko-utils.cpp b/src/yelp-gecko-utils.cpp
index 101c242a..f02d7eee 100644
--- a/src/yelp-gecko-utils.cpp
+++ b/src/yelp-gecko-utils.cpp
@@ -28,6 +28,94 @@
#include <nsIInterfaceRequestorUtils.h>
#include <nsReadableUtils.h>
#include <nsString.h>
+#include <nsIPrefService.h>
+#include <nsIServiceManager.h>
+#include <stdlib.h>
+
+#include "yelp-gecko-utils.h"
+
+static gboolean
+yelp_util_split_font_string (const gchar *font_name, gchar **name, gint *size)
+{
+ gchar *tmp_name, *ch;
+
+ tmp_name = g_strdup (font_name);
+
+ ch = g_utf8_strrchr (tmp_name, -1, ' ');
+ if (!ch || ch == tmp_name) {
+ return FALSE;
+ }
+
+ *ch = '\0';
+
+ *name = g_strdup (tmp_name);
+ *size = strtol (ch + 1, (char **) NULL, 10);
+
+ return TRUE;
+}
+
+static gboolean
+gecko_prefs_set_string (const gchar *key, const gchar *value)
+{
+ nsCOMPtr<nsIPrefService> prefService =
+ do_GetService (NS_PREFSERVICE_CONTRACTID);
+ nsCOMPtr<nsIPrefBranch> pref;
+ prefService->GetBranch ("", getter_AddRefs (pref));
+
+ if (pref) {
+ nsresult rv = pref->SetCharPref (key, value);
+ return NS_SUCCEEDED (rv) ? TRUE : FALSE;
+ }
+
+ return FALSE;
+
+}
+
+static gboolean
+gecko_prefs_set_int (const gchar *key, gint value)
+{
+ nsCOMPtr<nsIPrefService> prefService =
+ do_GetService (NS_PREFSERVICE_CONTRACTID);
+ nsCOMPtr<nsIPrefBranch> pref;
+ prefService->GetBranch ("", getter_AddRefs (pref));
+
+ if (pref) {
+ nsresult rv = pref->SetIntPref (key, value);
+ return NS_SUCCEEDED (rv) ? TRUE : FALSE;
+ }
+
+ return FALSE;
+}
+
+extern "C" void
+yelp_gecko_set_font (YelpFontType font_type, const gchar *fontname)
+{
+ gchar *name;
+ gint size;
+
+ name = NULL;
+ if (!yelp_util_split_font_string (fontname, &name, &size)) {
+ g_free (name);
+ return;
+ }
+
+ 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);
+ break;
+ case YELP_FONT_FIXED:
+ gecko_prefs_set_string ("font.name.fixed.x-western",
+ name);
+ gecko_prefs_set_int ("font.size.fixed.x-western",
+ size);
+ break;
+ }
+
+ g_free (name);
+}
extern "C" gboolean
yelp_gecko_find (GtkMozEmbed *embed,
diff --git a/src/yelp-gecko-utils.h b/src/yelp-gecko-utils.h
index 0a5622b5..b2c61eaf 100644
--- a/src/yelp-gecko-utils.h
+++ b/src/yelp-gecko-utils.h
@@ -23,15 +23,20 @@
#ifndef __YELP_GECKO_UTILS_H__
#define __YELP_GECKO_UTILS_H__
+#include <gtkmozembed.h>
+#include "yelp-settings.h"
+
G_BEGIN_DECLS
-gboolean yelp_gecko_find (GtkMozEmbed *html,
- const gchar *str,
- gboolean match_case,
- gboolean wrap,
- gboolean forward);
+void yelp_gecko_set_font (YelpFontType font_type,
+ const gchar *fontname);
+gboolean yelp_gecko_find (GtkMozEmbed *html,
+ const gchar *str,
+ gboolean match_case,
+ gboolean wrap,
+ gboolean forward);
G_END_DECLS
-#endif /* __YELP_HTML_H__ */
+#endif /* __YELP_GECKO_UTILS_H__ */
diff --git a/src/yelp-html-gecko.c b/src/yelp-html-gecko.c
index 8d39b043..632340cf 100644
--- a/src/yelp-html-gecko.c
+++ b/src/yelp-html-gecko.c
@@ -30,6 +30,7 @@
#include "yelp-html.h"
#include "yelp-marshal.h"
#include "yelp-gecko-utils.h"
+#include "yelp-settings.h"
#ifdef YELP_DEBUG
#define d(x) x
@@ -45,6 +46,7 @@ struct _YelpHtmlPriv {
static void html_init (YelpHtml *html);
static void html_class_init (YelpHtmlClass *klass);
+static void html_set_fonts (void);
enum {
URI_SELECTED,
@@ -100,8 +102,8 @@ embed_open_uri_cb (GtkMozEmbed *embed, const gchar *uri, YelpHtml *html)
g_return_val_if_fail (uri != NULL, FALSE);
g_return_val_if_fail (YELP_IS_HTML (html), FALSE);
- d (printf ("embed_open_uri_cb\n"));
- d (printf (" uri = \"%s\"\n", uri));
+ d (g_print ("embed_open_uri_cb\n"));
+ d (g_print (" uri = \"%s\"\n", uri));
g_signal_emit (html, signals[URI_SELECTED], 0, uri, FALSE);
@@ -111,7 +113,8 @@ embed_open_uri_cb (GtkMozEmbed *embed, const gchar *uri, YelpHtml *html)
static void
html_init (YelpHtml *html)
{
- YelpHtmlPriv *priv;
+ YelpHtmlPriv *priv;
+ YelpHtmlClass *klass;
priv = g_new0 (YelpHtmlPriv, 1);
html->priv = priv;
@@ -119,6 +122,15 @@ html_init (YelpHtml *html)
html->priv->base_uri = NULL;
html->priv->embed = gtk_moz_embed_new ();
+ klass = YELP_HTML_GET_CLASS (html);
+ if (!klass->font_handler) {
+ klass->font_handler =
+ yelp_settings_notify_add (YELP_SETTINGS_INFO_FONTS,
+ (GHookFunc) html_set_fonts,
+ NULL);
+ html_set_fonts ();
+ }
+
g_signal_connect (html->priv->embed, "title",
G_CALLBACK (embed_title_cb),
html);
@@ -130,6 +142,8 @@ html_init (YelpHtml *html)
static void
html_class_init (YelpHtmlClass *klass)
{
+ klass->font_handler = 0;
+
signals[URI_SELECTED] =
g_signal_new ("uri_selected",
G_TYPE_FROM_CLASS (klass),
@@ -170,8 +184,8 @@ yelp_html_set_base_uri (YelpHtml *html, const gchar *uri)
g_return_if_fail (YELP_IS_HTML (html));
- d (printf ("yelp_html_set_base_uri\n"));
- d (printf (" uri = \"%s\"\n", uri));
+ d (g_print ("yelp_html_set_base_uri\n"));
+ d (g_print (" uri = \"%s\"\n", uri));
priv = html->priv;
@@ -184,7 +198,7 @@ yelp_html_set_base_uri (YelpHtml *html, const gchar *uri)
void
yelp_html_clear (YelpHtml *html)
{
- d (printf ("yelp_html_clear\n"));
+ d (g_print ("yelp_html_clear\n"));
gtk_moz_embed_open_stream (GTK_MOZ_EMBED (html->priv->embed),
html->priv->base_uri,
"text/html");
@@ -195,9 +209,9 @@ yelp_html_write (YelpHtml *html, const gchar *data, gint len)
{
if (len == -1) len = strlen (data);
- d (printf ("yelp_html_write\n"));
- d (printf (" data = %i bytes\n", strlen (data)));
- d (printf (" len = %i\n", len));
+ d (g_print ("yelp_html_write\n"));
+ d (g_print (" data = %i bytes\n", strlen (data)));
+ d (g_print (" len = %i\n", len));
gtk_moz_embed_append_data (GTK_MOZ_EMBED (html->priv->embed),
data, len);
@@ -223,7 +237,7 @@ yelp_html_printf (YelpHtml *html, char *format, ...)
void
yelp_html_close (YelpHtml *html)
{
- d (printf ("yelp_html_close\n"));
+ d (g_print ("yelp_html_close\n"));
gtk_moz_embed_close_stream (GTK_MOZ_EMBED (html->priv->embed));
}
@@ -261,3 +275,17 @@ yelp_html_jump_to_anchor (YelpHtml *html,
priv->anchor = g_strdup (anchor);
}
+
+static void
+html_set_fonts (void)
+{
+ gchar *font;
+
+ font = yelp_settings_get_font (YELP_FONT_VARIABLE);
+ yelp_gecko_set_font (YELP_FONT_VARIABLE, font);
+ g_free (font);
+
+ font = yelp_settings_get_font (YELP_FONT_FIXED);
+ yelp_gecko_set_font (YELP_FONT_FIXED, font);
+ g_free (font);
+}
diff --git a/src/yelp-html.h b/src/yelp-html.h
index 50bf3bfe..9e6af004 100644
--- a/src/yelp-html.h
+++ b/src/yelp-html.h
@@ -27,11 +27,12 @@
#include <gtk/gtktypeutils.h>
#include <gtk/gtkmarshal.h>
-#define YELP_TYPE_HTML (yelp_html_get_type ())
-#define YELP_HTML(o) (GTK_CHECK_CAST ((o), YELP_TYPE_HTML, YelpHtml))
-#define YELP_HTML_CLASS(k) (GTK_CHECK_FOR_CAST((k), YELP_TYPE_HTML, YelpHtmlClass))
-#define YELP_IS_HTML(o) (GTK_CHECK_TYPE ((o), YELP_TYPE_HTML))
-#define YELP_IS_HTML_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), YELP_TYPE_HTML))
+#define YELP_TYPE_HTML (yelp_html_get_type ())
+#define YELP_HTML(o) (GTK_CHECK_CAST ((o), YELP_TYPE_HTML, YelpHtml))
+#define YELP_HTML_CLASS(k) (GTK_CHECK_FOR_CAST((k), YELP_TYPE_HTML, YelpHtmlClass))
+#define YELP_IS_HTML(o) (GTK_CHECK_TYPE ((o), YELP_TYPE_HTML))
+#define YELP_IS_HTML_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), YELP_TYPE_HTML))
+#define YELP_HTML_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_HTML, YelpHtmlClass))
typedef struct _YelpHtml YelpHtml;
typedef struct _YelpHtmlClass YelpHtmlClass;
@@ -46,6 +47,8 @@ struct _YelpHtml {
struct _YelpHtmlClass {
GObjectClass parent_class;
+ guint font_handler;
+
/* Signals */
void (*uri_selected) (YelpHtml *view,
gchar *uri,
diff --git a/src/yelp-man-pager.c b/src/yelp-man-pager.c
index 1fc4a7d7..1b268b03 100644
--- a/src/yelp-man-pager.c
+++ b/src/yelp-man-pager.c
@@ -38,8 +38,8 @@
#include "yelp-error.h"
#include "yelp-man-pager.h"
#include "yelp-man-parser.h"
+#include "yelp-settings.h"
#include "yelp-toc-pager.h"
-#include "yelp-theme.h"
#define YELP_NAMESPACE "http://www.gnome.org/yelp/ns"
@@ -196,9 +196,9 @@ man_pager_process (YelpPager *pager)
params[i++] = "stylesheet_path";
params[i++] = "\"file://" MAN_STYLESHEET_PATH "/\"";
params[i++] = "color_gray_background";
- params[i++] = yelp_theme_get_gray_background ();
+ params[i++] = yelp_settings_get_color (YELP_COLOR_GRAY_BACKGROUND);
params[i++] = "color_gray_border";
- params[i++] = yelp_theme_get_gray_border ();
+ params[i++] = yelp_settings_get_color (YELP_COLOR_GRAY_BORDER);
params[i++] = NULL;
stylesheet = xsltParseStylesheetFile (MAN_STYLESHEET);
diff --git a/src/yelp-pager.c b/src/yelp-pager.c
index b03222b4..e730a8b4 100644
--- a/src/yelp-pager.c
+++ b/src/yelp-pager.c
@@ -270,7 +270,7 @@ yelp_pager_cancel (YelpPager *pager)
g_return_if_fail (pager != NULL);
g_return_if_fail (YELP_IS_PAGER (pager));
- d (printf ("yelp_pager_cancel\n"));
+ d (g_print ("yelp_pager_cancel\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_INVALID);
@@ -322,7 +322,7 @@ yelp_pager_get_error (YelpPager *pager)
void
yelp_pager_error (YelpPager *pager, GError *error)
{
- d (printf ("yelp_pager_error\n"));
+ d (g_print ("yelp_pager_error\n"));
if (pager->priv->error)
g_error_free (pager->priv->error);
diff --git a/src/yelp-settings.c b/src/yelp-settings.c
new file mode 100644
index 00000000..a9283dc6
--- /dev/null
+++ b/src/yelp-settings.c
@@ -0,0 +1,429 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2004 Shaun McCance <shaunm@gnome.org>
+ *
+ * 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.
+ *
+ * Author: Shaun McCance <shaunm@gnome.org>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <gconf/gconf-client.h>
+#include <string.h>
+#include "yelp-settings.h"
+
+#define KEY_GNOME_DIR "/desktop/gnome/interface"
+#define KEY_GNOME_VARIABLE_FONT KEY_GNOME_DIR "/font_name"
+#define KEY_GNOME_FIXED_FONT KEY_GNOME_DIR "/monospace_font_name"
+#define KEY_GNOME_GTK_THEME KEY_GNOME_DIR "/gtk_theme"
+#define KEY_YELP_DIR "/apps/yelp"
+#define KEY_YELP_SYSTEM_FONTS KEY_YELP_DIR "/use_system_fonts"
+#define KEY_YELP_VARIABLE_FONT KEY_YELP_DIR "/variable_font"
+#define KEY_YELP_FIXED_FONT KEY_YELP_DIR "/fixed_font"
+
+#ifdef YELP_DEBUG
+#define d(x) x
+#else
+#define d(x)
+#endif
+
+static void settings_update (YelpSettingsType type);
+static void prefs_system_fonts_cb (GtkWidget *widget);
+static void prefs_font_cb (GtkWidget *widget);
+static void toggle_font_table (GtkWidget *widget);
+static void gconf_gtk_theme_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data);
+static void gconf_system_fonts_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data);
+static void gconf_font_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data);
+static void icon_theme_changed (GtkIconTheme *theme,
+ gpointer user_data);
+
+static GConfClient *gconf_client = NULL;
+
+static GHookList *hook_lists[YELP_SETTINGS_NUM_TYPES];
+
+static GtkIconTheme *icon_theme;
+static gchar colors[YELP_NUM_COLORS][10];
+
+static GtkWidget *prefs_dialog = NULL;
+static GtkWidget *system_fonts_widget = NULL;
+static GtkWidget *font_table_widget = NULL;
+static GtkWidget *variable_font_widget = NULL;
+static GtkWidget *fixed_font_widget = NULL;
+gulong system_fonts_handler = 0;
+gulong variable_font_handler = 0;
+gulong fixed_font_handler = 0;
+
+void
+yelp_settings_init (void)
+{
+ gint i;
+
+ gconf_client = gconf_client_get_default ();
+ gconf_client_add_dir (gconf_client, KEY_GNOME_DIR,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_add_dir (gconf_client, KEY_YELP_DIR,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_notify_add (gconf_client,
+ KEY_GNOME_VARIABLE_FONT,
+ gconf_font_cb,
+ NULL, NULL, NULL);
+ gconf_client_notify_add (gconf_client,
+ KEY_GNOME_FIXED_FONT,
+ gconf_font_cb,
+ NULL, NULL, NULL);
+ gconf_client_notify_add (gconf_client,
+ KEY_GNOME_GTK_THEME,
+ gconf_gtk_theme_cb,
+ NULL, NULL, NULL);
+ gconf_client_notify_add (gconf_client,
+ KEY_YELP_SYSTEM_FONTS,
+ gconf_system_fonts_cb,
+ NULL, NULL, NULL);
+ gconf_client_notify_add (gconf_client,
+ KEY_YELP_VARIABLE_FONT,
+ gconf_font_cb,
+ NULL, NULL, NULL);
+ gconf_client_notify_add (gconf_client,
+ KEY_YELP_FIXED_FONT,
+ gconf_font_cb,
+ NULL, NULL, NULL);
+
+ for (i = 0; i < YELP_SETTINGS_NUM_TYPES; i++) {
+ hook_lists[i] = g_new0 (GHookList, 1);
+ g_hook_list_init (hook_lists[i], sizeof (GHook));
+ }
+
+ icon_theme = gtk_icon_theme_get_default ();
+ g_signal_connect (icon_theme,
+ "changed",
+ (GCallback) icon_theme_changed,
+ NULL);
+
+ settings_update (YELP_SETTINGS_INFO_ALL);
+}
+
+void
+yelp_settings_open_preferences (void)
+{
+ gchar *font;
+ gboolean use;
+
+ if (!prefs_dialog) {
+ GladeXML *glade;
+ glade = glade_xml_new (DATADIR "/yelp/ui/yelp.glade",
+ "prefs_dialog",
+ NULL);
+ if (!glade) {
+ g_warning ("Could not find necessary glade file "
+ DATADIR "/yelp/ui/yelp.glade");
+ return;
+ }
+
+ prefs_dialog = glade_xml_get_widget (glade, "prefs_dialog");
+ system_fonts_widget = glade_xml_get_widget (glade, "use_system_fonts");
+ font_table_widget = glade_xml_get_widget (glade, "font_table");
+ variable_font_widget = glade_xml_get_widget (glade, "variable_font");
+ fixed_font_widget = glade_xml_get_widget (glade, "fixed_font");
+
+ use = gconf_client_get_bool (gconf_client, KEY_YELP_SYSTEM_FONTS, NULL);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (system_fonts_widget), use);
+ gtk_widget_set_sensitive (font_table_widget, !use);
+
+ font = gconf_client_get_string (gconf_client, KEY_YELP_VARIABLE_FONT, NULL);
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (variable_font_widget), font);
+ g_free (font);
+
+ font = gconf_client_get_string (gconf_client, KEY_YELP_FIXED_FONT, NULL);
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (fixed_font_widget), font);
+ g_free (font);
+
+ system_fonts_handler =
+ g_signal_connect (G_OBJECT (system_fonts_widget), "toggled",
+ G_CALLBACK (prefs_system_fonts_cb), NULL);
+ variable_font_handler =
+ g_signal_connect (G_OBJECT (variable_font_widget), "font_set",
+ G_CALLBACK (prefs_font_cb), NULL);
+ fixed_font_handler =
+ g_signal_connect (G_OBJECT (fixed_font_widget), "font_set",
+ G_CALLBACK (prefs_font_cb), NULL);
+
+ g_signal_connect (G_OBJECT (system_fonts_widget), "toggled",
+ G_CALLBACK (toggle_font_table), NULL);
+
+ g_signal_connect (G_OBJECT (prefs_dialog), "response",
+ G_CALLBACK (gtk_widget_hide), NULL);
+
+ g_object_unref (glade);
+ }
+
+ gtk_window_present (GTK_WINDOW (prefs_dialog));
+}
+
+guint
+yelp_settings_notify_add (YelpSettingsType type,
+ GHookFunc func,
+ gpointer data)
+{
+ GHook *hook;
+ gint i;
+
+ for (i = 0; i < YELP_SETTINGS_NUM_TYPES; i++) {
+ if (type & (1 << i)) {
+ hook = g_hook_alloc (hook_lists[i]);
+ hook->func = func;
+ hook->data = data;
+ g_hook_prepend (hook_lists[i], hook);
+ return hook->hook_id;
+ }
+ }
+
+ return 0;
+}
+
+void
+yelp_settings_notify_remove (YelpSettingsType type, guint id)
+{
+ gint i;
+
+ for (i = 0; i < YELP_SETTINGS_NUM_TYPES; i++)
+ if (type & (1 << i))
+ g_hook_destroy (hook_lists[i], id);
+}
+
+/** Getters *******************************************************************/
+
+const GtkIconTheme *
+yelp_settings_get_icon_theme (void)
+{
+ return icon_theme;
+}
+
+gchar *
+yelp_settings_get_font (YelpFontType font)
+{
+ gchar *key;
+ gboolean use;
+
+ use = gconf_client_get_bool (gconf_client,
+ KEY_YELP_SYSTEM_FONTS,
+ NULL);
+
+ switch (font) {
+ case YELP_FONT_VARIABLE:
+ key = (use ? KEY_GNOME_VARIABLE_FONT : KEY_YELP_VARIABLE_FONT);
+ break;
+ case YELP_FONT_FIXED:
+ key = (use ? KEY_GNOME_FIXED_FONT : KEY_YELP_FIXED_FONT);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ return gconf_client_get_string (gconf_client, key, NULL);
+}
+
+const gchar *
+yelp_settings_get_color (YelpColorType color)
+{
+ g_return_val_if_fail (color >= YELP_NUM_COLORS, NULL);
+
+ return colors[color];
+}
+
+const gchar *
+yelp_settings_get_css_file (void)
+{
+ return "file://" DATADIR "/yelp/default.css";
+}
+
+/** Widget Callbacks **********************************************************/
+
+static void
+prefs_system_fonts_cb (GtkWidget *widget)
+{
+ gboolean use;
+
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
+
+ use = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+ gconf_client_set_bool (gconf_client,
+ KEY_YELP_SYSTEM_FONTS,
+ use, NULL);
+}
+
+static void
+prefs_font_cb (GtkWidget *widget)
+{
+ const gchar *key;
+ const gchar *font;
+
+ g_return_if_fail (GTK_IS_FONT_BUTTON (widget));
+
+ font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (widget));
+
+ if (widget == variable_font_widget)
+ key = KEY_YELP_VARIABLE_FONT;
+ else if (widget == fixed_font_widget)
+ key = KEY_YELP_FIXED_FONT;
+ else
+ g_assert_not_reached ();
+
+ gconf_client_set_string (gconf_client,
+ key, font,
+ NULL);
+}
+
+static void
+toggle_font_table (GtkWidget *widget)
+{
+ gboolean use;
+
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
+
+ use = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+ gtk_widget_set_sensitive (font_table_widget, !use);
+}
+
+/** GConf Callbacks ***********************************************************/
+
+static void
+gconf_gtk_theme_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data)
+{
+ d (g_print ("gconf_gtk_theme_cb\n"));
+
+ if (g_str_equal (gconf_entry_get_key (entry), KEY_GNOME_GTK_THEME))
+ settings_update (YELP_SETTINGS_INFO_COLOR);
+}
+
+static void
+gconf_system_fonts_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data)
+{
+ gboolean use;
+
+ d (g_print ("gconf_system_fonts_cb\n"));
+
+ use = gconf_value_get_bool (gconf_entry_get_value (entry));
+
+ if (prefs_dialog) {
+ g_signal_handler_block (system_fonts_widget, system_fonts_handler);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (system_fonts_widget), use);
+ g_signal_handler_unblock (system_fonts_widget, system_fonts_handler);
+ }
+
+ settings_update (YELP_SETTINGS_INFO_FONTS);
+}
+
+static void
+gconf_font_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data)
+{
+ GtkFontButton *button;
+ gulong handler;
+ const gchar *font;
+
+ d (g_print ("gconf_font_cb\n"));
+
+ font = gconf_value_get_string (gconf_entry_get_value (entry));
+
+ if (prefs_dialog) {
+ if (g_str_equal (gconf_entry_get_key (entry), KEY_YELP_VARIABLE_FONT)) {
+ button = GTK_FONT_BUTTON (variable_font_widget);
+ handler = variable_font_handler;
+ }
+ else if (g_str_equal (gconf_entry_get_key (entry), KEY_YELP_FIXED_FONT)) {
+ button = GTK_FONT_BUTTON (fixed_font_widget);
+ handler = fixed_font_handler;
+ }
+ else
+ goto done;
+
+ g_signal_handler_block (button, handler);
+ gtk_font_button_set_font_name (button, font);
+ g_signal_handler_unblock (button, handler);
+ }
+
+ done:
+ settings_update (YELP_SETTINGS_INFO_FONTS);
+}
+
+/******************************************************************************/
+
+static void
+icon_theme_changed (GtkIconTheme *theme, gpointer user_data)
+{
+ settings_update (YELP_SETTINGS_INFO_ICONS);
+}
+
+static void
+settings_update (YelpSettingsType type)
+{
+ gint i;
+ GtkStyle *style;
+
+ d (g_print ("settings_update\n"));
+
+ if (type & YELP_SETTINGS_INFO_COLOR) {
+ style = gtk_rc_get_style_by_paths (gtk_settings_get_default (),
+ "GtkWidget", "GtkWidget",
+ GTK_TYPE_WIDGET);
+ if (style)
+ g_object_ref (G_OBJECT (style));
+ else
+ style = gtk_style_new ();
+
+ g_snprintf (colors[YELP_COLOR_GRAY_BACKGROUND], 10,
+ "\"#%02X%02X%02X\"",
+ style->bg[GTK_STATE_NORMAL].red >> 8,
+ style->bg[GTK_STATE_NORMAL].green >> 8,
+ style->bg[GTK_STATE_NORMAL].blue >> 8);
+ g_snprintf (colors[YELP_COLOR_GRAY_BACKGROUND], 10,
+ "\"#%02X%02X%02X\"",
+ style->dark[GTK_STATE_NORMAL].red >> 8,
+ style->dark[GTK_STATE_NORMAL].green >> 8,
+ style->dark[GTK_STATE_NORMAL].blue >> 8);
+
+ g_object_unref (G_OBJECT (style));
+ }
+
+ for (i = 0; i < YELP_SETTINGS_NUM_TYPES; i++)
+ if (type & (1 << i))
+ g_hook_list_invoke (hook_lists[i], FALSE);
+}
diff --git a/src/yelp-settings.h b/src/yelp-settings.h
new file mode 100644
index 00000000..74f62690
--- /dev/null
+++ b/src/yelp-settings.h
@@ -0,0 +1,69 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2004 Shaun McCance <shaunm@gnome.org>
+ *
+ * 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.
+ *
+ * Author: Shaun McCance <shaunm@gnome.org>
+ */
+
+#ifndef __YELP_SETTINGS_H__
+#define __YELP_SETTINGS_H__
+
+#include <glib.h>
+#include <gtk/gtkicontheme.h>
+
+typedef enum {
+ YELP_SETTINGS_INFO_COLOR = 1 << 0,
+ YELP_SETTINGS_INFO_FONTS = 1 << 1,
+ YELP_SETTINGS_INFO_ICONS = 1 << 2,
+ YELP_SETTINGS_INFO_CSS = 1 << 3,
+ YELP_SETTINGS_NUM_TYPES = 4,
+
+ YELP_SETTINGS_INFO_ALL =
+ YELP_SETTINGS_INFO_COLOR |
+ YELP_SETTINGS_INFO_FONTS |
+ YELP_SETTINGS_INFO_ICONS |
+ YELP_SETTINGS_INFO_CSS
+} YelpSettingsType;
+
+typedef enum {
+ YELP_FONT_VARIABLE,
+ YELP_FONT_FIXED,
+ YELP_NUM_FONTS
+} YelpFontType;
+
+typedef enum {
+ YELP_COLOR_GRAY_BACKGROUND,
+ YELP_COLOR_GRAY_BORDER,
+ YELP_NUM_COLORS
+} YelpColorType;
+
+void yelp_settings_init (void);
+void yelp_settings_open_preferences (void);
+
+guint yelp_settings_notify_add (YelpSettingsType type,
+ GHookFunc func,
+ gpointer data);
+void yelp_settings_notify_remove (YelpSettingsType type,
+ guint id);
+
+const GtkIconTheme * yelp_settings_get_icon_theme (void);
+gchar * yelp_settings_get_font (YelpFontType font);
+const gchar * yelp_settings_get_color (YelpColorType color);
+const gchar * yelp_settings_get_css_file (void);
+
+#endif /* __YELP_SETTINGS_H__ */
diff --git a/src/yelp-theme.c b/src/yelp-theme.c
deleted file mode 100644
index a2257f52..00000000
--- a/src/yelp-theme.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * Copyright (C) 2003 Shaun McCance <shaunm@gnome.org>
- *
- * 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.
- *
- * Author: Shaun McCance <shaunm@gnome.org>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include <libgnome/gnome-i18n.h>
-#include <gconf/gconf-client.h>
-#include "yelp-theme.h"
-
-#define KEY_INTERFACE_DIR "/desktop/gnome/interface"
-#define KEY_GTK_THEME KEY_INTERFACE_DIR "/gtk_theme"
-
-static GHookList *hook_lists[YELP_THEME_NUM_TYPES];
-
-static GtkIconTheme *icon_theme;
-
-static gchar gray_background[10];
-static gchar gray_border[10];
-
-static void yelp_theme_update (guint type);
-static void yelp_theme_notify (GConfClient *gconf,
- guint id,
- GConfEntry *entry,
- gpointer user_data);
-static void icon_theme_changed (GtkIconTheme *theme,
- gpointer user_data);
-
-void
-yelp_theme_init (void)
-{
- GConfClient *gconf;
- gint i;
-
- gconf = gconf_client_get_default ();
- gconf_client_notify_add (gconf,
- KEY_INTERFACE_DIR,
- yelp_theme_notify,
- NULL, NULL, NULL);
-
- for (i = 0; i < YELP_THEME_NUM_TYPES; i++) {
- hook_lists[i] = g_new0 (GHookList, 1);
- g_hook_list_init (hook_lists[i], sizeof (GHook));
- }
-
- icon_theme = gtk_icon_theme_get_default ();
- g_signal_connect (icon_theme,
- "changed",
- (GCallback) icon_theme_changed,
- NULL);
-
- yelp_theme_update (YELP_THEME_INFO_COLOR |
- YELP_THEME_INFO_ICONS |
- YELP_THEME_INFO_CSS );
-
-}
-
-guint
-yelp_theme_notify_add (guint type,
- GHookFunc func,
- gpointer data)
-{
- GHook *hook;
- gint i;
-
- for (i = 0; i < YELP_THEME_NUM_TYPES; i++) {
- if (type & (1 << i)) {
- hook = g_hook_alloc (hook_lists[i]);
- hook->func = func;
- hook->data = data;
- g_hook_prepend (hook_lists[i], hook);
- return hook->hook_id;
- }
- }
-
- return 0;
-}
-
-void
-yelp_theme_notify_remove (guint type, guint id)
-{
- gint i;
-
- for (i = 0; i < YELP_THEME_NUM_TYPES; i++)
- if (type & (1 << i))
- g_hook_destroy (hook_lists[i], id);
-}
-
-const GtkIconTheme*
-yelp_theme_get_icon_theme (void)
-{
- return (const GtkIconTheme *) icon_theme;
-}
-
-const gchar *
-yelp_theme_get_css_file (void)
-{
- return "file://" DATADIR "/yelp/default.css";
-}
-
-const gchar *
-yelp_theme_get_gray_background (void)
-{
- return gray_background;
-}
-
-const gchar *
-yelp_theme_get_gray_border (void)
-{
- return gray_border;
-}
-
-static void
-yelp_theme_update (guint type)
-{
- GtkStyle *style;
- gint i;
-
- if (type & YELP_THEME_INFO_COLOR) {
- style = gtk_rc_get_style_by_paths (gtk_settings_get_default (),
- "GtkWidget", "GtkWidget",
- GTK_TYPE_WIDGET);
- if (style)
- g_object_ref (G_OBJECT (style));
- else
- style = gtk_style_new ();
-
- g_snprintf (gray_background, 10,
- "\"#%02X%02X%02X\"",
- style->bg[GTK_STATE_NORMAL].red >> 8,
- style->bg[GTK_STATE_NORMAL].green >> 8,
- style->bg[GTK_STATE_NORMAL].blue >> 8);
- g_snprintf (gray_border, 10,
- "\"#%02X%02X%02X\"",
- style->dark[GTK_STATE_NORMAL].red >> 8,
- style->dark[GTK_STATE_NORMAL].green >> 8,
- style->dark[GTK_STATE_NORMAL].blue >> 8);
-
- g_object_unref (G_OBJECT (style));
- }
-
- for (i = 0; i < YELP_THEME_NUM_TYPES; i++)
- if (type & (1 << i))
- g_hook_list_invoke (hook_lists[i], FALSE);
-}
-
-static void
-yelp_theme_notify (GConfClient *gconf,
- guint id,
- GConfEntry *entry,
- gpointer user_data)
-{
- g_return_if_fail (entry && entry->key);
-
- if (g_str_equal (entry->key, KEY_GTK_THEME)) {
- yelp_theme_update (YELP_THEME_INFO_COLOR);
- }
-}
-
-static void
-icon_theme_changed (GtkIconTheme *theme, gpointer user_data)
-{
- yelp_theme_update (YELP_THEME_INFO_ICONS);
-}
diff --git a/src/yelp-theme.h b/src/yelp-theme.h
deleted file mode 100644
index aca29dc4..00000000
--- a/src/yelp-theme.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * Copyright (C) 2003 Shaun McCance <shaunm@gnome.org>
- *
- * 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.
- *
- * Author: Shaun McCance <shaunm@gnome.org>
- */
-
-#ifndef __YELP_THEME_H__
-#define __YELP_THEME_H__
-
-#include <glib.h>
-#include <gtk/gtkicontheme.h>
-
-typedef enum {
- YELP_THEME_INFO_COLOR = 1 << 0,
- YELP_THEME_INFO_ICONS = 1 << 1,
- YELP_THEME_INFO_CSS = 1 << 2,
- YELP_THEME_NUM_TYPES = 3
-} YelpThemeInfoType;
-
-void yelp_theme_init (void);
-guint yelp_theme_notify_add (guint type,
- GHookFunc func,
- gpointer data);
-void yelp_theme_notify_remove (guint type,
- guint id);
-
-const GtkIconTheme * yelp_theme_get_icon_theme (void);
-const gchar * yelp_theme_get_css_file (void);
-const gchar * yelp_theme_get_gray_background (void);
-const gchar * yelp_theme_get_gray_border (void);
-
-#endif /* __YELP_THEME_H__ */
diff --git a/src/yelp-toc-pager.c b/src/yelp-toc-pager.c
index af3e26ab..4d4e0656 100644
--- a/src/yelp-toc-pager.c
+++ b/src/yelp-toc-pager.c
@@ -32,7 +32,7 @@
#include <libxml/parserInternals.h>
#include "yelp-error.h"
-#include "yelp-theme.h"
+#include "yelp-settings.h"
#include "yelp-toc-pager.h"
#include "yelp-utils.h"
@@ -268,8 +268,8 @@ yelp_toc_pager_pause (YelpTocPager *pager)
{
g_return_if_fail (pager != NULL);
- d (printf ("yelp_toc_pager_pause\n"));
- d (printf (" pause_caunt = %i\n", pager->priv->pause_count + 1));
+ d (g_print ("yelp_toc_pager_pause\n"));
+ d (g_print (" pause_caunt = %i\n", pager->priv->pause_count + 1));
pager->priv->pause_count = pager->priv->pause_count + 1;
}
@@ -279,8 +279,8 @@ yelp_toc_pager_unpause (YelpTocPager *pager)
{
g_return_if_fail (pager != NULL);
- d (printf ("yelp_toc_pager_unpause\n"));
- d (printf (" pause_caunt = %i\n", pager->priv->pause_count - 1));
+ d (g_print ("yelp_toc_pager_unpause\n"));
+ d (g_print (" pause_caunt = %i\n", pager->priv->pause_count - 1));
pager->priv->pause_count = pager->priv->pause_count - 1;
if (pager->priv->pause_count < 0) {
@@ -300,7 +300,7 @@ yelp_toc_pager_unpause (YelpTocPager *pager)
static void
toc_pager_error (YelpPager *pager)
{
- d (printf ("toc_pager_error\n"));
+ d (g_print ("toc_pager_error\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_ERROR);
}
@@ -309,7 +309,7 @@ toc_pager_cancel (YelpPager *pager)
{
YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv;
- d (printf ("toc_pager_cancel\n"));
+ d (g_print ("toc_pager_cancel\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_INVALID);
priv->cancel = TRUE;
@@ -318,7 +318,7 @@ toc_pager_cancel (YelpPager *pager)
static void
toc_pager_finish (YelpPager *pager)
{
- d (printf ("toc_pager_finish\n"));
+ d (g_print ("toc_pager_finish\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_FINISHED);
}
@@ -328,7 +328,7 @@ toc_pager_process (YelpPager *pager)
gchar *manpath;
YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv;
- d (printf ("toc_pager_process\n"));
+ d (g_print ("toc_pager_process\n"));
yelp_pager_set_state (pager, YELP_PAGER_STATE_PARSING);
g_signal_emit_by_name (pager, "parse");
@@ -787,7 +787,7 @@ process_menu_pending (YelpTocPager *pager)
YelpTocPagerPriv *priv = pager->priv;
- d (printf ("process_menu_pending\n"));
+ d (g_print ("process_menu_pending\n"));
first = priv->menu_pending;
priv->menu_pending = g_slist_remove_link (priv->menu_pending, first);
@@ -914,7 +914,7 @@ menu_write_page (YelpMenu *menu)
"<head><meta http-equiv='Content-Type'"
" content='text/html=; charset=utf-8'>"
"<link rel='stylesheet' type='text/css' href='%s'></head>\n",
- yelp_theme_get_css_file ());
+ yelp_settings_get_css_file ());
g_string_append_printf (gstr, "<body><h1>%s</h1>\n", menu->title);
diff --git a/src/yelp-utils.c b/src/yelp-utils.c
index a37e6384..fe1bf2e9 100644
--- a/src/yelp-utils.c
+++ b/src/yelp-utils.c
@@ -78,8 +78,8 @@ yelp_doc_info_new (gchar *uri)
g_return_val_if_fail (uri != NULL, NULL);
- d (printf ("yelp_doc_info_new\n"));
- d (printf (" uri = \"%s\"\n", uri));
+ d (g_print ("yelp_doc_info_new\n"));
+ d (g_print (" uri = \"%s\"\n", uri));
if (g_str_has_prefix (uri, "file:")) {
if ((cur = strchr (uri, '#')))
@@ -111,7 +111,7 @@ yelp_doc_info_new (gchar *uri)
uri_type = YELP_URI_TYPE_TOC;
}
- d (printf (" doc_uri = \"%s\"\n", uri));
+ d (g_print (" doc_uri = \"%s\"\n", doc_uri));
if (doc_uri) {
doc = g_new0 (YelpDocInfo, 1);
@@ -139,8 +139,8 @@ yelp_doc_info_get (gchar *uri)
g_return_val_if_fail (uri != NULL, NULL);
- d (printf ("yelp_doc_info_get\n"));
- d (printf (" uri = \"%s\"\n", uri));
+ d (g_print ("yelp_doc_info_get\n"));
+ d (g_print (" uri = \"%s\"\n", uri));
if (!doc_info_table)
doc_info_table =
@@ -198,8 +198,8 @@ yelp_doc_info_free (YelpDocInfo *doc)
{
gint i;
- d (printf ("yelp_doc_info_free\n"));
- d (printf (" uri = \"%s\"\n", doc->uris->uri));
+ d (g_print ("yelp_doc_info_free\n"));
+ d (g_print (" uri = \"%s\"\n", doc->uris->uri));
if (!doc)
return;
@@ -395,7 +395,7 @@ doc_info_add_uri (YelpDocInfo *doc_info,
{
DocInfoURI *info_uri;
- d (printf ("yelp_doc_add_uri\n"));
+ d (g_print ("yelp_doc_add_uri\n"));
g_assert (doc_info->num_uris <= doc_info->max_uris);
@@ -413,9 +413,9 @@ doc_info_add_uri (YelpDocInfo *doc_info,
doc_info->num_uris++;
- d (printf (" uri = \"%s\"\n", uri));
- d (printf (" num_uris = %i\n", doc_info->num_uris));
- d (printf (" max_uris = %i\n", doc_info->max_uris));
+ d (g_print (" uri = \"%s\"\n", uri));
+ d (g_print (" num_uris = %i\n", doc_info->num_uris));
+ d (g_print (" max_uris = %i\n", doc_info->max_uris));
}
/******************************************************************************/
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 79473070..48e1667a 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -37,6 +37,7 @@
#include <libgnome/gnome-program.h>
#include <libgnome/gnome-config.h>
#include <glade/glade.h>
+#include <gconf/gconf-client.h>
#include <string.h>
#include "yelp-cache.h"
#include "yelp-db-pager.h"
@@ -44,8 +45,8 @@
#include "yelp-html.h"
#include "yelp-man-pager.h"
#include "yelp-pager.h"
+#include "yelp-settings.h"
#include "yelp-toc-pager.h"
-#include "yelp-theme.h"
#include "yelp-window.h"
#ifdef YELP_DEBUG
@@ -54,8 +55,8 @@
#define d(x)
#endif
-#define YELP_CONFIG_WIDTH "/yelp/Geometry/width"
-#define YELP_CONFIG_HEIGHT "/yelp/Geometry/height"
+#define YELP_CONFIG_WIDTH "/yelp/Geometry/width"
+#define YELP_CONFIG_HEIGHT "/yelp/Geometry/height"
#define YELP_CONFIG_WIDTH_DEFAULT "600"
#define YELP_CONFIG_HEIGHT_DEFAULT "420"
@@ -147,6 +148,7 @@ static void window_open_location_cb (GtkAction *action, YelpWindow *window);
static void window_close_window_cb (GtkAction *action, YelpWindow *window);
static void window_copy_cb (GtkAction *action, YelpWindow *window);
static void window_find_cb (GtkAction *action, YelpWindow *window);
+static void window_preferences_cb (GtkAction *action, YelpWindow *window);
static void window_go_back_cb (GtkAction *action, YelpWindow *window);
static void window_go_forward_cb (GtkAction *action, YelpWindow *window);
static void window_go_home_cb (GtkAction *action, YelpWindow *window);
@@ -163,9 +165,9 @@ static YelpHistoryEntry * history_pop_back (YelpWindow *window);
static YelpHistoryEntry * history_pop_forward (YelpWindow *window);
static void history_entry_free (YelpHistoryEntry *entry);
-static void location_response_cb (GtkDialog *dialog,
- gint id,
- YelpWindow *window);
+static void location_response_cb (GtkDialog *dialog,
+ gint id,
+ YelpWindow *window);
static void window_find_again_cb (gpointer data,
guint action,
@@ -186,11 +188,12 @@ static void window_find_clicked_cb (GtkWidget *button,
static gboolean tree_model_iter_following (GtkTreeModel *model,
GtkTreeIter *iter);
+static GConfClient *gconf_client = NULL;
+
enum {
NEW_WINDOW_REQUESTED,
LAST_SIGNAL
};
-
static gint signals[LAST_SIGNAL] = { 0 };
struct _YelpWindowPriv {
@@ -293,6 +296,10 @@ static GtkActionEntry entries[] = {
"<Control>F",
NULL,
G_CALLBACK (window_find_cb) },
+ { "Preferences", GTK_STOCK_PREFERENCES,
+ N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (window_preferences_cb) },
{ "GoBack", GTK_STOCK_GO_BACK,
N_("_Back"),
@@ -383,6 +390,9 @@ window_init (YelpWindow *window)
static void
window_class_init (YelpWindowClass *klass)
{
+ if (!gconf_client)
+ gconf_client = gconf_client_get_default ();
+
signals[NEW_WINDOW_REQUESTED] =
g_signal_new ("new_window_requested",
G_TYPE_FROM_CLASS (klass),
@@ -540,12 +550,12 @@ yelp_window_new (GNode *doc_tree, GList *index)
priv = window->priv;
- d (printf ("yelp_window_new\n"));
+ d (g_print ("yelp_window_new\n"));
window_set_icon (window);
- priv->icons_hook = yelp_theme_notify_add (YELP_THEME_INFO_ICONS,
- (GHookFunc) window_set_icon,
- window);
+ priv->icons_hook = yelp_settings_notify_add (YELP_SETTINGS_INFO_ICONS,
+ (GHookFunc) window_set_icon,
+ window);
window_populate (window);
@@ -565,8 +575,8 @@ yelp_window_load (YelpWindow *window, gchar *uri)
g_return_if_fail (YELP_IS_WINDOW (window));
- d (printf ("yelp_window_load\n"));
- d (printf (" uri = \"%s\"\n", uri));
+ d (g_print ("yelp_window_load\n"));
+ d (g_print (" uri = \"%s\"\n", uri));
if (!uri) {
GError *error = NULL;
@@ -882,7 +892,7 @@ window_set_icon (YelpWindow *window)
g_return_if_fail (YELP_IS_WINDOW (window));
- icon_theme = (GtkIconTheme *) yelp_theme_get_icon_theme ();
+ icon_theme = (GtkIconTheme *) yelp_settings_get_icon_theme ();
pixbuf = gtk_icon_theme_load_icon (icon_theme,
"gnome-help",
@@ -1182,10 +1192,10 @@ window_handle_page (YelpWindow *window,
priv = window->priv;
window_disconnect (window);
- d (printf ("window_handle_page\n"));
- d (printf (" page->page_id = \"%s\"\n", page->page_id));
- d (printf (" page->title = \"%s\"\n", page->title));
- d (printf (" page->contents = %i bytes\n", strlen (page->contents)));
+ d (g_print ("window_handle_page\n"));
+ d (g_print (" page->page_id = \"%s\"\n", page->page_id));
+ d (g_print (" page->title = \"%s\"\n", page->title));
+ d (g_print (" page->contents = %i bytes\n", strlen (page->contents)));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->side_sects));
pager = yelp_doc_info_get_pager (priv->current_doc);
@@ -1261,7 +1271,7 @@ window_handle_page (YelpWindow *window,
page->page_id,
YELP_URI_TYPE_FILE);
- d (printf (" uri = %s\n", uri));
+ d (g_print (" uri = %s\n", uri));
yelp_html_set_base_uri (priv->html_view, uri);
yelp_html_clear (priv->html_view);
@@ -1333,8 +1343,8 @@ yelp_window_destroyed (GtkWidget *window,
priv = YELP_WINDOW(window)->priv;
- yelp_theme_notify_remove (YELP_THEME_INFO_ICONS,
- priv->icons_hook);
+ yelp_settings_notify_remove (YELP_SETTINGS_INFO_ICONS,
+ priv->icons_hook);
window_disconnect (YELP_WINDOW (window));
@@ -1375,8 +1385,8 @@ pager_start_cb (YelpPager *pager,
page_id = yelp_pager_resolve_frag (pager,
window->priv->current_frag);
- d (printf ("pager_start_cb\n"));
- d (printf (" page_id=\"%s\"\n", page_id));
+ d (g_print ("pager_start_cb\n"));
+ d (g_print (" page_id=\"%s\"\n", page_id));
if (!page_id && (window->priv->current_frag && strcmp (window->priv->current_frag, ""))) {
window_disconnect (window);
@@ -1395,8 +1405,8 @@ pager_page_cb (YelpPager *pager,
YelpWindow *window = YELP_WINDOW (user_data);
YelpPage *page;
- d (printf ("pager_page_cb\n"));
- d (printf (" page_id=\"%s\"\n", page_id));
+ d (g_print ("pager_page_cb\n"));
+ d (g_print (" page_id=\"%s\"\n", page_id));
if (yelp_pager_page_contains_frag (pager,
page_id,
@@ -1415,7 +1425,7 @@ pager_error_cb (YelpPager *pager,
YelpWindow *window = YELP_WINDOW (user_data);
GError *error = yelp_pager_get_error (pager);
- d (printf ("pager_error_cb\n"));
+ d (g_print ("pager_error_cb\n"));
window_disconnect (window);
window_error (window, error);
@@ -1432,7 +1442,7 @@ pager_finish_cb (YelpPager *pager,
GError *error = NULL;
YelpWindow *window = YELP_WINDOW (user_data);
- d (printf ("pager_finish_cb\n"));
+ d (g_print ("pager_finish_cb\n"));
window_disconnect (window);
@@ -1454,8 +1464,8 @@ html_uri_selected_cb (YelpHtml *html,
{
YelpWindow *window = YELP_WINDOW (user_data);
- d (printf ("html_uri_selected_cb\n"));
- d (printf (" uri = \"%s\"\n", uri));
+ d (g_print ("html_uri_selected_cb\n"));
+ d (g_print (" uri = \"%s\"\n", uri));
if (!handled) {
yelp_window_load (window, uri);
@@ -1512,7 +1522,7 @@ tree_drag_data_get_cb (GtkWidget *widget,
g_return_if_fail (YELP_IS_WINDOW (window));
- d (printf ("tree_drag_data_get_cb\n"));
+ d (g_print ("tree_drag_data_get_cb\n"));
priv = window->priv;
@@ -1591,7 +1601,6 @@ window_open_location_cb (GtkAction *action, YelpWindow *window)
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (window));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
g_signal_connect (G_OBJECT (dialog),
"response",
G_CALLBACK (location_response_cb),
@@ -1622,13 +1631,21 @@ window_find_cb (GtkAction *action, YelpWindow *window)
priv = window->priv;
- d (printf ("window_find_cb\n"));
+ d (g_print ("window_find_cb\n"));
gtk_widget_show_all (priv->find_bar);
gtk_widget_grab_focus (priv->find_entry);
}
static void
+window_preferences_cb (GtkAction *action, YelpWindow *window)
+{
+ g_return_if_fail (YELP_IS_WINDOW (window));
+
+ yelp_settings_open_preferences ();
+}
+
+static void
window_go_back_cb (GtkAction *action, YelpWindow *window)
{
YelpWindowPriv *priv;
@@ -1687,7 +1704,7 @@ window_go_forward_cb (GtkAction *action, YelpWindow *window)
static void
window_go_home_cb (GtkAction *action, YelpWindow *window)
{
- d (printf ("window_go_home_cb\n"));
+ d (g_print ("window_go_home_cb\n"));
g_return_if_fail (YELP_IS_WINDOW (window));
yelp_window_load (window, "x-yelp-toc:");
}
@@ -1698,7 +1715,7 @@ window_go_previous_cb (GtkAction *action, YelpWindow *window)
YelpWindowPriv *priv;
gchar *base, *uri;
- d (printf ("window_go_previous_cb\n"));
+ d (g_print ("window_go_previous_cb\n"));
g_return_if_fail (YELP_IS_WINDOW (window));
g_return_if_fail (window->priv->current_doc);
priv = window->priv;
@@ -1718,7 +1735,7 @@ window_go_next_cb (GtkAction *action, YelpWindow *window)
YelpWindowPriv *priv;
gchar *base, *uri;
- d (printf ("window_go_next_cb\n"));
+ d (g_print ("window_go_next_cb\n"));
g_return_if_fail (YELP_IS_WINDOW (window));
g_return_if_fail (window->priv->current_doc);
priv = window->priv;
@@ -1738,7 +1755,7 @@ window_go_toc_cb (GtkAction *action, YelpWindow *window)
YelpWindowPriv *priv;
gchar *base, *uri;
- d (printf ("window_go_toc_cb\n"));
+ d (g_print ("window_go_toc_cb\n"));
g_return_if_fail (YELP_IS_WINDOW (window));
g_return_if_fail (window->priv->current_doc);
priv = window->priv;
@@ -1757,7 +1774,7 @@ window_about_cb (GtkAction *action, YelpWindow *window)
{
static GtkWidget *about = NULL;
- d (printf ("window_go_about_cb\n"));
+ d (g_print ("window_go_about_cb\n"));
if (about == NULL) {
const gchar *authors[] = {
@@ -1796,8 +1813,8 @@ location_response_cb (GtkDialog *dialog, gint id, YelpWindow *window)
{
g_return_if_fail (YELP_IS_WINDOW (window));
- d (printf ("location_response_cb\n"));
- d (printf (" id = %i\n", id));
+ d (g_print ("location_response_cb\n"));
+ d (g_print (" id = %i\n", id));
if (id == GTK_RESPONSE_OK) {
const gchar *uri =
@@ -2007,15 +2024,15 @@ idle_write (IdleWriterContext *context)
g_return_val_if_fail (context != NULL, FALSE);
g_return_val_if_fail (context->window != NULL, FALSE);
- d (printf ("idle_write\n"));
+ d (g_print ("idle_write\n"));
priv = context->window->priv;
switch (context->type) {
case IDLE_WRITER_MEMORY:
- d (printf (" context->buffer = %i bytes\n", strlen (context->buffer)));
- d (printf (" context->cur = %i\n", context->cur));
- d (printf (" context->length = %i\n", context->length));
+ d (g_print (" context->buffer = %i bytes\n", strlen (context->buffer)));
+ d (g_print (" context->cur = %i\n", context->cur));
+ d (g_print (" context->length = %i\n", context->length));
if (context->cur + BUFFER_SIZE < context->length) {
yelp_html_write (priv->html_view,