static void _on_add_filename(gchar const * pathname, gpointer data) { const char scheme[] = "file://"; Favorites * favorites = data; GtkTreeIter iter; struct stat st; gchar * filename; String * path; gint size = 24; GdkPixbuf * pixbuf; /* XXX ignore non-directories */ if(browser_vfs_stat(pathname, &st) != 0 || !S_ISDIR(st.st_mode)) return; if((filename = g_path_get_basename(pathname)) == NULL) return; if((path = string_new_append(scheme, pathname, NULL)) == NULL) return; gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &size, &size); if((pixbuf = browser_vfs_mime_icon(favorites->mime, pathname, NULL, NULL, &st, size)) == NULL) pixbuf = favorites->folder; #if GTK_CHECK_VERSION(2, 6, 0) gtk_list_store_insert_with_values(favorites->store, &iter, -1, #else gtk_list_store_append(favorites->store, &iter); gtk_list_store_set(favorites->store, &iter, #endif FC_ICON, pixbuf, FC_NAME, filename, FC_PATH, path, -1); string_delete(path); g_free(filename); _favorites_save(favorites); }
/* vfs */ static int _vfs(void) { int ret = 0; Mime * mime; char const downloads[] = "/home/user/Downloads"; char const * type; GdkPixbuf * icon; if((mime = mime_new(NULL)) == NULL) return -1; if((type = browser_vfs_mime_type(mime, downloads, S_IFDIR)) == NULL || strcmp(type, "inode/directory") != 0) ret = -1; else printf("%s\n", type); if((icon = browser_vfs_mime_icon(mime, downloads, type, NULL, NULL, 48)) != NULL) g_object_unref(icon); mime_delete(mime); return ret; }
static void _refresh_add_file(Favorites * favorites, gint size, char const * buf) { const char scheme[] = "file:///"; gchar * filename; GtkTreeIter iter; GdkPixbuf * pixbuf; filename = g_path_get_basename( &buf[sizeof(scheme) - 2]); if((pixbuf = browser_vfs_mime_icon(favorites->mime, &buf[sizeof(scheme) - 2], NULL, NULL, NULL, size)) == NULL) pixbuf = favorites->folder; #if GTK_CHECK_VERSION(2, 6, 0) gtk_list_store_insert_with_values(favorites->store, &iter, -1, #else gtk_list_store_append(favorites->store, &iter); gtk_list_store_set(favorites->store, &iter, #endif FC_ICON, pixbuf, FC_NAME, filename, FC_PATH, buf, -1); g_free(filename); }