diff options
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | idl/GNOME_Yelp.idl | 3 | ||||
-rw-r--r-- | src/yelp-base.c | 12 | ||||
-rw-r--r-- | src/yelp-main.c | 37 | ||||
-rw-r--r-- | src/yelp-marshal.list | 1 | ||||
-rw-r--r-- | src/yelp-util.c | 7 | ||||
-rw-r--r-- | src/yelp-util.h | 16 | ||||
-rw-r--r-- | src/yelp-view-content.c | 40 | ||||
-rw-r--r-- | src/yelp-view-content.h | 7 | ||||
-rw-r--r-- | src/yelp-window.c | 8 |
10 files changed, 115 insertions, 36 deletions
@@ -1,5 +1,25 @@ 2002-01-27 Mikael Hallendal <micke@codefactory.se> + * src/yelp-view-content.c: added title-changed signal. Shouldn't + perhaps be here. Will perhaps remove it and do it all from + YelpWindow. + + * src/yelp-util.[ch] (yelp_util_find_node_from_uri): added + unimpl. + + * src/yelp-marshal.list: added VOID:STRING + + * src/yelp-main.c (main): look if an extra argument was passed, if + it was send it to yelp_main_start. + (yelp_main_idle_start): take url as argument + (yelp_main_start): dito + (yelp_main_open_new_window): send url to GNOME_Yelp_newWindow + + * src/yelp-base.c (impl_Yelp_newWindow): take a url argument. If + it's not NULL it will open the window with that URI showing. + + * idl/GNOME_Yelp.idl (GNOME): newWindow now takes a url-argument. + * src/yelp-view-content.c (yelp_view_content_show_uri): - if uri starts with ghelp:, try to find the TOC for that document in scrollkeeper. If it's found, display it in the tree widget. diff --git a/idl/GNOME_Yelp.idl b/idl/GNOME_Yelp.idl index 9e8e2683..2f563f9c 100644 --- a/idl/GNOME_Yelp.idl +++ b/idl/GNOME_Yelp.idl @@ -8,9 +8,10 @@ module GNOME { interface Yelp : Bonobo::Unknown { - void newWindow (); + void newWindow (in string url); }; }; + diff --git a/src/yelp-base.c b/src/yelp-base.c index 095b83a7..e34a09d3 100644 --- a/src/yelp-base.c +++ b/src/yelp-base.c @@ -54,8 +54,9 @@ static void yelp_base_window_finalized_cb (YelpBase *base, static BonoboObjectClass *parent_class; static void -impl_Yelp_newWindow (PortableServer_Servant servant, - CORBA_Environment *ev) +impl_Yelp_newWindow (PortableServer_Servant servant, + const CORBA_char *url, + CORBA_Environment *ev) { YelpBase *yelp_base; GtkWidget *window; @@ -63,13 +64,18 @@ impl_Yelp_newWindow (PortableServer_Servant servant, yelp_base = YELP_BASE (bonobo_object (servant)); window = yelp_base_new_window (yelp_base); + gtk_widget_show_all (window); + + if (url) { + yelp_window_open_uri (YELP_WINDOW (window), url); + } } static void yelp_base_init (YelpBase *base) { - YelpBasePriv *priv; + YelpBasePriv *priv; priv = g_new0 (YelpBasePriv, 1); diff --git a/src/yelp-main.c b/src/yelp-main.c index 095d21ca..ffaf0884 100644 --- a/src/yelp-main.c +++ b/src/yelp-main.c @@ -44,7 +44,7 @@ static BonoboObject * yelp_base_factory (BonoboGenericFactory *factory, const gchar *iid, gpointer closure); static CORBA_Object yelp_main_activate_base (void); -static gboolean yelp_main_idle_start (gpointer data); +static gboolean yelp_main_idle_start (gchar *url); static BonoboObject * yelp_base_factory (BonoboGenericFactory *factory, @@ -85,13 +85,13 @@ yelp_main_activate_base () } static void -yelp_main_open_new_window (CORBA_Object yelp_base) +yelp_main_open_new_window (CORBA_Object yelp_base, const gchar *url) { CORBA_Environment ev; CORBA_exception_init (&ev); - - GNOME_Yelp_newWindow (yelp_base, &ev); + + GNOME_Yelp_newWindow (yelp_base, url, &ev); if (BONOBO_EX (&ev)) { g_warning (_("Could not open new window.")); @@ -102,7 +102,7 @@ yelp_main_open_new_window (CORBA_Object yelp_base) } static void -yelp_main_start () +yelp_main_start (gchar *url) { CORBA_Object yelp_base; @@ -112,13 +112,17 @@ yelp_main_start () g_error ("Couldn't activate YelpBase"); } - yelp_main_open_new_window (yelp_base); + yelp_main_open_new_window (yelp_base, url); bonobo_object_release_unref (yelp_base, NULL); + + if (url) { + g_free (url); + } } static gboolean -yelp_main_idle_start (gpointer null_data) +yelp_main_idle_start (gchar *url) { CORBA_Object yelp_base; @@ -128,7 +132,11 @@ yelp_main_idle_start (gpointer null_data) g_error ("Couldn't activate YelpBase"); } - yelp_main_open_new_window (yelp_base); + yelp_main_open_new_window (yelp_base, url); + + if (url) { + g_free (url); + } return FALSE; } @@ -136,8 +144,9 @@ yelp_main_idle_start (gpointer null_data) int main (int argc, char **argv) { - GnomeProgram *program; - CORBA_Object factory; + GnomeProgram *program; + CORBA_Object factory; + gchar *url = NULL; #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); @@ -146,6 +155,10 @@ main (int argc, char **argv) #endif g_thread_init (NULL); + if (argc >= 2) { + url = g_strdup (argv[1]); + } + program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, @@ -169,10 +182,10 @@ main (int argc, char **argv) NULL); bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); - g_idle_add (yelp_main_idle_start, NULL); + g_idle_add ((GSourceFunc) yelp_main_idle_start, url); bonobo_main (); } else { - yelp_main_start (); + yelp_main_start (url); } return 0; diff --git a/src/yelp-marshal.list b/src/yelp-marshal.list index dc011ec3..f15156e8 100644 --- a/src/yelp-marshal.list +++ b/src/yelp-marshal.list @@ -1 +1,2 @@ VOID:STRING,STRING,BOOLEAN +VOID:STRING diff --git a/src/yelp-util.c b/src/yelp-util.c index 75d75c87..ddab5b4b 100644 --- a/src/yelp-util.c +++ b/src/yelp-util.c @@ -453,3 +453,10 @@ yelp_util_find_toplevel (GNode *doc_tree, return NULL; } + +GNode * +yelp_util_find_node_from_uri (GNode *doc_tree, const gchar *uri) +{ + return NULL; +} + diff --git a/src/yelp-util.h b/src/yelp-util.h index ea04a5fa..e9482168 100644 --- a/src/yelp-util.h +++ b/src/yelp-util.h @@ -30,21 +30,23 @@ GtkTreeIter *yelp_util_contents_add_section (GtkTreeStore *store, GtkTreeIter *parent, YelpSection *section); -char * yelp_util_resolve_relative_uri (const char *base_uri, - const char *uri); +gchar * yelp_util_resolve_relative_uri (const gchar *base_uri, + const gchar *uri); -char * yelp_util_node_to_string_path (GNode *node); -GNode * yelp_util_string_path_to_node (const char *string_path, +gchar * yelp_util_node_to_string_path (GNode *node); +GNode * yelp_util_string_path_to_node (const gchar *string_path, GNode *root); GNode * yelp_util_decompose_path_url (GNode *root, - const char *path_url, + const gchar *path_url, char **embedded_url); -char * yelp_util_compose_path_url (GNode *node, - const char *embedded_url); +gchar * yelp_util_compose_path_url (GNode *node, + const gchar *embedded_url); GNode * yelp_util_find_toplevel (GNode *doc_tree, gchar *name); +GNode * yelp_util_find_node_from_uri (GNode *doc_tree, + const gchar *uri); #endif /* __YELP_UTIL_H__ */ diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c index 1359b438..16a202b8 100644 --- a/src/yelp-view-content.c +++ b/src/yelp-view-content.c @@ -29,8 +29,9 @@ #include <string.h> #include "yelp-html.h" #include "yelp-marshal.h" -#include "yelp-view-content.h" +#include "yelp-scrollkeeper.h" #include "yelp-util.h" +#include "yelp-view-content.h" static void yvc_init (YelpViewContent *html); static void yvc_class_init (YelpViewContentClass *klass); @@ -40,6 +41,7 @@ static void yvc_tree_selection_changed_cb (GtkTreeSelection *selection, enum { URL_SELECTED, + TITLE_CHANGED, LAST_SIGNAL }; @@ -133,6 +135,17 @@ 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 @@ -284,10 +297,11 @@ void yelp_view_content_show_uri (YelpViewContent *content, const gchar *url) { - YelpSection *section; - char *content_url; - GNode *node; YelpViewContentPriv *priv; + YelpSection *section; + gchar *content_url; + gchar *title = NULL; + GNode *node; g_return_if_fail (YELP_IS_VIEW_CONTENT (content)); @@ -297,14 +311,21 @@ yelp_view_content_show_uri (YelpViewContent *content, node = yelp_util_decompose_path_url (priv->doc_tree, url, &content_url); + + title = ((YelpSection *) node->data)->name; + yelp_view_content_set_tree (content, node); } else if (strncmp (url, "ghelp:", 6) == 0) { - gchar *docpath; + const gchar *docpath; + GNode *doc_node; docpath = url + 6; node = yelp_scrollkeeper_get_toc_tree_model (docpath); - + + doc_node = yelp_util_find_node_from_uri (priv->doc_tree, + url); + if (node) { yelp_view_content_set_tree (content, node); } @@ -312,13 +333,18 @@ yelp_view_content_show_uri (YelpViewContent *content, content_url = (char *)url; } else { } - + + if (title) { + g_signal_emit (content, signals[TITLE_CHANGED], 0, title); + } /* FIXME: This is a quite dubious way to load the url... */ section = yelp_section_new (YELP_SECTION_DOCUMENT, NULL, content_url, NULL, NULL); + yelp_html_open_section (YELP_HTML (content->priv->html_view), section); yelp_section_free (section); + if (content_url != url) { g_free (content_url); } diff --git a/src/yelp-view-content.h b/src/yelp-view-content.h index 1732473a..0674cd7f 100644 --- a/src/yelp-view-content.h +++ b/src/yelp-view-content.h @@ -48,10 +48,13 @@ struct _YelpViewContentClass { /* Signals */ void (*url_selected) (YelpViewContent *view, - char *url, - char *base_url, + gchar *url, + gchar *base_url, gboolean handled); + void (*title_changed) (YelpViewContent *view, + const gchar *title); + /* Signal when icon is clicked. */ }; diff --git a/src/yelp-window.c b/src/yelp-window.c index bb18278e..6dcf1f8b 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -245,7 +245,7 @@ yw_handle_url (YelpWindow *window, const gchar *url) YelpWindowPriv *priv; priv = window->priv; - + if (strncmp (url, "toc:", 4) == 0) { yelp_view_toc_open_url (YELP_VIEW_TOC (priv->toc_view), url); @@ -256,10 +256,10 @@ yw_handle_url (YelpWindow *window, const gchar *url) strncmp (url, "info:", 5) == 0 || strncmp (url, "ghelp:", 6) == 0 || strncmp (url, "path:", 5) == 0) { - yelp_view_content_show_uri (YELP_VIEW_CONTENT (priv->content_view), - url); gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), PAGE_CONTENT_VIEW); + yelp_view_content_show_uri (YELP_VIEW_CONTENT (priv->content_view), + url); return TRUE; } else { g_warning ("Unhandled URL: %s\n", url); @@ -530,6 +530,6 @@ yelp_window_open_uri (YelpWindow *window, priv = window->priv; - /* FIXME: Select content-view and set root to str_uri */ + yw_handle_url (window, str_uri); } |