summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-04-04 11:45:19 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-04-04 11:45:19 +0000
commit0f57e2864047623adfcdb4e7444d7dcd8bfcc7c9 (patch)
treef72e24531f6d93275ecf3c2e7bf261551d60cb15
parente0d27d1e36397854c29ec59420c30f6488fe0a2d (diff)
downloadyelp-0f57e2864047623adfcdb4e7444d7dcd8bfcc7c9.tar.gz
use GConf for the toolbar style.
2002-04-04 Mikael Hallendal <micke@codefactory.se> * src/yelp-window.c: use GConf for the toolbar style. * src/yelp-html.c: added a "Loading..." while loading the document. New string, sorry about that. This also needs a new change in gtkhtml2 so I'll update the reqs after the next release of gtkhtml2. * configure.in (GNOMELOCALEDIR): added gconf-2.0
-rw-r--r--ChangeLog11
-rw-r--r--configure.in3
-rw-r--r--src/yelp-html.c44
-rw-r--r--src/yelp-window.c197
4 files changed, 182 insertions, 73 deletions
diff --git a/ChangeLog b/ChangeLog
index 2df43949..ee1cfbe2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-04-04 Mikael Hallendal <micke@codefactory.se>
+
+ * src/yelp-window.c: use GConf for the toolbar style.
+
+ * src/yelp-html.c: added a "Loading..." while loading the
+ document. New string, sorry about that. This also needs a new
+ change in gtkhtml2 so I'll update the reqs after the next
+ release of gtkhtml2.
+
+ * configure.in (GNOMELOCALEDIR): added gconf-2.0
+
2002-04-03 Gustavo Maciel Dias Vieira <gdvieira@zaz.com.br>
* configure.in (ALL_LINGUAS): Added pt_BR.
diff --git a/configure.in b/configure.in
index 47ffe64e..578a6fd3 100644
--- a/configure.in
+++ b/configure.in
@@ -42,7 +42,8 @@ PKG_CHECK_MODULES(YELP, libgtkhtml-2.0 >= 1.99.3 \
gnome-vfs-2.0 >= 1.1 \
libgnome-2.0 >= 1.112.1 \
libgnomeui-2.0 >= 1.103.0 \
- libbonobo-2.0 >= 1.108.0)
+ libbonobo-2.0 >= 1.108.0 \
+ gconf-2.0)
AC_SUBST(YELP_CFLAGS)
AC_SUBST(YELP_LIBS)
diff --git a/src/yelp-html.c b/src/yelp-html.c
index aaefb166..42c861e6 100644
--- a/src/yelp-html.c
+++ b/src/yelp-html.c
@@ -77,6 +77,7 @@ static GHashTable *cache_table = NULL;
struct _YelpHtmlPriv {
HtmlDocument *doc;
+ HtmlDocument *load_doc;
GSList *connections;
gchar *base_uri;
};
@@ -120,13 +121,29 @@ static void
yh_init (YelpHtml *view)
{
YelpHtmlPriv *priv;
-
+
priv = g_new0 (YelpHtmlPriv, 1);
priv->doc = html_document_new ();
priv->connections = NULL;
priv->base_uri = g_strdup ("");
+ priv->load_doc = html_document_new ();
+
+ html_document_open_stream (priv->load_doc, "text/html");
+
+ {
+ gint len;
+ gchar *str = _("Loading...");
+ gchar *text = g_strdup_printf ("<html><body bgcolor=\"white\"><center>%s</center></body></html>", str);
+ len = strlen (text);
+
+ html_document_write_stream (priv->load_doc, text, len);
+ g_free (text);
+ }
+
+ html_document_close_stream (priv->load_doc);
+
html_view_set_document (HTML_VIEW (view), priv->doc);
g_signal_connect (G_OBJECT (priv->doc), "link_clicked",
@@ -186,11 +203,13 @@ yh_async_read_cb (GnomeVFSAsyncHandle *handle,
gpointer callback_data)
{
StreamData *sdata;
-
+ YelpHtml *view;
+
d(puts(G_GNUC_FUNCTION));
sdata = (StreamData *) callback_data;
-
+ view = sdata->view;
+
if (result != GNOME_VFS_OK) {
gnome_vfs_async_close (handle,
yh_async_close_cb,
@@ -199,6 +218,11 @@ yh_async_read_cb (GnomeVFSAsyncHandle *handle,
g_free (buffer);
} else {
html_stream_write (sdata->stream, buffer, bytes_read);
+
+ if (HTML_VIEW(view)->document == view->priv->load_doc) {
+ html_view_set_document (HTML_VIEW (view),
+ view->priv->doc);
+ }
gnome_vfs_async_read (handle, buffer, bytes_requested,
yh_async_read_cb, sdata);
@@ -318,7 +342,7 @@ yh_link_clicked_cb (HtmlDocument *doc, const gchar *url, YelpHtml *html)
g_return_if_fail (YELP_IS_HTML (html));
handled = FALSE;
-
+
/* If this is a relative reference. Shortcut reload. */
if (url && (url[0] == '#' || url[0] == '?')) {
html_view_jump_to_anchor (HTML_VIEW (html),
@@ -401,6 +425,8 @@ yelp_html_open_uri (YelpHtml *view,
return;
}
+ html_view_set_document (HTML_VIEW (view), priv->load_doc);
+
/* New document needs to be read. */
g_free (priv->base_uri);
priv->base_uri = g_strdup (docpath);
@@ -411,11 +437,11 @@ yelp_html_open_uri (YelpHtml *view,
gtk_adjustment_set_value (
gtk_layout_get_vadjustment (GTK_LAYOUT (view)), 0);
- sdata = g_new0 (StreamData, 1);
- sdata->view = view;
- sdata->stream = priv->doc->current_stream;
- sdata->anchor = NULL;
-
+ sdata = g_new0 (StreamData, 1);
+ sdata->view = view;
+ sdata->stream = priv->doc->current_stream;
+ sdata->anchor = NULL;
+
priv->connections = g_slist_prepend (priv->connections, sdata);
uri = gnome_vfs_uri_new (docpath);
diff --git a/src/yelp-window.c b/src/yelp-window.c
index b733def0..0e490b7c 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -27,6 +27,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
#include <bonobo/bonobo-main.h>
+#include <gconf/gconf-client.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomeui/gnome-about.h>
#include <libgnome/gnome-i18n.h>
@@ -48,58 +49,69 @@ typedef enum {
YELP_WINDOW_ACTION_FORWARD,
} YelpHistoryAction;
-static void yw_init (YelpWindow *window);
-static void yw_class_init (YelpWindowClass *klass);
-
-static void yw_populate (YelpWindow *window);
-
-static gboolean yw_handle_url (YelpWindow *window,
- const gchar *url);
-static void yw_url_selected_cb (gpointer view,
- char *url,
- char *base_url,
- gboolean handled,
- YelpWindow *window);
-static void yw_toggle_history_back (YelpHistory *history,
- gboolean sensitive,
- YelpWindow *window);
-
-static void yw_toggle_history_forward (YelpHistory *history,
- gboolean sensitive,
- YelpWindow *window);
-
-static void yw_history_action (YelpWindow *window,
- YelpHistoryAction action);
-static void yw_back_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void yw_forward_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void yw_home_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void yw_index_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void yw_new_window_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void yw_close_window_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void yw_exit_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void yw_history_go_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void yw_go_home_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void yw_go_index_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void yw_about_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static GtkWidget * yw_create_toolbar (YelpWindow *window);
+static GConfEnumStringPair toolbar_styles[] = {
+ { GTK_TOOLBAR_TEXT, "text" },
+ { GTK_TOOLBAR_ICONS, "icons" },
+ { GTK_TOOLBAR_BOTH, "both" }
+};
+
+static void yw_init (YelpWindow *window);
+static void yw_class_init (YelpWindowClass *klass);
+
+static void yw_populate (YelpWindow *window);
+
+static gboolean yw_handle_url (YelpWindow *window,
+ const gchar *url);
+static void yw_url_selected_cb (gpointer view,
+ char *url,
+ char *base_url,
+ gboolean handled,
+ YelpWindow *window);
+static void yw_toggle_history_back (YelpHistory *history,
+ gboolean sensitive,
+ YelpWindow *window);
+
+static void yw_toggle_history_forward (YelpHistory *history,
+ gboolean sensitive,
+ YelpWindow *window);
+
+static void yw_history_action (YelpWindow *window,
+ YelpHistoryAction action);
+static void yw_back_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void yw_forward_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void yw_home_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void yw_index_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void yw_new_window_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void yw_close_window_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void yw_history_go_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void yw_go_home_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void yw_go_index_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void yw_about_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static GtkWidget * yw_create_toolbar (YelpWindow *window);
+
+static void yw_toolbar_style_changed_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data);
+
+static void yw_remove_notify_cb (GtkObject *obj,
+ gpointer data);
enum {
PAGE_TOC_VIEW,
@@ -502,12 +514,6 @@ yw_close_window_cb (gpointer data,
}
static void
-yw_exit_cb (gpointer data, guint section, GtkWidget *widget)
-{
- bonobo_main_quit ();
-}
-
-static void
yw_history_go_cb (gpointer data, guint section, GtkWidget *widget)
{
yw_history_action (data, section);
@@ -552,17 +558,45 @@ yw_about_cb (gpointer data, guint section, GtkWidget *widget)
static GtkWidget *
yw_create_toolbar (YelpWindow *window)
{
- YelpWindowPriv *priv;
- GtkWidget *toolbar;
- GtkWidget *button;
- GtkWidget *icon;
-
+ YelpWindowPriv *priv;
+ GtkWidget *toolbar;
+ GtkWidget *button;
+ GtkWidget *icon;
+ GConfClient *conf_client;
+ gchar *str;
+ GtkToolbarStyle style = GTK_TOOLBAR_BOTH;
+ guint notify_id;
+
g_return_val_if_fail (YELP_IS_WINDOW (window), NULL);
priv = window->priv;
toolbar = gtk_toolbar_new ();
+ conf_client = gconf_client_get_default ();
+
+ str = gconf_client_get_string (conf_client,
+ "/desktop/gnome/interface/toolbar_style",
+ NULL);
+
+ if (str) {
+ gconf_string_to_enum (toolbar_styles,
+ str,
+ (gint*)&style);
+ g_free (str);
+ }
+
+ gconf_client_notify_add (conf_client,
+ "/desktop/gnome/interface/toolbar_style",
+ yw_toolbar_style_changed_cb,
+ toolbar, NULL, NULL);
+
+/* g_signal_connect(toolbar, "destroy", */
+/* G_CALLBACK(yw_remove_notify_cb), */
+/* GINT_TO_POINTER(notify_id)); */
+
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), style);
+
icon = gtk_image_new_from_stock ("gtk-go-back",
GTK_ICON_SIZE_LARGE_TOOLBAR);
@@ -615,6 +649,42 @@ yw_create_toolbar (YelpWindow *window)
return toolbar;
}
+static void
+yw_toolbar_style_changed_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data)
+{
+ GtkToolbarStyle style = GTK_TOOLBAR_BOTH;
+ GtkToolbar *toolbar = GTK_TOOLBAR(data);
+ GConfValue *value;
+
+ value = gconf_entry_get_value (entry);
+
+ /* If no per-app setting use this new global setting */
+ if (value &&
+ value->type == GCONF_VALUE_STRING &&
+ gconf_value_get_string (value) != NULL) {
+ gconf_string_to_enum(toolbar_styles,
+ gconf_value_get_string(value),
+ (gint*)&style);
+ }
+
+ gtk_toolbar_set_style(toolbar, style);
+}
+
+static void
+yw_remove_notify_cb (GtkObject *obj, gpointer data)
+{
+ GConfClient *conf_client;
+ guint notify_id;
+
+ conf_client = gconf_client_get_default ();
+ notify_id = GPOINTER_TO_INT(data);
+
+ gconf_client_notify_remove(conf_client, notify_id);
+}
+
GtkWidget *
yelp_window_new (GNode *doc_tree, GList *index)
{
@@ -670,3 +740,4 @@ yelp_window_get_current_uri (YelpWindow *window)
return yelp_history_get_current (window->priv->history);
}
+