devhelp r1119 - in trunk: . src



Author: rhult
Date: Sat Oct  4 11:18:33 2008
New Revision: 1119
URL: http://svn.gnome.org/viewvc/devhelp?rev=1119&view=rev

Log:
2008-10-04  Richard Hult  <richard imendio com>

	* src/dh-link.[ch]: (dh_link_new),
	(dh_link_get_book_id): Add id for links, only used for books.

	* src/dh-keyword-model.c: Remove unused book/page link lists. Also
	remove the ability to search for page ids, they are more or less
	random anywya and just clutters the search result list.
	(dh_keyword_model_filter): Change the book search to use the id,
	not the title (this restores the book search entry to work as
	before the recent refactoring).

	* src/dh-parser.c: Adapt to link API change by specifying the id
	when creating links.

	* src/dh-search.c: Remove the page search entry.


Modified:
   trunk/ChangeLog
   trunk/src/dh-keyword-model.c
   trunk/src/dh-link.c
   trunk/src/dh-link.h
   trunk/src/dh-parser.c
   trunk/src/dh-search.c

Modified: trunk/src/dh-keyword-model.c
==============================================================================
--- trunk/src/dh-keyword-model.c	(original)
+++ trunk/src/dh-keyword-model.c	Sat Oct  4 11:18:33 2008
@@ -30,8 +30,6 @@
         GList *original_list;
 
         GList *keys_list;
-        GList *book_list;
-        GList *page_list;
 
         GList *keyword_words;
 
@@ -169,8 +167,6 @@
         g_list_free (priv->keyword_words);
         g_list_free (priv->original_list);
         g_list_free (priv->keys_list);
-        g_list_free (priv->book_list);
-        g_list_free (priv->page_list);
 
         g_free (model->priv);
 
@@ -407,26 +403,15 @@
 
         g_list_free (priv->original_list);
         g_list_free (priv->keys_list);
-        g_list_free (priv->book_list);
-        g_list_free (priv->page_list);
 
         priv->original_list = g_list_copy (keyword_words);
-        priv->keys_list = priv->book_list = priv->page_list = NULL;
+        priv->keys_list = NULL;
 
-        /* Parse it into usable lists
-         */
+        /* Parse it into usable lists. */
         for (list = priv->original_list;
              list; list = list->next) {
                 link = list->data;
                 switch (dh_link_get_link_type (link)) {
-                case DH_LINK_TYPE_BOOK:
-                        priv->book_list =
-                                g_list_prepend (priv->book_list, link);
-                        break;
-                case DH_LINK_TYPE_PAGE:
-                        priv->page_list =
-                                g_list_prepend (priv->page_list, link);
-                        break;
                 case DH_LINK_TYPE_KEYWORD:
                 case DH_LINK_TYPE_FUNCTION:
                 case DH_LINK_TYPE_STRUCT:
@@ -437,7 +422,7 @@
                                 g_list_prepend (priv->keys_list, link);
                         break;
                 default:
-                        g_assert_not_reached();
+                        break;
                 }
         }
 }
@@ -460,7 +445,7 @@
         gboolean             case_sensitive;
         gchar               *lower, *name;
         gchar              **stringv, **searchv, *search = NULL;
-        gchar               *book_search, *page_search;
+        gchar               *book_search;
 
         g_return_val_if_fail (DH_IS_KEYWORD_MODEL (model), NULL);
         g_return_val_if_fail (string != NULL, NULL);
@@ -479,7 +464,6 @@
                 stringv = g_strsplit (string, " ", -1);
 
                 book_search    = NULL;
-                page_search    = NULL;
                 case_sensitive = FALSE;
                 searchv        = stringv;
 
@@ -495,17 +479,11 @@
                         /* Parse specifications insensitively. */
                         lower = g_ascii_strdown (stringv[i], -1);
 
