Better yet image download.
This commit is contained in:
parent
84c47861ad
commit
e0c837642b
@ -11,6 +11,7 @@ typedef struct {
|
|||||||
AdwViewStack *view_stack;
|
AdwViewStack *view_stack;
|
||||||
GCancellable **image_threads;
|
GCancellable **image_threads;
|
||||||
size_t image_threads_len;
|
size_t image_threads_len;
|
||||||
|
bool avoid_list_image_downloads;
|
||||||
GtkButton *previous;
|
GtkButton *previous;
|
||||||
gboolean is_set_previous;
|
gboolean is_set_previous;
|
||||||
} ControlsAdwaita;
|
} ControlsAdwaita;
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
GtkPicture *
|
GtkPicture *
|
||||||
create_picture_from_url (const char *const url, gint picture_size,
|
create_picture_from_url (const char *const url, gint picture_size,
|
||||||
GAsyncReadyCallback ready, gpointer source_object,
|
GAsyncReadyCallback ready, gpointer source_object,
|
||||||
gpointer callback_data);
|
gpointer callback_data, bool do_not_download);
|
||||||
|
@ -168,7 +168,7 @@ set_image_zoomable_picture_container (ChapterVisorData *chapter_visor_data) {
|
|||||||
strlen (url_image_not_owned));
|
strlen (url_image_not_owned));
|
||||||
|
|
||||||
GtkPicture *picture = create_picture_from_url (url_image, 0, picture_ready_manga_page,
|
GtkPicture *picture = create_picture_from_url (url_image, 0, picture_ready_manga_page,
|
||||||
zoomable_picture_container, chapter_visor_data);
|
zoomable_picture_container, chapter_visor_data, false);
|
||||||
if (picture) {
|
if (picture) {
|
||||||
chapter_visor_data->current_picture = GTK_PICTURE (picture);
|
chapter_visor_data->current_picture = GTK_PICTURE (picture);
|
||||||
g_signal_connect (G_OBJECT (picture), "map",
|
g_signal_connect (G_OBJECT (picture), "map",
|
||||||
|
@ -90,7 +90,7 @@ create_detail_view (MgManga *manga, ControlsAdwaita *controls) {
|
|||||||
GtkListView *chapter_list = NULL;
|
GtkListView *chapter_list = NULL;
|
||||||
char *url_image = mg_manga_get_image_url(manga);
|
char *url_image = mg_manga_get_image_url(manga);
|
||||||
GtkPicture *picture = create_picture_from_url (url_image, 200,
|
GtkPicture *picture = create_picture_from_url (url_image, 200,
|
||||||
picture_ready_manga_detail, avatar_title_box, NULL);
|
picture_ready_manga_detail, avatar_title_box, NULL, false);
|
||||||
char *manga_title_text = mg_manga_get_title (manga);
|
char *manga_title_text = mg_manga_get_title (manga);
|
||||||
char *title_text = mg_util_xml_get_title_text (
|
char *title_text = mg_util_xml_get_title_text (
|
||||||
xml_util, manga_title_text);
|
xml_util, manga_title_text);
|
||||||
|
@ -26,6 +26,7 @@ manga_selected (GtkListView *list_view,
|
|||||||
guint position,
|
guint position,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
ControlsAdwaita *controls = (ControlsAdwaita *) user_data;
|
ControlsAdwaita *controls = (ControlsAdwaita *) user_data;
|
||||||
|
controls->avoid_list_image_downloads = true;;
|
||||||
for (size_t i = 0; i < controls->image_threads_len; i++) {
|
for (size_t i = 0; i < controls->image_threads_len; i++) {
|
||||||
g_cancellable_cancel (controls->image_threads[i]);
|
g_cancellable_cancel (controls->image_threads[i]);
|
||||||
}
|
}
|
||||||
@ -52,6 +53,7 @@ manga_selected (GtkListView *list_view,
|
|||||||
GtkBox *detail_view = create_detail_view (manga, controls);
|
GtkBox *detail_view = create_detail_view (manga, controls);
|
||||||
adw_leaflet_append (views_leaflet, GTK_WIDGET (detail_view));
|
adw_leaflet_append (views_leaflet, GTK_WIDGET (detail_view));
|
||||||
adw_leaflet_navigate (views_leaflet, ADW_NAVIGATION_DIRECTION_FORWARD);
|
adw_leaflet_navigate (views_leaflet, ADW_NAVIGATION_DIRECTION_FORWARD);
|
||||||
|
controls->avoid_list_image_downloads = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIST_IMAGES
|
#ifdef LIST_IMAGES
|
||||||
@ -80,10 +82,13 @@ setup_list_view_mangas (GtkSignalListItemFactory *factory,
|
|||||||
char *image_url = mg_manga_get_image_url (manga);
|
char *image_url = mg_manga_get_image_url (manga);
|
||||||
|
|
||||||
GtkWidget *label = gtk_label_new (manga_title);
|
GtkWidget *label = gtk_label_new (manga_title);
|
||||||
|
GtkPicture *picture = NULL;
|
||||||
#ifdef LIST_IMAGES
|
#ifdef LIST_IMAGES
|
||||||
|
printf ("%d\n", controls->avoid_list_image_downloads);
|
||||||
GCancellable *cancellable = g_cancellable_new ();
|
GCancellable *cancellable = g_cancellable_new ();
|
||||||
GtkPicture *picture = create_picture_from_url (image_url, 100,
|
picture = create_picture_from_url (image_url, 100,
|
||||||
picture_ready_manga_preview, box, cancellable);
|
picture_ready_manga_preview, box, cancellable,
|
||||||
|
controls->avoid_list_image_downloads);
|
||||||
controls->image_threads_len++;
|
controls->image_threads_len++;
|
||||||
controls->image_threads = g_realloc (controls->image_threads,
|
controls->image_threads = g_realloc (controls->image_threads,
|
||||||
controls->image_threads_len * sizeof *(controls->image_threads));
|
controls->image_threads_len * sizeof *(controls->image_threads));
|
||||||
|
@ -56,6 +56,7 @@ activate (AdwApplication *app,
|
|||||||
controls->view_stack = view_stack;
|
controls->view_stack = view_stack;
|
||||||
controls->image_threads_len = 0;
|
controls->image_threads_len = 0;
|
||||||
controls->image_threads = NULL;
|
controls->image_threads = NULL;
|
||||||
|
controls->avoid_list_image_downloads = false;
|
||||||
|
|
||||||
views_leaflet_explore = create_explore_leaflet (controls, swipe_back);
|
views_leaflet_explore = create_explore_leaflet (controls, swipe_back);
|
||||||
views_leaflet_search = create_search_leaflet (controls, swipe_back);
|
views_leaflet_search = create_search_leaflet (controls, swipe_back);
|
||||||
|
@ -96,7 +96,7 @@ free_picture_thread_attributes (gpointer user_data) {
|
|||||||
GtkPicture *
|
GtkPicture *
|
||||||
create_picture_from_url (const char *const url, gint picture_size,
|
create_picture_from_url (const char *const url, gint picture_size,
|
||||||
GAsyncReadyCallback ready, gpointer source_object,
|
GAsyncReadyCallback ready, gpointer source_object,
|
||||||
gpointer callback_data) {
|
gpointer callback_data, bool do_not_download) {
|
||||||
GtkPicture *picture = NULL;
|
GtkPicture *picture = NULL;
|
||||||
GFile *image = NULL;
|
GFile *image = NULL;
|
||||||
GdkTexture *texture = NULL;
|
GdkTexture *texture = NULL;
|
||||||
@ -118,7 +118,7 @@ create_picture_from_url (const char *const url, gint picture_size,
|
|||||||
g_object_set_property_int (G_OBJECT(picture), "width-request", picture_size);
|
g_object_set_property_int (G_OBJECT(picture), "width-request", picture_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else if (!do_not_download) {
|
||||||
GTask *task = g_task_new (source_object, NULL, ready, callback_data);
|
GTask *task = g_task_new (source_object, NULL, ready, callback_data);
|
||||||
PictureThreadAttributes *attrs = g_malloc (sizeof *attrs);
|
PictureThreadAttributes *attrs = g_malloc (sizeof *attrs);
|
||||||
attrs->url = g_malloc (url_len * sizeof *url);
|
attrs->url = g_malloc (url_len * sizeof *url);
|
||||||
|
@ -59,9 +59,11 @@ search_text_changed (GtkEntry *entry,
|
|||||||
}
|
}
|
||||||
controls->image_threads = NULL;
|
controls->image_threads = NULL;
|
||||||
controls->image_threads_len = 0;
|
controls->image_threads_len = 0;
|
||||||
|
controls->avoid_list_image_downloads = true;
|
||||||
if (!mangas) return;
|
if (!mangas) return;
|
||||||
GtkSingleSelection *selection = GTK_SINGLE_SELECTION (
|
GtkSingleSelection *selection = GTK_SINGLE_SELECTION (
|
||||||
gtk_list_view_get_model (list_view_mangas));
|
gtk_list_view_get_model (list_view_mangas));
|
||||||
gtk_single_selection_set_model (selection,
|
gtk_single_selection_set_model (selection,
|
||||||
G_LIST_MODEL (mangas));
|
G_LIST_MODEL (mangas));
|
||||||
|
controls->avoid_list_image_downloads = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user