From bdcb925c6e58fd8102325589e26669f78c6ce428 Mon Sep 17 00:00:00 2001 From: Gotam Gorabh Date: Tue, 26 Mar 2024 11:06:35 +0530 Subject: [PATCH] enums: Introduce single header file to gather all enums The aim is to allow phosh-mobile-settings to use these to map GSettngs values. This will bring all the enums into a single header file to tackle duplicacy as well. Closes: https://gitlab.gnome.org/World/Phosh/phosh/-/issues/1036 Part-of: --- data/meson.build | 5 +- .../mobile-data-quick-setting.c | 3 +- src/app-grid.h | 14 +--- src/layout-manager.h | 19 +---- src/meson.build | 14 ++++ src/notifications/notify-feedback.h | 17 +---- src/phosh-settings-enums.h | 70 +++++++++++++++++++ src/shell.c | 3 +- src/wwan/meson.build | 1 - src/wwan/phosh-wwan-backend.h | 19 ----- 10 files changed, 94 insertions(+), 71 deletions(-) create mode 100644 src/phosh-settings-enums.h delete mode 100644 src/wwan/phosh-wwan-backend.h diff --git a/data/meson.build b/data/meson.build index a54d6730d..790fd494c 100644 --- a/data/meson.build +++ b/data/meson.build @@ -90,10 +90,7 @@ configure_file( # Generate XML enum definitions for GSettings schema schema_enum_headers = files( - meson.project_source_root() / 'src' / 'app-grid.h', - meson.project_source_root() / 'src' / 'layout-manager.h', - meson.project_source_root() / 'src' / 'wwan' / 'phosh-wwan-backend.h', - meson.project_source_root() / 'src' / 'notifications' / 'notify-feedback.h', + meson.project_source_root() / 'src' / 'phosh-settings-enums.h', ) generate_enums_schema = gnome.mkenums('sm.puri.phosh.enums.xml', sources: schema_enum_headers, diff --git a/plugins/mobile-data-quick-setting/mobile-data-quick-setting.c b/plugins/mobile-data-quick-setting/mobile-data-quick-setting.c index 49194be92..7a1c81baf 100644 --- a/plugins/mobile-data-quick-setting/mobile-data-quick-setting.c +++ b/plugins/mobile-data-quick-setting/mobile-data-quick-setting.c @@ -6,13 +6,14 @@ * Author: Guido Günther */ -#include "wwan/phosh-wwan-backend.h" #include "mobile-data-quick-setting.h" #include "plugin-shell.h" #include "quick-setting.h" #include +#include "phosh-settings-enums.h" + /** * PhoshMobileDataQuickSetting: * diff --git a/src/app-grid.h b/src/app-grid.h index 3be16e69f..ce4daac2e 100644 --- a/src/app-grid.h +++ b/src/app-grid.h @@ -9,22 +9,12 @@ #include +#include "phosh-settings-enums.h" + #pragma once G_BEGIN_DECLS -/** - * PhoshAppFilterModeFlags: - * @PHOSH_APP_FILTER_MODE_FLAGS_NONE: No filtering - * @PHOSH_APP_FILTER_MODE_FLAGS_ADAPTIVE: Only show apps in mobile mode that adapt - * to smalls screen sizes. - * - * Controls what kind of app filtering is done. -*/ -typedef enum { - PHOSH_APP_FILTER_MODE_FLAGS_NONE = 0, - PHOSH_APP_FILTER_MODE_FLAGS_ADAPTIVE = (1 << 0), -} PhoshAppFilterModeFlags; #define PHOSH_TYPE_APP_GRID phosh_app_grid_get_type() G_DECLARE_DERIVABLE_TYPE (PhoshAppGrid, phosh_app_grid, PHOSH, APP_GRID, GtkBox) diff --git a/src/layout-manager.h b/src/layout-manager.h index 8a74c7dbd..a8563e7c1 100644 --- a/src/layout-manager.h +++ b/src/layout-manager.h @@ -7,29 +7,12 @@ #include "monitor/monitor.h" #include +#include "phosh-settings-enums.h" #pragma once G_BEGIN_DECLS -/** - * PhoshShellLayout: - * @PHOSH_SHELL_LAYOUT_NONE: Don't perform any additional layouting - * @PHOSH_SHELL_LAYOUT_DEVICE: Use device information to optimize layout - * - * How the shell's UI elements are layed out. - */ -typedef enum { - PHOSH_SHELL_LAYOUT_NONE = 0, - PHOSH_SHELL_LAYOUT_DEVICE = 1, -} PhoshShellLayout; - - -typedef enum { - PHOSH_LAYOUT_CLOCK_POS_CENTER = 0, - PHOSH_LAYOUT_CLOCK_POS_LEFT = 1, - PHOSH_LAYOUT_CLOCK_POS_RIGHT = 2, -} PhoshLayoutClockPosition; #define PHOSH_TYPE_LAYOUT_MANAGER (phosh_layout_manager_get_type ()) diff --git a/src/meson.build b/src/meson.build index a1b31d382..9cc5e5ce6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -5,6 +5,20 @@ subdir('wwan') subdir('settings') subdir('gtk-list-models') +phosh_enums_header_subdir = 'phosh' + +install_headers('phosh-settings-enums.h', subdir : phosh_enums_header_subdir) + +pkgconfig.generate( + requires : gsettings_desktop_schemas_dep, + subdirs : phosh_enums_header_subdir, + version : meson.project_version(), + install_dir : libdir / 'pkgconfig', + filebase : 'phosh-settings', + name : 'phosh-settings-schemas', + description : 'Shared gsettings schema and enum headers for Phosh', +) + phosh_resources = gnome.compile_resources( 'phosh-resources', 'phosh.gresources.xml', diff --git a/src/notifications/notify-feedback.h b/src/notifications/notify-feedback.h index 481990520..75494b472 100644 --- a/src/notifications/notify-feedback.h +++ b/src/notifications/notify-feedback.h @@ -10,23 +10,10 @@ #include +#include "phosh-settings-enums.h" + G_BEGIN_DECLS -/** - * PhoshNotifyScreenWakeupFlags: - * @PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_NONE: No wakeup - * @PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_URGENCY: Wakeup screen based on notification urgency - * @PHOSH_NOTIFY_SCREEN_WAKUP_FLAG_CATEGORY: Wakeup screen based on notification category - * @PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_ANY: Wakeup screen on any notification - * - * What notification properties trigger screen wakeup - */ -typedef enum { - PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_NONE = 0, /*< skip >*/ - PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_ANY = (1 << 0), - PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_URGENCY = (1 << 1), - PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_CATEGORY = (1 << 2), -} PhoshNotifyScreenWakeupFlags; #define PHOSH_TYPE_NOTIFY_FEEDBACK (phosh_notify_feedback_get_type ()) diff --git a/src/phosh-settings-enums.h b/src/phosh-settings-enums.h new file mode 100644 index 000000000..ec04cb73f --- /dev/null +++ b/src/phosh-settings-enums.h @@ -0,0 +1,70 @@ +/* + * Copyright © 2019 Zander Brown + * 2020-2021 Purism SPC + * 2023 The Phosh Developers + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +/** + * PhoshAppFilterModeFlags: + * @PHOSH_APP_FILTER_MODE_FLAGS_NONE: No filtering + * @PHOSH_APP_FILTER_MODE_FLAGS_ADAPTIVE: Only show apps in mobile mode that adapt + * to smalls screen sizes. + * + * Controls what kind of app filtering is done. +*/ +typedef enum { + PHOSH_APP_FILTER_MODE_FLAGS_NONE = 0, + PHOSH_APP_FILTER_MODE_FLAGS_ADAPTIVE = (1 << 0), +} PhoshAppFilterModeFlags; + +/** + * PhoshShellLayout: + * @PHOSH_SHELL_LAYOUT_NONE: Don't perform any additional layouting + * @PHOSH_SHELL_LAYOUT_DEVICE: Use device information to optimize layout + * + * How the shell's UI elements are layed out. + */ +typedef enum { + PHOSH_SHELL_LAYOUT_NONE = 0, + PHOSH_SHELL_LAYOUT_DEVICE = 1, +} PhoshShellLayout; + + +typedef enum { + PHOSH_LAYOUT_CLOCK_POS_CENTER = 0, + PHOSH_LAYOUT_CLOCK_POS_LEFT = 1, + PHOSH_LAYOUT_CLOCK_POS_RIGHT = 2, +} PhoshLayoutClockPosition; + +/** + * PhoshNotifyScreenWakeupFlags: + * @PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_NONE: No wakeup + * @PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_URGENCY: Wakeup screen based on notification urgency + * @PHOSH_NOTIFY_SCREEN_WAKUP_FLAG_CATEGORY: Wakeup screen based on notification category + * @PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_ANY: Wakeup screen on any notification + * + * What notification properties trigger screen wakeup + */ +typedef enum { + PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_NONE = 0, /*< skip >*/ + PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_ANY = (1 << 0), + PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_URGENCY = (1 << 1), + PHOSH_NOTIFY_SCREEN_WAKEUP_FLAG_CATEGORY = (1 << 2), +} PhoshNotifyScreenWakeupFlags; + +/** + * PhoshWWanBackend: + * @PHOSH_WWAN_BACKEND_MM: Use ModemManager + * @PHOSH_WWAN_BACKEND_OFONO: Use oFono + * + * Which WWAN backend to use. + */ +typedef enum /*< enum,prefix=PHOSH >*/ +{ + PHOSH_WWAN_BACKEND_MM, /*< nick=modemmanager >*/ + PHOSH_WWAN_BACKEND_OFONO, /*< nick=ofono >*/ +} PhoshWWanBackend; diff --git a/src/shell.c b/src/shell.c index 8d842a707..ab147d2f2 100644 --- a/src/shell.c +++ b/src/shell.c @@ -88,9 +88,10 @@ #include "wwan-info.h" #include "wwan/phosh-wwan-ofono.h" #include "wwan/phosh-wwan-mm.h" -#include "wwan/phosh-wwan-backend.h" #include "wall-clock.h" +#include "phosh-settings-enums.h" + #define WWAN_BACKEND_KEY "wwan-backend" /** diff --git a/src/wwan/meson.build b/src/wwan/meson.build index e7fd28ff6..e63e40ac6 100644 --- a/src/wwan/meson.build +++ b/src/wwan/meson.build @@ -1,7 +1,6 @@ phosh_wwan_inc = include_directories('.') phosh_wwan_headers = files( - 'phosh-wwan-backend.h', 'phosh-wwan-ofono.h', 'phosh-wwan-mm.h', 'phosh-wwan-iface.h', diff --git a/src/wwan/phosh-wwan-backend.h b/src/wwan/phosh-wwan-backend.h deleted file mode 100644 index 665761ed0..000000000 --- a/src/wwan/phosh-wwan-backend.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2020 Purism SPC - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ -#pragma once - -/** - * PhoshWWanBackend: - * @PHOSH_WWAN_BACKEND_MM: Use ModemManager - * @PHOSH_WWAN_BACKEND_OFONO: Use oFono - * - * Which WWAN backend to use. - */ -typedef enum /*< enum,prefix=PHOSH >*/ -{ - PHOSH_WWAN_BACKEND_MM, /*< nick=modemmanager >*/ - PHOSH_WWAN_BACKEND_OFONO, /*< nick=ofono >*/ -} PhoshWWanBackend; -- GitLab