[gnome-font-viewer/wip/cdavis/code-modernization: 1/4] general: Split main() into main.c
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-font-viewer/wip/cdavis/code-modernization: 1/4] general: Split main() into main.c
- Date: Mon, 10 Oct 2022 22:11:24 +0000 (UTC)
commit 075cb518cb554be4286f57e815762ad37977241c
Author: Christopher Davis <christopherdavis gnome org>
Date: Sun Oct 9 20:42:38 2022 -0400
general: Split main() into main.c
src/font-view.c | 45 ++----------------------------------------
src/font-view.h | 41 ++++++++++++++++++++++++++++++++++++++
src/main.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/meson.build | 2 ++
4 files changed, 106 insertions(+), 43 deletions(-)
---
diff --git a/src/font-view.c b/src/font-view.c
index b22135a..41fc001 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -42,18 +42,10 @@
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
+#include "font-view.h"
#include "font-model.h"
#include "sushi-font-widget.h"
-#define FONT_VIEW_TYPE_APPLICATION (font_view_application_get_type ())
-#define FONT_VIEW_ICON_NAME APPLICATION_ID
-
-G_DECLARE_FINAL_TYPE (FontViewApplication,
- font_view_application,
- FONT_VIEW,
- APPLICATION,
- AdwApplication)
-
struct _FontViewApplication
{
AdwApplication parent;
@@ -196,22 +188,6 @@ static void ensure_window (FontViewApplication *self);
#define VIEW_COLUMN_SPACING 18
#define VIEW_MARGIN 16
-static gboolean
-_print_version_and_exit (const gchar *option_name,
- const gchar *value,
- gpointer data,
- GError **error)
-{
- g_print ("%s %s\n", _ ("GNOME Fonts"), VERSION);
- exit (EXIT_SUCCESS);
- return TRUE;
-}
-
-static const GOptionEntry goption_options[] = {
- {"version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- _print_version_and_exit, N_ ("Show the application's version"), NULL},
- {NULL}};
-
#define WHITESPACE_CHARS "\f \t"
static void
@@ -1339,7 +1315,7 @@ font_view_application_class_init (FontViewApplicationClass *klass)
oclass->dispose = font_view_application_dispose;
}
-static GApplication *
+GApplication *
font_view_application_new (void)
{
return g_object_new (FONT_VIEW_TYPE_APPLICATION,
@@ -1348,20 +1324,3 @@ font_view_application_new (void)
"resource-base-path", "/org/gnome/font-viewer/",
NULL);
}
-
-int
-main (int argc, char **argv)
-{
- g_autoptr (GApplication) app = NULL;
- gint retval;
-
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
-
- app = font_view_application_new ();
- g_application_add_main_option_entries (app, goption_options);
- retval = g_application_run (app, argc, argv);
-
- return retval;
-}
diff --git a/src/font-view.h b/src/font-view.h
new file mode 100644
index 0000000..dcf1c48
--- /dev/null
+++ b/src/font-view.h
@@ -0,0 +1,41 @@
+/*
+ * font-view.h
+ *
+ * Copyright (C) 2002-2003 James Henstridge <james daa com au>
+ * Copyright (C) 2010 Cosimo Cecchi <cosimoc gnome org>
+ * Copyright 2022 Christopher Davis <christopherdavis gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <adwaita.h>
+
+G_BEGIN_DECLS
+
+#define FONT_VIEW_TYPE_APPLICATION (font_view_application_get_type ())
+#define FONT_VIEW_ICON_NAME APPLICATION_ID
+
+G_DECLARE_FINAL_TYPE (FontViewApplication,
+ font_view_application,
+ FONT_VIEW,
+ APPLICATION,
+ AdwApplication)
+
+GApplication * font_view_application_new (void);
+
+G_END_DECLS
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..9557700
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,61 @@
+/*
+ * main.c
+ *
+ * Copyright (C) 2002-2003 James Henstridge <james daa com au>
+ * Copyright (C) 2010 Cosimo Cecchi <cosimoc gnome org>
+ * Copyright 2022 Christopher Davis <christopherdavis gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include "font-view.h"
+
+static gboolean
+_print_version_and_exit (const gchar *option_name,
+ const gchar *value,
+ gpointer data,
+ GError **error)
+{
+ g_print ("%s %s\n", _ ("GNOME Fonts"), VERSION);
+ exit (EXIT_SUCCESS);
+ return TRUE;
+}
+
+static const GOptionEntry goption_options[] = {
+ {"version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ _print_version_and_exit, N_ ("Show the application's version"), NULL},
+ {NULL}};
+
+int
+main (int argc, char **argv)
+{
+ g_autoptr (GApplication) app = NULL;
+ gint retval;
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ app = font_view_application_new ();
+ g_application_add_main_option_entries (app, goption_options);
+ retval = g_application_run (app, argc, argv);
+
+ return retval;
+}
diff --git a/src/meson.build b/src/meson.build
index 7ef8993..9d07dc2 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -16,7 +16,9 @@ viewer_sources = [
'font-model.c',
'sushi-font-widget.h',
'sushi-font-widget.c',
+ 'font-view.h',
'font-view.c',
+ 'main.c',
]
resources = gnome.compile_resources('font-view-resources',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]