summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-03-02 01:06:31 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-03-02 01:06:31 +0000
commitbf75148ce99d3bb9c0fce594bb88f2ff44b08160 (patch)
treeb424d531ac8911a7c4c40328a9997be722130d11
parent0bcf62c77c87db2d2fe00e7ea7eb333f685db267 (diff)
downloadyelp-bf75148ce99d3bb9c0fce594bb88f2ff44b08160.tar.gz
- replaced the old ListStore with the new YelpIndexModel.
2002-03-02 Mikael Hallendal <micke@codefactory.se> * src/yelp-view-index.c: - replaced the old ListStore with the new YelpIndexModel. (yvi_index_term_add): removed, not needed when using own model. (yvi_setup_index_view): removed. * src/yelp-index-model.[ch]: missed some copy&paste-changes when copying the model from MrProject :) (yelp_index_model_set_words): added. Please don't report problems running/building Yelp after this commit, I'm in the middle of hacking and will finish this during the weekend.
-rw-r--r--ChangeLog9
-rw-r--r--src/yelp-index-model.c24
-rw-r--r--src/yelp-index-model.h13
-rw-r--r--src/yelp-view-index.c63
4 files changed, 44 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index 7549f3b1..84e69ce9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
2002-03-02 Mikael Hallendal <micke@codefactory.se>
* src/yelp-view-index.c:
+ - replaced the old ListStore with the new YelpIndexModel.
+ (yvi_index_term_add): removed, not needed when using own model.
+ (yvi_setup_index_view): removed.
+
+ * src/yelp-index-model.[ch]: missed some copy&paste-changes when
+ copying the model from MrProject :)
+ (yelp_index_model_set_words): added.
+
+ * src/yelp-view-index.c:
- in-the-middle-commit on index search stuff.
(yvi_entry_changed_cb): added
(yvi_entry_activated_cb): added
diff --git a/src/yelp-index-model.c b/src/yelp-index-model.c
index 1605dfcf..5b40b61e 100644
--- a/src/yelp-index-model.c
+++ b/src/yelp-index-model.c
@@ -192,7 +192,7 @@ yim_get_iter (GtkTreeModel *tree_model,
GList *node;
gint i;
- g_return_val_if_fail (MG_IS_RESOURCE_MODEL (tree_model), FALSE);
+ g_return_val_if_fail (YELP_IS_INDEX_MODEL (tree_model), FALSE);
g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
model = YELP_INDEX_MODEL (tree_model);
@@ -222,7 +222,7 @@ yim_get_path (GtkTreeModel *tree_model,
GList *node;
gint i = 0;
- g_return_val_if_fail (MG_IS_RESOURCE_MODEL (tree_model), NULL);
+ g_return_val_if_fail (YELP_IS_INDEX_MODEL (tree_model), NULL);
g_return_val_if_fail (iter->stamp == model->priv->stamp, NULL);
priv = model->priv;
@@ -252,7 +252,7 @@ yim_get_value (GtkTreeModel *tree_model,
{
YelpSection *section;
- g_return_if_fail (MG_IS_RESOURCE_MODEL (tree_model));
+ g_return_if_fail (YELP_IS_INDEX_MODEL (tree_model));
g_return_if_fail (iter != NULL);
section = (YelpSection *) (G_LIST(iter->user_data)->data);
@@ -272,7 +272,7 @@ yim_iter_next (GtkTreeModel *tree_model,
{
YelpIndexModel *model = YELP_INDEX_MODEL (tree_model);
- g_return_val_if_fail (MG_IS_RESOURCE_MODEL (tree_model), FALSE);
+ g_return_val_if_fail (YELP_IS_INDEX_MODEL (tree_model), FALSE);
g_return_val_if_fail (model->priv->stamp == iter->stamp, FALSE);
iter->user_data = G_LIST(iter->user_data)->next;
@@ -287,7 +287,7 @@ yim_iter_children (GtkTreeModel *tree_model,
{
YelpIndexModelPriv *priv;
- g_return_val_if_fail (MG_IS_RESOURCE_MODEL (tree_model), FALSE);
+ g_return_val_if_fail (YELP_IS_INDEX_MODEL (tree_model), FALSE);
priv = YELP_INDEX_MODEL(tree_model)->priv;
@@ -322,7 +322,7 @@ yim_iter_n_children (GtkTreeModel *tree_model,
{
YelpIndexModelPriv *priv;
- g_return_val_if_fail (MG_IS_RESOURCE_MODEL (tree_model), -1);
+ g_return_val_if_fail (YELP_IS_INDEX_MODEL (tree_model), -1);
priv = YELP_INDEX_MODEL(tree_model)->priv;
@@ -344,7 +344,7 @@ yim_iter_nth_child (GtkTreeModel *tree_model,
YelpIndexModelPriv *priv;
GList *child;
- g_return_val_if_fail (MG_IS_RESOURCE_MODEL (tree_model), FALSE);
+ g_return_val_if_fail (YELP_IS_INDEX_MODEL (tree_model), FALSE);
priv = YELP_INDEX_MODEL(tree_model)->priv;
@@ -372,7 +372,7 @@ yim_iter_parent (GtkTreeModel *tree_model,
}
YelpIndexModel *
-yelp_index_model_new (GList *index_words)
+yelp_index_model_new (void)
{
YelpIndexModel *model;
YelpIndexModelPriv *priv;
@@ -381,8 +381,14 @@ yelp_index_model_new (GList *index_words)
priv = model->priv;
- priv->index_words = index_words;
return model;
}
+void
+yelp_index_model_set_words (YelpIndexModel *model, GList *index_words)
+{
+ g_return_if_fail (YELP_IS_INDEX_MODEL (model));
+
+ model->priv->index_words = index_words;
+}
diff --git a/src/yelp-index-model.h b/src/yelp-index-model.h
index 86f0a479..e4504320 100644
--- a/src/yelp-index-model.h
+++ b/src/yelp-index-model.h
@@ -30,9 +30,9 @@
#define YELP_TYPE_INDEX_MODEL (yelp_index_model_get_type ())
#define YELP_INDEX_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), YELP_TYPE_INDEX_MODEL, YelpIndexModel))
#define YELP_INDEX_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), YELP_TYPE_INDEX_MODEL, YelpIndexModelClass))
-#define MG_IS_RESOURCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YELP_TYPE_INDEX_MODEL))
-#define MG_IS_RESOURCE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), YELP_TYPE_INDEX_MODEL))
-#define YELP_INDEX_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), YELP_TYPE_INDEX_MODEL, YelpIndexModelClass))
+#define YELP_IS_INDEX_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YELP_TYPE_INDEX_MODEL))
+#define YELP_IS_INDEX_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), YELP_TYPE_INDEX_MODEL))
+#define YELP_INDEX_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), YELP_TYPE_INDEX_MODEL, YelpIndexModelClass))
typedef struct _YelpIndexModel YelpIndexModel;
typedef struct _YelpIndexModelClass YelpIndexModelClass;
@@ -51,7 +51,10 @@ struct _YelpIndexModelClass
GObjectClass parent_class;
};
-GtkType yelp_index_model_get_type (void);
-YelpIndexModel *yelp_index_model_new (GList *index_words);
+GtkType yelp_index_model_get_type (void);
+
+YelpIndexModel *yelp_index_model_new (void);
+void yelp_index_model_set_words (YelpIndexModel *model,
+ GList *index_words);
#endif /* __YELP_INDEX_MODEL_H__ */
diff --git a/src/yelp-view-index.c b/src/yelp-view-index.c
index 7d83dfa8..184396a6 100644
--- a/src/yelp-view-index.c
+++ b/src/yelp-view-index.c
@@ -28,6 +28,7 @@
#include <gtk/gtktreeview.h>
#include <string.h>
+#include "yelp-index-model.h"
#include "yelp-html.h"
#include "yelp-view-index.h"
@@ -39,7 +40,6 @@ static void yvi_html_url_selected_cb (YelpViewIndex *content,
char *url,
char *base_url,
gboolean handled);
-static void yvi_setup_index_view (YelpViewIndex *view);
static void yvi_entry_changed_cb (GtkEntry *entry,
YelpViewIndex *view);
static void yvi_entry_activated_cb (GtkEntry *entry,
@@ -55,21 +55,19 @@ static gboolean yvi_complete_idle (YelpViewIndex *view);
static gchar * yvi_complete_func (YelpSection *section);
struct _YelpViewIndexPriv {
- GList *index;
-
/* List of keywords */
- GtkWidget *index_view;
- GtkListStore *list_store;
+ GtkWidget *index_view;
+ YelpIndexModel *model;
/* Query entry */
- GtkWidget *entry;
+ GtkWidget *entry;
/* Html view */
- GtkWidget *html_view;
+ GtkWidget *html_view;
- GCompletion *completion;
+ GCompletion *completion;
- guint complete;
+ guint complete;
};
GType
@@ -114,11 +112,10 @@ yvi_init (YelpViewIndex *view)
g_completion_set_compare (priv->completion, g_ascii_strncasecmp);
priv->index_view = gtk_tree_view_new ();
- priv->list_store = gtk_list_store_new (2,
- G_TYPE_STRING, G_TYPE_POINTER);
+ priv->model = yelp_index_model_new ();
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->index_view),
- GTK_TREE_MODEL (priv->list_store));
+ GTK_TREE_MODEL (priv->model));
priv->html_view = yelp_html_new ();
@@ -147,7 +144,7 @@ yvi_index_selection_changed_cb (GtkTreeSelection *selection,
priv = view->priv;
if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter,
1, &section,
-1);
@@ -176,41 +173,6 @@ yvi_html_url_selected_cb (YelpViewIndex *content,
}
static void
-yvi_index_term_add (YelpSection *section, YelpViewIndex *view)
-{
- YelpViewIndexPriv *priv;
- GtkTreeIter iter;
-
- g_return_if_fail (YELP_IS_VIEW_INDEX (view));
-
- priv = view->priv;
-
- gtk_list_store_append (GTK_LIST_STORE (priv->list_store), &iter);
-
- gtk_list_store_set (GTK_LIST_STORE (priv->list_store),
- &iter,
- 0, section->name,
- 1, section,
- -1);
-}
-
-static void
-yvi_setup_index_view (YelpViewIndex *view)
-{
- YelpViewIndexPriv *priv;
-
- g_return_if_fail (YELP_IS_VIEW_INDEX (view));
-
- priv = view->priv;
-
- g_completion_add_items (priv->completion, priv->index);
-
- g_list_foreach (priv->index,
- (GFunc )yvi_index_term_add,
- view);
-}
-
-static void
yvi_entry_changed_cb (GtkEntry *entry, YelpViewIndex *view)
{
g_print ("Entry changed\n");
@@ -312,8 +274,6 @@ yelp_view_index_new (GList *index)
view = g_object_new (YELP_TYPE_VIEW_INDEX, NULL);
priv = view->priv;
- priv->index = index;
-
/* Setup the index box */
box = gtk_vbox_new (FALSE, 0);
@@ -383,7 +343,8 @@ yelp_view_index_new (GList *index)
gtk_paned_add2 (GTK_PANED (view), frame);
gtk_paned_set_position (GTK_PANED (view), 250);
- yvi_setup_index_view (view);
+ g_completion_add_items (priv->completion, index);
+ yelp_index_model_set_words (priv->model, index);
return GTK_WIDGET (view);
}