Index: src/dh-base.c
===================================================================
RCS file: /cvs/gnome/devhelp/src/dh-base.c,v
retrieving revision 1.31
diff -u -r1.31 dh-base.c
--- src/dh-base.c	17 Aug 2006 20:05:54 -0000	1.31
+++ src/dh-base.c	18 Oct 2006 01:08:04 -0000
@@ -302,6 +302,31 @@
 	return book_path;
 }	
 
+gboolean
+dh_base_add_book (DhBase *base, const gchar *name, const gchar *book_path, GError **error)
+{
+	DhBasePriv  *priv;
+
+	priv = base->priv;
+
+	if (g_hash_table_lookup (priv->books, name)) {
+		return TRUE;
+	}
+
+	if (!dh_parser_read_file (book_path,
+				  priv->book_tree,
+				  &priv->keywords,
+				  error)) {
+		return FALSE;
+	} else {
+		g_hash_table_insert (priv->books,
+				     g_strdup (name),
+				     (gchar*) book_path);
+		d(g_print ("Found book: '%s'\n", book_path));
+	}
+	return TRUE;
+}
+
 static void
 base_add_books (DhBase *base, const gchar *path)
 {
@@ -341,18 +366,10 @@
 			continue;
 		}
 
-		if (!dh_parser_read_file  (book_path,
-					   priv->book_tree,
-					   &priv->keywords,
-					   &error)) {
+		if (!dh_base_add_book (base, name, book_path, &error)) {
 			g_warning ("Failed to read '%s': %s",
 				   book_path, error->message);
 			g_clear_error (&error);
-		} else {
-			g_hash_table_insert (priv->books,
-					     g_strdup (name),
-					     book_path);
-			d(g_print ("Found book: '%s'\n", book_path));
 		}
 
 		g_free (book_path);
Index: src/dh-base.h
===================================================================
RCS file: /cvs/gnome/devhelp/src/dh-base.h,v
retrieving revision 1.9
diff -u -r1.9 dh-base.h
--- src/dh-base.h	16 May 2006 18:46:41 -0000	1.9
+++ src/dh-base.h	18 Oct 2006 01:08:04 -0000
@@ -58,5 +58,6 @@
 GList *      dh_base_get_keywords                    (DhBase *base);
 GSList *     dh_base_get_windows                     (DhBase *base);
 GConfClient *dh_base_get_gconf_client                (DhBase *base);
+gboolean     dh_base_add_book			     (DhBase *base, const gchar *name, const gchar *book_path, GError **error);
 
 #endif /* __DH_BASE_H__ */
Index: src/dh-main.c
===================================================================
RCS file: /cvs/gnome/devhelp/src/dh-main.c,v
retrieving revision 1.36
diff -u -r1.36 dh-main.c
--- src/dh-main.c	16 May 2006 18:46:41 -0000	1.36
+++ src/dh-main.c	18 Oct 2006 01:08:04 -0000
@@ -31,9 +31,47 @@
 
 #define COMMAND_QUIT   "quit"
 #define COMMAND_SEARCH "search"
+#define COMMAND_BOOK   "book"
 #define COMMAND_RAISE  "raise"
 
 static void
+open_book (const gchar *book_path, DhBase *base, GtkWidget *window)
+{
+	GError	*error = NULL;
+	gchar	*tmp;
+	gchar	*name;
+	gchar	*needle;
+
+	tmp = g_strdup (book_path);
+
+	/* extract the book name from the book_path */
+	needle = g_strrstr (tmp, ".devhelp");
+	if (needle) {
+		*needle = '\0';
+	} 
+
+	needle = strrchr (tmp, '/');
+	if (needle) {
+		name = needle + 1;
+	} else {
+		name = tmp;
+	}
+
+	if (!dh_base_add_book (base, name, book_path, &error)) {
+		g_warning ("Failed to read '%s': %s",
+			   book_path, error->message);
+		g_clear_error (&error);
+	} else if (window) {
+		gchar	*str;
+		str = g_strconcat ("book:", name, NULL);
+		dh_window_search (DH_WINDOW (window), str);
+		g_free (str);
+	}
+	
+	g_free (tmp);
+}
+
+static void
 message_received_cb (const gchar *message, DhBase *base)
 {
 	GtkWidget *window;
@@ -61,6 +99,10 @@
 				  message + strlen (COMMAND_SEARCH) + 1);
 	}	
 	
