pre-inst should install 'installer' group rather than the hardcoded plover-gtkui
2 * Copyright (C) 2010 J. Ali Harlow <ali@juiblex.co.uk>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <plover-gtk/packagestore.h>
28 #include <plover-gtk/packagefilestore.h>
29 #include "app-manager.h"
32 static BOOL CALLBACK plover_applications_visible_callback(HMODULE module,
33 const char *type,char *name,long *param)
35 gboolean *visible=(void *)param;
36 if (!IS_INTRESOURCE(name) && !strcmp(name,"MAINICON"))
42 static gboolean plover_applications_visible_func(GtkTreeModel *model,
43 GtkTreeIter *iter,gpointer data)
45 /* Visible if row is non-empty and package contains a .desktop file
46 * in /usr/share/applications (UNIX) or package contains a .exe file
47 * which has a default application icon (MS-Windows).
49 PloverPackage *package;
50 GtkTreeModel *file_store;
56 #ifdef LOAD_LIBRARY_AS_IMAGE_RESOURCE
57 LOAD_LIBRARY_AS_IMAGE_RESOURCE|
59 LOAD_LIBRARY_AS_DATAFILE;
63 gboolean visible=FALSE;
64 gtk_tree_model_get(model,iter,PLOVER_PACKAGE_STORE_OBJ_COLUMN,&package,-1);
68 GTK_TREE_MODEL(plover_package_file_store_new_from_package(package));
69 if (gtk_tree_model_get_iter_first(file_store,&fi))
73 gtk_tree_model_get(file_store,&fi,
74 PLOVER_PACKAGE_FILE_STORE_NAME_COLUMN,&name,-1);
76 if (g_str_has_suffix(name,".exe"))
78 module=LoadLibraryExA(name,NULL,flags);
81 (void)EnumResourceNamesA(module,RT_ICON,
82 plover_applications_visible_callback,&visible);
84 (void)EnumResourceNamesA(module,RT_GROUP_ICON,
85 plover_applications_visible_callback,&visible);
90 dir=g_path_get_dirname(name);
91 if (!strcmp(dir,"/usr/share/applications") &&
92 g_str_has_suffix(name,".desktop"))
97 } while(!visible && gtk_tree_model_iter_next(file_store,&fi));
99 g_object_unref(file_store);
101 g_object_unref(package);
105 GtkTreeModel *plover_applications_model_new(GtkTreeModel *installed)
108 model=gtk_tree_model_filter_new(installed,NULL);
109 gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(model),
110 plover_applications_visible_func,NULL,NULL);