~tristan957/harvest-almanac

92e91ee3a2c2aa72222b049eae12c20e71973c75 — Tristan Partin 2 years ago f18058c
meta: adjusted configuration config to compile with clang

Not tested
M data/ui/hal-preferences-window.ui => data/ui/hal-preferences-window.ui +12 -0
@@ 47,6 47,9 @@
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="valign">center</property>
                    <property name="visibility">False</property>
                    <property name="invisible_char">•</property>
                    <property name="input_purpose">password</property>
                  </object>
                </child>
              </object>


@@ 120,6 123,15 @@
      </object>
    </child>
  </template>
  <object class="GtkButton" id="save_button">
    <property name="label" translatable="yes">Save</property>
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <property name="receives_default">True</property>
    <style>
      <class name="suggested-action"/>
    </style>
  </object>
  <object class="GtkAdjustment" id="soup_max_connections_adjustment">
    <property name="lower">1</property>
    <property name="upper">10</property>

A harvest-almanac/config.h.in => harvest-almanac/config.h.in +28 -0
@@ 0,0 1,28 @@
#pragma once

#ifdef __GNUC__
#	define HAL_COMPILER GCC
#elif __clang__
#	define HAL_COMPILER clang
#endif

#ifdef HAL_COMPILER
#	define HAL_DIAGNOSTIC_PUSH (HAL_COMPILER diagnostic push)
#	define HAL_DIAGNOSTIC_POP (HAL_COMPILER diagnostic pop)
#	define HAL_DIAGNOSTIC_IGNORED (HAL_COMPILER diagnostic ignored)
#else
#	define HAL_DIAGNOSTIC_PUSH
#	define HAL_DIAGNOSTIC_POP
#	define HAL_DIAGNOSTIC_IGNORED
#endif

#define PACKAGE_NAME "@package_name@"
#define PACKAGE_VERSION "@package_version@"
// clang-format off
#define PACKAGE_LICENSE @package_license@
// clang-format on
#define PACKAGE_WEBSITE "@package_website@"
#define PACKAGE_WEBSITE_LABEL "@package_website_label@"
#define GETTEXT_PACKAGE "@gettext_package@"
#define LOCALEDIR "@localedir@"
#define LIBDIR "@libdir@"

M harvest-almanac/hal-preferences-window.c => harvest-almanac/hal-preferences-window.c +28 -5
@@ 14,6 14,7 @@ struct _HalPreferencesWindow
{
	HdyPreferencesWindow parent_instance;

	gboolean dirty : 1;
	GSettings *settings;
};



@@ 24,6 25,7 @@ typedef struct HalPreferencesWindowPrivate
	GtkSwitch *prefer_dark_theme_switch;
	GtkSpinButton *soup_max_connections_spin;
	GtkComboBoxText *soup_logger_level_combo;
	GtkButton *save_button;
} HalPreferencesWindowPrivate;

G_DEFINE_TYPE_WITH_PRIVATE(


@@ 60,13 62,25 @@ hal_get_secret_schema(void)
	return &hal_schema;
}

static void G_GNUC_UNUSED
hal_preferences_window_set_dirty(HalPreferencesWindow *self)
{
	HalPreferencesWindowPrivate *priv = hal_preferences_window_get_instance_private(self);

	gboolean dirty = FALSE;
	// check the state for each preferences widget and set dirty appropriately
	gtk_widget_set_sensitive(GTK_WIDGET(priv->save_button), dirty);
	self->dirty = dirty;
}

static void
on_prefer_dark_theme_switch_activate(
	GtkSwitch *widget, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
on_save_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	HalPreferencesWindow *self = HAL_PREFERENCES_WINDOW(user_data);
	HalPreferencesWindow *self		  = HAL_PREFERENCES_WINDOW(user_data);
	HalPreferencesWindowPrivate *priv = hal_preferences_window_get_instance_private(self);

	g_settings_set_boolean(self->settings, "prefer-dark-theme", gtk_switch_get_active(widget));
	g_settings_set_boolean(
		self->settings, "prefer-dark-theme", gtk_switch_get_active(priv->prefer_dark_theme_switch));
}

static void


@@ 138,13 152,22 @@ hal_preferences_window_class_init(HalPreferencesWindowClass *klass)
		wid_class, HalPreferencesWindow, soup_max_connections_spin);
	gtk_widget_class_bind_template_child_private(
		wid_class, HalPreferencesWindow, soup_logger_level_combo);
	gtk_widget_class_bind_template_callback(wid_class, on_prefer_dark_theme_switch_activate);
	gtk_widget_class_bind_template_child_private(wid_class, HalPreferencesWindow, save_button);
	gtk_widget_class_bind_template_callback(wid_class, on_save_button_clicked);
}

static void
hal_preferences_window_init(HalPreferencesWindow *self)
{
	HalPreferencesWindowPrivate *priv = hal_preferences_window_get_instance_private(self);

	gtk_widget_init_template(GTK_WIDGET(self));

	HdyHeaderBar *header_bar = HDY_HEADER_BAR(gtk_window_get_titlebar(GTK_WINDOW(self)));
	hdy_header_bar_pack_start(header_bar, GTK_WIDGET(priv->save_button));
	gtk_widget_show_all(GTK_WIDGET(header_bar));

	self->dirty = FALSE;
}

HalPreferencesWindow *

M harvest-almanac/meson.build => harvest-almanac/meson.build +11 -8
@@ 1,15 1,18 @@
harvest_almanac_version = '1.0.0'