+	if (strncmp (message, COMMAND_BOOK, strlen (COMMAND_BOOK)) == 0) {
+		open_book (message + strlen (COMMAND_BOOK) + 1, base, window);
+	}
+
 	timestamp = gdk_x11_get_server_time (window->window);
 	gtk_window_present_with_time (GTK_WINDOW (window), timestamp);
 }
@@ -69,6 +111,7 @@
 main (int argc, char **argv)
 {
 	gchar                  *option_search = NULL;
+	gchar                  *option_book = NULL;
 	gboolean                option_quit = FALSE;
 	gboolean                option_version = FALSE;
 	BaconMessageConnection *message_conn;
@@ -104,6 +147,14 @@
 			NULL
 		},
 		{
+			"book",
+			'b',
+			0,
+			G_OPTION_ARG_STRING,
+			&option_book,
+			_("Open a book given a filename or a book name"),
+		},
+		{
 			NULL, '\0', 0, 0, NULL, NULL, NULL
 		}
 	};
@@ -122,6 +173,14 @@
 		return 0;
 	}
 
+	if (option_book) {
+		if (option_book[0] != '/') {
+			gchar	*tmp = option_book;
+			
+			option_book = g_build_filename (g_get_current_dir(), tmp, NULL);
+			g_free (tmp);
+		}
+	}
 	g_set_application_name (_("Devhelp"));
 	gtk_window_set_default_icon_name ("devhelp");
 
@@ -141,6 +200,16 @@
 
 			bacon_message_connection_send (message_conn, command);
 			g_free (command);
+		}
+		if (option_book) {
+			gchar *command;
+
+			command = g_strdup_printf ("%s %s",
+						   COMMAND_BOOK,
+						   option_book);
+
+			bacon_message_connection_send (message_conn, command);
+			g_free (command);
 		} else {
 			bacon_message_connection_send (message_conn, COMMAND_RAISE);
 		}
@@ -155,6 +224,9 @@
 	}
 
 	base = dh_base_new ();
+	if (option_book) {
+		open_book (option_book, base, NULL);
+	}
 	window = dh_base_new_window (base);
 
 	bacon_message_connection_set_callback (
@@ -162,8 +234,11 @@
 		(BaconMessageReceivedFunc) message_received_cb,
 		base);
 
-	if (option_search) {
+	if (option_book) {
+		open_book (option_book, base, window);
+	} if (option_search) {
 		dh_window_search (DH_WINDOW (window), option_search);
+		g_free (option_search);
 	}
 
 	gtk_widget_show (window);
Index: src/dh-preferences.c
===================================================================
RCS file: /cvs/gnome/devhelp/src/dh-preferences.c,v
retrieving revision 1.7
diff -u -r1.7 dh-preferences.c
--- src/dh-preferences.c	16 May 2006 18:46:41 -0000	1.7
+++ src/dh-preferences.c	18 Oct 2006 01:08:05 -0000
@@ -464,10 +464,15 @@
 
 	preferences_get_font_names (FALSE, &var_font_name, &fixed_font_name);
 	
-	gtk_font_button_set_font_name (GTK_FONT_BUTTON (prefs->variable_font_button),
-				       var_font_name);
-	gtk_font_button_set_font_name (GTK_FONT_BUTTON (prefs->fixed_font_button),
-				       fixed_font_name);
+	if (var_font_name) {
+		gtk_font_button_set_font_name (GTK_FONT_BUTTON (prefs->variable_font_button),
+					       var_font_name);
+	}
+
+	if (fixed_font_name) {
+		gtk_font_button_set_font_name (GTK_FONT_BUTTON (prefs->fixed_font_button),
+					       fixed_font_name);
+	}
 	
 	g_free (var_font_name);
 	g_free (fixed_font_name);
