Skip to content

Commit

Permalink
Update .clang-format and update formatting of code.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWiseNoob committed Dec 6, 2023
1 parent a8667de commit 70778d9
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 156 deletions.
9 changes: 4 additions & 5 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
13 changes: 2 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
57 changes: 27 additions & 30 deletions src/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
2 changes: 1 addition & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
82 changes: 49 additions & 33 deletions src/appwin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
11 changes: 6 additions & 5 deletions src/appwin.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#pragma once

#include "app.h"
#include <adwaita.h>
#include <gtk/gtk.h>
#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
7 changes: 3 additions & 4 deletions src/main.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#include <adwaita.h>
#include "app.h"
#include <adwaita.h>

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);
}

Loading

0 comments on commit 70778d9

Please sign in to comment.