diff options
author | Mikael Hallendal <micke@codefactory.se> | 2002-03-03 01:37:37 +0000 |
---|---|---|
committer | Mikael Hallendal <hallski@src.gnome.org> | 2002-03-03 01:37:37 +0000 |
commit | 8d0265d777cd68c75efbfd9e42267711902a90dc (patch) | |
tree | 54a554b3a5515e8e97fe547fe79da6e76856465b | |
parent | 9bb790e63177da7f80dc51bf78ae67e9c282ca5a (diff) | |
download | yelp-8d0265d777cd68c75efbfd9e42267711902a90dc.tar.gz |
check if url starts with index:, if so, let YelpViewIndex handle it.
2002-03-03 Mikael Hallendal <micke@codefactory.se>
* src/yelp-window.c:
(yw_handle_url): check if url starts with index:, if so, let
YelpViewIndex handle it.
(yelp_window_new): connect to url_selected on YelpViewIndex.
* src/yelp-view-index.c:
- added URL_SELECTED signal.
(yvi_index_selection_changed_cb): emit url_selected.
(yvi_entry_activated_cb): fixed warning.
(yvi_filter_idle): same.
(yelp_view_index_show_uri): added/impl.
* src/yelp-view-content.c: removed the title-changed signal for
now. I should really make all views derive from the same
object. Lots of things are similar. (at least for YelpViewIndex
and YelpViewContent.
* src/yelp-scrollkeeper.c:
(ys_parse_index_item):
- add a ? before the link.
- add a index: before the uri
The uri will now be index:ghelp:... (not soo nice but it's to
make the window know which view it is).
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | src/yelp-index-model.c | 2 | ||||
-rw-r--r-- | src/yelp-scrollkeeper.c | 15 | ||||
-rw-r--r-- | src/yelp-view-content.c | 14 | ||||
-rw-r--r-- | src/yelp-view-content.h | 13 | ||||
-rw-r--r-- | src/yelp-view-index.c | 62 | ||||
-rw-r--r-- | src/yelp-view-index.h | 10 | ||||
-rw-r--r-- | src/yelp-window.c | 11 |
8 files changed, 107 insertions, 46 deletions
@@ -1,3 +1,29 @@ +2002-03-03 Mikael Hallendal <micke@codefactory.se> + + * src/yelp-window.c: + (yw_handle_url): check if url starts with index:, if so, let + YelpViewIndex handle it. + (yelp_window_new): connect to url_selected on YelpViewIndex. + + * src/yelp-view-index.c: + - added URL_SELECTED signal. + (yvi_index_selection_changed_cb): emit url_selected. + (yvi_entry_activated_cb): fixed warning. + (yvi_filter_idle): same. + (yelp_view_index_show_uri): added/impl. + + * src/yelp-view-content.c: removed the title-changed signal for + now. I should really make all views derive from the same + object. Lots of things are similar. (at least for YelpViewIndex + and YelpViewContent. + + * src/yelp-scrollkeeper.c: + (ys_parse_index_item): + - add a ? before the link. + - add a index: before the uri + The uri will now be index:ghelp:... (not soo nice but it's to + make the window know which view it is). + 2002-03-02 Mikael Hallendal <micke@codefactory.se> * src/yelp-view-index.c: diff --git a/src/yelp-index-model.c b/src/yelp-index-model.c index b3f4f469..e9af0bfe 100644 --- a/src/yelp-index-model.c +++ b/src/yelp-index-model.c @@ -503,7 +503,7 @@ yelp_index_model_filter (YelpIndexModel *model, const gchar *string) path); gtk_tree_path_free (path); } - } + } else if (old_length < new_length) { /* Add rows old_length - new_length */ for (i = old_length; i < new_length; ++i) { diff --git a/src/yelp-scrollkeeper.c b/src/yelp-scrollkeeper.c index d833b17a..27724d5b 100644 --- a/src/yelp-scrollkeeper.c +++ b/src/yelp-scrollkeeper.c @@ -457,6 +457,7 @@ ys_parse_index_item (GList **index, YelpSection *section, xmlNode *node) xmlChar *link = NULL; YelpSection *index_section; xmlChar *xml_str; + gchar *index_uri; for (cur = node->xmlChildrenNode; cur; cur = cur->next) { if (!g_ascii_strcasecmp (cur->name, "title")) { @@ -472,7 +473,9 @@ ys_parse_index_item (GList **index, YelpSection *section, xmlNode *node) xmlFree (xml_str); } else if (!g_ascii_strcasecmp (cur->name, "link")) { - link = xmlGetProp (cur, "linkid"); + xml_str = xmlGetProp (cur, "linkid"); + link = g_strconcat ("?", xml_str, NULL); + xmlFree (xml_str); } else if (!g_ascii_strcasecmp (cur->name, "indexitem")) { ys_parse_index_item (index, section, cur); @@ -480,14 +483,18 @@ ys_parse_index_item (GList **index, YelpSection *section, xmlNode *node) } if (title && link) { + index_uri = g_strconcat ("index:", section->uri, NULL); + index_section = yelp_section_new (YELP_SECTION_INDEX, - title, section->uri, + title, index_uri, link, NULL); + g_free (index_uri); + *index = g_list_prepend (*index, index_section); - xmlFree (title); - xmlFree (link); + g_free (title); + g_free (link); } } diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c index 9dcb2346..2a32deb1 100644 --- a/src/yelp-view-content.c +++ b/src/yelp-view-content.c @@ -44,7 +44,6 @@ static void yvc_tree_selection_changed_cb (GtkTreeSelection *selection, enum { URL_SELECTED, - TITLE_CHANGED, LAST_SIGNAL }; @@ -144,17 +143,6 @@ yvc_class_init (YelpViewContentClass *klass) yelp_marshal_VOID__STRING_STRING_BOOLEAN, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, 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 @@ -350,7 +338,7 @@ yelp_view_content_show_uri (YelpViewContent *content, content_url = (char *) url; } - yelp_html_open_uri (YELP_HTML (content->priv->html_view), + yelp_html_open_uri (YELP_HTML (priv->html_view), content_url, NULL); if (content_url != url) { diff --git a/src/yelp-view-content.h b/src/yelp-view-content.h index 0674cd7f..0284c54b 100644 --- a/src/yelp-view-content.h +++ b/src/yelp-view-content.h @@ -51,25 +51,12 @@ struct _YelpViewContentClass { gchar *url, gchar *base_url, gboolean handled); - - void (*title_changed) (YelpViewContent *view, - const gchar *title); - - /* Signal when icon is clicked. */ }; GType yelp_view_content_get_type (void); GtkWidget *yelp_view_content_new (GNode *doc_tree); -#if 0 -void yelp_view_content_show_path (YelpViewContent *content, - GtkTreePath *path); -#endif void yelp_view_content_show_uri (YelpViewContent *content, const gchar *uri); -#if 0 -gboolean yelp_view_content_set_root (YelpViewContent *content, - GtkTreePath *path); -#endif #endif /* __YELP_VIEW_CONTENT__ */ diff --git a/src/yelp-view-index.c b/src/yelp-view-index.c index 2bd97098..ff2b5812 100644 --- a/src/yelp-view-index.c +++ b/src/yelp-view-index.c @@ -30,6 +30,7 @@ #include "yelp-index-model.h" #include "yelp-html.h" +#include "yelp-marshal.h" #include "yelp-view-index.h" static void yvi_init (YelpViewIndex *view); @@ -70,6 +71,13 @@ struct _YelpViewIndexPriv { guint idle_filter; }; +enum { + URL_SELECTED, + LAST_SIGNAL +}; + +static gint signals[LAST_SIGNAL] = { 0 }; + GType yelp_view_index_get_type (void) { @@ -128,7 +136,16 @@ yvi_init (YelpViewIndex *view) static void yvi_class_init (YelpViewIndexClass *klass) { - + signals[URL_SELECTED] = + g_signal_new ("url_selected", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (YelpViewIndexClass, + url_selected), + NULL, NULL, + yelp_marshal_VOID__STRING_STRING_BOOLEAN, + G_TYPE_NONE, + 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); } static void @@ -149,14 +166,8 @@ yvi_index_selection_changed_cb (GtkTreeSelection *selection, YELP_INDEX_MODEL_COL_SECTION, §ion, -1); - /* FIXME: Emit index:string */ - - yelp_html_open_uri (YELP_HTML (priv->html_view), - section->uri, - section->reference); - -/* g_signal_emit (view, signals[URL_SELECTED], 0, */ -/* section->reference, section->uri, FALSE); */ + g_signal_emit (view, signals[URL_SELECTED], 0, + section->reference, section->uri, FALSE); } } @@ -192,11 +203,17 @@ yvi_entry_changed_cb (GtkEntry *entry, YelpViewIndex *view) static void yvi_entry_activated_cb (GtkEntry *entry, YelpViewIndex *view) { + YelpViewIndexPriv *priv; + gchar *str; + g_return_if_fail (GTK_IS_ENTRY (entry)); g_return_if_fail (YELP_IS_VIEW_INDEX (view)); + + priv = view->priv; + + str = (gchar *) gtk_entry_get_text (GTK_ENTRY (priv->entry)); - yelp_index_model_filter (view->priv->model, - gtk_entry_get_text (view->priv->entry)); + yelp_index_model_filter (view->priv->model, str); } static void @@ -256,13 +273,15 @@ static gboolean yvi_filter_idle (YelpViewIndex *view) { YelpViewIndexPriv *priv; + gchar *str; g_return_val_if_fail (YELP_IS_VIEW_INDEX (view), FALSE); priv = view->priv; + + str = (gchar *) gtk_entry_get_text (GTK_ENTRY (priv->entry)); - yelp_index_model_filter (view->priv->model, - gtk_entry_get_text (priv->entry)); + yelp_index_model_filter (view->priv->model, str); priv->idle_filter = 0; @@ -365,3 +384,20 @@ yelp_view_index_new (GList *index) return GTK_WIDGET (view); } + +void +yelp_view_index_show_uri (YelpViewIndex *view, const gchar *uri) +{ + YelpViewIndexPriv *priv; + gchar *real_uri; + + g_return_if_fail (YELP_IS_VIEW_INDEX (view)); + g_return_if_fail (uri != NULL); + g_return_if_fail (strncmp (uri, "index:", 6) == 0); + + priv = view->priv; + + real_uri = uri + 6; + + yelp_html_open_uri (YELP_HTML (priv->html_view), real_uri, NULL); +} diff --git a/src/yelp-view-index.h b/src/yelp-view-index.h index 0e031f1c..8824adf0 100644 --- a/src/yelp-view-index.h +++ b/src/yelp-view-index.h @@ -48,10 +48,16 @@ struct _YelpViewIndexClass { /* Signals */ - /* Signal when icon is clicked. */ + void (*url_selected) (YelpViewIndex *view, + gchar *url, + gchar *base_url, + gboolean handled); }; GType yelp_view_index_get_type (void); -GtkWidget *yelp_view_index_new (GList *index); +GtkWidget *yelp_view_index_new (GList *index); + +void yelp_view_index_show_uri (YelpViewIndex *view, + const gchar *uri); #endif /* __YELP_VIEW_INDEX__ */ diff --git a/src/yelp-window.c b/src/yelp-window.c index 82972506..9c20b223 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -318,6 +318,12 @@ yw_handle_url (YelpWindow *window, const gchar *url) yelp_view_content_show_uri (YELP_VIEW_CONTENT (priv->content_view), url); return TRUE; + } else if (strncmp (url, "index:", 6) == 0) { + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), + PAGE_INDEX_VIEW); + yelp_view_index_show_uri (YELP_VIEW_INDEX (priv->index_view), + url); + return TRUE; } else { /* FIXME: Show dialog on failure? */ gnome_url_show (url, NULL); @@ -336,6 +342,7 @@ yw_url_selected_cb (gpointer view, YelpWindowPriv *priv; gchar *abs_url = NULL; + g_return_if_fail (YELP_IS_WINDOW (window)); d(g_print ("url_selected: %s base: %s, handled: %d\n", url, base_url, handled)); @@ -344,6 +351,7 @@ yw_url_selected_cb (gpointer view, if (url && base_url) { abs_url = yelp_util_resolve_relative_uri (base_url, url); + d(g_print ("Link '%s' pressed relative to: %s -> %s\n", url, base_url, @@ -644,6 +652,9 @@ yelp_window_new (GNode *doc_tree, GList *index) g_signal_connect (priv->content_view, "url_selected", G_CALLBACK (yw_url_selected_cb), window); + g_signal_connect (priv->index_view, "url_selected", + G_CALLBACK (yw_url_selected_cb), + window); yw_populate (window); |