summary refs log tree commit diff
path: root/pkgs/development/libraries/granite/02-datetime-clock-format-gsettings.patch
blob: 7b7c9871133a1bbf9106ed533bb9ccff7a4827d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
From 698e34dd6e8d98a1818ae00d3313b69a86340771 Mon Sep 17 00:00:00 2001
From: Fabio Valentini <decathorpe@gmail.com>
Date: Mon, 17 Dec 2018 14:58:14 +0100
Subject: DateTime: include "clock-format" gsettings key here

---
 data/io.elementary.granite.gschema.xml | 15 +++++++++++++++
 data/meson.build                       |  4 ++++
 lib/DateTime.vala                      |  4 ++--
 meson.build                            | 11 +++++++++++
 meson/post_install.py                  |  5 +++++
 5 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 data/io.elementary.granite.gschema.xml
 create mode 100644 data/meson.build

diff --git a/data/io.elementary.granite.gschema.xml b/data/io.elementary.granite.gschema.xml
new file mode 100644
index 0000000..1540fb0
--- /dev/null
+++ b/data/io.elementary.granite.gschema.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+  <enum id="io.elementary.granite.clock-formats">
+    <value nick="12h" value="0" />
+    <value nick="24h" value="1" />
+    <value nick="ISO8601" value="2" />
+  </enum>
+  <schema id="io.elementary.granite" path="/io/elementary/granite/">
+    <key name="clock-format" enum="io.elementary.granite.clock-formats">
+      <default>"12h"</default>
+      <summary>Whether the clock displays in 12h or 24h format</summary>
+      <description>Whether the clock displays in 12h or 24h format</description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..96cc3b1
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,4 @@
+install_data(
+    rdnn + '.gschema.xml',
+    install_dir: schema_dir
+)
diff --git a/lib/DateTime.vala b/lib/DateTime.vala
index aea2ec6..3d81191 100644
--- a/lib/DateTime.vala
+++ b/lib/DateTime.vala
@@ -104,13 +104,13 @@ namespace Granite.DateTime {
     }
 
     /**
-     * Gets the //clock-format// key from //org.gnome.desktop.interface// schema
+     * Gets the //clock-format// key from //io.elementary.granite// schema
      * and determines if the clock format is 12h based
      *
      * @return true if the clock format is 12h based, false otherwise.
      */
     private static bool is_clock_format_12h () {
-        var h24_settings = new Settings ("io.elementary.desktop.wingpanel.datetime");
+        var h24_settings = new Settings ("io.elementary.granite");
         var format = h24_settings.get_string ("clock-format");
         return (format.contains ("12h"));
     }
diff --git a/meson.build b/meson.build
index 8b98eeb..f0abcdf 100644
--- a/meson.build
+++ b/meson.build
@@ -4,6 +4,8 @@ project(
     version: '5.2.2'
 )
 
+rdnn = 'io.elementary.' + meson.project_name()
+
 if meson.get_compiler('vala').version().version_compare('<0.40.0')
     error('vala compiler version 0.40.0 or newer is required.')
 endif
@@ -52,10 +54,18 @@ icons_dir = join_paths(
     'hicolor'
 )
 
+schema_dir = join_paths(
+    get_option('prefix'),
+    get_option('datadir'),
+    'glib-2.0',
+    'schemas'
+)
+
 pkgconfig = import('pkgconfig')
 i18n = import('i18n')
 
 subdir('lib')
+subdir('data')
 subdir('demo')
 subdir('icons')
 subdir('po')
@@ -68,5 +78,6 @@ endif
 meson.add_install_script(
     join_paths(meson.current_source_dir(), 'meson', 'post_install.py'),
     '--iconsdir', icons_dir,
+    '--schemadir', schema_dir,
 )
 
diff --git a/meson/post_install.py b/meson/post_install.py
index 1864515..5313f96 100755
--- a/meson/post_install.py
+++ b/meson/post_install.py
@@ -6,11 +6,16 @@ import subprocess
 
 parser = argparse.ArgumentParser()
 parser.add_argument("--iconsdir", action="store", required=True)
+parser.add_argument("--schemadir", action="store", required=True)
 args = vars(parser.parse_args())
 
 icons_dir = args["iconsdir"]
+schema_dir = args["schemadir"]
 
 if not os.environ.get('DESTDIR'):
     print('Compiling icon cache ...')
     subprocess.run(['gtk-update-icon-cache', icons_dir])
 
+    print('Compiling GSettings schemas ...')
+    subprocess.run(['glib-compile-schemas', schema_dir])
+
-- 
2.20.1