[epiphany] ephy-hosts-view: add a method to select a given host



commit 5596d5fb76a9d39ad3ea78e613ad9058a5ed948c
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Wed Mar 7 16:44:51 2012 +0200

    ephy-hosts-view: add a method to select a given host
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671559

 lib/widgets/ephy-hosts-view.c |   32 ++++++++++++++++++++++++++++++++
 lib/widgets/ephy-hosts-view.h |    2 ++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/lib/widgets/ephy-hosts-view.c b/lib/widgets/ephy-hosts-view.c
index 7ed6b44..b6c6e75 100644
--- a/lib/widgets/ephy-hosts-view.c
+++ b/lib/widgets/ephy-hosts-view.c
@@ -53,3 +53,35 @@ ephy_hosts_view_new (void)
   return g_object_new (EPHY_TYPE_HOSTS_VIEW, NULL);
 }
 
+gboolean
+ephy_hosts_view_select_host (EphyHostsView *view,
+                             EphyHistoryHost *host)
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  gint id;
+  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);
+  }
+
+  return found;
+}
diff --git a/lib/widgets/ephy-hosts-view.h b/lib/widgets/ephy-hosts-view.h
index 393ad4e..15abb59 100644
--- a/lib/widgets/ephy-hosts-view.h
+++ b/lib/widgets/ephy-hosts-view.h
@@ -22,6 +22,7 @@
 #ifndef _EPHY_HOSTS_VIEW_H
 #define _EPHY_HOSTS_VIEW_H
 
+#include "ephy-history-types.h"
 #include "ephy-history-view.h"
 
 #include <gtk/gtk.h>
@@ -51,6 +52,7 @@ struct _EphyHostsViewClass
 
 GType      ephy_hosts_view_get_type      (void) G_GNUC_CONST;
 GtkWidget *ephy_hosts_view_new           (void);
+gboolean   ephy_hosts_view_select_host   (EphyHostsView *view, EphyHistoryHost *host);
 
 G_END_DECLS
 



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