Skip to content

Commit

Permalink
Rename project and upgrade windows project (#2072)
Browse files Browse the repository at this point in the history
* chore: rename product name

* chore: upgrade windows project to latest template

---------

Co-authored-by: vedon <[email protected]>
  • Loading branch information
LucasXu0 and vedon authored Mar 22, 2023
1 parent ec444d4 commit 063ec18
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 65 deletions.
26 changes: 23 additions & 3 deletions frontend/appflowy_flutter/.metadata
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: fa5883b78e566877613ad1ccb48dd92075cb5c23
channel: dev
revision: 135454af32477f815a7525073027a3ff9eff1bfd
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
- platform: windows
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
2 changes: 1 addition & 1 deletion frontend/appflowy_flutter/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.10)
project(runner LANGUAGES CXX)

set(BINARY_NAME "appflowy_flutter")
set(BINARY_NAME "AppFlowy")
set(APPLICATION_ID "io.appflowy.appflowy")

cmake_policy(SET CMP0063 NEW)
Expand Down
2 changes: 1 addition & 1 deletion frontend/appflowy_flutter/linux/appflowy.desktop.temp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Name=AppFlowy
Comment=An Open Source Alternative to Notion
Icon=[CHANGE_THIS]/AppFlowy/flowy_logo.svg
Exec=[CHANGE_THIS]/AppFlowy/appflowy_flutter
Exec=[CHANGE_THIS]/AppFlowy/AppFlowy
Categories=Office
Type=Application
Terminal=false
64 changes: 38 additions & 26 deletions frontend/appflowy_flutter/linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@

#include "flutter/generated_plugin_registrant.h"

struct _MyApplication {
struct _MyApplication
{
GtkApplication parent_instance;
char** dart_entrypoint_arguments;
char **dart_entrypoint_arguments;
};

G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)

// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
GtkWindow* window =
static void my_application_activate(GApplication *application)
{
MyApplication *self = MY_APPLICATION(application);
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
Expand All @@ -29,22 +31,27 @@ static void my_application_activate(GApplication* application) {
// 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) {
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;
}
}
#endif
if (use_header_bar) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
if (use_header_bar)
{
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "appflowy_flutter");
gtk_header_bar_set_title(header_bar, "AppFlowy");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
} else {
gtk_window_set_title(window, "appflowy_flutter");
}
else
{
gtk_window_set_title(window, "AppFlowy");
}

gtk_window_set_default_size(window, 1280, 720);
Expand All @@ -53,7 +60,7 @@ static void my_application_activate(GApplication* application) {
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);

FlView* view = fl_view_new(project);
FlView *view = fl_view_new(project);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));

Expand All @@ -63,16 +70,18 @@ static void my_application_activate(GApplication* application) {
}

// Implements GApplication::local_command_line.
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
MyApplication* self = MY_APPLICATION(application);
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);
*exit_status = 1;
return TRUE;
if (!g_application_register(application, nullptr, &error))
{
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}

g_application_activate(application);
Expand All @@ -82,21 +91,24 @@ static gboolean my_application_local_command_line(GApplication* application, gch
}

