G_MODULE_EXPORT int test_model_main (int argc, char *argv[]) { ClutterModel *model; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; model = clutter_list_model_new (N_COLUMNS, G_TYPE_INT, "Foo", G_TYPE_STRING, "Bar"); g_timeout_add (1000, (GSourceFunc) populate_model, model); g_signal_connect (model, "row-added", G_CALLBACK (on_row_added), NULL); g_signal_connect (model, "row-removed", G_CALLBACK (on_row_removed), NULL); g_signal_connect (model, "sort-changed", G_CALLBACK (on_sort_changed), NULL); g_signal_connect (model, "filter-changed", G_CALLBACK (on_filter_changed), NULL); clutter_main(); g_object_unref (model); return 0; }
ClutterModel * mnp_get_world_timezones (void) { GWeatherLocation *world; ClutterModel *store; world = gweather_location_new_world (FALSE); if (!world) return NULL; store = clutter_list_model_new (4, G_TYPE_STRING, "DisplayName", G_TYPE_POINTER, "location", G_TYPE_STRING, "CompareName", G_TYPE_STRING, "SortName"); fill_location_entry_model(store, world, NULL, NULL, NULL); /* gweather_location_unref (world); */ clutter_model_set_sort (store, 3, sort_weather_model, NULL, NULL); return (ClutterModel *)store; }
static void mnb_home_new_widget_dialog_init (MnbHomeNewWidgetDialog *self) { ClutterActor *table, *itemview; MnbHomeNewWidgetDialogItemFactory *factory; MnbHomePluginsEngine *engine; const GList *l; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MNB_TYPE_HOME_NEW_WIDGET_DIALOG, MnbHomeNewWidgetDialogPrivate); /* set up model and view */ self->priv->items = clutter_list_model_new (ITEMS_N_COLUMNS, G_TYPE_STRING, "Module", /* ITEMS_MODULE */ G_TYPE_STRING, "Name", /* ITEMS_NAME */ G_TYPE_STRING, "Icon" /* ITEMS_ICON */); table = mx_table_new (); mx_bin_set_child (MX_BIN (self), table); factory = g_object_new (MNB_TYPE_HOME_NEW_WIDGET_DIALOG_ITEM_FACTORY, NULL); factory->dialog = self; itemview = mx_item_view_new (); mx_table_add_actor (MX_TABLE (table), itemview, 0, 1); mx_item_view_set_model (MX_ITEM_VIEW (itemview), self->priv->items); mx_item_view_set_factory (MX_ITEM_VIEW (itemview), MX_ITEM_FACTORY (factory)); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "module", ITEMS_MODULE); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "label", ITEMS_NAME); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "icon", ITEMS_ICON); clutter_actor_show_all (table); /* find plugins */ /* FIXME: should we monitor for new plugins on the fly? */ engine = mnb_home_plugins_engine_dup (); for (l = peas_engine_get_plugin_list (PEAS_ENGINE (engine)); l != NULL; l = g_list_next (l)) { PeasPluginInfo *info = l->data; char *icon; if (!peas_plugin_info_is_available (info, NULL)) continue; icon = g_build_filename ( peas_plugin_info_get_module_dir (info), peas_plugin_info_get_icon_name (info), NULL); clutter_model_append (self->priv->items, ITEMS_MODULE, peas_plugin_info_get_module_name (info), ITEMS_NAME, peas_plugin_info_get_name (info), ITEMS_ICON, icon, -1); g_free (icon); } /* add actions */ mx_dialog_add_action (MX_DIALOG (self), mx_action_new_full ("cancel", _("Cancel"), G_CALLBACK (home_new_widget_dialog_cancel), self)); g_object_unref (engine); g_object_unref (factory); }