static GnomeVFSURI *content_make_src_uri(WebsiteContent *content, GenerateWebsiteWorkspace *workspace) { g_assert(content); g_assert(workspace); return gnome_vfs_uri_append_file_name(workspace->src_uri, content->src_page); }
void lister_view_from_tree_view (GtkTreeView *tree_view) { GtkTreePath *path = NULL; GtkTreeIter iter; GfmRowData *row_data = NULL; GnomeVFSURI *uri = NULL; GtkTreeModel *model; g_return_if_fail (tree_view != NULL); gtk_tree_view_get_cursor (tree_view, &path, NULL); model = gtk_tree_view_get_model (tree_view); if (!model) goto done; if (!gtk_tree_model_get_iter (model, &iter, path)) goto done; gtk_tree_model_get (model, &iter, GFM_COLUMN_DATA, &row_data, -1); if (!row_data) goto done; uri = gnome_vfs_uri_append_file_name (panels_data[get_panel_id(tree_view)].uri_wdir, row_data->info->name); if (!uri) goto done; lister_view_uri (uri, row_data->info->mime_type); done: if (path) gtk_tree_path_free (path); if (row_data) gfm_row_data_free (row_data); if (uri) gnome_vfs_uri_unref (uri); }
static void directory_load_callback (GnomeVFSAsyncHandle *handle, GnomeVFSResult result, GList *list, guint entries_read, gpointer callback_data) { CallbackData *data; GnomeVFSFileInfo *info; GnomeVFSURI *parent_uri; GnomeVFSURI *uri; GList *node; guint i; data = (CallbackData *)callback_data; if (!measure_speed) { printf ("Directory load callback: %s, %d entries, callback_data `%s'\n", gnome_vfs_result_to_string (result), entries_read, (gchar *) data->parent_uri); } parent_uri = gnome_vfs_uri_new (data->parent_uri); for (i = 0, node = list; i < entries_read && node != NULL; i++, node = node->next) { info = node->data; if (!measure_speed) { printf (" File `%s'%s (%s, %s), " "size %"GNOME_VFS_SIZE_FORMAT_STR", mode %04o\n", info->name, (info->flags & GNOME_VFS_FILE_FLAGS_SYMLINK) ? " [link]" : "", type_to_string (info->type), gnome_vfs_file_info_get_mime_type (info), info->size, info->permissions); fflush (stdout); } if (read_files) { if ((info->type & GNOME_VFS_FILE_TYPE_REGULAR) != 0) { uri = gnome_vfs_uri_append_file_name (parent_uri, info->name); test_read_file_async (uri); gnome_vfs_uri_unref (uri); } if (!measure_speed) { printf ("reading a bit of %s\n", info->name); } } } data->num_entries_read += entries_read; gnome_vfs_uri_unref (parent_uri); if (result != GNOME_VFS_OK) { if (--async_task_counter == 0) { g_main_loop_quit (main_loop); } } }
/*--------------------------------------------------------------------------*/ static void download_files( GnomeVFSURI *uri, GList *list, gint n ) { GnomeVFSFileInfo *info; GnomeVFSURI *file_uri; DownloadCallbackData *data; gint total_bytes; GList *p; gchar *status_string; gb_debug (DEBUG_UPDATE, "START"); if ( list ) { status_string = g_strdup_printf( _("Downloading redemption tables...") ); gtk_label_set_text( GTK_LABEL(status_label), status_string ); g_free( status_string ); total_bytes = 0; for ( p=list; p!=NULL; p=p->next ) { info = (GnomeVFSFileInfo *)p->data; total_bytes += info->size; } data = g_new0( DownloadCallbackData, 1 ); data->i = 0; data->n = n; data->total_bytes_read = 0; data->total_bytes = total_bytes; data->list = list; data->p = list; data->uri = uri; data->buffer = g_malloc0( 4096 ); data->buffer_length = 4096; data->line_buffer = g_malloc0( 4096 ); data->local_handle = NULL; info = (GnomeVFSFileInfo *)data->p->data; gb_debug (DEBUG_UPDATE, "Opening %s", info->name ); file_uri = gnome_vfs_uri_append_file_name( data->uri, info->name ); gb_debug (DEBUG_UPDATE, " URI = %s", gnome_vfs_uri_to_string (file_uri, 0) ); gnome_vfs_async_open_uri (&remote_file_handle, file_uri, GNOME_VFS_OPEN_READ, 0, open_remote_file_callback, data); } else { no_download(); } gb_debug (DEBUG_UPDATE, "END"); }
/*--------------------------------------------------------------------------*/ static void close_remote_file_callback( GnomeVFSAsyncHandle *handle, GnomeVFSResult result, gpointer callback_data ) { DownloadCallbackData *data = (DownloadCallbackData *)callback_data; GnomeVFSFileInfo *info; GnomeVFSURI *file_uri; gb_debug (DEBUG_UPDATE, "START"); if ( data->local_handle ) { gnome_vfs_close( data->local_handle ); data->local_handle = NULL; } if ( update_cancel_flag ) { gtk_widget_destroy( update_window ); update_window = NULL; gb_debug (DEBUG_UPDATE, "END -- CANCEL"); return; } if (result != GNOME_VFS_OK) { g_warning( "Close failed: %s", gnome_vfs_result_to_string(result) ); } data->i++; data->p = data->p->next; if ( data->p ) { info = (GnomeVFSFileInfo *)data->p->data; gb_debug (DEBUG_UPDATE, "Opening %s", info->name ); file_uri = gnome_vfs_uri_append_file_name( data->uri, info->name ); gb_debug (DEBUG_UPDATE, " URI = %s", gnome_vfs_uri_to_string (file_uri, 0) ); gnome_vfs_async_cancel (handle); gnome_vfs_async_open_uri (&remote_file_handle, file_uri, GNOME_VFS_OPEN_READ, 0, open_remote_file_callback, data); } else { download_done( data ); } gb_debug (DEBUG_UPDATE, "END"); }