diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 077edd402..c6ce2f346 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,7 +5,7 @@ on: branches: [main] env: - FLUTTER_VERSION: '3.24.x' + FLUTTER_VERSION: '3.24.3' jobs: analyze: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c4550d41e..efb5e82a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: env: - FLUTTER_VERSION: '3.24.x' + FLUTTER_VERSION: '3.24.3' jobs: release_with_macos_dmg: diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index f23055ea1..f04de8ec1 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -6,8 +6,6 @@ set(APPLICATION_ID "org.feichtmeier.Musicpod") cmake_policy(SET CMP0063 NEW) -set(USE_LIBHANDY ON) - set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Configure build options. diff --git a/linux/my_application.cc b/linux/my_application.cc index 6e5432cf0..c0c9863f3 100644 --- a/linux/my_application.cc +++ b/linux/my_application.cc @@ -1,7 +1,9 @@ #include "my_application.h" #include -#include +#ifdef GDK_WINDOWING_X11 +#include +#endif #include "flutter/generated_plugin_registrant.h" @@ -15,19 +17,31 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) // Implements GApplication::activate. static void my_application_activate(GApplication* application) { MyApplication* self = MY_APPLICATION(application); - - GList* windows = gtk_application_get_windows(GTK_APPLICATION(application)); - if (windows) { - gtk_window_present(GTK_WINDOW(windows->data)); - return; + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } } - GtkWindow* window = GTK_WINDOW(hdy_application_window_new()); - gtk_window_set_application(window, GTK_APPLICATION(application)); - - GtkBox* box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0)); - gtk_widget_show(GTK_WIDGET(box)); - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(box)); +#endif + if (use_header_bar) { + } else { + gtk_window_set_title(window, "MusicPod"); + } GdkGeometry geometry_min; geometry_min.min_width = 500; geometry_min.min_height = 700; @@ -35,11 +49,10 @@ static void my_application_activate(GApplication* application) { gtk_window_set_default_size(window, 950, 820); g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments( - project, self->dart_entrypoint_arguments); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); FlView* view = fl_view_new(project); - gtk_box_pack_end(GTK_BOX(box), GTK_WIDGET(view), true, true, 0); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); fl_register_plugins(FL_PLUGIN_REGISTRY(view)); @@ -48,18 +61,41 @@ static void my_application_activate(GApplication* application) { gtk_widget_grab_focus(GTK_WIDGET(view)); } -static gint my_application_command_line(GApplication *application, GApplicationCommandLine *command_line) { - MyApplication *self = MY_APPLICATION(application); - gchar **arguments = g_application_command_line_get_arguments(command_line, nullptr); - self->dart_entrypoint_arguments = g_strdupv(arguments + 1); +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); g_autoptr(GError) error = nullptr; if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - return 1; + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; } + g_application_activate(application); - return 0; + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); } // Implements GObject::dispose. @@ -71,15 +107,17 @@ static void my_application_dispose(GObject* object) { static void my_application_class_init(MyApplicationClass* klass) { G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->command_line = my_application_command_line; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; G_OBJECT_CLASS(klass)->dispose = my_application_dispose; } static void my_application_init(MyApplication* self) {} MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new( - my_application_get_type(), "application-id", APPLICATION_ID, "flags", - G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN, - nullptr)); -} \ No newline at end of file + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/pubspec.lock b/pubspec.lock index f24b2601c..cb8a50708 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1647,10 +1647,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "14.2.5" volume_controller: dependency: transitive description: @@ -1806,4 +1806,4 @@ packages: version: "0.0.3" sdks: dart: ">=3.5.0 <4.0.0" - flutter: ">=3.24.0" + flutter: ">=3.24.3" diff --git a/pubspec.yaml b/pubspec.yaml index 5ae170908..a851019e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: "none" environment: sdk: ">=3.0.0 <4.0.0" - flutter: ">=3.24.0" + flutter: ">=3.24.3" dependencies: animated_emoji: ^3.1.0 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 83f0001f2..b7a4cc974 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -61,7 +61,7 @@ parts: flutter-git: source: https://github.com/flutter/flutter.git - source-tag: 3.24.0 + source-tag: 3.24.3 source-depth: 1 plugin: nil override-build: |