summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2010-04-02 10:39:47 -0500
committerShaun McCance <shaunm@gnome.org>2010-04-02 10:39:47 -0500
commitaf956b77830ed03e492effa87a8132f8c883ab7d (patch)
tree53155cfd72417f3724197e72334f51ab65606045 /src
parentc1d0c3d380366d2272a1013b82c4738904ebb2be (diff)
downloadyelp-af956b77830ed03e492effa87a8132f8c883ab7d.tar.gz
[yelp-window] Add search entry to history dropdown, limit to 15 entries
Diffstat (limited to 'src')
-rw-r--r--src/yelp-window.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 3934d8f9..990b2bdc 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -211,6 +211,7 @@ yelp_window_init (YelpWindow *window)
GtkUIManager *ui_manager;
GtkAction *action;
GError *error = NULL;
+ GtkTreeIter iter;
YelpWindowPrivate *priv = GET_PRIV (window);
gtk_window_set_icon_name (GTK_WINDOW (window), "help-browser");
@@ -275,6 +276,16 @@ yelp_window_init (YelpWindow *window)
G_TYPE_INT, /* flags */
G_TYPE_STRING /* search terms */
);
+ gtk_list_store_append (priv->history, &iter);
+ gtk_list_store_set (priv->history, &iter,
+ COL_FLAGS, YELP_LOCATION_ENTRY_IS_SEPARATOR,
+ -1);
+ gtk_list_store_append (priv->history, &iter);
+ gtk_list_store_set (priv->history, &iter,
+ COL_ICON, "system-search",
+ COL_TITLE, _("Search..."),
+ COL_FLAGS, YELP_LOCATION_ENTRY_IS_SEARCH,
+ -1);
priv->completion = gtk_list_store_new (4,
G_TYPE_STRING, /* title */
G_TYPE_STRING, /* desc */
@@ -781,12 +792,25 @@ view_uri_selected (YelpView *view,
gtk_list_store_move_before (priv->history, &iter, &first);
}
else {
+ gint num;
+ GtkTreeIter last;
gtk_list_store_prepend (priv->history, &iter);
gtk_list_store_set (priv->history, &iter,
COL_TITLE, _("Loading"),
COL_ICON, "help-contents",
COL_URI, struri,
-1);
+ /* Limit to 15 entries. There are two extra for the search entry and
+ * the separator above it.
+ */
+ num = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->history), NULL);
+ if (num > 17) {
+ if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->history),
+ &last, NULL,
+ num - 3)) {
+ gtk_list_store_remove (priv->history, &last);
+ }
+ }
}
g_signal_handler_block (priv->entry,
priv->entry_location_selected);