Skip to content

Commit

Permalink
chore: update to 3.24.3 and use (almost) default my_application.cc (#918
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Feichtmeier authored Sep 14, 2024
1 parent f0a48e3 commit 8938026
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main]

env:
FLUTTER_VERSION: '3.24.x'
FLUTTER_VERSION: '3.24.3'

jobs:
analyze:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

env:
FLUTTER_VERSION: '3.24.x'
FLUTTER_VERSION: '3.24.3'

jobs:
release_with_macos_dmg:
Expand Down
2 changes: 0 additions & 2 deletions linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
94 changes: 66 additions & 28 deletions linux/my_application.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "my_application.h"

#include <flutter_linux/flutter_linux.h>
#include <handy.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif

#include "flutter/generated_plugin_registrant.h"

Expand All @@ -15,31 +17,42 @@ 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;
gtk_window_set_geometry_hints(window, nullptr, &geometry_min, GDK_HINT_MIN_SIZE);
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));

Expand All @@ -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.
Expand All @@ -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));
}
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
nullptr));
}
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit 8938026

Please sign in to comment.