-                        /* Determine if there was a book or page
-                         * specification.
-                         */
+                        /* Determine if there was a book. */
                         if (!strncmp (lower, "book:", 5)) {
                                 book_search = g_strdup (stringv[i] + 5);
                                 searchv++;
-                        } else if (!strncmp (lower, "page:", 5)) {
-                                page_search = g_strdup (stringv[i] + 5);
-                                searchv++;
                         } else {
-
                                 /* Determine wether or not we should search
                                  * with case sensitivity, searches are case
                                  * sensitive when upper case is used in the
@@ -539,11 +517,7 @@
                         found = FALSE;
 
                         if (book_search &&
-                            strcmp (dh_link_get_book_name (link), book_search) != 0) {
-                                continue;
-                        }
-                        if (page_search &&
-                            strcmp (dh_link_get_page_name (link), page_search) != 0) {
+                            strcmp (dh_link_get_book_id (link), book_search) != 0) {
                                 continue;
                         }
 
@@ -581,17 +555,8 @@
                 new_list = g_list_sort (new_list, dh_link_compare);
                 g_strfreev (stringv);
 
-                if (search) {
-                        g_free (search);
-                }
-
-                if (book_search) {
-                        g_free (book_search);
-                }
-
-                if (page_search) {
-                        g_free (page_search);
-                }
+                g_free (search);
+                g_free (book_search);
         }
 
         new_length = g_list_length (new_list);

Modified: trunk/src/dh-link.c
==============================================================================
--- trunk/src/dh-link.c	(original)
+++ trunk/src/dh-link.c	Sat Oct  4 11:18:33 2008
@@ -26,6 +26,8 @@
 #include "dh-link.h"
 
 struct _DhLink {
+        gchar       *id;
+
         gchar       *name;
         gchar       *uri;
 
@@ -55,20 +57,23 @@
 static void
 link_free (DhLink *link)
 {
+	g_free (link->id);
 	g_free (link->name);
+	g_free (link->uri);
+
         if (link->book) {
                 dh_link_unref (link->book);
         }
 	if (link->page) {
                 dh_link_unref (link->page);
         }
-	g_free (link->uri);
 
 	g_slice_free (DhLink, link);
 }
 
 DhLink *
 dh_link_new (DhLinkType   type,
+	     const gchar *id,
 	     const gchar *name,
 	     DhLink      *book,
 	     DhLink      *page,
@@ -81,18 +86,19 @@
 
 	link = g_slice_new0 (DhLink);
 
+	link->ref_count = 1;
 	link->type = type;
 
+	link->id = g_strdup (id);
 	link->name = g_strdup (name);
+	link->uri  = g_strdup (uri);
+
 	if (book) {
                 link->book = dh_link_ref (book);
         }
 	if (page) {
                 link->page = dh_link_ref (page);
         }
-	link->uri  = g_strdup (uri);
-
-	link->ref_count = 1;
 
 	return link;
 }
@@ -176,6 +182,16 @@
 }
 
 const gchar *
+dh_link_get_book_id (DhLink *link)
+{
+        if (link->book) {
+                return link->book->id;
+        }
+
+        return "";
+}
+
+const gchar *
 dh_link_get_uri (DhLink *link)
 {
         return link->uri;

Modified: trunk/src/dh-link.h
==============================================================================
--- trunk/src/dh-link.h	(original)
+++ trunk/src/dh-link.h	Sat Oct  4 11:18:33 2008
@@ -47,6 +47,7 @@
 
 GType        dh_link_get_type           (void);
 DhLink *     dh_link_new                (DhLinkType     type,
+                                         const gchar   *id,
 					 const gchar   *name,
                                          DhLink        *book,
                                          DhLink        *page,
@@ -59,6 +60,7 @@
 const gchar *dh_link_get_name           (DhLink        *link);
 const gchar *dh_link_get_book_name      (DhLink        *link);
 const gchar *dh_link_get_page_name      (DhLink        *link);
+const gchar *dh_link_get_book_id        (DhLink        *link);
 const gchar *dh_link_get_uri            (DhLink        *link);
 DhLinkFlags  dh_link_get_flags          (DhLink        *link);
 void         dh_link_set_flags          (DhLink        *link,

Modified: trunk/src/dh-parser.c
==============================================================================
--- trunk/src/dh-parser.c	(original)
+++ trunk/src/dh-parser.c	Sat Oct  4 11:18:33 2008
@@ -147,7 +147,12 @@
         }
 
         full_uri = g_strconcat (parser->base, "/", uri, NULL);
-        link = dh_link_new (DH_LINK_TYPE_BOOK, title, NULL, NULL, full_uri);
+        link = dh_link_new (DH_LINK_TYPE_BOOK,
+                            name,
+                            title,
+                            NULL,
+                            NULL,
+                            full_uri);
         g_free (full_uri);
 
         *parser->keywords = g_list_prepend (*parser->keywords, link);
@@ -206,9 +211,13 @@
 
         full_uri = g_strconcat (parser->base, "/", uri, NULL);
         page = extract_page_name (uri);
-        link = dh_link_new (DH_LINK_TYPE_PAGE, name, 
+        link = dh_link_new (DH_LINK_TYPE_PAGE,
+                            NULL,
+                            name, 
                             parser->book_node->data,
-                            NULL, full_uri);
+                            NULL,
+                            full_uri);
+
         g_free (full_uri);
         g_free (page);
 
@@ -234,7 +243,6 @@
         const gchar *type = NULL;
         const gchar *deprecated = NULL;
 	gchar       *full_uri;
-	gchar       *page;
         DhLinkType   link_type;
 	DhLink      *link;
         gchar       *tmp;
@@ -300,7 +308,6 @@
         }
 
         full_uri = g_strconcat (parser->base, "/", uri, NULL);
-        page = extract_page_name (uri);
 
         if (parser->version == 2) {
                 if (strcmp (type, "function") == 0) {
@@ -352,14 +359,15 @@
                 }
         }
 
-        link = dh_link_new (link_type, name, 
+        link = dh_link_new (link_type,
+                            NULL, // koko id
+                            name, 
                             parser->book_node->data,
                             parser->parent->data,
                             full_uri);
 
         g_free (tmp);
         g_free (full_uri);
-        g_free (page);
 
         if (deprecated) {
                 dh_link_set_flags (

Modified: trunk/src/dh-search.c
==============================================================================
--- trunk/src/dh-search.c	(original)
+++ trunk/src/dh-search.c	Sat Oct  4 11:18:33 2008
@@ -48,7 +48,6 @@
 	GtkWidget      *advanced_box;
 
 	GtkWidget      *book;
-	GtkWidget      *page;
 	GtkWidget      *entry;
 	GtkWidget      *hitlist;
 
@@ -62,7 +61,6 @@
 	guint           advanced_options_id;
 	
 	GString        *book_str;
-	GString        *page_str;
 	GString        *entry_str;
 
 	DhSearchSource  search_source;
@@ -119,7 +117,6 @@
 	priv = GET_PRIVATE (object);
 
 	g_string_free (priv->book_str, TRUE);
-	g_string_free (priv->page_str, TRUE);
 	g_string_free (priv->entry_str, TRUE);
 
 	g_completion_free (priv->completion);
@@ -162,7 +159,6 @@
 	priv = GET_PRIVATE (search);
 	
 	priv->book_str = g_string_new ("");
-	priv->page_str = g_string_new ("");
 	priv->entry_str = g_string_new ("");
 
 	priv->idle_complete = 0;
@@ -198,18 +194,12 @@
 		gtk_widget_show (priv->advanced_box);
 
 		g_signal_handlers_block_by_func (priv->book, search_entry_changed_cb, search);
-		g_signal_handlers_block_by_func (priv->page, search_entry_changed_cb, search);
 
 		gtk_entry_set_text (GTK_ENTRY (priv->book), 
 				    priv->book_str->len > 5 ? 
 				    priv->book_str->str + 5 : "");
-		gtk_entry_set_text (GTK_ENTRY (priv->page), 
-				    priv->page_str->len > 5 ? 
-				    priv->page_str->str + 5 : "");
 
 		g_signal_handlers_unblock_by_func (priv->book, search_entry_changed_cb, search);
-		g_signal_handlers_unblock_by_func (priv->page, search_entry_changed_cb, search);
-
 	} else {
 		gtk_widget_hide (priv->advanced_box);
 	}		
@@ -360,11 +350,6 @@
 			g_string_append (string, priv->book_str->str);
 			g_string_append (string, " ");
 		}
-		
-		if (priv->page_str->len > 0) {
-			g_string_append (string, priv->page_str->str);
-			g_string_append (string, " ");
-		}
 	}
 
 	if (priv->entry_str->len > 0) {
@@ -390,16 +375,9 @@
 		} else {
 			g_string_set_size (priv->book_str, 0);
 		}
-	} else if (GTK_WIDGET (entry) == priv->page) {
-		if (str && str[0]) {
-			g_string_printf (priv->page_str, "page:%s", str);
-		} else {
-			g_string_set_size (priv->page_str, 0);
-		}
 	} else {
 		if (GTK_WIDGET_VISIBLE (priv->advanced_box) == FALSE) {
 			g_string_set_size (priv->book_str, 0);
-			g_string_set_size (priv->page_str, 0);
 		}
 
 		g_string_set_size (priv->entry_str, 0);
@@ -556,8 +534,7 @@
         GtkWidget        *list_sw;
 	GtkWidget        *frame;
 	GtkWidget        *hbox;
-	GtkWidget        *book_label, *page_label;
-	GtkSizeGroup     *group;
+	GtkWidget        *book_label;
 	GtkCellRenderer  *cell;
 	GConfClient      *gconf_client;
 		
@@ -587,29 +564,6 @@
 	gtk_box_pack_start (GTK_BOX (hbox), priv->book, TRUE, TRUE, 0);
  	gtk_box_pack_start (GTK_BOX (priv->advanced_box), hbox, FALSE, FALSE, 0);
 
-	/* Setup the page box */
-	priv->page = gtk_entry_new ();
-	g_signal_connect (priv->page, "changed", 
-			  G_CALLBACK (search_entry_changed_cb),
-			  search);
-	g_signal_connect (priv->page, "activate",
-			  G_CALLBACK (search_entry_activated_cb),
-			  search);
-
-	page_label = gtk_label_new_with_mnemonic (_("_Page:"));
-	gtk_label_set_mnemonic_widget (GTK_LABEL (page_label), priv->page);
-
-	hbox = gtk_hbox_new (FALSE, 6);
-	gtk_box_pack_start (GTK_BOX (hbox), page_label, FALSE, FALSE, 0);
-	gtk_box_pack_start (GTK_BOX (hbox), priv->page, TRUE, TRUE, 0);
- 	gtk_box_pack_start (GTK_BOX (priv->advanced_box), hbox, FALSE, FALSE, 0);
-	
-	/* Align the labels */
-	group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-	gtk_size_group_add_widget (group, book_label);
-	gtk_size_group_add_widget (group, page_label);
-	g_object_unref (G_OBJECT (group));
-
 	gtk_widget_show_all (priv->advanced_box);
 	gtk_widget_set_no_show_all (priv->advanced_box, TRUE);
 
@@ -708,11 +662,9 @@
 	priv->search_source = SEARCH_API;
 
 	g_string_set_size (priv->book_str, 0);
-	g_string_set_size (priv->page_str, 0);
 	g_string_set_size (priv->entry_str, 0);
 
 	g_signal_handlers_block_by_func (priv->book, search_entry_changed_cb, search);
-	g_signal_handlers_block_by_func (priv->page, search_entry_changed_cb, search);
 	g_signal_handlers_block_by_func (priv->entry, search_entry_changed_cb, search);
 
 	if ((leftover = split = g_strsplit (str, " ", -1)) != NULL) {
@@ -721,14 +673,10 @@
 
 			lower = g_ascii_strdown (split[i], -1);
 			
-			/* Determine if there was a book or page specification
-			 */
+			/* Determine if there was a book specification. */
 			if (!strncmp (lower, "book:", 5)) {
 				g_string_append (priv->book_str, split[i]);
 				leftover++;
-			} else if (!strncmp (lower, "page:", 5)) {
-				g_string_append (priv->page_str, split[i]);
-				leftover++;
 			} else {
 				/* No more specifications */
 				break;
@@ -770,16 +718,12 @@
 		gtk_entry_set_text (GTK_ENTRY (priv->book), 
 				    priv->book_str->len > 5 ? 
 				    priv->book_str->str + 5 : "");
-		gtk_entry_set_text (GTK_ENTRY (priv->page), 
-				    priv->page_str->len > 5 ? 
-				    priv->page_str->str + 5 : "");
 	}
 
 	gtk_editable_set_position (GTK_EDITABLE (priv->entry), -1);
 	gtk_editable_select_region (GTK_EDITABLE (priv->entry), -1, -1);
 
 	g_signal_handlers_unblock_by_func (priv->book, search_entry_changed_cb, search);
-	g_signal_handlers_unblock_by_func (priv->page, search_entry_changed_cb, search);
 	g_signal_handlers_unblock_by_func (priv->entry, search_entry_changed_cb, search);
 
 	if (!priv->idle_filter) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]