67
alarm_list_entry_new_file (const gchar *uri, GnomeVFSResult *ret, gchar **mime_ret)
65
alarm_list_entry_new_file (const gchar *uri, gchar **mime_ret, GError **error)
69
67
AlarmListEntry *entry;
70
GnomeVFSResult result;
71
GnomeVFSFileInfo *info;
72
GtkIconTheme *theme = NULL;
74
if (!gnome_vfs_initialized())
77
if (gtk_init_check (NULL, NULL))
78
theme = gtk_icon_theme_get_default ();
80
g_warning ("gtk_init_check failed, icon lookup disabled.");
82
info = gnome_vfs_file_info_new ();
84
result = gnome_vfs_get_file_info (uri, info,
85
GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
90
if (result != GNOME_VFS_OK) {
91
g_warning ("Could not open uri: %s", uri);
68
GError *new_error = NULL;
72
file = g_file_new_for_uri (uri);
73
info = g_file_query_info (file, "standard::content-type,standard::icon",
74
G_FILE_QUERY_INFO_NONE, NULL, &new_error);
76
if (new_error != NULL) {
77
//g_warning ("Could not open uri: %s", uri);
81
g_error_free (new_error);
95
85
entry = g_new (AlarmListEntry, 1);
96
86
entry->data = g_strdup (uri);
97
entry->name = to_basename (info->name);
100
entry->icon = gnome_icon_lookup(theme, NULL,
101
entry->data, NULL, info,
102
info->mime_type, 0, 0);
87
entry->name = g_file_get_basename (file);
88
entry->icon = g_icon_to_string (g_file_info_get_icon (info));
104
90
if (mime_ret != NULL)
105
*mime_ret = g_strdup (info->mime_type);
91
*mime_ret = g_strdup (g_file_info_get_content_type (info));
107
gnome_vfs_file_info_unref (info);
93
g_object_unref (info);
94
g_object_unref (file);
113
100
alarm_list_entry_list_new (const gchar *dir_uri, const gchar *supported_types[])
115
GnomeVFSResult result;
116
GnomeVFSFileInfoOptions options;
117
GnomeVFSFileInfo *info;
121
GList *list, *l, *flist;
102
GError *error = NULL;
104
GFileEnumerator *result;
122
108
AlarmListEntry *entry;
123
109
const gchar *mime;
127
if (!gnome_vfs_initialized())
130
if (gtk_init_check (NULL, NULL))
131
theme = gtk_icon_theme_get_default ();
133
g_warning ("gtk_init_check failed, icon lookup disabled.");
135
options = GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FOLLOW_LINKS;
137
result = gnome_vfs_directory_list_load (&list, dir_uri, options);
139
if (result != GNOME_VFS_OK) {
113
dir = g_file_new_for_uri (dir_uri);
114
result = g_file_enumerate_children (dir,
115
"standard::type,standard::content-type,"
116
"standard::icon,standard::name",
117
G_FILE_QUERY_INFO_NONE, NULL, &error);
140
120
g_critical ("Could not open directory: %s", dir_uri);
121
g_error_free (error);
148
for (l = list; l; l = l->next) {
150
//g_debug ("-- %s", info->name);
151
if (info->type == GNOME_VFS_FILE_TYPE_REGULAR) {
152
mime = gnome_vfs_file_info_get_mime_type(info);
129
while ((info = g_file_enumerator_next_file (result, NULL, NULL))) {
130
//g_debug ("-- %s", g_file_info_get_name (info));
131
if (g_file_info_get_file_type (info) == G_FILE_TYPE_REGULAR) {
132
mime = g_file_info_get_content_type (info);
153
133
//g_debug (" [ regular file: MIME: %s ]", mime);
169
149
entry = g_new (AlarmListEntry, 1);
170
entry->data = g_strdup_printf ("%s/%s", dir_uri, info->name);
171
entry->name = to_basename (info->name);
175
entry->icon = gnome_icon_lookup(theme, NULL,
176
entry->data, NULL, info,
150
entry->name = g_strdup (g_file_info_get_name (info));
151
entry->data = g_strdup_printf ("%s/%s", dir_uri, entry->name);
152
entry->icon = g_icon_to_string (g_file_info_get_icon (info));
179
154
//g_debug ("Icon found: %s", entry->icon);
180
155
flist = g_list_append (flist, entry);