Adding support for building in both postmarketos and flatpak.

Neat trick with dlsym employed.
This commit is contained in:
sergiotarxz 2021-11-22 20:18:56 +01:00
parent 155d08ac4c
commit 07537a71f1
2 changed files with 18 additions and 4 deletions

View File

@ -28,10 +28,15 @@ sources = [
'src/backend/readmng.c', 'src/backend/readmng.c',
'src/main.c', 'src/main.c',
] ]
link_arguments = [
'-ldl'
]
executable('openmg', executable('openmg',
sources, sources,
dependencies : openmgdeps, dependencies : openmgdeps,
include_directories : inc, include_directories : inc,
install : true install : true,
link_args : link_arguments
) )

View File

@ -1,3 +1,5 @@
#include <dlfcn.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <adwaita.h> #include <adwaita.h>
@ -26,7 +28,14 @@ activate (AdwApplication *app,
GtkListView *list_view; GtkListView *list_view;
GtkWidget *scroll; GtkWidget *scroll;
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); typedef void (*swipe_back_t)(AdwLeaflet *, gboolean);
swipe_back_t swipe_back = (swipe_back_t) dlsym
(NULL, "adw_leaflet_set_can_navigate_back");
if (!swipe_back) {
swipe_back = (swipe_back_t) dlsym
(NULL, "adw_leaflet_set_can_swipe_back");
}
swipe_back (views_leaflet, 1);
create_headerbar (box, views_leaflet); create_headerbar (box, views_leaflet);
@ -37,7 +46,7 @@ activate (AdwApplication *app,
gtk_widget_set_valign (scroll, GTK_ALIGN_FILL); gtk_widget_set_valign (scroll, GTK_ALIGN_FILL);
gtk_widget_set_vexpand (scroll, 1); gtk_widget_set_vexpand (scroll, 1);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll), GTK_WIDGET (list_view)); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll), GTK_WIDGET (list_view));
adw_leaflet_append (views_leaflet, scroll); adw_leaflet_append (views_leaflet, scroll);
adw_leaflet_set_can_unfold (views_leaflet, false); adw_leaflet_set_can_unfold (views_leaflet, false);
@ -73,7 +82,7 @@ create_headerbar (GtkBox *box, AdwLeaflet *views_leaflet) {
views_leaflet); views_leaflet);
adw_header_bar_pack_start (ADW_HEADER_BAR (header), previous); adw_header_bar_pack_start (ADW_HEADER_BAR (header), previous);
return ADW_HEADER_BAR (header); return ADW_HEADER_BAR (header);
} }