aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-03-08 00:57:24 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2012-03-08 05:17:54 +0800
commit161c78698fcce7a6cad9a562691dd51ec087265c (patch)
tree35a0511b6b885011b7aed0e32f8ae2d069af1f1c /lib
parent7cc9e4a8e9d7a9ae063005e27bca383687b3084e (diff)
downloadgsoc2013-epiphany-161c78698fcce7a6cad9a562691dd51ec087265c.tar
gsoc2013-epiphany-161c78698fcce7a6cad9a562691dd51ec087265c.tar.gz
gsoc2013-epiphany-161c78698fcce7a6cad9a562691dd51ec087265c.tar.bz2
gsoc2013-epiphany-161c78698fcce7a6cad9a562691dd51ec087265c.tar.lz
gsoc2013-epiphany-161c78698fcce7a6cad9a562691dd51ec087265c.tar.xz
gsoc2013-epiphany-161c78698fcce7a6cad9a562691dd51ec087265c.tar.zst
gsoc2013-epiphany-161c78698fcce7a6cad9a562691dd51ec087265c.zip
ephy-hosts-view: ensure "all hosts" is selected by default
If no host can be selected, always select the "all hosts" row. https://bugzilla.gnome.org/show_bug.cgi?id=671575
Diffstat (limited to 'lib')
-rw-r--r--lib/widgets/ephy-hosts-view.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/widgets/ephy-hosts-view.c b/lib/widgets/ephy-hosts-view.c
index b6c6e756a..e59d89c60 100644
--- a/lib/widgets/ephy-hosts-view.c
+++ b/lib/widgets/ephy-hosts-view.c
@@ -53,6 +53,16 @@ ephy_hosts_view_new (void)
return g_object_new (EPHY_TYPE_HOSTS_VIEW, NULL);
}
+/**
+ * ephy_hosts_view_select_host:
+ * @view: A #EphyHostView
+ * @host: a @host or %NULL to select the first item
+ *
+ * Selects the row pointed by @host or, when not found or row is
+ * %NULL, select the first item ("All sites").
+ *
+ * Returns: whether @host was found.
+ **/
gboolean
ephy_hosts_view_select_host (EphyHostsView *view,
EphyHistoryHost *host)
@@ -63,25 +73,29 @@ ephy_hosts_view_select_host (EphyHostsView *view,
gboolean found = FALSE;
g_return_val_if_fail (EPHY_IS_HOSTS_VIEW (view), FALSE);
- g_return_val_if_fail (host != NULL, FALSE);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
gtk_tree_model_get_iter_first (model, &iter);
- do {
- gtk_tree_model_get (model, &iter,
- EPHY_HOSTS_STORE_COLUMN_ID, &id,
- -1);
- if (id == host->id) {
- found = TRUE;
- break;
- }
- } while (gtk_tree_model_iter_next (model, &iter));
-
- if (found) {
- gtk_tree_selection_select_iter (
- gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), &iter);
+
+ if (host != NULL) {
+ do {
+ gtk_tree_model_get (model, &iter,
+ EPHY_HOSTS_STORE_COLUMN_ID, &id,
+ -1);
+ if (id == host->id) {
+ found = TRUE;
+ break;
+ }
+ } while (gtk_tree_model_iter_next (model, &iter));
}
+ if (host == NULL || found == FALSE) {
+ gtk_tree_model_get_iter_first (model, &iter);
+ }
+
+ gtk_tree_selection_select_iter (
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), &iter);
+
return found;
}