harvest_almanac_config_h = configuration_data({
    'PACKAGE_NAME': '"@0@"'.format('Harvest Almanac'),
    'PACKAGE_VERSION': '"@0@"'.format(meson.project_version()),
    'GETTEXT_PACKAGE': '"@0@"'.format(meson.project_name()),
    'LOCALEDIR': '"@0@"'.format(join_paths(get_option('prefix'), get_option('localedir'))),
    'LIBDIR': '"@0@"'.format(join_paths(get_option('prefix'), get_option('libdir'))),
    'PACKAGE_LICENSE': 'GTK_LICENSE_GPL_3_0_ONLY',
    'PACKAGE_WEBSITE': '"@0@"'.format('https://git.sr.ht/~tristan957/harvest-almanac'),
    'PACKAGE_WEBSITE_LABEL': '"@0@"'.format('Repository'),
    'package_name': 'Harvest Almanac',
    'package_version': meson.project_version(),
    'package_license': 'GTK_LICENSE_GPL_3_0_ONLY',
    'package_website': 'https://git.sr.ht/~tristan957/harvest-almanac',
    'package_website_label': 'Repository',
    'gettext_package': 'meson.project_name()',
    'localedir': join_paths(get_option('prefix'), get_option('localedir')),
    'libdir': join_paths(get_option('prefix'), get_option('libdir')),
})

configure_file(
    input: 'config.h.in',
    output: 'config.h',
    configuration: harvest_almanac_config_h,
)

D harvest-glib/config.h => harvest-glib/config.h +0 -3
@@ 1,3 0,0 @@
#pragma once

#define GETTEXT_PACKAGE "harvest-glib"

A harvest-glib/config.h.in => harvest-glib/config.h.in +19 -0
@@ 0,0 1,19 @@
#pragma once

#ifdef __GNUC__
#	define HAL_COMPILER GCC
#elif __clang__
#	define HAL_COMPILER clang
#endif

#ifdef HAL_COMPILER
#	define HAL_DIAGNOSTIC_PUSH (HAL_COMPILER diagnostic push)
#	define HAL_DIAGNOSTIC_POP (HAL_COMPILER diagnostic pop)
#	define HAL_DIAGNOSTIC_IGNORED (HAL_COMPILER diagnostic ignored)
#else
#	define HAL_DIAGNOSTIC_PUSH
#	define HAL_DIAGNOSTIC_POP
#	define HAL_DIAGNOSTIC_IGNORED
#endif

#define GETTEXT_PACKAGE "@gettext_package@"

M harvest-glib/harvest-user.c => harvest-glib/harvest-user.c +7 -0
@@ 9,6 9,7 @@
#include <glib/gi18n-lib.h>
#include <json-glib/json-glib.h>

#include "harvest-api-client.h"
#include "harvest-user.h"

struct _HarvestUser


@@ 385,3 386,9 @@ harvest_user_class_init(HarvestUserClass *klass)
static void
harvest_user_init(G_GNUC_UNUSED HarvestUser *self)
{}

HarvestUser *
harvest_user_get_me(G_GNUC_UNUSED HarvestApiClient *client)
{
	return NULL;
}

M harvest-glib/meson.build => harvest-glib/meson.build +35 -10
@@ 1,3 1,15 @@
harvest_glib_version = '1.0.0'

harvest_glib_config_h = configuration_data({
    'gettext_package': 'harvest-glib',
})

configure_file(
    input: 'config.h.in',
    output: 'config.h',
    configuration: harvest_glib_config_h,
)

harvest_glib_sources = [
    'harvest-api-client.c',
    'harvest-client.c',


@@ 55,20 67,34 @@ harvest_glib_public_headers = [

install_headers(harvest_glib_public_headers, subdir: 'harvest-glib')

harvest_glib_version = '1.0.0'
harvest_glib_c_args = [
    '-D__HARVEST_COMPILATION__',
]

if get_option('buildtype') == 'release'
    harvest_glib_c_args += [
        '-DG_DISABLE_ASSERT',
        '-DG_DISABLE_CHECKS',
        '-DG_DISABLE_CAST_CHECKS',
    ]
elif get_option('buildtype').startswith('debug')
    harvest_glib_c_args += [
        '-DG_ENABLE_DEBUG',
    ]
endif

harvest_glib_dependencies = [
    libgio_dep,
    json_glib_dep,
    libsoup_dep,
]

harvest_glib = library(
    'harvest-glib',
    harvest_glib_sources,
    version: harvest_glib_version,
    c_args: [
        '-D__HARVEST_COMPILATION__',
    ],
    dependencies: [
        libgio_dep,
        json_glib_dep,
        libsoup_dep,
    ],
    c_args: harvest_glib_c_args,
    dependencies: harvest_glib_dependencies,
    install: true,
)



@@ 90,7 116,6 @@ pkg.generate(
    requires_private: [
        libgio_dep,
        json_glib_dep,
        libsecret_dep,
    ],
	url: 'https://git.sr.ht/~tristan957/harvest-almanac',
)

M meson.build => meson.build +1 -1
@@ 1,9 1,9 @@
project(
    'harvest-almanac',
    'c',
    version: '1.0.0',
    license: [
        'GPL-3.0-only',
        'LGPL-3.0-only',
    ],
    default_options: [
        'c_std=gnu11', # Enable GCC extensions