summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@src.gnome.org>2005-01-02 13:14:10 +0000
committerShaun McCance <shaunm@src.gnome.org>2005-01-02 13:14:10 +0000
commitc8bd49284f2be0c491a2287b45ffab4f0bce2a73 (patch)
treef9e9d4b83255cb4883daa2c40876f3de96361032
parenta0652ef8be5eaf4e34ccef34358fd79ef6b5509d (diff)
downloadyelp-c8bd49284f2be0c491a2287b45ffab4f0bce2a73.tar.gz
- Set the params correct for current stylesheets - Removed 'Titlepage'
* data/ui/yelp-ui.xml: * src/yelp-db-pager.c: * src/yelp-window.c: - Set the params correct for current stylesheets - Removed 'Titlepage' from the sidebar - Added 'About This Document' menu item - Got titles working correctly for DocBook * src/yelp-bookmarks.c: - Got the tree view working correctly for bookmarks
-rw-r--r--ChangeLog13
-rw-r--r--data/ui/yelp-ui.xml4
-rw-r--r--src/yelp-bookmarks.c68
-rw-r--r--src/yelp-db-pager.c95
-rw-r--r--src/yelp-window.c54
-rw-r--r--src/yelp-xslt-pager.c1
6 files changed, 123 insertions, 112 deletions
diff --git a/ChangeLog b/ChangeLog
index ccc42c03..12bf2b4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2005-01-02 Shaun McCance <shaunm@gnome.org>
+
+ * data/ui/yelp-ui.xml:
+ * src/yelp-db-pager.c:
+ * src/yelp-window.c:
+ - Set the params correct for current stylesheets
+ - Removed 'Titlepage' from the sidebar
+ - Added 'About This Document' menu item
+ - Got titles working correctly for DocBook
+
+ * src/yelp-bookmarks.c:
+ - Got the tree view working correctly for bookmarks
+
2005-01-02 Davyd Madeley <davyd@madeley.id.au>
* src/yelp-info-pager.c:
diff --git a/data/ui/yelp-ui.xml b/data/ui/yelp-ui.xml
index 419b7bfc..5011afe2 100644
--- a/data/ui/yelp-ui.xml
+++ b/data/ui/yelp-ui.xml
@@ -3,11 +3,13 @@
<menubar>
<menu action="FileMenu">
<menuitem action="NewWindow"/>
+ <separator/>
+ <menuitem action="AboutDocument"/>
+ <separator/>
<menuitem action="CloseWindow"/>
</menu>
<menu action="EditMenu">
<menuitem action="Copy"/>
- <separator/>
<menuitem action="SelectAll"/>
<separator/>
<menuitem action="Find"/>
diff --git a/src/yelp-bookmarks.c b/src/yelp-bookmarks.c
index a938045d..2f99e8c4 100644
--- a/src/yelp-bookmarks.c
+++ b/src/yelp-bookmarks.c
@@ -53,6 +53,10 @@ static GSList *windows;
static GtkListStore *actions_store;
static gboolean dup_flag;
+static gboolean have_tocs = FALSE;
+static gboolean have_docs = FALSE;
+static GtkTreeIter *seperator_iter = NULL;
+
typedef struct _YelpWindowData YelpWindowData;
struct _YelpWindowData {
YelpWindow *window;
@@ -90,9 +94,9 @@ void bookmarks_key_event_cb (GtkWidget *widget,
static gboolean bookmarks_read (void);
-void bookmarks_add_seperator (void);
+static void bookmarks_add_seperator (void);
-gboolean bookmarks_dup_finder (GtkTreeModel *model,
+static gboolean bookmarks_dup_finder (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data);
@@ -110,16 +114,6 @@ yelp_bookmarks_init (void)
G_TYPE_BOOLEAN);
read = bookmarks_read ();
-
- if (!read) {
- gtk_list_store_append (actions_store, &iter);
-
- gtk_list_store_set (actions_store, &iter,
- COL_NAME, NULL,
- COL_LABEL, NULL,
- COL_SEP, TRUE,
- -1);
- }
}
void
@@ -175,19 +169,26 @@ yelp_bookmarks_register (YelpWindow *window)
windows = g_slist_append (windows, data);
}
-void bookmarks_add_seperator (void)
+static void
+bookmarks_add_seperator (void)
{
GtkTreeIter iter;
- gtk_list_store_append (actions_store, &iter);
- gtk_list_store_set (actions_store, &iter,
- COL_NAME, NULL,
- COL_LABEL, NULL,
- COL_SEP, TRUE,
- -1);
+ if (seperator_iter == NULL) {
+ if (have_tocs)
+ gtk_list_store_append (actions_store, &iter);
+ else
+ gtk_list_store_prepend (actions_store, &iter);
+ gtk_list_store_set (actions_store, &iter,
+ COL_NAME, NULL,
+ COL_LABEL, NULL,
+ COL_SEP, TRUE,
+ -1);
+ seperator_iter = gtk_tree_iter_copy (&iter);
+ }
}
-gboolean
+static gboolean
bookmarks_dup_finder (GtkTreeModel *model, GtkTreePath *path,
GtkTreeIter *iter, gpointer data)
{
@@ -208,12 +209,34 @@ void yelp_bookmarks_add (gchar *uri, const gchar *title, gboolean save)
{
GtkTreeIter iter;
GSList *cur;
+ gboolean tocQ;
dup_flag = FALSE;
gtk_tree_model_foreach (GTK_TREE_MODEL (actions_store),
bookmarks_dup_finder, uri);
if (!dup_flag) {
- gtk_list_store_append (actions_store, &iter);
+ tocQ = g_str_has_prefix (uri, "x-yelp-toc:");
+
+ if (tocQ) {
+ if (seperator_iter == NULL) {
+ if (have_docs) {
+ bookmarks_add_seperator ();
+ gtk_list_store_prepend (actions_store, &iter);
+ } else {
+ gtk_list_store_append (actions_store, &iter);
+ }
+ } else {
+ gtk_list_store_insert_before (actions_store,
+ &iter, seperator_iter);
+ }
+ have_tocs = TRUE;
+ } else {
+ if (seperator_iter == NULL && have_tocs)
+ bookmarks_add_seperator ();
+ gtk_list_store_append (actions_store, &iter);
+ have_docs = TRUE;
+ }
+
gtk_list_store_set (actions_store, &iter,
COL_NAME, uri,
COL_LABEL, title,
@@ -540,9 +563,6 @@ bookmarks_read (void)
if (name && title) {
yelp_bookmarks_add (name, title, FALSE);
}
- else if (sep) {
- bookmarks_add_seperator ();
- }
g_free (name);
g_free (title);
g_free (sep);
diff --git a/src/yelp-db-pager.c b/src/yelp-db-pager.c
index a688fd38..7c53ec46 100644
--- a/src/yelp-db-pager.c
+++ b/src/yelp-db-pager.c
@@ -95,7 +95,6 @@ static void walker_walk_xml (DBWalker *walker);
static gboolean walker_is_chunk (DBWalker *walker);
static gboolean xml_is_division (xmlNodePtr node);
-static gboolean xml_is_info (xmlNodePtr node);
static gchar * xml_get_title (xmlNodePtr node);
static YelpPagerClass *parent_class;
@@ -189,6 +188,10 @@ yelp_db_pager_new (YelpDocInfo *doc_info)
"document-info", doc_info,
NULL);
+ g_hash_table_insert (pager->priv->frags_hash,
+ g_strdup ("x-yelp-titlepage"),
+ g_strdup ("x-yelp-titlepage"));
+
if (!pager->priv->sects)
pager->priv->sects =
GTK_TREE_MODEL (gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
@@ -307,14 +310,10 @@ db_pager_params (YelpPager *pager)
params_max += 20;
params = g_renew (gchar *, params, params_max);
}
- params[params_i++] = "stylesheet_path";
- params[params_i++] = g_strdup_printf ("\"file://%s\"", DB_STYLESHEET_PATH);
- params[params_i++] = "html_extension";
+ params[params_i++] = "db.chunk.extension";
params[params_i++] = g_strdup ("\"\"");
- params[params_i++] = "resolve_xref_chunk";
- params[params_i++] = g_strdup ("0");
- params[params_i++] = "admon_graphics_path";
- params[params_i++] = g_strdup_printf ("\"file://%s\"", DATADIR "/yelp/icons/");
+ params[params_i++] = "db.chunk.info_basename";
+ params[params_i++] = g_strdup ("\"x-yelp-titlepage\"");
params[params_i] = NULL;
@@ -401,21 +400,11 @@ walker_walk_xml (DBWalker *walker)
}
if (walker_is_chunk (walker)) {
- if (xml_is_info (walker->cur)) {
- if (id)
- xmlFree (id);
- id = xmlStrdup ("titlepage");
- }
-
title = xml_get_title (walker->cur);
if (id) {
- if (xml_is_info (walker->cur))
- gtk_tree_store_prepend (GTK_TREE_STORE (priv->sects),
- &iter, walker->iter);
- else
- gtk_tree_store_append (GTK_TREE_STORE (priv->sects),
- &iter, walker->iter);
+ gtk_tree_store_append (GTK_TREE_STORE (priv->sects),
+ &iter, walker->iter);
gtk_tree_store_set (GTK_TREE_STORE (priv->sects),
&iter,
@@ -427,11 +416,9 @@ walker_walk_xml (DBWalker *walker)
walker->page_id = id;
old_iter = walker->iter;
- if (!xml_is_info (walker->cur) &&
- walker->cur->parent->type != XML_DOCUMENT_NODE) {
- walker->iter = &iter;
- }
+ if (walker->cur->parent->type != XML_DOCUMENT_NODE)
+ walker->iter = &iter;
}
}
@@ -479,23 +466,19 @@ xml_get_title (xmlNodePtr node)
gchar *ret = NULL;
xmlNodePtr cur;
- if (xml_is_info (node))
- title = g_strdup (_("Titlepage"));
- else if (node->parent && node->parent->type == XML_DOCUMENT_NODE)
- title = g_strdup (_("Contents"));
- else {
- for (cur = node->children; cur; cur = cur->next) {
- if (!xmlStrcmp (cur->name, (xmlChar *) "title")) {
- if (title)
- g_free (title);
- title = xmlNodeGetContent (cur);
- }
- else if (!xmlStrcmp (cur->name, (xmlChar *) "titleabbrev")) {
- if (title)
- g_free (title);
- title = xmlNodeGetContent (cur);
- break;
- }
+ /* FIXME: this needs so much work */
+
+ for (cur = node->children; cur; cur = cur->next) {
+ if (!xmlStrcmp (cur->name, (xmlChar *) "title")) {
+ if (title)
+ g_free (title);
+ title = xmlNodeGetContent (cur);
+ }
+ else if (!xmlStrcmp (cur->name, (xmlChar *) "titleabbrev")) {
+ if (title)
+ g_free (title);
+ title = xmlNodeGetContent (cur);
+ break;
}
}
@@ -515,8 +498,6 @@ walker_is_chunk (DBWalker *walker)
if (walker->depth <= walker->max_depth) {
if (xml_is_division (walker->cur))
return TRUE;
- else if (walker->depth == 1 && xml_is_info (walker->cur))
- return TRUE;
}
return FALSE;
}
@@ -550,31 +531,3 @@ xml_is_division (xmlNodePtr node)
!xmlStrcmp (node->name, (const xmlChar *) "setindex") ||
!xmlStrcmp (node->name, (const xmlChar *) "simplesect") );
}
-
-gboolean
-xml_is_info (xmlNodePtr node)
-{
- return (!xmlStrcmp (node->name, (const xmlChar *) "appendixinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "articleinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "bookinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "bibliographyinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "chapterinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "glossaryinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "indexinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "partinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "prefaceinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "referenceinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "refentryinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "refsect1info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "refsect2info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "refsect3info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "refsectioninfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "sect1info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "sect2info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "sect3info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "sect4info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "sect5info") ||
- !xmlStrcmp (node->name, (const xmlChar *) "sectioninfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "setinfo") ||
- !xmlStrcmp (node->name, (const xmlChar *) "setindexinfo") );
-}
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 9ae483e2..1d2a7eb4 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -160,6 +160,7 @@ static void window_add_widget (GtkUIManager *ui_manager,
GtkWidget *widget,
GtkWidget *vbox);
static void window_new_window_cb (GtkAction *action, YelpWindow *window);
+static void window_about_document_cb (GtkAction *action, YelpWindow *window);
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);
@@ -305,17 +306,22 @@ static GtkActionEntry entries[] = {
{ "HelpMenu", NULL, N_("_Help") },
{ "NewWindow", GTK_STOCK_NEW,
- N_("_New window"),
+ N_("_New Window"),
"<Control>N",
NULL,
G_CALLBACK (window_new_window_cb) },
+ { "AboutDocument", NULL,
+ N_("About This Document"),
+ NULL,
+ NULL,
+ G_CALLBACK (window_about_document_cb) },
{ "OpenLocation", NULL,
N_("Open _Location"),
"<Control>L",
NULL,
G_CALLBACK (window_open_location_cb) },
{ "CloseWindow", GTK_STOCK_CLOSE,
- N_("_Close window"),
+ N_("_Close Window"),
"<Control>W",
NULL,
G_CALLBACK (window_close_window_cb) },
@@ -945,11 +951,13 @@ window_populate (YelpWindow *window)
"text", YELP_PAGER_COLUMN_TITLE,
NULL);
+ /* DISABLE FOR NOW
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (priv->side_sects),
GDK_BUTTON1_MASK,
row_targets,
G_N_ELEMENTS (row_targets),
GDK_ACTION_LINK);
+ */
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->side_sects));
@@ -1376,6 +1384,13 @@ window_handle_page (YelpWindow *window,
pager = yelp_doc_info_get_pager (priv->current_doc);
if (model) {
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->side_sects));
+ g_signal_handlers_block_by_func (selection,
+ tree_selection_changed_cb,
+ window);
+ gtk_tree_selection_unselect_all (selection);
+
valid = gtk_tree_model_get_iter_first (model, &iter);
while (valid) {
gtk_tree_model_get (model, &iter,
@@ -1385,21 +1400,11 @@ window_handle_page (YelpWindow *window,
id,
priv->current_frag)) {
GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
- GtkTreeSelection *selection =
- gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->side_sects));
-
- g_signal_handlers_block_by_func (selection,
- tree_selection_changed_cb,
- window);
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->side_sects),
path);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->side_sects),
- path, NULL, FALSE);
+ gtk_tree_selection_select_path (selection, path);
- g_signal_handlers_unblock_by_func (selection,
- tree_selection_changed_cb,
- window);
gtk_tree_path_free (path);
g_free (id);
break;
@@ -1409,6 +1414,9 @@ window_handle_page (YelpWindow *window,
valid = tree_model_iter_following (model, &iter);
}
+ g_signal_handlers_unblock_by_func (selection,
+ tree_selection_changed_cb,
+ window);
}
priv->prev_id = page->prev_id;
@@ -1433,9 +1441,6 @@ window_handle_page (YelpWindow *window,
priv->toc_id ? TRUE : FALSE,
NULL);
- gtk_window_set_title (GTK_WINDOW (window),
- (const gchar *) page->title);
-
context = g_new0 (IdleWriterContext, 1);
context->window = window;
context->type = IDLE_WRITER_MEMORY;
@@ -1785,6 +1790,23 @@ window_new_window_cb (GtkAction *action, YelpWindow *window)
}
static void
+window_about_document_cb (GtkAction *action, YelpWindow *window)
+{
+ YelpWindowPriv *priv;
+ gchar *uri;
+
+ g_return_if_fail (YELP_IS_WINDOW (window));
+
+ priv = window->priv;
+
+ uri = yelp_doc_info_get_uri (priv->current_doc,
+ "x-yelp-titlepage",
+ YELP_URI_TYPE_ANY);
+ yelp_window_load (window, uri);
+ g_free (uri);
+}
+
+static void
window_open_location_cb (GtkAction *action, YelpWindow *window)
{
YelpWindowPriv *priv;
diff --git a/src/yelp-xslt-pager.c b/src/yelp-xslt-pager.c
index 5ec99d22..e781b4cb 100644
--- a/src/yelp-xslt-pager.c
+++ b/src/yelp-xslt-pager.c
@@ -363,6 +363,7 @@ xslt_yelp_document (xsltTransformContextPtr ctxt,
if (page_id == NULL) {
xsltTransformError (ctxt, NULL, inst,
_("No href attribute found on yelp:document"));
+ /* FIXME: put a real error here */
error = NULL;
yelp_pager_error (pager, error);
goto done;