NetSurf
|
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/nsurl.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "desktop/download.h"
#include "netsurf/download.h"
#include "gtk/warn.h"
#include "gtk/scaffolding.h"
#include "gtk/toolbar_items.h"
#include "gtk/window.h"
#include "gtk/compat.h"
#include "gtk/resources.h"
#include "gtk/download.h"
Go to the source code of this file.
Data Structures | |
struct | gui_download_window |
context for each download. More... | |
struct | download_window_ctx |
context for a nsgtk download window. More... | |
Macros | |
#define | UPDATE_RATE 500 /* In milliseconds */ |
Typedefs | |
typedef void(* | nsgtk_download_selection_action) (struct gui_download_window *dl, void *user_data) |
Enumerations | |
enum | { NSGTK_DOWNLOAD_PROGRESS , NSGTK_DOWNLOAD_INFO , NSGTK_DOWNLOAD_REMAINING , NSGTK_DOWNLOAD_SPEED , NSGTK_DOWNLOAD_PULSE , NSGTK_DOWNLOAD_STATUS , NSGTK_DOWNLOAD , NSGTK_DOWNLOAD_N_COLUMNS } |
enum | nsgtk_download_status { NSGTK_DOWNLOAD_NONE , NSGTK_DOWNLOAD_WORKING , NSGTK_DOWNLOAD_ERROR , NSGTK_DOWNLOAD_COMPLETE , NSGTK_DOWNLOAD_CANCELED } |
enum | nsgtk_download_actions { NSGTK_DOWNLOAD_PAUSE = 1 << 0 , NSGTK_DOWNLOAD_RESUME = 1 << 1 , NSGTK_DOWNLOAD_CANCEL = 1 << 2 , NSGTK_DOWNLOAD_CLEAR = 1 << 3 } |
Functions | |
static GtkTreeView * | nsgtk_download_tree_view_new (GtkBuilder *gladeFile) |
static gint | nsgtk_download_sort (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) |
static void | nsgtk_download_sensitivity_update_buttons (nsgtk_download_actions sensitivity) |
static void | nsgtk_download_sensitivity_evaluate (GtkTreeSelection *selection) |
static void | nsgtk_download_gfunc__gtk_tree_path_free (gpointer data, gpointer user_data) |
Wrapper to GFunc-ify gtk_tree_path_free for g_list_foreach. More... | |
static void | nsgtk_download_gfunc__g_free (gpointer data, gpointer user_data) |
Wrapper to GFunc-ify g_free for g_list_foreach. More... | |
static void | nsgtk_download_do (nsgtk_download_selection_action action) |
static gchar * | nsgtk_download_info_to_string (struct gui_download_window *dl) |
static gchar * | nsgtk_download_time_to_string (gint seconds) |
static void | nsgtk_download_store_update_item (struct gui_download_window *dl) |
static gboolean | nsgtk_download_update (gboolean force_update) |
static void | nsgtk_download_store_clear_item (struct gui_download_window *dl, void *user_data) |
static void | nsgtk_download_tree_view_row_activated (GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data) |
static void | nsgtk_download_change_sensitivity (struct gui_download_window *dl, nsgtk_download_actions sensitivity) |
static void | nsgtk_download_change_status (struct gui_download_window *dl, nsgtk_download_status status) |
static void | nsgtk_download_store_cancel_item (struct gui_download_window *dl, void *user_data) |
static gboolean | nsgtk_download_hide (GtkWidget *window) |
static gchar * | nsgtk_download_dialog_show (const gchar *filename, const gchar *domain, const gchar *size) |
Prompt user for downloaded file name. More... | |
static gboolean | nsgtk_download_handle_error (GError *error) |
static void | nsgtk_download_store_create_item (struct gui_download_window *dl) |
static gboolean | nsgtk_download_gsourcefunc__nsgtk_download_update (gpointer user_data) |
Wrapper to GSourceFunc-ify nsgtk_download_update. More... | |
static struct gui_download_window * | gui_download_window_create (download_context *ctx, struct gui_window *gui) |
core callback on creating a new download More... | |
static nserror | gui_download_window_data (struct gui_download_window *dw, const char *data, unsigned int size) |
core callback on receipt of data More... | |
static void | gui_download_window_error (struct gui_download_window *dw, const char *error_msg) |
core callback on error More... | |
static void | gui_download_window_done (struct gui_download_window *dw) |
core callback when core download is complete More... | |
nserror | nsgtk_download_init (void) |
Initialise download window ready for use. More... | |
void | nsgtk_download_destroy (void) |
Destroy download window. More... | |
bool | nsgtk_check_for_downloads (GtkWindow *parent) |
Check with user if download is in progress they want to complete. More... | |
void | nsgtk_download_show (GtkWindow *parent) |
Show the download window. More... | |
Variables | |
static const gchar * | status_messages [] |
static struct download_window_ctx | dl_ctx |
global instance of the download window More... | |
static struct gui_download_table | download_table |
struct gui_download_table * | nsgtk_download_table = &download_table |
download operation table for gtk More... | |
#define UPDATE_RATE 500 /* In milliseconds */ |
Definition at line 43 of file download.c.
typedef void(* nsgtk_download_selection_action) (struct gui_download_window *dl, void *user_data) |
Definition at line 104 of file download.c.
anonymous enum |
Enumerator | |
---|---|
NSGTK_DOWNLOAD_PROGRESS | |
NSGTK_DOWNLOAD_INFO | |
NSGTK_DOWNLOAD_REMAINING | |
NSGTK_DOWNLOAD_SPEED | |
NSGTK_DOWNLOAD_PULSE | |
NSGTK_DOWNLOAD_STATUS | |
NSGTK_DOWNLOAD | |
NSGTK_DOWNLOAD_N_COLUMNS |
Definition at line 47 of file download.c.
Enumerator | |
---|---|
NSGTK_DOWNLOAD_PAUSE | |
NSGTK_DOWNLOAD_RESUME | |
NSGTK_DOWNLOAD_CANCEL | |
NSGTK_DOWNLOAD_CLEAR |
Definition at line 67 of file download.c.
Enumerator | |
---|---|
NSGTK_DOWNLOAD_NONE | |
NSGTK_DOWNLOAD_WORKING | |
NSGTK_DOWNLOAD_ERROR | |
NSGTK_DOWNLOAD_COMPLETE | |
NSGTK_DOWNLOAD_CANCELED |
Definition at line 59 of file download.c.
|
static |
core callback on creating a new download
Definition at line 765 of file download.c.
References gui_download_window::ctx, gui_download_window::destination, dl_ctx, gui_download_window::domain, download_context_get_filename(), download_context_get_total_length(), download_context_get_url(), gui_download_window::error, human_friendly_bytesize(), download_window_ctx::iter, download_window_ctx::list, messages_get(), gui_download_window::name, NSGTK_DOWNLOAD_CANCEL, nsgtk_download_change_sensitivity(), nsgtk_download_change_status(), nsgtk_download_dialog_show(), nsgtk_download_gsourcefunc__nsgtk_download_update(), nsgtk_download_handle_error(), NSGTK_DOWNLOAD_NONE, nsgtk_download_show(), nsgtk_download_store_create_item(), NSGTK_DOWNLOAD_WORKING, nsgtk_get_scaffold(), nsgtk_scaffolding_window(), nsurl_get_component(), nsurl_has_component(), NSURL_HOST, download_window_ctx::num_active, download_window_ctx::parent, gui_download_window::progress, gui_download_window::row, gui_download_window::size, gui_download_window::size_downloaded, gui_download_window::size_total, gui_download_window::speed, gui_download_window::start_time, gui_download_window::status, download_window_ctx::store, gui_download_window::time_left, gui_download_window::time_remaining, download_window_ctx::timer, gui_download_window::total_size, UPDATE_RATE, gui_download_window::url, and gui_download_window::write.
|
static |
core callback on receipt of data
Definition at line 867 of file download.c.
References dl_ctx, gui_download_window::error, NSERROR_OK, NSERROR_SAVE_FAILED, nsgtk_download_change_sensitivity(), nsgtk_download_change_status(), NSGTK_DOWNLOAD_CLEAR, NSGTK_DOWNLOAD_ERROR, nsgtk_download_update(), gui_download_window::size, gui_download_window::size_downloaded, gui_download_window::speed, gui_download_window::time_remaining, download_window_ctx::window, and gui_download_window::write.
|
static |
core callback when core download is complete
Definition at line 903 of file download.c.
References gui_download_window::error, nsgtk_download_change_sensitivity(), nsgtk_download_change_status(), NSGTK_DOWNLOAD_CLEAR, NSGTK_DOWNLOAD_COMPLETE, nsgtk_download_store_clear_item(), nsgtk_download_update(), nsoption_bool, gui_download_window::progress, gui_download_window::size_downloaded, gui_download_window::size_total, gui_download_window::speed, gui_download_window::time_remaining, and gui_download_window::write.
|
static |
core callback on error
Definition at line 895 of file download.c.
bool nsgtk_check_for_downloads | ( | GtkWindow * | parent | ) |
Check with user if download is in progress they want to complete.
parent | The parent window for the prompt dialog. |
Definition at line 1033 of file download.c.
References dialog, dl_ctx, messages_get(), download_window_ctx::num_active, and parent.
Referenced by nsgtk_scaffolding_destroy_all(), and scaffolding_window_delete_event().
|
static |
Definition at line 538 of file download.c.
References dl_ctx, nsgtk_download_sensitivity_evaluate(), download_window_ctx::selection, and gui_download_window::sensitivity.
Referenced by gui_download_window_create(), gui_download_window_data(), gui_download_window_done(), and nsgtk_download_store_cancel_item().
|
static |
Definition at line 547 of file download.c.
References dl_ctx, download_window_ctx::iter, messages_get(), NSGTK_DOWNLOAD_NONE, NSGTK_DOWNLOAD_STATUS, gui_download_window::row, gui_download_window::status, status_messages, and download_window_ctx::store.
Referenced by gui_download_window_create(), gui_download_window_data(), gui_download_window_done(), and nsgtk_download_store_cancel_item().
void nsgtk_download_destroy | ( | void | ) |
Destroy download window.
Definition at line 1026 of file download.c.
References nsgtk_download_do(), and nsgtk_download_store_cancel_item().
Referenced by nsgtk_finalise().
|
static |
Prompt user for downloaded file name.
filename | The original name of the file |
domain | the domain the file is being downloaded from |
size | The size of the file being downloaded |
Definition at line 599 of file download.c.
References gui_download_window::destination, dialog, dl_ctx, gui_download_window::domain, gui_download_window::filename, messages_get(), nsgtk_image_new_from_stock(), NSGTK_STOCK_CANCEL, NSGTK_STOCK_SAVE, NSGTK_STOCK_SAVE_AS, nsgtk_warning(), nsoption_bool, nsoption_charp, download_window_ctx::parent, result, gui_download_window::size, and SLEN.
Referenced by gui_download_window_create().
|
static |
Definition at line 293 of file download.c.
References dl_ctx, download_window_ctx::iter, download_window_ctx::list, NSGTK_DOWNLOAD, nsgtk_download_gfunc__g_free(), nsgtk_download_gfunc__gtk_tree_path_free(), download_window_ctx::selection, and download_window_ctx::store.
Referenced by nsgtk_download_destroy(), nsgtk_download_init(), and nsgtk_download_tree_view_row_activated().
|
static |
Wrapper to GFunc-ify g_free for g_list_foreach.
Definition at line 287 of file download.c.
Referenced by nsgtk_download_do().
|
static |
Wrapper to GFunc-ify gtk_tree_path_free for g_list_foreach.
Definition at line 277 of file download.c.
Referenced by nsgtk_download_do().
|
static |
Wrapper to GSourceFunc-ify nsgtk_download_update.
Definition at line 755 of file download.c.
References nsgtk_download_update().
Referenced by gui_download_window_create().
|
static |
Definition at line 712 of file download.c.
References dialog, dl_ctx, gui_download_window::error, messages_get(), and download_window_ctx::parent.
Referenced by gui_download_window_create().
|
static |
Definition at line 584 of file download.c.
References gui_download_window::window.
Referenced by nsgtk_download_init().
|
static |
Definition at line 336 of file download.c.
References gui_download_window::error, human_friendly_bytesize(), messages_get(), gui_download_window::name, NSGTK_DOWNLOAD_ERROR, gui_download_window::size_downloaded, gui_download_window::size_total, and gui_download_window::status.
Referenced by nsgtk_download_store_update_item().
nserror nsgtk_download_init | ( | void | ) |
Initialise download window ready for use.
Definition at line 934 of file download.c.
References download_window_ctx::cancel, download_window_ctx::clear, dl_ctx, NSERROR_OK, nsgtk_builder_new_from_resname(), nsgtk_download_do(), nsgtk_download_hide(), NSGTK_DOWNLOAD_N_COLUMNS, nsgtk_download_sensitivity_evaluate(), nsgtk_download_sort(), NSGTK_DOWNLOAD_STATUS, nsgtk_download_store_cancel_item(), nsgtk_download_store_clear_item(), nsgtk_download_tree_view_new(), nsgtk_download_tree_view_row_activated(), NSLOG, download_window_ctx::parent, download_window_ctx::pause, download_window_ctx::progress, download_window_ctx::resume, download_window_ctx::selection, download_window_ctx::store, download_window_ctx::timer, download_window_ctx::tree, and download_window_ctx::window.
Referenced by nsgtk_setup().
|
static |
Definition at line 234 of file download.c.
References dl_ctx, download_window_ctx::list, NSGTK_DOWNLOAD, NSGTK_DOWNLOAD_CLEAR, nsgtk_download_sensitivity_update_buttons(), gui_download_window::sensitivity, and download_window_ctx::store.
Referenced by nsgtk_download_change_sensitivity(), nsgtk_download_init(), and nsgtk_download_store_clear_item().
|
static |
Definition at line 218 of file download.c.
References download_window_ctx::cancel, download_window_ctx::clear, dl_ctx, NSGTK_DOWNLOAD_CANCEL, NSGTK_DOWNLOAD_CLEAR, NSGTK_DOWNLOAD_PAUSE, NSGTK_DOWNLOAD_RESUME, download_window_ctx::pause, download_window_ctx::resume, and gui_download_window::sensitivity.
Referenced by nsgtk_download_sensitivity_evaluate().
void nsgtk_download_show | ( | GtkWindow * | parent | ) |
Show the download window.
parent | The parent window to use for the shown window |
Definition at line 1069 of file download.c.
References dl_ctx, download_window_ctx::parent, and download_window_ctx::window.
Referenced by downloads_button_clicked_cb(), and gui_download_window_create().
|
static |
Definition at line 203 of file download.c.
References NSGTK_DOWNLOAD, and gui_download_window::status.
Referenced by nsgtk_download_init().
|
static |
Definition at line 564 of file download.c.
References gui_download_window::ctx, download_context_abort(), download_context_get_filename(), NSGTK_DOWNLOAD_CANCEL, NSGTK_DOWNLOAD_CANCELED, nsgtk_download_change_sensitivity(), nsgtk_download_change_status(), NSGTK_DOWNLOAD_CLEAR, nsgtk_download_update(), gui_download_window::progress, gui_download_window::sensitivity, gui_download_window::size_downloaded, gui_download_window::speed, and gui_download_window::time_remaining.
Referenced by nsgtk_download_destroy(), and nsgtk_download_init().
|
static |
Definition at line 497 of file download.c.
References gui_download_window::ctx, dl_ctx, download_context_destroy(), download_window_ctx::iter, download_window_ctx::list, gui_download_window::name, NSGTK_DOWNLOAD_CLEAR, nsgtk_download_sensitivity_evaluate(), nsgtk_download_update(), gui_download_window::row, download_window_ctx::selection, gui_download_window::sensitivity, download_window_ctx::store, and gui_download_window::time_left.
Referenced by gui_download_window_done(), nsgtk_download_init(), and nsgtk_download_tree_view_row_activated().
|
static |
Definition at line 739 of file download.c.
References dl_ctx, download_window_ctx::iter, NSGTK_DOWNLOAD, nsgtk_download_store_update_item(), and download_window_ctx::store.
Referenced by gui_download_window_create().
|
static |
Definition at line 383 of file download.c.
References dl_ctx, human_friendly_bytesize(), download_window_ctx::iter, NSGTK_DOWNLOAD, NSGTK_DOWNLOAD_INFO, nsgtk_download_info_to_string(), NSGTK_DOWNLOAD_PROGRESS, NSGTK_DOWNLOAD_PULSE, NSGTK_DOWNLOAD_REMAINING, NSGTK_DOWNLOAD_SPEED, nsgtk_download_time_to_string(), NSGTK_DOWNLOAD_WORKING, gui_download_window::progress, gui_download_window::row, SLEN, gui_download_window::speed, gui_download_window::status, download_window_ctx::store, and gui_download_window::time_remaining.
Referenced by nsgtk_download_store_create_item(), and nsgtk_download_update().
|
static |
Definition at line 359 of file download.c.
Referenced by nsgtk_download_store_update_item().
|
static |
Definition at line 137 of file download.c.
References messages_get(), NSGTK_DOWNLOAD_INFO, NSGTK_DOWNLOAD_PROGRESS, NSGTK_DOWNLOAD_PULSE, NSGTK_DOWNLOAD_REMAINING, NSGTK_DOWNLOAD_SPEED, and NSGTK_DOWNLOAD_STATUS.
Referenced by nsgtk_download_init().
|
static |
Definition at line 520 of file download.c.
References nsgtk_download_do(), nsgtk_download_store_clear_item(), path(), and gui_download_window::tree.
Referenced by nsgtk_download_init().
|
static |
Definition at line 411 of file download.c.
References dl_ctx, gui_download_window::downloaded, fallthrough, download_window_ctx::list, messages_get(), NSGTK_DOWNLOAD_COMPLETE, NSGTK_DOWNLOAD_NONE, nsgtk_download_store_update_item(), NSGTK_DOWNLOAD_WORKING, nsgtk_widget_get_visible(), download_window_ctx::num_active, gui_download_window::progress, download_window_ctx::progress, gui_download_window::size_downloaded, gui_download_window::size_total, gui_download_window::speed, gui_download_window::start_time, gui_download_window::status, text(), gui_download_window::time_remaining, download_window_ctx::timer, and download_window_ctx::window.
Referenced by gui_download_window_data(), gui_download_window_done(), nsgtk_download_gsourcefunc__nsgtk_download_update(), nsgtk_download_store_cancel_item(), and nsgtk_download_store_clear_item().
|
static |
global instance of the download window
Definition at line 134 of file download.c.
Referenced by gui_download_window_create(), gui_download_window_data(), nsgtk_check_for_downloads(), nsgtk_download_change_sensitivity(), nsgtk_download_change_status(), nsgtk_download_dialog_show(), nsgtk_download_do(), nsgtk_download_handle_error(), nsgtk_download_init(), nsgtk_download_sensitivity_evaluate(), nsgtk_download_sensitivity_update_buttons(), nsgtk_download_show(), nsgtk_download_store_clear_item(), nsgtk_download_store_create_item(), nsgtk_download_store_update_item(), and nsgtk_download_update().
|
static |
Definition at line 923 of file download.c.
struct gui_download_table* nsgtk_download_table = &download_table |
|
static |
Definition at line 74 of file download.c.
Referenced by nsgtk_download_change_status().