diff --git a/.clang-format b/.clang-format index 10bab5d..0cdebe9 100644 --- a/.clang-format +++ b/.clang-format @@ -1,8 +1,7 @@ Language: Cpp BasedOnStyle: GNU -# Our column limit is actually 80, but setting that results in clang-format -# making a lot of dubious hanging-indent choices; disable it and assume the -# developer will line wrap appropriately. clang-format will still check -# existing hanging indents. + +AlignAfterOpenBracket: BlockIndent ColumnLimit: 80 -IndentWidth: 4 +IndentWidth: 4 +PointerAlignment: Left diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fff0a9..c631f1b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,15 +8,6 @@ jobs: - uses: actions/checkout@v2 - name: Install Dependencies run: sudo apt-get install clang-format - - name: Link + - name: Check For Formatting Errors id: format_check - run: | - cd src - errors=$(clang-format --dry-run *.cc *.h 2>&1; echo $?) - if [ -z "$errors" ] - then - echo "Format is valid. Nice!" - else - echo "::error::Formatting errors exist." - exit 1 - fi + run: cd src && clang-format --dry-run --Werror *.cc *.h diff --git a/src/app.cc b/src/app.cc index e891b74..baf9eb9 100644 --- a/src/app.cc +++ b/src/app.cc @@ -6,59 +6,56 @@ struct _OMPApp { - AdwApplication parent; + AdwApplication parent; }; -G_DEFINE_TYPE(OMPApp, omp_app, ADW_TYPE_APPLICATION); +G_DEFINE_TYPE (OMPApp, omp_app, ADW_TYPE_APPLICATION); static void -omp_app_init (OMPApp *app) +omp_app_init (OMPApp* app) { } static void -omp_app_activate (GApplication *app) +omp_app_activate (GApplication* app) { - OMPAppWindow *win; + OMPAppWindow* win; - win = omp_app_window_new (OMP_APP (app)); - gtk_window_present (GTK_WINDOW (win)); + win = omp_app_window_new (OMP_APP (app)); + gtk_window_present (GTK_WINDOW (win)); } static void -omp_app_open (GApplication *app, - GFile **files, - int n_files, - const char *hint) +omp_app_open (GApplication* app, GFile** files, int n_files, const char* hint) { - GList *windows; - OMPAppWindow *win; - int i; + GList* windows; + OMPAppWindow* win; + int i; - windows = gtk_application_get_windows (GTK_APPLICATION (app)); - if (windows) - win = OMP_APP_WINDOW (windows->data); - else - win = omp_app_window_new (OMP_APP (app)); + windows = gtk_application_get_windows (GTK_APPLICATION (app)); + if (windows) + win = OMP_APP_WINDOW (windows->data); + else + win = omp_app_window_new (OMP_APP (app)); - for (i = 0; i < n_files; i++) - omp_app_window_open (win, files[i]); + for (i = 0; i < n_files; i++) + omp_app_window_open (win, files[i]); - gtk_window_present (GTK_WINDOW (win)); + gtk_window_present (GTK_WINDOW (win)); } static void -omp_app_class_init (OMPAppClass *self) +omp_app_class_init (OMPAppClass* self) { - G_APPLICATION_CLASS (self)->activate = omp_app_activate; - G_APPLICATION_CLASS (self)->open = omp_app_open; + G_APPLICATION_CLASS (self)->activate = omp_app_activate; + G_APPLICATION_CLASS (self)->open = omp_app_open; } -OMPApp * +OMPApp* omp_app_new (void) { - return (OMPApp*)g_object_new (OMP_APP_TYPE, - "application-id", "org.gtk.omp", - "flags", G_APPLICATION_HANDLES_OPEN, - NULL); + return (OMPApp*)g_object_new ( + OMP_APP_TYPE, "application-id", "org.gtk.omp", "flags", + G_APPLICATION_HANDLES_OPEN, NULL + ); } diff --git a/src/app.h b/src/app.h index aca79f1..e3cf887 100644 --- a/src/app.h +++ b/src/app.h @@ -8,6 +8,6 @@ G_BEGIN_DECLS #define OMP_APP_TYPE (omp_app_get_type ()) G_DECLARE_FINAL_TYPE (OMPApp, omp_app, OMP, APP, AdwApplication) -OMPApp *omp_app_new (void); +OMPApp* omp_app_new (void); G_END_DECLS diff --git a/src/appwin.cc b/src/appwin.cc index 5e77f6b..c9c911a 100644 --- a/src/appwin.cc +++ b/src/appwin.cc @@ -7,65 +7,81 @@ struct _OMPAppWindow { - AdwApplicationWindow parent; + AdwApplicationWindow parent; - GtkWidget *sidebar; - GtkWidget *split_view; - GtkWidget *open_sidebar_overlay_button; + GtkWidget* sidebar; + GtkWidget* split_view; + GtkWidget* open_sidebar_overlay_button; }; -G_DEFINE_TYPE(OMPAppWindow, omp_app_window, ADW_TYPE_APPLICATION_WINDOW); +G_DEFINE_TYPE (OMPAppWindow, omp_app_window, ADW_TYPE_APPLICATION_WINDOW); static void -open_clicked (GtkButton *source, - OMPAppWindow* omp_app_window) +open_clicked (GtkButton* source, OMPAppWindow* omp_app_window) { - g_object_set(omp_app_window->split_view, "show-sidebar", true, NULL); - g_object_set(source, "visible", false, NULL); + g_object_set (omp_app_window->split_view, "show-sidebar", true, NULL); + g_object_set (source, "visible", false, NULL); } static void -omp_app_window_show_open_sidebar_overlay_button(OMPAppWindow *win) +omp_app_window_show_open_sidebar_overlay_button (OMPAppWindow* win) { - g_object_set(win->open_sidebar_overlay_button, "visible", true, NULL); + g_object_set (win->open_sidebar_overlay_button, "visible", true, NULL); } static void -omp_app_window_init (OMPAppWindow *win) +omp_app_window_init (OMPAppWindow* win) { - g_type_ensure (OMP_SIDEBAR_TYPE); - gtk_widget_init_template (GTK_WIDGET (win)); + g_type_ensure (OMP_SIDEBAR_TYPE); + gtk_widget_init_template (GTK_WIDGET (win)); - gtk_widget_add_css_class(win->open_sidebar_overlay_button, "open_sidebar_overlay_button"); + gtk_widget_add_css_class ( + win->open_sidebar_overlay_button, "open_sidebar_overlay_button" + ); } static void -omp_app_window_class_init (OMPAppWindowClass *self) +omp_app_window_class_init (OMPAppWindowClass* self) { - gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (self), - "/com/openmusicplayer/omp/ui/window.ui"); - gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (self), OMPAppWindow, sidebar); - gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (self), OMPAppWindow, split_view); - gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (self), OMPAppWindow, open_sidebar_overlay_button); + gtk_widget_class_set_template_from_resource ( + GTK_WIDGET_CLASS (self), "/com/openmusicplayer/omp/ui/window.ui" + ); + gtk_widget_class_bind_template_child ( + GTK_WIDGET_CLASS (self), OMPAppWindow, sidebar + ); + gtk_widget_class_bind_template_child ( + GTK_WIDGET_CLASS (self), OMPAppWindow, split_view + ); + gtk_widget_class_bind_template_child ( + GTK_WIDGET_CLASS (self), OMPAppWindow, open_sidebar_overlay_button + ); - GtkCssProvider* window_css_provider = gtk_css_provider_new(); - gtk_css_provider_load_from_resource (window_css_provider, "/com/openmusicplayer/omp/ui/window.css"); - gtk_style_context_add_provider_for_display (gdk_display_get_default(), - GTK_STYLE_PROVIDER (window_css_provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + GtkCssProvider* window_css_provider = gtk_css_provider_new (); + gtk_css_provider_load_from_resource ( + window_css_provider, "/com/openmusicplayer/omp/ui/window.css" + ); + gtk_style_context_add_provider_for_display ( + gdk_display_get_default (), GTK_STYLE_PROVIDER (window_css_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + ); - gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (self), open_clicked); - gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (self), omp_app_window_show_open_sidebar_overlay_button); + gtk_widget_class_bind_template_callback ( + GTK_WIDGET_CLASS (self), open_clicked + ); + gtk_widget_class_bind_template_callback ( + GTK_WIDGET_CLASS (self), omp_app_window_show_open_sidebar_overlay_button + ); } -OMPAppWindow * -omp_app_window_new (OMPApp *app) +OMPAppWindow* +omp_app_window_new (OMPApp* app) { - return (OMPAppWindow*) g_object_new (OMP_APP_WINDOW_TYPE, "application", app, NULL); + return (OMPAppWindow*)g_object_new ( + OMP_APP_WINDOW_TYPE, "application", app, NULL + ); } void -omp_app_window_open (OMPAppWindow *win, - GFile *file) +omp_app_window_open (OMPAppWindow* win, GFile* file) { } diff --git a/src/appwin.h b/src/appwin.h index bc82f69..073005f 100644 --- a/src/appwin.h +++ b/src/appwin.h @@ -1,17 +1,18 @@ #pragma once +#include "app.h" #include #include -#include "app.h" G_BEGIN_DECLS #define OMP_APP_WINDOW_TYPE (omp_app_window_get_type ()) -G_DECLARE_FINAL_TYPE (OMPAppWindow, omp_app_window, OMP, APP_WINDOW, AdwApplicationWindow) +G_DECLARE_FINAL_TYPE ( + OMPAppWindow, omp_app_window, OMP, APP_WINDOW, AdwApplicationWindow +) -OMPAppWindow *omp_app_window_new (OMPApp *app); +OMPAppWindow* omp_app_window_new (OMPApp* app); -void omp_app_window_open (OMPAppWindow *win, - GFile *file); +void omp_app_window_open (OMPAppWindow* win, GFile* file); G_END_DECLS diff --git a/src/main.cc b/src/main.cc index e904f4e..0c2509a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,9 +1,8 @@ -#include #include "app.h" +#include int -main (int argc, char *argv[]) +main (int argc, char* argv[]) { - return g_application_run (G_APPLICATION (omp_app_new ()), argc, argv); + return g_application_run (G_APPLICATION (omp_app_new ()), argc, argv); } - diff --git a/src/sidebar.cc b/src/sidebar.cc index a218718..b4e9f42 100644 --- a/src/sidebar.cc +++ b/src/sidebar.cc @@ -1,15 +1,15 @@ #include "sidebar.h" +#include "appwin.h" #include #include -#include "appwin.h" struct _OMPSidebar { - AdwBin parent; + AdwBin parent; - GtkWidget *show_sidebar_button; - gboolean sidebar_button_active; + GtkWidget* show_sidebar_button; + gboolean sidebar_button_active; }; enum @@ -21,111 +21,115 @@ enum enum { - SHOW_PANEL, - LAST_SIGNAL + SHOW_PANEL, + LAST_SIGNAL }; -static GParamSpec *properties[NUM_PROPERTIES] = { NULL, }; -static gint signals [LAST_SIGNAL] = { 0, }; +static GParamSpec* properties[NUM_PROPERTIES] = { + NULL, +}; +static gint signals[LAST_SIGNAL] = { + 0, +}; -G_DEFINE_TYPE(OMPSidebar, omp_sidebar, ADW_TYPE_BIN); +G_DEFINE_TYPE (OMPSidebar, omp_sidebar, ADW_TYPE_BIN); static void -output_state (GtkToggleButton *source, - OMPSidebar *sidebar) +output_state (GtkToggleButton* source, OMPSidebar* sidebar) { - g_signal_emit (sidebar, signals[SHOW_PANEL], 0); + g_signal_emit (sidebar, signals[SHOW_PANEL], 0); } static void -omp_sidebar_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +omp_sidebar_get_property ( + GObject* object, guint property_id, GValue* value, GParamSpec* pspec +) { - OMPSidebar *self = OMP_APP_SIDEBAR (object); + OMPSidebar* self = OMP_APP_SIDEBAR (object); switch (property_id) - { - case PROP_SIDEBAR_BUTTON_ACTIVE: { - g_value_set_boolean (value, self->sidebar_button_active); - } - break; + case PROP_SIDEBAR_BUTTON_ACTIVE: + { + g_value_set_boolean (value, self->sidebar_button_active); + } + break; default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + { + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } + break; } - break; - } } static void -omp_sidebar_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +omp_sidebar_set_property ( + GObject* object, guint property_id, const GValue* value, GParamSpec* pspec +) { - OMPSidebar *self = OMP_APP_SIDEBAR (object); + OMPSidebar* self = OMP_APP_SIDEBAR (object); switch (property_id) - { - case PROP_SIDEBAR_BUTTON_ACTIVE: { - self->sidebar_button_active = g_value_get_boolean (value); - } - break; + case PROP_SIDEBAR_BUTTON_ACTIVE: + { + self->sidebar_button_active = g_value_get_boolean (value); + } + break; default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + { + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } + break; } - break; - } } static void -omp_sidebar_init (OMPSidebar *sidebar) +omp_sidebar_init (OMPSidebar* sidebar) { - gtk_widget_init_template (GTK_WIDGET (sidebar)); + gtk_widget_init_template (GTK_WIDGET (sidebar)); } static void -omp_sidebar_class_init (OMPSidebarClass *self) +omp_sidebar_class_init (OMPSidebarClass* self) { - gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (self), - "/com/openmusicplayer/omp/ui/sidebar.ui"); - - gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (self), OMPSidebar, show_sidebar_button); + gtk_widget_class_set_template_from_resource ( + GTK_WIDGET_CLASS (self), "/com/openmusicplayer/omp/ui/sidebar.ui" + ); - gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (self), output_state); + gtk_widget_class_bind_template_child ( + GTK_WIDGET_CLASS (self), OMPSidebar, show_sidebar_button + ); + gtk_widget_class_bind_template_callback ( + GTK_WIDGET_CLASS (self), output_state + ); - GObjectClass *oclass; - GtkWidgetClass *widget_class; + GObjectClass* oclass; + GtkWidgetClass* widget_class; - widget_class = GTK_WIDGET_CLASS (self); - oclass = G_OBJECT_CLASS (self); - oclass->get_property = omp_sidebar_get_property; - oclass->set_property = omp_sidebar_set_property; + widget_class = GTK_WIDGET_CLASS (self); + oclass = G_OBJECT_CLASS (self); + oclass->get_property = omp_sidebar_get_property; + oclass->set_property = omp_sidebar_set_property; - signals[SHOW_PANEL] = g_signal_new ("show-open-sidebar-overlay-button", - OMP_SIDEBAR_TYPE, - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, NULL, - G_TYPE_NONE, - 0); + signals[SHOW_PANEL] = g_signal_new ( + "show-open-sidebar-overlay-button", OMP_SIDEBAR_TYPE, G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, G_TYPE_NONE, 0 + ); - properties[PROP_SIDEBAR_BUTTON_ACTIVE] = - g_param_spec_boolean ("sidebar-button-active", NULL, NULL, FALSE, - (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties[PROP_SIDEBAR_BUTTON_ACTIVE] = g_param_spec_boolean ( + "sidebar-button-active", NULL, NULL, FALSE, + (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); - g_object_class_install_properties (oclass, NUM_PROPERTIES, properties); + g_object_class_install_properties (oclass, NUM_PROPERTIES, properties); } -OMPSidebar * +OMPSidebar* omp_sidebar_new (void) { - return (OMPSidebar*) g_object_new (OMP_SIDEBAR_TYPE, NULL); + return (OMPSidebar*)g_object_new (OMP_SIDEBAR_TYPE, NULL); } diff --git a/src/sidebar.h b/src/sidebar.h index 26e1435..a3ba4ce 100644 --- a/src/sidebar.h +++ b/src/sidebar.h @@ -8,6 +8,6 @@ G_BEGIN_DECLS #define OMP_SIDEBAR_TYPE (omp_sidebar_get_type ()) G_DECLARE_FINAL_TYPE (OMPSidebar, omp_sidebar, OMP, APP_SIDEBAR, AdwBin) -OMPSidebar *omp_sidebar_new (void); +OMPSidebar* omp_sidebar_new (void); G_END_DECLS