// Implements GObject::dispose.
static void my_application_dispose(GObject* object) {
MyApplication* self = MY_APPLICATION(object);
static void my_application_dispose(GObject *object)
{
MyApplication *self = MY_APPLICATION(object);
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
}

static void my_application_class_init(MyApplicationClass* klass) {
static void my_application_class_init(MyApplicationClass *klass)
{
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
}

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

MyApplication* my_application_new() {
MyApplication *my_application_new()
{
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// 'flutter create' template.

// The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = appflowy_flutter
PRODUCT_NAME = AppFlowy

// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = io.appflowy.appflowy
Expand Down
6 changes: 4 additions & 2 deletions frontend/appflowy_flutter/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
cmake_minimum_required(VERSION 3.14)
project(appflowy_flutter LANGUAGES CXX)

set(BINARY_NAME "appflowy_flutter")
set(BINARY_NAME "AppFlowy")

cmake_policy(SET CMP0063 NEW)

set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")

# Configure build options.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
Expand Down Expand Up @@ -50,14 +51,15 @@ add_subdirectory("runner")
# them to the application.
include(flutter/generated_plugins.cmake)


# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")

# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
Expand Down
27 changes: 22 additions & 5 deletions frontend/appflowy_flutter/windows/runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)

# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
Expand All @@ -10,13 +15,25 @@ add_executable(${BINARY_NAME} WIN32
"Runner.rc"
"runner.exe.manifest"
)

# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})

# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")

# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")

# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
add_dependencies(${BINARY_NAME} flutter_assemble)


# === Flutter Library ===
#set(DART_FFI "${CMAKE_CURRENT_SOURCE_DIR}/dart_ffi/dart_ffi.dll")
#set(DART_FFI ${DART_FFI} PARENT_SCOPE)
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
20 changes: 10 additions & 10 deletions frontend/appflowy_flutter/windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
// Version
//

#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0
#define VERSION_AS_NUMBER 1,0,0,0
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
Expand All @@ -89,13 +89,13 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "AppFlowy.IO" "\0"
VALUE "CompanyName", "io.appflowy" "\0"
VALUE "FileDescription", "AppFlowy" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "appflowy_flutter" "\0"
VALUE "LegalCopyright", "Copyright (C) 2023 AppFlowy.IO. All rights reserved." "\0"
VALUE "OriginalFilename", "appflowy_flutter.exe" "\0"
VALUE "ProductName", "appflowy_flutter" "\0"
VALUE "InternalName", "AppFlowy" "\0"
VALUE "LegalCopyright", "Copyright (C) 2023 io.appflowy. All rights reserved." "\0"
VALUE "OriginalFilename", "AppFlowy.exe" "\0"
VALUE "ProductName", "AppFlowy" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
Expand Down
12 changes: 8 additions & 4 deletions frontend/appflowy_flutter/windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include "utils.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
_In_ wchar_t *command_line, _In_ int show_command)
{
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent())
{
CreateAndAttachConsole();
}

Expand All @@ -27,13 +29,15 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"appflowy_flutter", origin, size)) {
if (!window.CreateAndShow(L"AppFlowy", origin, size))
{
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);

::MSG msg;
while (::GetMessage(&msg, nullptr, 0, 0)) {
while (::GetMessage(&msg, nullptr, 0, 0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Type=Application
Name=AppFlowy
Icon=io.appflowy.AppFlowy
Exec=env GDK_GL=gles appflowy_flutter %U
Exec=env GDK_GL=gles AppFlowy %U
Categories=Network;Productivity;
Keywords=Notes
6 changes: 3 additions & 3 deletions frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ app-id: io.appflowy.AppFlowy
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: appflowy_flutter
command: AppFlowy
separate-locales: false
finish-args:
- --share=ipc
Expand All @@ -18,10 +18,10 @@ modules:
build-commands:
# - ls .
- cp -r appflowy /app/appflowy
- chmod +x /app/appflowy/appflowy_flutter
- chmod +x /app/appflowy/AppFlowy
- install -Dm644 logo.svg /app/share/icons/hicolor/scalable/apps/io.appflowy.AppFlowy.svg
- mkdir /app/bin
- ln -s /app/appflowy/appflowy_flutter /app/bin/appflowy_flutter
- ln -s /app/appflowy/AppFlowy /app/bin/AppFlowy
- install -Dm644 io.appflowy.AppFlowy.desktop /app/share/applications/io.appflowy.AppFlowy.desktop
sources:
- type: archive
Expand Down
10 changes: 5 additions & 5 deletions frontend/scripts/linux_installer/postinst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
if [ -e /usr/local/bin/appflowy ]; then
echo "Symlink already exists, skipping."
if [ -e /usr/local/bin/AppFlowy ]; then
echo "Symlink already exists, skipping."
else
echo "Creating Symlink in /usr/local/bin/appflowy"
ln -s /opt/AppFlowy/appflowy_flutter /usr/local/bin/appflowy
fi
echo "Creating Symlink in /usr/local/bin/appflowy"
ln -s /opt/AppFlowy/AppFlowy /usr/local/bin/AppFlowy
fi
Loading

0 comments on commit 063ec18

Please sign in to comment.