diff options
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | data/icons/Makefile.am | 2 | ||||
-rw-r--r-- | data/icons/hicolor/16x16/Makefile.am | 1 | ||||
-rw-r--r-- | data/icons/hicolor/16x16/status/Makefile.am | 9 | ||||
-rw-r--r-- | data/icons/hicolor/16x16/status/yelp-page-task.png | bin | 0 -> 298 bytes | |||
-rw-r--r-- | data/icons/hicolor/16x16/status/yelp-page-tip.png | bin | 0 -> 671 bytes | |||
-rw-r--r-- | data/icons/hicolor/16x16/status/yelp-page-ui.png | bin | 0 -> 230 bytes | |||
-rw-r--r-- | data/icons/hicolor/16x16/status/yelp-page-video.png | bin | 0 -> 230 bytes | |||
-rw-r--r-- | data/icons/hicolor/Makefile.am | 1 | ||||
-rw-r--r-- | libyelp/yelp-document.c | 35 | ||||
-rw-r--r-- | libyelp/yelp-document.h | 6 | ||||
-rw-r--r-- | libyelp/yelp-location-entry.c | 2 | ||||
-rw-r--r-- | libyelp/yelp-mallard-document.c | 29 | ||||
-rw-r--r-- | libyelp/yelp-settings.c | 9 | ||||
-rw-r--r-- | libyelp/yelp-view.c | 23 | ||||
-rw-r--r-- | src/yelp-window.c | 35 |
16 files changed, 151 insertions, 4 deletions
diff --git a/configure.in b/configure.in index 3b62e972..399dee52 100644 --- a/configure.in +++ b/configure.in @@ -270,6 +270,9 @@ stylesheets/mal2html.xsl stylesheets/toc2html.xsl data/Makefile data/icons/Makefile +data/icons/hicolor/Makefile +data/icons/hicolor/16x16/Makefile +data/icons/hicolor/16x16/status/Makefile data/ui/Makefile po/Makefile.in tests/Makefile diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am index 94bedc35..161f5665 100644 --- a/data/icons/Makefile.am +++ b/data/icons/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = hicolor + icon192dir = $(datadir)/icons/hicolor/192x192/apps icon192_DATA = yelp-icon-big.png diff --git a/data/icons/hicolor/16x16/Makefile.am b/data/icons/hicolor/16x16/Makefile.am new file mode 100644 index 00000000..d52da2b9 --- /dev/null +++ b/data/icons/hicolor/16x16/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = status diff --git a/data/icons/hicolor/16x16/status/Makefile.am b/data/icons/hicolor/16x16/status/Makefile.am new file mode 100644 index 00000000..8c0f341d --- /dev/null +++ b/data/icons/hicolor/16x16/status/Makefile.am @@ -0,0 +1,9 @@ +icondir = $(datadir)/yelp/icons/hicolor/16x16/status + +icon_DATA = \ + yelp-page-task.png \ + yelp-page-tip.png \ + yelp-page-ui.png \ + yelp-page-video.png + +EXTRA_DIST = $(icon_DATA) diff --git a/data/icons/hicolor/16x16/status/yelp-page-task.png b/data/icons/hicolor/16x16/status/yelp-page-task.png Binary files differnew file mode 100644 index 00000000..1d9c2796 --- /dev/null +++ b/data/icons/hicolor/16x16/status/yelp-page-task.png diff --git a/data/icons/hicolor/16x16/status/yelp-page-tip.png b/data/icons/hicolor/16x16/status/yelp-page-tip.png Binary files differnew file mode 100644 index 00000000..cc005843 --- /dev/null +++ b/data/icons/hicolor/16x16/status/yelp-page-tip.png diff --git a/data/icons/hicolor/16x16/status/yelp-page-ui.png b/data/icons/hicolor/16x16/status/yelp-page-ui.png Binary files differnew file mode 100644 index 00000000..79609692 --- /dev/null +++ b/data/icons/hicolor/16x16/status/yelp-page-ui.png diff --git a/data/icons/hicolor/16x16/status/yelp-page-video.png b/data/icons/hicolor/16x16/status/yelp-page-video.png Binary files differnew file mode 100644 index 00000000..324fdda1 --- /dev/null +++ b/data/icons/hicolor/16x16/status/yelp-page-video.png diff --git a/data/icons/hicolor/Makefile.am b/data/icons/hicolor/Makefile.am new file mode 100644 index 00000000..9eb5fc4d --- /dev/null +++ b/data/icons/hicolor/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = 16x16 diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c index 7914b3bb..d30e4027 100644 --- a/libyelp/yelp-document.c +++ b/libyelp/yelp-document.c @@ -67,6 +67,7 @@ struct _YelpDocumentPriv { Hash *page_ids; /* Mapping of fragment IDs to real page IDs */ Hash *titles; /* Mapping of page IDs to titles */ Hash *descs; /* Mapping of page IDs to descs */ + Hash *icons; /* Mapping of page IDs to icons */ Hash *mime_types; /* Mapping of page IDs to mime types */ Hash *contents; /* Mapping of page IDs to string content */ @@ -227,6 +228,7 @@ yelp_document_init (YelpDocument *document) priv->page_ids = hash_new (g_free ); priv->titles = hash_new (g_free); priv->descs = hash_new (g_free); + priv->icons = hash_new (g_free); priv->mime_types = hash_new (g_free); priv->contents = hash_new ((GDestroyNotify) str_unref); @@ -263,6 +265,7 @@ yelp_document_finalize (GObject *object) hash_free (document->priv->page_ids); hash_free (document->priv->titles); hash_free (document->priv->descs); + hash_free (document->priv->icons); hash_free (document->priv->mime_types); hash_free (document->priv->contents); @@ -575,6 +578,38 @@ yelp_document_set_page_desc (YelpDocument *document, g_mutex_unlock (document->priv->mutex); } +gchar * +yelp_document_get_page_icon (YelpDocument *document, + const gchar *page_id) +{ + gchar *real, *ret = NULL; + + g_assert (document != NULL && YELP_IS_DOCUMENT (document)); + + g_mutex_lock (document->priv->mutex); + real = hash_lookup (document->priv->page_ids, page_id); + if (real) { + ret = hash_lookup (document->priv->icons, real); + if (ret) + ret = g_strdup (ret); + } + g_mutex_unlock (document->priv->mutex); + + return ret; +} + +gchar * +yelp_document_set_page_icon (YelpDocument *document, + const gchar *page_id, + const gchar *icon) +{ + g_assert (document != NULL && YELP_IS_DOCUMENT (document)); + + g_mutex_lock (document->priv->mutex); + hash_replace (document->priv->icons, page_id, g_strdup (icon)); + g_mutex_unlock (document->priv->mutex); +} + /******************************************************************************/ gboolean diff --git a/libyelp/yelp-document.h b/libyelp/yelp-document.h index 4366a485..d9f30af2 100644 --- a/libyelp/yelp-document.h +++ b/libyelp/yelp-document.h @@ -143,6 +143,12 @@ void yelp_document_set_page_desc (YelpDocument *document, const gchar *page_id, const gchar *desc); +gchar * yelp_document_get_page_icon (YelpDocument *document, + const gchar *page_id); +gchar * yelp_document_set_page_icon (YelpDocument *document, + const gchar *page_id, + const gchar *icon); + gboolean yelp_document_has_page (YelpDocument *document, const gchar *page_id); diff --git a/libyelp/yelp-location-entry.c b/libyelp/yelp-location-entry.c index 6cd7a265..4cec1e5e 100644 --- a/libyelp/yelp-location-entry.c +++ b/libyelp/yelp-location-entry.c @@ -697,6 +697,8 @@ entry_focus_out_cb (GtkWidget *widget, priv->search_mode = FALSE; location_entry_set_entry ((YelpLocationEntry *) user_data, FALSE); } + + return FALSE; } static void diff --git a/libyelp/yelp-mallard-document.c b/libyelp/yelp-mallard-document.c index 7b3a0ee7..12f89ec6 100644 --- a/libyelp/yelp-mallard-document.c +++ b/libyelp/yelp-mallard-document.c @@ -459,11 +459,40 @@ mallard_page_data_walk (MallardPageData *page_data) NULL); if (xmlStrEqual (page_data->cur->name, BAD_CAST "page")) { + xmlChar *style; + gchar **styles; + gchar *icon = "help-contents"; page_data->page_id = g_strdup ((gchar *) id); xmlSetProp (page_data->cache, BAD_CAST "id", id); yelp_document_set_page_id ((YelpDocument *) page_data->mallard, g_strrstr (page_data->filename, G_DIR_SEPARATOR_S), page_data->page_id); + style = xmlGetProp (page_data->cur, BAD_CAST "style"); + if (style) { + gint i; + styles = g_strsplit (style, " ", -1); + for (i = 0; styles[i] != NULL; i++) { + if (g_str_equal (styles[i], "task")) { + icon = "yelp-page-task"; + break; + } + else if (g_str_equal (styles[i], "tip")) { + icon = "yelp-page-tip"; + break; + } + else if (g_str_equal (styles[i], "ui")) { + icon = "yelp-page-ui"; + break; + } + else if (g_str_equal (styles[i], "video")) { + icon = "yelp-page-video"; + break; + } + } + xmlFree (style); + } + yelp_document_set_page_icon ((YelpDocument *) page_data->mallard, + page_data->page_id, icon); } else { gchar *newid = g_strdup_printf ("%s#%s", page_data->page_id, id); xmlSetProp (page_data->cache, BAD_CAST "id", BAD_CAST newid); diff --git a/libyelp/yelp-settings.c b/libyelp/yelp-settings.c index 26034e1e..91c590a7 100644 --- a/libyelp/yelp-settings.c +++ b/libyelp/yelp-settings.c @@ -325,6 +325,15 @@ yelp_settings_set_property (GObject *object, if (append_search_path) gtk_icon_theme_append_search_path (settings->priv->gtk_icon_theme, YELP_ICON_PATH); + append_search_path = TRUE; + for (i = search_path_len - 1; i >= 0; i--) + if (g_str_equal (search_path[i], DATADIR"/yelp/icons")) { + append_search_path = FALSE; + break; + } + if (append_search_path) + gtk_icon_theme_append_search_path (settings->priv->gtk_icon_theme, + DATADIR"/yelp/icons"); g_object_ref (settings->priv->gtk_icon_theme); settings->priv->icon_theme_changed = g_signal_connect (settings->priv->gtk_icon_theme, diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c index 24a1220c..3971c805 100644 --- a/libyelp/yelp-view.c +++ b/libyelp/yelp-view.c @@ -87,7 +87,8 @@ enum { PROP_STATE, PROP_ROOT_TITLE, PROP_PAGE_TITLE, - PROP_PAGE_DESC + PROP_PAGE_DESC, + PROP_PAGE_ICON }; enum { @@ -116,6 +117,7 @@ struct _YelpViewPrivate { gchar *root_title; gchar *page_title; gchar *page_desc; + gchar *page_icon; gint navigation_requested; }; @@ -175,6 +177,7 @@ yelp_view_finalize (GObject *object) g_free (priv->root_title); g_free (priv->page_title); g_free (priv->page_desc); + g_free (priv->page_icon); g_free (priv->bogus_uri); @@ -275,6 +278,15 @@ yelp_view_class_init (YelpViewClass *klass) NULL, G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (object_class, + PROP_PAGE_ICON, + g_param_spec_string ("page-icon", + N_("Page Icon"), + N_("The icon of the page being viewed"), + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); } static void @@ -299,6 +311,9 @@ yelp_view_get_property (GObject *object, case PROP_PAGE_DESC: g_value_set_string (value, priv->page_desc); break; + case PROP_PAGE_ICON: + g_value_set_string (value, priv->page_icon); + break; case PROP_STATE: g_value_set_enum (value, priv->state); break; @@ -362,12 +377,15 @@ yelp_view_load_uri (YelpView *view, g_free (priv->root_title); g_free (priv->page_title); g_free (priv->page_desc); + g_free (priv->page_icon); priv->root_title = NULL; priv->page_title = NULL; priv->page_desc = NULL; + priv->page_icon = NULL; g_signal_emit_by_name (view, "notify::root-title", 0); g_signal_emit_by_name (view, "notify::page-title", 0); g_signal_emit_by_name (view, "notify::page-desc", 0); + g_signal_emit_by_name (view, "notify::page-icon", 0); priv->uri = g_object_ref (uri); if (!yelp_uri_is_resolved (uri)) { @@ -688,14 +706,17 @@ document_callback (YelpDocument *document, g_free (priv->root_title); g_free (priv->page_title); g_free (priv->page_desc); + g_free (priv->page_icon); priv->root_title = yelp_document_get_root_title (document, page_id); priv->page_title = yelp_document_get_page_title (document, page_id); priv->page_desc = yelp_document_get_page_desc (document, page_id); + priv->page_icon = yelp_document_get_page_icon (document, page_id); g_signal_emit_by_name (view, "notify::root-title", 0); g_signal_emit_by_name (view, "notify::page-title", 0); g_signal_emit_by_name (view, "notify::page-desc", 0); + g_signal_emit_by_name (view, "notify::page-icon", 0); } else if (signal == YELP_DOCUMENT_SIGNAL_CONTENTS) { const gchar *contents; diff --git a/src/yelp-window.c b/src/yelp-window.c index 0e5fbeb9..67d23a77 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -87,6 +87,9 @@ static void view_page_title (YelpView *view, static void view_page_desc (YelpView *view, GParamSpec *pspec, YelpWindow *window); +static void view_page_icon (YelpView *view, + GParamSpec *pspec, + YelpWindow *window); static void hidden_entry_activate (GtkEntry *entry, YelpWindow *window); @@ -306,6 +309,7 @@ yelp_window_init (YelpWindow *window) g_signal_connect (priv->view, "notify::root-title", G_CALLBACK (view_root_title), window); g_signal_connect (priv->view, "notify::page-title", G_CALLBACK (view_page_title), window); g_signal_connect (priv->view, "notify::page-desc", G_CALLBACK (view_page_desc), window); + g_signal_connect (priv->view, "notify::page-icon", G_CALLBACK (view_page_icon), window); gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (priv->view)); gtk_widget_grab_focus (GTK_WIDGET (priv->view)); } @@ -607,16 +611,18 @@ view_loaded (YelpView *view, gtk_list_store_clear (priv->completion); for (i = 0; ids[i]; i++) { GtkTreeIter iter; - gchar *title, *desc; + gchar *title, *desc, *icon; gtk_list_store_insert (GTK_LIST_STORE (priv->completion), &iter, 0); title = yelp_document_get_page_title (document, ids[i]); desc = yelp_document_get_page_desc (document, ids[i]); + icon = yelp_document_get_page_icon (document, ids[i]); gtk_list_store_set (priv->completion, &iter, COL_TITLE, title, COL_DESC, desc, - COL_ICON, "help-browser", + COL_ICON, icon, COL_URI, ids[i], -1); + g_free (icon); g_free (desc); g_free (title); } @@ -696,7 +702,7 @@ view_uri_selected (YelpView *view, gtk_list_store_prepend (priv->history, &iter); gtk_list_store_set (priv->history, &iter, COL_TITLE, _("Loading"), - COL_ICON, "help-browser", + COL_ICON, "help-contents", COL_URI, struri, -1); } @@ -772,6 +778,7 @@ view_page_title (YelpView *view, } } + g_free (title); g_object_unref (uri); } @@ -800,6 +807,28 @@ view_page_desc (YelpView *view, g_free (back->desc); back->desc = g_strdup (desc); } + + g_free (desc); +} + +static void +view_page_icon (YelpView *view, + GParamSpec *pspec, + YelpWindow *window) +{ + GtkTreeIter first; + gchar *icon; + YelpWindowPrivate *priv = GET_PRIV (window); + + g_object_get (view, "page-icon", &icon, NULL); + if (icon == NULL) + return; + + gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->history), &first); + gtk_list_store_set (priv->history, &first, + COL_ICON, icon, + -1); + g_free (icon); } static void |