forked from sergiotarxz/mangareader
Making the back button work as well as swipes and deleting stack items
after the list if a new manga is selected.
This commit is contained in:
parent
d48967f1bf
commit
fa9b3d5f20
@ -26,6 +26,15 @@ manga_selected (GtkListView *list_view,
|
|||||||
MangaPressedValues *manga_pressed_values = (MangaPressedValues *) user_data;
|
MangaPressedValues *manga_pressed_values = (MangaPressedValues *) user_data;
|
||||||
AdwLeaflet *views_leaflet = manga_pressed_values->views_leaflet;
|
AdwLeaflet *views_leaflet = manga_pressed_values->views_leaflet;
|
||||||
GtkBox *box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0));
|
GtkBox *box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0));
|
||||||
|
GtkWidget *widget = adw_leaflet_get_adjacent_child (views_leaflet,
|
||||||
|
ADW_NAVIGATION_DIRECTION_FORWARD);
|
||||||
|
|
||||||
|
while (widget) {
|
||||||
|
adw_leaflet_remove (views_leaflet, widget);
|
||||||
|
widget = adw_leaflet_get_adjacent_child (views_leaflet,
|
||||||
|
ADW_NAVIGATION_DIRECTION_FORWARD);
|
||||||
|
}
|
||||||
|
|
||||||
adw_leaflet_append (views_leaflet, GTK_WIDGET (box));
|
adw_leaflet_append (views_leaflet, GTK_WIDGET (box));
|
||||||
adw_leaflet_navigate (views_leaflet, ADW_NAVIGATION_DIRECTION_FORWARD);
|
adw_leaflet_navigate (views_leaflet, ADW_NAVIGATION_DIRECTION_FORWARD);
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@
|
|||||||
#include <openmg/view/list_view_manga.h>
|
#include <openmg/view/list_view_manga.h>
|
||||||
|
|
||||||
static AdwHeaderBar *
|
static AdwHeaderBar *
|
||||||
create_headerbar (GtkBox *box);
|
create_headerbar (GtkBox *box, AdwLeaflet *views_leaflet);
|
||||||
static GtkBox *
|
static GtkBox *
|
||||||
create_main_box (AdwApplicationWindow *window);
|
create_main_box (AdwApplicationWindow *window);
|
||||||
|
static void
|
||||||
|
go_back_view (GtkButton *previous, gpointer user_data);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
activate (AdwApplication *app,
|
activate (AdwApplication *app,
|
||||||
@ -26,7 +28,7 @@ activate (AdwApplication *app,
|
|||||||
AdwLeaflet *views_leaflet = ADW_LEAFLET (adw_leaflet_new ());
|
AdwLeaflet *views_leaflet = ADW_LEAFLET (adw_leaflet_new ());
|
||||||
adw_leaflet_set_can_swipe_back (views_leaflet, 1);
|
adw_leaflet_set_can_swipe_back (views_leaflet, 1);
|
||||||
|
|
||||||
create_headerbar (box);
|
create_headerbar (box, views_leaflet);
|
||||||
|
|
||||||
mangas = mg_backend_readmng_get_featured_manga (readmng);
|
mangas = mg_backend_readmng_get_featured_manga (readmng);
|
||||||
list_view = create_list_view_mangas (mangas, views_leaflet);
|
list_view = create_list_view_mangas (mangas, views_leaflet);
|
||||||
@ -56,7 +58,7 @@ create_main_box (AdwApplicationWindow *window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static AdwHeaderBar *
|
static AdwHeaderBar *
|
||||||
create_headerbar (GtkBox *box) {
|
create_headerbar (GtkBox *box, AdwLeaflet *views_leaflet) {
|
||||||
GtkWidget *title =
|
GtkWidget *title =
|
||||||
adw_window_title_new ("Window", NULL);
|
adw_window_title_new ("Window", NULL);
|
||||||
GtkWidget *header =
|
GtkWidget *header =
|
||||||
@ -66,6 +68,8 @@ create_headerbar (GtkBox *box) {
|
|||||||
GTK_WIDGET (title));
|
GTK_WIDGET (title));
|
||||||
gtk_box_append (box, header);
|
gtk_box_append (box, header);
|
||||||
GtkWidget *previous = gtk_button_new_from_icon_name ("go-previous-symbolic");
|
GtkWidget *previous = gtk_button_new_from_icon_name ("go-previous-symbolic");
|
||||||
|
g_signal_connect (G_OBJECT (previous), "clicked", G_CALLBACK (go_back_view),
|
||||||
|
views_leaflet);
|
||||||
|
|
||||||
adw_header_bar_pack_start (ADW_HEADER_BAR (header), previous);
|
adw_header_bar_pack_start (ADW_HEADER_BAR (header), previous);
|
||||||
|
|
||||||
@ -73,6 +77,11 @@ create_headerbar (GtkBox *box) {
|
|||||||
return ADW_HEADER_BAR (header);
|
return ADW_HEADER_BAR (header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
go_back_view (GtkButton *previous, gpointer user_data) {
|
||||||
|
AdwLeaflet *views_leaflet = ADW_LEAFLET (user_data);
|
||||||
|
adw_leaflet_navigate (views_leaflet, ADW_NAVIGATION_DIRECTION_BACK);
|
||||||
|
}
|
||||||
int
|
int
|
||||||
main_view_run (int argc,
|
main_view_run (int argc,
|
||||||
char **argv)
|
char **argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user