Skip to content

Commit 8938026

Browse files
authored
chore: update to 3.24.3 and use (almost) default my_application.cc (#918)
1 parent f0a48e3 commit 8938026

File tree

7 files changed

+73
-37
lines changed

7 files changed

+73
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches: [main]
66

77
env:
8-
FLUTTER_VERSION: '3.24.x'
8+
FLUTTER_VERSION: '3.24.3'
99

1010
jobs:
1111
analyze:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88

99
env:
10-
FLUTTER_VERSION: '3.24.x'
10+
FLUTTER_VERSION: '3.24.3'
1111

1212
jobs:
1313
release_with_macos_dmg:

linux/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ set(APPLICATION_ID "org.feichtmeier.Musicpod")
66

77
cmake_policy(SET CMP0063 NEW)
88

9-
set(USE_LIBHANDY ON)
10-
119
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
1210

1311
# Configure build options.

linux/my_application.cc

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "my_application.h"
22

33
#include <flutter_linux/flutter_linux.h>
4-
#include <handy.h>
4+
#ifdef GDK_WINDOWING_X11
5+
#include <gdk/gdkx.h>
6+
#endif
57

68
#include "flutter/generated_plugin_registrant.h"
79

@@ -15,31 +17,42 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1517
// Implements GApplication::activate.
1618
static void my_application_activate(GApplication* application) {
1719
MyApplication* self = MY_APPLICATION(application);
18-
19-
GList* windows = gtk_application_get_windows(GTK_APPLICATION(application));
20-
if (windows) {
21-
gtk_window_present(GTK_WINDOW(windows->data));
22-
return;
20+
GtkWindow* window =
21+
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22+
23+
// Use a header bar when running in GNOME as this is the common style used
24+
// by applications and is the setup most users will be using (e.g. Ubuntu
25+
// desktop).
26+
// If running on X and not using GNOME then just use a traditional title bar
27+
// in case the window manager does more exotic layout, e.g. tiling.
28+
// If running on Wayland assume the header bar will work (may need changing
29+
// if future cases occur).
30+
gboolean use_header_bar = TRUE;
31+
#ifdef GDK_WINDOWING_X11
32+
GdkScreen* screen = gtk_window_get_screen(window);
33+
if (GDK_IS_X11_SCREEN(screen)) {
34+
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35+
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36+
use_header_bar = FALSE;
37+
}
2338
}
24-
GtkWindow* window = GTK_WINDOW(hdy_application_window_new());
25-
gtk_window_set_application(window, GTK_APPLICATION(application));
26-
27-
GtkBox* box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
28-
gtk_widget_show(GTK_WIDGET(box));
29-
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(box));
39+
#endif
40+
if (use_header_bar) {
3041

42+
} else {
43+
gtk_window_set_title(window, "MusicPod");
44+
}
3145
GdkGeometry geometry_min;
3246
geometry_min.min_width = 500;
3347
geometry_min.min_height = 700;
3448
gtk_window_set_geometry_hints(window, nullptr, &geometry_min, GDK_HINT_MIN_SIZE);
3549
gtk_window_set_default_size(window, 950, 820);
3650

3751
g_autoptr(FlDartProject) project = fl_dart_project_new();
38-
fl_dart_project_set_dart_entrypoint_arguments(
39-
project, self->dart_entrypoint_arguments);
52+
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
4053

4154
FlView* view = fl_view_new(project);
42-
gtk_box_pack_end(GTK_BOX(box), GTK_WIDGET(view), true, true, 0);
55+
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
4356

4457
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
4558

@@ -48,18 +61,41 @@ static void my_application_activate(GApplication* application) {
4861
gtk_widget_grab_focus(GTK_WIDGET(view));
4962
}
5063

51-
static gint my_application_command_line(GApplication *application, GApplicationCommandLine *command_line) {
52-
MyApplication *self = MY_APPLICATION(application);
53-
gchar **arguments = g_application_command_line_get_arguments(command_line, nullptr);
54-
self->dart_entrypoint_arguments = g_strdupv(arguments + 1);
64+
// Implements GApplication::local_command_line.
65+
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
66+
MyApplication* self = MY_APPLICATION(application);
67+
// Strip out the first argument as it is the binary name.
68+
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
5569

5670
g_autoptr(GError) error = nullptr;
5771
if (!g_application_register(application, nullptr, &error)) {
58-
g_warning("Failed to register: %s", error->message);
59-
return 1;
72+
g_warning("Failed to register: %s", error->message);
73+
*exit_status = 1;
74+
return TRUE;
6075
}
76+
6177
g_application_activate(application);
62-
return 0;
78+
*exit_status = 0;
79+
80+
return TRUE;
81+
}
82+
83+
// Implements GApplication::startup.
84+
static void my_application_startup(GApplication* application) {
85+
//MyApplication* self = MY_APPLICATION(object);
86+
87+
// Perform any actions required at application startup.
88+
89+
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
90+
}
91+
92+
// Implements GApplication::shutdown.
93+
static void my_application_shutdown(GApplication* application) {
94+
//MyApplication* self = MY_APPLICATION(object);
95+
96+
// Perform any actions required at application shutdown.
97+
98+
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
6399
}
64100

65101
// Implements GObject::dispose.
@@ -71,15 +107,17 @@ static void my_application_dispose(GObject* object) {
71107

72108
static void my_application_class_init(MyApplicationClass* klass) {
73109
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
74-
G_APPLICATION_CLASS(klass)->command_line = my_application_command_line;
110+
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
111+
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
112+
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
75113
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
76114
}
77115

78116
static void my_application_init(MyApplication* self) {}
79117

80118
MyApplication* my_application_new() {
81-
return MY_APPLICATION(g_object_new(
82-
my_application_get_type(), "application-id", APPLICATION_ID, "flags",
83-
G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN,
84-
nullptr));
85-
}
119+
return MY_APPLICATION(g_object_new(my_application_get_type(),
120+
"application-id", APPLICATION_ID,
121+
"flags", G_APPLICATION_NON_UNIQUE,
122+
nullptr));
123+
}

pubspec.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,10 +1647,10 @@ packages:
16471647
dependency: transitive
16481648
description:
16491649
name: vm_service
1650-
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
1650+
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
16511651
url: "https://pub.dev"
16521652
source: hosted
1653-
version: "14.2.4"
1653+
version: "14.2.5"
16541654
volume_controller:
16551655
dependency: transitive
16561656
description:
@@ -1806,4 +1806,4 @@ packages:
18061806
version: "0.0.3"
18071807
sdks:
18081808
dart: ">=3.5.0 <4.0.0"
1809-
flutter: ">=3.24.0"
1809+
flutter: ">=3.24.3"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ publish_to: "none"
66

77
environment:
88
sdk: ">=3.0.0 <4.0.0"
9-
flutter: ">=3.24.0"
9+
flutter: ">=3.24.3"
1010

1111
dependencies:
1212
animated_emoji: ^3.1.0

snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ parts:
6161

6262
flutter-git:
6363
source: https://github.com/flutter/flutter.git
64-
source-tag: 3.24.0
64+
source-tag: 3.24.3
6565
source-depth: 1
6666
plugin: nil
6767
override-build: |

0 commit comments

Comments
 (0)