Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gspencergoog committed Aug 5, 2024
1 parent 5edfc9c commit 67c2a4a
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 171 deletions.
2 changes: 1 addition & 1 deletion packages/diagram_generator/linux/main.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "my_application.h"

int main(int argc, char** argv) {
int main(int argc, char **argv) {
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}
57 changes: 30 additions & 27 deletions packages/diagram_generator/linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

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,16 +29,16 @@ 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);
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);
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());
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "diagram_generator");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
Expand All @@ -51,9 +51,10 @@ static void my_application_activate(GApplication* application) {
gtk_widget_show(GTK_WIDGET(window));

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);
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 +64,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;
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}

g_application_activate(application);
Expand All @@ -82,43 +85,43 @@ static gboolean my_application_local_command_line(GApplication* application, gch
}

// Implements GApplication::startup.
static void my_application_startup(GApplication* application) {
//MyApplication* self = MY_APPLICATION(object);
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);
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.
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_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) {}
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,
nullptr));
"application-id", APPLICATION_ID, "flags",
G_APPLICATION_NON_UNIQUE, nullptr));
}
4 changes: 2 additions & 2 deletions packages/diagram_generator/linux/my_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
*
* Returns: a new #MyApplication.
*/
MyApplication* my_application_new();
MyApplication *my_application_new();

#endif // FLUTTER_MY_APPLICATION_H_
#endif // FLUTTER_MY_APPLICATION_H_
2 changes: 1 addition & 1 deletion packages/diagram_viewer/linux/main.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "my_application.h"

int main(int argc, char** argv) {
int main(int argc, char **argv) {
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}
57 changes: 30 additions & 27 deletions packages/diagram_viewer/linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

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,16 +29,16 @@ 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);
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);
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());
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "diagram_viewer");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
Expand All @@ -51,9 +51,10 @@ static void my_application_activate(GApplication* application) {
gtk_widget_show(GTK_WIDGET(window));

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);
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 +64,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;
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}

g_application_activate(application);
Expand All @@ -82,43 +85,43 @@ static gboolean my_application_local_command_line(GApplication* application, gch
}

// Implements GApplication::startup.
static void my_application_startup(GApplication* application) {
//MyApplication* self = MY_APPLICATION(object);
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);
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.
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_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) {}
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,
nullptr));
"application-id", APPLICATION_ID, "flags",
G_APPLICATION_NON_UNIQUE, nullptr));
}
4 changes: 2 additions & 2 deletions packages/diagram_viewer/linux/my_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
*
* Returns: a new #MyApplication.
*/
MyApplication* my_application_new();
MyApplication *my_application_new();

#endif // FLUTTER_MY_APPLICATION_H_
#endif // FLUTTER_MY_APPLICATION_H_
12 changes: 5 additions & 7 deletions packages/diagram_viewer/windows/runner/flutter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "flutter/generated_plugin_registrant.h"

FlutterWindow::FlutterWindow(const flutter::DartProject& project)
FlutterWindow::FlutterWindow(const flutter::DartProject &project)
: project_(project) {}

FlutterWindow::~FlutterWindow() {}
Expand All @@ -27,9 +27,7 @@ bool FlutterWindow::OnCreate() {
RegisterPlugins(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());

flutter_controller_->engine()->SetNextFrameCallback([&]() {
this->Show();
});
flutter_controller_->engine()->SetNextFrameCallback([&]() { this->Show(); });

// Flutter can complete the first frame before the "show window" callback is
// registered. The following call ensures a frame is pending to ensure the
Expand Down Expand Up @@ -62,9 +60,9 @@ FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
}

switch (message) {
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
}

return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
Expand Down
10 changes: 5 additions & 5 deletions packages/diagram_viewer/windows/runner/flutter_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

// A window that does nothing but host a Flutter view.
class FlutterWindow : public Win32Window {
public:
public:
// Creates a new FlutterWindow hosting a Flutter view running |project|.
explicit FlutterWindow(const flutter::DartProject& project);
explicit FlutterWindow(const flutter::DartProject &project);
virtual ~FlutterWindow();

protected:
protected:
// Win32Window:
bool OnCreate() override;
void OnDestroy() override;
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
LPARAM const lparam) noexcept override;

private:
private:
// The project to run.
flutter::DartProject project_;

// The Flutter instance hosted by this window.
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
};

#endif // RUNNER_FLUTTER_WINDOW_H_
#endif // RUNNER_FLUTTER_WINDOW_H_
3 changes: 1 addition & 2 deletions packages/diagram_viewer/windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,

flutter::DartProject project(L"data");

std::vector<std::string> command_line_arguments =
GetCommandLineArguments();
std::vector<std::string> command_line_arguments = GetCommandLineArguments();

project.set_dart_entrypoint_arguments(std::move(command_line_arguments));

Expand Down
10 changes: 5 additions & 5 deletions packages/diagram_viewer/windows/runner/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Microsoft Visual C++ generated include file.
// Used by Runner.rc
//
#define IDI_APP_ICON 101
#define IDI_APP_ICON 101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Loading

0 comments on commit 67c2a4a

Please sign in to comment.