diff -r 000000000000 -r 8d3b1ddf789c app-manager/applications.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app-manager/applications.c Sat Feb 20 12:11:02 2010 +0000 @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010 J. Ali Harlow + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include +#include +#include +#include +#include +#include "app-manager.h" + +static gboolean plover_applications_visible_func(GtkTreeModel *model, + GtkTreeIter *iter,gpointer data) +{ + /* Visible if row is non-empty and package contains a .desktop file + * in /usr/share/applications + */ + PloverPackage *package; + GtkTreeModel *file_store; + GtkTreeIter fi; + gchar *name,*dir; + gboolean visible=FALSE; + gtk_tree_model_get(model,iter,PLOVER_PACKAGE_STORE_OBJ_COLUMN,&package,-1); + if (package) + { + file_store=GTK_TREE_MODEL(plover_package_get_file_store(package)); + if (gtk_tree_model_get_iter_first(file_store,&fi)) + { + do + { + gtk_tree_model_get(file_store,&fi, + PLOVER_PACKAGE_FILE_STORE_NAME_COLUMN,&name,-1); + dir=g_path_get_dirname(name); + if (!strcmp(dir,"/usr/share/applications") && + g_str_has_suffix(name,".desktop")) + visible=TRUE; + g_free(dir); + g_free(name); + } while(!visible && gtk_tree_model_iter_next(file_store,&fi)); + } + } + g_object_unref(package); + return visible; +} + +GtkTreeModel *plover_applications_model_new(GtkTreeModel *installed) +{ + GtkTreeModel *model; + model=gtk_tree_model_filter_new(installed,NULL); + gtk_tree_model_filter_set_visible_func(model, + plover_applications_visible_func,NULL,NULL); + return model; +}