From 673987f1816a9c63712b5683f11e9cae75de2038 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 30 Jul 2008 18:50:40 +0200 Subject: [PATCH] First round at updating combo logic in the filter builder (not working). --- libmmanager-gtk/mm-gtk-filter-builder.c | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/libmmanager-gtk/mm-gtk-filter-builder.c b/libmmanager-gtk/mm-gtk-filter-builder.c index cf51a35..c27a28b 100644 --- a/libmmanager-gtk/mm-gtk-filter-builder.c +++ b/libmmanager-gtk/mm-gtk-filter-builder.c @@ -19,6 +19,9 @@ */ #include "mm-gtk-filter-builder.h" +#include "mm-gtk-attribute-store.h" +#include "libmmanager/mm-attribute-manager.h" +#include "libmmanager/mm-attribute-base-manager.h" #include #include @@ -30,6 +33,7 @@ G_DEFINE_TYPE (MMGtkFilterBuilder, mm_gtk_filter_builder, GTK_TYPE_VBOX); struct _MMGtkFilterBuilderDetails { GtkListStore *filter_store; + MMGtkAttributeStore *attribute_store; GtkWidget *filter_view; GtkWidget *cat_combo; @@ -65,6 +69,13 @@ populate_logic_combo (GtkWidget *combo) } static void +cat_combo_changed_cb (GtkComboBox *combo, + MMGtkFilterBuilder *self) +{ + +} + +static void mm_gtk_filter_builder_init (MMGtkFilterBuilder *self) { MMGtkFilterBuilderDetails *details = self->details = @@ -75,6 +86,7 @@ mm_gtk_filter_builder_init (MMGtkFilterBuilder *self) GtkWidget *table; GtkWidget *w; + details->attribute_store = mm_gtk_attribute_store_new (); details->filter_store = gtk_list_store_new (3, G_TYPE_STRING, /* attribute name */ G_TYPE_STRING, /* operator */ @@ -106,7 +118,9 @@ mm_gtk_filter_builder_init (MMGtkFilterBuilder *self) gtk_table_attach (GTK_TABLE (table), w, 0, 1, 0, 1, 0, 0, 0, 0); - details->cat_combo = gtk_combo_box_new (); + details->cat_combo = gtk_combo_box_new_text (); + g_signal_connect (details->cat_combo, "changed", + G_CALLBACK (cat_combo_changed_cb), self); gtk_table_attach (GTK_TABLE (table), details->cat_combo, 1, 2, 0, 1, 0, 0, 0, 0); @@ -115,6 +129,9 @@ mm_gtk_filter_builder_init (MMGtkFilterBuilder *self) 2, 3, 0, 1, 0, 0, 0, 0); details->attr_combo = gtk_combo_box_new (); + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (details->attr_combo), + renderer, + "text", MM_GTK_ATTR_STORE_NAME_COL); gtk_table_attach (GTK_TABLE (table), details->attr_combo, 3, 4, 0, 1, 0, 0, 0, 0); @@ -146,12 +163,42 @@ mm_gtk_filter_builder_init (MMGtkFilterBuilder *self) } static void +populate_cat_combo (MMGtkFilterBuilder *self, MMApplicationType type) +{ + /* TODO: update this when we support more attr managers */ + gtk_combo_box_append_text (GTK_COMBO_BOX (self->details->cat_combo), + _("Base attributes")); + /* this should trigger population in the attr combo box */ + gtk_combo_box_set_active (GTK_COMBO_BOX (self->details->cat_combo), 0); +} + +static void populate_from_category (MMGtkFilterBuilder *self, MMCategory *cat) { MMApplication *app; MMApplicationType type; + MMAttributeManager *attr_manager; + + /* TODO: we should take care in some way that applications may want to define + * a custom AttributeManager. The API here in libmmanager-gtk is already + * setup for that, but this needs an API addition in MMApplication. + */ + + g_return_if_fail (MM_GTK_IS_FILTER_BUILDER (self)); + g_return_if_fail (MM_IS_CATEGORY (cat)); + + app = mm_category_get_application (cat); + g_object_get (app, "supported-type", &type, NULL); + + attr_manager = mm_attribute_base_manager_get (); + /* TODO: when I will create Photo, Video and Music attribute managers, + * here is the place for adding those custom attributes. + */ + mm_gtk_attribute_store_add_from_attribute_manager (self->details->attribute_store, + attr_manager); + g_object_unref (app); - + populate_cat_combo (self, type); } /* public methods */ -- 2.11.4.GIT