static void monitor_changed_cb (GnomeVFSVolumeMonitor *volume_monitor, gpointer data, GthLocation *loc) { g_list_foreach (loc->priv->drives, (GFunc) gnome_vfs_drive_unref, NULL); g_list_free (loc->priv->drives); loc->priv->drives = gnome_vfs_volume_monitor_get_connected_drives (volume_monitor); update_drives (loc); }
static void update_places(Menu_list_item **p, char* file_manager) { static GnomeVFSVolumeMonitor* vfsvolumes = NULL; Menu_list_item * sublist = *p; Menu_list_item * item; sublist = g_slist_append(sublist, get_blank()); item = g_malloc(sizeof(Menu_list_item)); item->item_type = MENU_ITEM_ENTRY; item->name = g_strdup("Home"); item->icon = g_strdup("stock_home"); const char *homedir = g_getenv("HOME"); if (!homedir) homedir = g_get_home_dir(); item->exec = g_strdup_printf("%s %s", file_manager, homedir); item->comment = g_strdup("Your Home Directory"); item->desktop = g_strdup(""); sublist = g_slist_append(sublist, item); item = g_malloc(sizeof(Menu_list_item)); item->item_type = MENU_ITEM_ENTRY; item->name = g_strdup("File System"); item->icon = g_strdup("stock_folder"); item->exec = g_strdup_printf("%s /", file_manager); item->comment = g_strdup("Root File System"); item->desktop = g_strdup(""); sublist = g_slist_append(sublist, item); //mount monitor if (!vfsvolumes) { vfsvolumes = gnome_vfs_get_volume_monitor(); g_signal_connect(G_OBJECT(vfsvolumes), "volume-mounted", G_CALLBACK(_vfs_changed_v_m), NULL); g_signal_connect(G_OBJECT(vfsvolumes), "volume-unmounted", G_CALLBACK(_vfs_changed_v_u), NULL); g_signal_connect(G_OBJECT(vfsvolumes), "drive-disconnected" , G_CALLBACK(_vfs_changed_d_d), NULL); g_signal_connect(G_OBJECT(vfsvolumes), "drive-connected", G_CALLBACK(_vfs_changed_d_c), NULL); } GList *connected = gnome_vfs_volume_monitor_get_connected_drives(vfsvolumes); if (connected) g_list_foreach(connected, _fillin_connected, &sublist); g_list_free(connected); sublist = g_slist_append(sublist, get_separator()); /*bookmarks*/ FILE* handle; gchar * filename = g_strdup_printf("%s/.gtk-bookmarks", homedir); handle = g_fopen(filename, "r"); if (handle) { char * line = NULL; size_t len = 0; while (getline(&line, &len, handle) != -1) { gchar ** tokens; tokens = g_strsplit(line, " ", 2); if (tokens) { if (tokens[0]) { gchar * shell_quoted; g_strstrip(tokens[0]); item = g_malloc(sizeof(Menu_list_item)); item->item_type = MENU_ITEM_ENTRY; if (tokens[1]) { g_strstrip(tokens[1]); item->name = g_strdup(tokens[1]); } else { item->name = urldecode(g_path_get_basename(tokens[0]), NULL); } item->icon = g_strdup("stock_folder"); shell_quoted = g_shell_quote(tokens[0]); item->exec = g_strdup_printf("%s %s", file_manager, shell_quoted); item->comment = urldecode(g_strdup(shell_quoted),NULL); g_free(shell_quoted); item->desktop = g_strdup(""); sublist = g_slist_append(sublist, item); } } g_strfreev(tokens); free(line); line = NULL; } fclose(handle); g_free(filename); } else { printf("Unable to open bookmark file: %s/.gtk-bookmarks\n", homedir); } sublist = g_slist_append(sublist, get_blank()); *p = sublist; }