r1712 - trunk/src/target/OM-2007/applications/openmoko-rssreader/src
zecke at sita.openmoko.org
zecke at sita.openmoko.org
Sun Apr 8 18:59:11 CEST 2007
Author: zecke
Date: 2007-04-08 18:59:10 +0200 (Sun, 08 Apr 2007)
New Revision: 1712
Modified:
trunk/src/target/OM-2007/applications/openmoko-rssreader/src/application-data.h
trunk/src/target/OM-2007/applications/openmoko-rssreader/src/callbacks.c
trunk/src/target/OM-2007/applications/openmoko-rssreader/src/main.c
Log:
openmoko-rssreader: Implement filtering the feed categories
Modified: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/application-data.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/application-data.h 2007-04-08 00:42:26 UTC (rev 1711)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/application-data.h 2007-04-08 16:59:10 UTC (rev 1712)
@@ -55,6 +55,8 @@
GtkTextView *textView;
gchar *current_filter;
+ int is_all_filter;
+ gchar *current_search_text;
};
/*
Modified: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/callbacks.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/callbacks.c 2007-04-08 00:42:26 UTC (rev 1711)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/callbacks.c 2007-04-08 16:59:10 UTC (rev 1712)
@@ -56,6 +56,7 @@
* TODO: Use the ModelFilter to filter for All or Category
*/
void filter_feeds( struct RSSReaderData *data ) {
+ gtk_tree_model_filter_refilter (data->filter_model);
}
/*
@@ -82,6 +83,10 @@
g_free( data->current_filter );
data->current_filter = g_strdup( text );
+ /*
+ * shortcut for the later filter function
+ */
+ data->is_all_filter = strcmp( _( "All" ), text ) == 0;
filter_feeds( data );
return TRUE;
}
Modified: trunk/src/target/OM-2007/applications/openmoko-rssreader/src/main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-rssreader/src/main.c 2007-04-08 00:42:26 UTC (rev 1711)
+++ trunk/src/target/OM-2007/applications/openmoko-rssreader/src/main.c 2007-04-08 16:59:10 UTC (rev 1712)
@@ -32,11 +32,38 @@
#include <libmokoui/moko-details-window.h>
+#include <string.h>
#include <assert.h>
#define ASSERT_X(x, error) assert(x)
/*
+ * filter categories and such terms
+ */
+static gboolean
+rss_filter_entries (GtkTreeModel *model, GtkTreeIter *iter, struct RSSReaderData *data)
+{
+ /*
+ * filter the category
+ */
+ if ( !data->is_all_filter ) {
+ gchar *category;
+ gtk_tree_model_get (model, iter, RSS_READER_COLUMN_CATEGORY, &category, -1);
+
+
+ if ( strcmp(category, data->current_filter) != 0 )
+ return FALSE;
+ }
+
+
+ /*
+ * filter the text according to the search now
+ */
+
+ return TRUE;
+}
+
+/*
* sort the dates according to zsort. Ideally they should sort ascending
*/
static gint
@@ -109,6 +136,7 @@
* allow to filter for a search string
*/
data->filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_filter_new(GTK_TREE_MODEL(data->feed_data),NULL));
+ gtk_tree_model_filter_set_visible_func (data->filter_model, (GtkTreeModelFilterVisibleFunc)rss_filter_entries, data, NULL);
/*
* Allow sorting of the base model
@@ -235,6 +263,7 @@
* load data
*/
refresh_categories( data );
+ data->is_all_filter = TRUE;
moko_menu_box_set_active_filter( data->menubox, _("All") );
gtk_widget_show_all( GTK_WIDGET(data->window) );
More information about the commitlog
mailing list