[gnome-builder/wip/gtk4-port: 1412/1774] plugins/meson-templates: more style cleanup
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1412/1774] plugins/meson-templates: more style cleanup
- Date: Mon, 11 Jul 2022 22:31:45 +0000 (UTC)
commit 192e1a495becf4a623f485378ce823a67053ce05
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 7 20:32:21 2022 -0700
plugins/meson-templates: more style cleanup
* use "config.h" without namespace, which is most common
* remove a bunch of comments, which are great for learning but
annoying for actual use. the templates are so small its not really
all that necessary.
* spacing fixes
src/plugins/meson-templates/resources/meson.build | 17 ++++-------
.../meson-templates/resources/src/application.c | 3 +-
.../meson-templates/resources/src/main-cli.c | 2 +-
.../meson-templates/resources/src/main-gtk4.c | 20 ++-----------
src/plugins/meson-templates/resources/src/main.c | 35 ++--------------------
src/plugins/meson-templates/resources/src/window.c | 3 +-
6 files changed, 14 insertions(+), 66 deletions(-)
---
diff --git a/src/plugins/meson-templates/resources/meson.build
b/src/plugins/meson-templates/resources/meson.build
index 507434a70..def9f1832 100644
--- a/src/plugins/meson-templates/resources/meson.build
+++ b/src/plugins/meson-templates/resources/meson.build
@@ -22,13 +22,8 @@ config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set_quoted('GETTEXT_PACKAGE', '{{name}}')
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
{{end}}
-configure_file(
- output: '{{prefix}}-config.h',
- configuration: config_h,
-)
-add_project_arguments([
- '-I' + meson.project_build_root(),
-], language: 'c')
+configure_file(output: 'config.h', configuration: config_h)
+add_project_arguments(['-I' + meson.project_build_root()], language: 'c')
{{end}}
{{if language == "c"}}
@@ -86,18 +81,16 @@ test_c_args = [
'-Wuninitialized',
'-Wunused',
'-fno-strict-aliasing',
- ['-Werror=format-security', '-Werror=format=2' ],
+ ['-Werror=format-security', '-Werror=format=2'],
]
if get_option('buildtype') != 'plain'
test_c_args += '-fstack-protector-strong'
endif
-
foreach arg: test_c_args
if cc.has_multi_arguments(arg)
project_c_args += arg
endif
endforeach
-
add_project_arguments(project_c_args, language: 'c')
{{end}}
{{if language == "rust"}}
@@ -117,8 +110,8 @@ subdir('po')
{{if enable_gnome}}
gnome.post_install(
- glib_compile_schemas: true,
- gtk_update_icon_cache: true,
+ glib_compile_schemas: true,
+ gtk_update_icon_cache: true,
update_desktop_database: true,
)
{{end}}
diff --git a/src/plugins/meson-templates/resources/src/application.c
b/src/plugins/meson-templates/resources/src/application.c
index 27b290107..636652a3d 100644
--- a/src/plugins/meson-templates/resources/src/application.c
+++ b/src/plugins/meson-templates/resources/src/application.c
@@ -1,7 +1,8 @@
{{include "license.c"}}
+#include "config.h"
+
#include "{{prefix}}-application.h"
-#include "{{prefix}}-config.h"
#include "{{prefix}}-window.h"
struct _{{PreFix}}Application
diff --git a/src/plugins/meson-templates/resources/src/main-cli.c
b/src/plugins/meson-templates/resources/src/main-cli.c
index fe5e9bab8..1cdc55b63 100644
--- a/src/plugins/meson-templates/resources/src/main-cli.c
+++ b/src/plugins/meson-templates/resources/src/main-cli.c
@@ -1,6 +1,6 @@
{{include "license.c"}}
-#include "{{prefix}}-config.h"
+#include "config.h"
#include <glib.h>
{{if enable_i18n}}
diff --git a/src/plugins/meson-templates/resources/src/main-gtk4.c
b/src/plugins/meson-templates/resources/src/main-gtk4.c
index ebaa237a4..848061839 100644
--- a/src/plugins/meson-templates/resources/src/main-gtk4.c
+++ b/src/plugins/meson-templates/resources/src/main-gtk4.c
@@ -1,8 +1,9 @@
{{include "license.c"}}
+#include "config.h"
+
#include <glib/gi18n.h>
-#include "{{prefix}}-config.h"
#include "{{prefix}}-application.h"
int
@@ -12,28 +13,11 @@ main (int argc,
g_autoptr({{PreFix}}Application) app = NULL;
int ret;
- /* Set up gettext translations */
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- /*
- * Create a new GtkApplication. The application manages our main loop,
- * application windows, integration with the window manager/compositor, and
- * desktop features such as file opening and single-instance applications.
- */
app = {{prefix_}}_application_new ("{{appid}}", G_APPLICATION_FLAGS_NONE);
-
- /*
- * Run the application. This function will block until the application
- * exits. Upon return, we have our exit code to return to the shell. (This
- * is the code you see when you do `echo $?` after running a command in a
- * terminal.
- *
- * Since GtkApplication inherits from GApplication, we use the parent class
- * method "run". But we need to cast, which is what the "G_APPLICATION()"
- * macro does.
- */
ret = g_application_run (G_APPLICATION (app), argc, argv);
return ret;
diff --git a/src/plugins/meson-templates/resources/src/main.c
b/src/plugins/meson-templates/resources/src/main.c
index 20f81d217..81a8a8169 100644
--- a/src/plugins/meson-templates/resources/src/main.c
+++ b/src/plugins/meson-templates/resources/src/main.c
@@ -1,8 +1,9 @@
{{include "license.c"}}
+#include "config.h"
+
#include <glib/gi18n.h>
-#include "{{prefix}}-config.h"
#include "{{prefix}}-window.h"
static void
@@ -10,20 +11,14 @@ on_activate (GtkApplication *app)
{
GtkWindow *window;
- /* It's good practice to check your parameters at the beginning of the
- * function. It helps catch errors early and in development instead of
- * by your users.
- */
g_assert (GTK_IS_APPLICATION (app));
- /* Get the current window or create one if necessary. */
window = gtk_application_get_active_window (app);
if (window == NULL)
window = g_object_new ({{PREFIX}}_TYPE_WINDOW,
"application", app,
NULL);
- /* Ask the window manager/compositor to present the window. */
gtk_window_present (window);
}
@@ -39,34 +34,8 @@ main (int argc,
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- /*
- * Create a new GtkApplication. The application manages our main loop,
- * application windows, integration with the window manager/compositor, and
- * desktop features such as file opening and single-instance applications.
- */
app = gtk_application_new ("{{appid}}", G_APPLICATION_FLAGS_NONE);
-
- /*
- * We connect to the activate signal to create a window when the application
- * has been launched. Additionally, this signal notifies us when the user
- * tries to launch a "second instance" of the application. When they try
- * to do that, we'll just present any existing window.
- *
- * Because we can't pass a pointer to any function type, we have to cast
- * our "on_activate" function to a GCallback.
- */
g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
-
- /*
- * Run the application. This function will block until the application
- * exits. Upon return, we have our exit code to return to the shell. (This
- * is the code you see when you do `echo $?` after running a command in a
- * terminal.
- *
- * Since GtkApplication inherits from GApplication, we use the parent class
- * method "run". But we need to cast, which is what the "G_APPLICATION()"
- * macro does.
- */
ret = g_application_run (G_APPLICATION (app), argc, argv);
return ret;
diff --git a/src/plugins/meson-templates/resources/src/window.c
b/src/plugins/meson-templates/resources/src/window.c
index 21a10f8fe..d2098b936 100644
--- a/src/plugins/meson-templates/resources/src/window.c
+++ b/src/plugins/meson-templates/resources/src/window.c
@@ -1,6 +1,7 @@
{{include "license.c"}}
-#include "{{prefix}}-config.h"
+#include "config.h"
+
#include "{{prefix}}-window.h"
struct _{{PreFix}}Window
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]