2 * Camera Launcher for Maemo.
3 * Copyright (C) 2009 Roman Moravcik
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <glib/gi18n-lib.h>
32 #include <hildon/hildon.h>
37 get_desktop_file_info (const gchar *desktop_file)
39 DesktopFileInfo *dfinfo = NULL;
41 gchar *filename = NULL;
44 filename = g_strdup_printf ("%s/%s", CL_LAUNCHER_DESKTOP_DATADIR, desktop_file);
46 key_file = g_key_file_new ();
47 if (g_key_file_load_from_file (key_file, filename, 0, NULL)) {
48 dfinfo = g_new0 (DesktopFileInfo, 1);
50 /* get application icon */
51 if (g_key_file_has_key (key_file, "Desktop Entry", "Icon", &error)) {
52 dfinfo->icon = g_key_file_get_string (key_file, "Desktop Entry", "Icon", &error);
57 /* get application name */
58 if (g_key_file_has_key (key_file, "Desktop Entry", "X-Text-Domain", &error)) {
59 textdomain (g_key_file_get_string (key_file, "Desktop Entry", "X-Text-Domain", &error));
60 dfinfo->name = gettext (g_key_file_get_string (key_file, "Desktop Entry", "Name", &error));
61 } else if (g_key_file_has_key (key_file, "Desktop Entry", "Name", &error)) {
62 dfinfo->name = g_key_file_get_string (key_file, "Desktop Entry", "Name", &error);
68 /* get application osso_service */
69 if (g_key_file_has_key (key_file, "Desktop Entry", "X-Osso-Service", &error)) {
70 dfinfo->osso_service = g_key_file_get_string (key_file, "Desktop Entry", "X-Osso-Service", &error);
72 dfinfo->osso_service = NULL;
75 /* get application exec */
76 if (g_key_file_has_key (key_file, "Desktop Entry", "Exec", &error)) {
77 dfinfo->exec = g_key_file_get_string (key_file, "Desktop Entry", "Exec", &error);
83 g_key_file_free (key_file);
89 get_application_list (GtkListStore *list)
91 gboolean found = FALSE;
92 GtkIconTheme *icon_theme;
96 icon_theme = gtk_icon_theme_get_default ();
98 dir = g_dir_open (CL_LAUNCHER_DESKTOP_DATADIR, 0, NULL);
100 const gchar *filename;
102 while ((filename = g_dir_read_name (dir)) != NULL) {
103 if (g_str_has_suffix (filename, ".desktop")) {
104 DesktopFileInfo *dfinfo = NULL;
105 GtkIconInfo *icon_info;
106 GdkPixbuf *icon_pixbuf = NULL;
108 dfinfo = get_desktop_file_info (filename);
111 dfinfo->icon = g_strdup ("tasklaunch_default_application");
114 icon_info = gtk_icon_theme_lookup_icon (icon_theme, dfinfo->icon, 48, GTK_ICON_LOOKUP_NO_SVG);
116 const gchar *fname = gtk_icon_info_get_filename (icon_info);
117 icon_pixbuf = gdk_pixbuf_new_from_file_at_size (fname, 48, 48, 0);
118 gtk_icon_info_free (icon_info);
121 /* fill application list */
122 gtk_list_store_append (list, &iter);
123 gtk_list_store_set (list, &iter,
124 SELECTOR_COLUMN_ICON, icon_pixbuf,
125 SELECTOR_COLUMN_NAME, dfinfo->name,
126 SELECTOR_COLUMN_OSSO_SERVICE, dfinfo->osso_service,
127 SELECTOR_COLUMN_EXEC, dfinfo->exec,
134 g_object_unref (icon_pixbuf);