summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-06-02 17:32:29 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-06-02 17:32:29 +0000
commitf81272f47913fa10f1a1e54d65791e4e385b4272 (patch)
tree9a09d469922ab770353f45a047505743884c3e10
parent9dd5351e004600b75899e1e4a99c9bca1e65e8b3 (diff)
downloadyelp-f81272f47913fa10f1a1e54d65791e4e385b4272.tar.gz
Fixes #69047
2002-06-02 Mikael Hallendal <micke@codefactory.se> * Fixes #69047 * src/yelp-window.c (yelp_window_new): connect to title_changed signal on content and TOC views. (window_title_changed_cb): set the new title. * src/yelp-view-toc.c: added title_changed signal. I soooo want the views to inherit from the same base :) Will fix after 2.0.0 (toc_html_title_changed_cb): emit title changed signal. (toc_page_start): take extra argument so that you can set title and page header. * src/yelp-view-content.c: added signal title_changed. (content_html_title_changed_cb): emit title changed signal. * src/yelp-html-gtkhtml2.c: (html_title_changed_cb): emit title changed signal. * src/yelp-html.h: added title_changed signal. * src/yelp-html-gtkhtml1.c: - started on emit title changed code. WIP.
-rw-r--r--ChangeLog23
-rw-r--r--src/yelp-html-gtkhtml1.c12
-rw-r--r--src/yelp-html-gtkhtml2.c30
-rw-r--r--src/yelp-html.h8
-rw-r--r--src/yelp-view-content.c28
-rw-r--r--src/yelp-view-content.h2
-rw-r--r--src/yelp-view-toc.c69
-rw-r--r--src/yelp-view-toc.h8
-rw-r--r--src/yelp-window.c108
9 files changed, 225 insertions, 63 deletions
diff --git a/ChangeLog b/ChangeLog
index e94102de..f5a583e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2002-06-02 Mikael Hallendal <micke@codefactory.se>
+ * Fixes #69047
+
+ * src/yelp-window.c (yelp_window_new): connect to title_changed
+ signal on content and TOC views.
+ (window_title_changed_cb): set the new title.
+
+ * src/yelp-view-toc.c: added title_changed signal. I soooo want
+ the views to inherit from the same base :) Will fix after 2.0.0
+ (toc_html_title_changed_cb): emit title changed signal.
+ (toc_page_start): take extra argument so that you can set title
+ and page header.
+
+ * src/yelp-view-content.c: added signal title_changed.
+ (content_html_title_changed_cb): emit title changed signal.
+
+ * src/yelp-html-gtkhtml2.c:
+ (html_title_changed_cb): emit title changed signal.
+
+ * src/yelp-html.h: added title_changed signal.
+
+ * src/yelp-html-gtkhtml1.c:
+ - started on emit title changed code. WIP.
+
* src/yelp-uri.c:
(uri_get_doc_type): set info:dir to be toc:info
(uri_get_doc_path): same
diff --git a/src/yelp-html-gtkhtml1.c b/src/yelp-html-gtkhtml1.c
index fda4fd0a..ac184963 100644
--- a/src/yelp-html-gtkhtml1.c
+++ b/src/yelp-html-gtkhtml1.c
@@ -67,6 +67,7 @@ static void html_link_clicked_cb (GtkHTML *html_view,
enum {
URI_SELECTED,
+ TITLE_CHANGED,
LAST_SIGNAL
};
@@ -134,6 +135,17 @@ html_class_init (YelpHtmlClass *klass)
yelp_marshal_VOID__POINTER_BOOLEAN,
G_TYPE_NONE,
2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+
+ signals[TITLE_CHANGED] =
+ g_signal_new ("title_changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (YelpHtmlClass,
+ title_changed),
+ NULL, NULL,
+ yelp_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
}
static void
diff --git a/src/yelp-html-gtkhtml2.c b/src/yelp-html-gtkhtml2.c
index e0424f40..5eb11806 100644
--- a/src/yelp-html-gtkhtml2.c
+++ b/src/yelp-html-gtkhtml2.c
@@ -64,11 +64,16 @@ static void html_cancel_stream (HtmlStream *stream,
static void html_link_clicked_cb (HtmlDocument *doc,
const gchar *url,
YelpHtml *html);
+static void html_title_changed_cb (HtmlDocument *doc,
+ const gchar *new_title,
+ YelpHtml *html);
+
#define BUFFER_SIZE 16384
enum {
URI_SELECTED,
+ TITLE_CHANGED,
LAST_SIGNAL
};
@@ -121,6 +126,9 @@ html_init (YelpHtml *html)
g_signal_connect (G_OBJECT (priv->doc), "request_url",
G_CALLBACK (html_url_requested_cb), html);
+ g_signal_connect (G_OBJECT (priv->doc), "title_changed",
+ G_CALLBACK (html_title_changed_cb), html);
+
html->priv = priv;
}
@@ -137,6 +145,17 @@ html_class_init (YelpHtmlClass *klass)
yelp_marshal_VOID__POINTER_BOOLEAN,
G_TYPE_NONE,
2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+
+ signals[TITLE_CHANGED] =
+ g_signal_new ("title_changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (YelpHtmlClass,
+ title_changed),
+ NULL, NULL,
+ yelp_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
}
static void
@@ -231,6 +250,17 @@ html_link_clicked_cb (HtmlDocument *doc, const gchar *url, YelpHtml *html)
yelp_uri_unref (uri);
}
+static void
+html_title_changed_cb (HtmlDocument *doc,
+ const gchar *new_title,
+ YelpHtml *html)
+{
+ g_return_if_fail (HTML_IS_DOCUMENT (doc));
+ g_return_if_fail (new_title != NULL);
+
+ g_signal_emit (html, signals[TITLE_CHANGED], 0, new_title);
+}
+
YelpHtml *
yelp_html_new (void)
{
diff --git a/src/yelp-html.h b/src/yelp-html.h
index c99d873a..0d3958a8 100644
--- a/src/yelp-html.h
+++ b/src/yelp-html.h
@@ -48,9 +48,11 @@ struct _YelpHtmlClass {
GObjectClass parent_class;
/* Signals */
- void (*uri_selected) (YelpHtml *view,
- YelpURI *uri,
- gboolean handled);
+ void (*uri_selected) (YelpHtml *view,
+ YelpURI *uri,
+ gboolean handled);
+ void (*title_changed) (YelpHtml *view,
+ const gchar *new_title);
};
GType yelp_html_get_type (void);
diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c
index ae97213d..0db26c18 100644
--- a/src/yelp-view-content.c
+++ b/src/yelp-view-content.c
@@ -50,6 +50,9 @@ static void content_html_uri_selected_cb (YelpHtml *html,
YelpURI *uri,
gboolean handled,
YelpViewContent *view);
+static void content_html_title_changed_cb (YelpHtml *html,
+ const gchar *title,
+ YelpViewContent *view);
#if 0
static void content_reader_start_cb (YelpReader *reader,
YelpViewContent *view);
@@ -68,6 +71,7 @@ static void content_reader_error_cb (YelpReader *reader,
enum {
URI_SELECTED,
+ TITLE_CHANGED,
LAST_SIGNAL
};
@@ -145,6 +149,9 @@ content_init (YelpViewContent *view)
g_signal_connect (priv->html_view, "uri_selected",
G_CALLBACK (content_html_uri_selected_cb),
view);
+ g_signal_connect (priv->html_view, "title_changed",
+ G_CALLBACK (content_html_title_changed_cb),
+ view);
priv->reader = yelp_reader_new ();
@@ -177,6 +184,17 @@ content_class_init (YelpViewContentClass *klass)
yelp_marshal_VOID__POINTER_BOOLEAN,
G_TYPE_NONE,
2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+
+ signals[TITLE_CHANGED] =
+ g_signal_new ("title_changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (YelpViewContentClass,
+ title_changed),
+ NULL, NULL,
+ yelp_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
}
static void
@@ -194,6 +212,16 @@ content_html_uri_selected_cb (YelpHtml *html,
}
static void
+content_html_title_changed_cb (YelpHtml *html,
+ const gchar *title,
+ YelpViewContent *view)
+{
+ g_print ("Title changed to: %s\n", title);
+
+ g_signal_emit (view, signals[TITLE_CHANGED], 0, title);
+}
+
+static void
content_tree_selection_changed_cb (GtkTreeSelection *selection,
YelpViewContent *content)
{
diff --git a/src/yelp-view-content.h b/src/yelp-view-content.h
index 53d8ce3d..00b999ba 100644
--- a/src/yelp-view-content.h
+++ b/src/yelp-view-content.h
@@ -52,6 +52,8 @@ struct _YelpViewContentClass {
void (*uri_selected) (YelpViewContent *view,
YelpURI *uri,
gboolean handled);
+ void (*title_changed) (YelpViewContent *view,
+ const gchar *new_title);
};
GType yelp_view_content_get_type (void);
diff --git a/src/yelp-view-toc.c b/src/yelp-view-toc.c
index f50c1002..9c5b6549 100644
--- a/src/yelp-view-toc.c
+++ b/src/yelp-view-toc.c
@@ -51,12 +51,17 @@ static void toc_uri_selected_cb (YelpHtml *html,
YelpURI *uri,
gboolean handled,
YelpViewTOC *view);
+static void toc_html_title_changed_cb (YelpHtml *html,
+ const gchar *title,
+ YelpViewTOC *view);
static void toc_page_start (YelpViewTOC *view,
- const gchar *page_name);
+ const gchar *title,
+ const gchar *heading);
static void toc_page_end (YelpViewTOC *view);
enum {
URI_SELECTED,
+ TITLE_CHANGED,
LAST_SIGNAL
};
@@ -117,8 +122,12 @@ toc_init (YelpViewTOC *view)
priv->html_view = yelp_html_new ();
priv->html_widget = yelp_html_get_widget (priv->html_view);
- g_signal_connect (G_OBJECT (priv->html_view), "uri_selected",
- G_CALLBACK (toc_uri_selected_cb),
+ g_signal_connect (priv->html_view, "uri_selected",
+ G_CALLBACK (toc_uri_selected_cb),
+ view);
+
+ g_signal_connect (priv->html_view, "title_changed",
+ G_CALLBACK (toc_html_title_changed_cb),
view);
}
@@ -135,6 +144,17 @@ toc_class_init (YelpViewTOCClass *klass)
yelp_marshal_VOID__POINTER_BOOLEAN,
G_TYPE_NONE,
2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+
+ signals[TITLE_CHANGED] =
+ g_signal_new ("title_changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (YelpViewTOCClass,
+ title_changed),
+ NULL, NULL,
+ yelp_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
}
#if 0
@@ -176,7 +196,7 @@ toc_start (YelpViewTOC *view)
yelp_html_clear (priv->html_view);
- toc_page_start (view, page_title);
+ toc_page_start (view, page_title, page_title);
sections = priv->important_sections;
@@ -444,6 +464,7 @@ toc_man_2 (YelpViewTOC *view,
GNode *first;
gchar *name;
gchar *string = _("Manual pages");
+ gchar *title;
g_return_if_fail (YELP_IS_VIEW_TOC (view));
@@ -456,15 +477,18 @@ toc_man_2 (YelpViewTOC *view,
first = root->children;
yelp_html_clear (priv->html_view);
-
- toc_page_start (view, string);
-
+
name = toc_full_path_name (view, root);
+
+ title = g_strdup_printf ("%s/%s", string, name);
- yelp_html_printf (priv->html_view,
- "<td colspan=\"2\"><h2>%s/%s</h2><ul>",
- string, name);
+ toc_page_start (view, title, string);
+ yelp_html_printf (priv->html_view,
+ "<td colspan=\"2\"><h2>%s</h2><ul>",
+ title);
+
+ g_free (title);
g_free (name);
toc_man_emit (view, first);
@@ -505,7 +529,7 @@ toc_man_1 (YelpViewTOC *view)
yelp_html_clear (priv->html_view);
- toc_page_start (view, string);
+ toc_page_start (view, string, string);
yelp_html_printf (priv->html_view,
"<td colspan=\"2\"><h2>%s</h2><ul>",
@@ -561,7 +585,7 @@ toc_info (YelpViewTOC *view)
yelp_html_clear (priv->html_view);
- toc_page_start (view, string);
+ toc_page_start (view, string, string);
yelp_html_printf (priv->html_view,
"<td colspan=\"2\"><h2>%s</h2><ul>", str_docs);
@@ -657,12 +681,23 @@ toc_uri_selected_cb (YelpHtml *html,
}
static void
-toc_page_start (YelpViewTOC *view, const gchar *page_name)
+toc_html_title_changed_cb (YelpHtml *html,
+ const gchar *title,
+ YelpViewTOC *view)
+{
+ g_print ("Title changed to: %s\n", title);
+
+ g_signal_emit (view, signals[TITLE_CHANGED], 0, title);
+}
+
+static void
+toc_page_start (YelpViewTOC *view, const gchar *title, const gchar *heading)
{
YelpViewTOCPriv *priv;
g_return_if_fail (YELP_IS_VIEW_TOC (view));
- g_return_if_fail (page_name != NULL);
+ g_return_if_fail (title != NULL);
+ g_return_if_fail (heading != NULL);
priv = view->priv;
@@ -670,6 +705,7 @@ toc_page_start (YelpViewTOC *view, const gchar *page_name)
"<html>\n"
"<head>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
+ "<title>%s</title>\n"
"</head>\n"
"<body marginwidth=\"0\"\n"
"background=\"file:" IMAGEDIR "/bcg.png\" marginheight=\"0\"\n"
@@ -686,7 +722,8 @@ toc_page_start (YelpViewTOC *view, const gchar *page_name)
"<td width=\"75\">\n"
"<img alt=\"\" src=\"file:" IMAGEDIR "/empty.png\" width=\"75\" height=\"1\">\n"
"</td>\n",
- page_name);
+ title,
+ heading);
}
static void
@@ -761,7 +798,7 @@ toc_scrollkeeper (YelpViewTOC *view, GNode *root)
yelp_html_clear (priv->html_view);
- toc_page_start (view, name);
+ toc_page_start (view, name, name);
yelp_html_printf (priv->html_view, "<td colspan=\"2\">");
diff --git a/src/yelp-view-toc.h b/src/yelp-view-toc.h
index 8c1407ec..f38db758 100644
--- a/src/yelp-view-toc.h
+++ b/src/yelp-view-toc.h
@@ -50,9 +50,11 @@ struct _YelpViewTOCClass {
/* Signals */
- void (*uri_selected) (YelpViewTOC *view,
- YelpURI *uri,
- gboolean handled);
+ void (*uri_selected) (YelpViewTOC *view,
+ YelpURI *uri,
+ gboolean handled);
+ void (*title_changed) (YelpViewTOC *view,
+ const gchar *new_title);
};
GType yelp_view_toc_get_type (void);
diff --git a/src/yelp-window.c b/src/yelp-window.c
index f4e1f9cc..5d2be55c 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -63,57 +63,60 @@ static void window_class_init (YelpWindowClass *klass);
static void window_populate (YelpWindow *window);
static gboolean window_handle_uri (YelpWindow *window,
- YelpURI *uri);
+ YelpURI *uri);
static void window_uri_selected_cb (gpointer view,
- YelpURI *uri,
- gboolean handled,
- YelpWindow *window);
+ YelpURI *uri,
+ gboolean handled,
+ YelpWindow *window);
+static void window_title_changed_cb (gpointer view,
+ const gchar *title,
+ YelpWindow *window);
static void window_toggle_history_back (YelpHistory *history,
- gboolean sensitive,
- YelpWindow *window);
-
+ gboolean sensitive,
+ YelpWindow *window);
+
static void window_toggle_history_forward (YelpHistory *history,
gboolean sensitive,
YelpWindow *window);
static void window_history_action (YelpWindow *window,
YelpHistoryAction action);
-static void window_back_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void window_forward_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void window_home_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void window_index_button_clicked (GtkWidget *button,
- YelpWindow *window);
-static void window_new_window_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void window_close_window_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void window_history_go_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void window_go_home_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void window_go_index_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static void window_about_cb (gpointer data,
- guint section,
- GtkWidget *widget);
-static GtkWidget * window_create_toolbar (YelpWindow *window);
-
-static void window_toolbar_style_changed_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data);
+static void window_back_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void window_forward_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void window_home_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void window_index_button_clicked (GtkWidget *button,
+ YelpWindow *window);
+static void window_new_window_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void window_close_window_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void window_history_go_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void window_go_home_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void window_go_index_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static void window_about_cb (gpointer data,
+ guint section,
+ GtkWidget *widget);
+static GtkWidget * window_create_toolbar (YelpWindow *window);
+
+static void window_toolbar_style_changed_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data);
#if 0
-static void window_remove_notify_cb (GtkObject *obj,
- gpointer data);
+static void window_remove_notify_cb (GtkObject *obj,
+ gpointer data);
#endif
enum {
@@ -413,6 +416,21 @@ window_uri_selected_cb (gpointer view,
}
static void
+window_title_changed_cb (gpointer view, const gchar *title, YelpWindow *window)
+{
+ gchar *new_title;
+
+ g_return_if_fail (title != NULL);
+ g_return_if_fail (YELP_IS_WINDOW (window));
+
+ new_title = g_strconcat (_("Help Browser"), ":", title, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (window), new_title);
+
+ g_free (new_title);
+}
+
+static void
window_toggle_history_back (YelpHistory *history,
gboolean sensitive,
YelpWindow *window)
@@ -746,10 +764,18 @@ yelp_window_new (GNode *doc_tree, GList *index)
G_CALLBACK (window_uri_selected_cb),
window);
+ g_signal_connect (priv->toc_view, "title_changed",
+ G_CALLBACK (window_title_changed_cb),
+ window);
+
g_signal_connect (priv->content_view, "uri_selected",
G_CALLBACK (window_uri_selected_cb),
window);
+ g_signal_connect (priv->content_view, "title_changed",
+ G_CALLBACK (window_title_changed_cb),
+ window);
+
window_populate (window);
yelp_window_open_uri (window, "toc:");