Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 3abfbf0

Browse files
committed
redshift-config-gtk: Implement GTK+ GUI config tool
1 parent ca8362c commit 3abfbf0

11 files changed

Lines changed: 1604 additions & 25 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ m4/lt~obsolete.m4
115115
/src/redshift-gtk/defs.py
116116
/src/redshift-gtk/redshift-gtk
117117
/src/redshift-gtk/__pycache__/
118+
/src/redshift-config-gtk/redshift-config-gtk-resource.c
119+
/src/redshift-config-gtk/redshift-config-gtk
118120

119121
# gettext
120122
/po/POTFILES

‎.travis.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ addons:
2525
- libxxf86vm-dev
2626
# GeoClue2
2727
- libglib2.0-dev
28+
# GUI config tool
29+
- libgtk-3-dev
30+
- libxml2-utils
2831
# GUI
2932
- python3
3033

@@ -35,6 +38,7 @@ before_install: |
3538
brew link --force gettext
3639
brew install intltool
3740
brew upgrade python
41+
brew install gtk+3
3842
3943
# distuninstallcheck fails on macOS when automake 1.16 or 1.16.1 is used.
4044
# http://gnu-automake.7480.n7.nabble.com/bug-31222-automake-1-16-1-am-pep3147-tweak-bug-td22937.html

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Dependencies
5353
* libxcb, libxcb-randr (Optional, for RandR support)
5454
* libX11, libXxf86vm (Optional, for VidMode support)
5555
* Glib 2 (Optional, for GeoClue2 support)
56+
* GTK+ 3 (Optional, for GUI config tool)
5657

5758
* python3, pygobject, pyxdg (Optional, for GUI support)
5859
* appindicator (Optional, for Ubuntu-style GUI status icon)

‎configure.ac‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ PKG_CHECK_MODULES([XCB_RANDR], [xcb-randr],
6969
[have_xcb_randr=yes], [have_xcb_randr=no])
7070

7171
PKG_CHECK_MODULES([GLIB], [glib-2.0 gobject-2.0], [have_glib=yes], [have_glib=no])
72+
PKG_CHECK_MODULES([GTK3], [gtk+-3.0], [have_gtk3=yes], [have_gtk3=no])
7273
PKG_CHECK_MODULES([GEOCLUE2], [glib-2.0 gio-2.0 >= 2.26], [have_geoclue2=yes], [have_geoclue2=no])
7374

7475
# macOS headers
@@ -100,6 +101,30 @@ AC_CHECK_HEADER([windows.h], [have_windows_h=yes], [have_windows_h=no])
100101
# Check for Python
101102
AM_PATH_PYTHON([3.2], [have_python=yes], [have_python=no])
102103

104+
# Check GTK+ GUI config tool
105+
AC_MSG_CHECKING([whether to enable GTK+ GUI config tool])
106+
AC_ARG_ENABLE([config-gui], [AC_HELP_STRING([--enable-config-gui],
107+
[enable GTK+ GUI config tool])],
108+
[enable_config_gui=$enableval],[enable_config_gui=maybe])
109+
AS_IF([test "x$enable_config_gui" != xno], [
110+
AS_IF([test "x$have_gtk3" = xyes], [
111+
AC_DEFINE([ENABLE_CONFIG_GUI], 1,
112+
[Define to 1 to enable GTK+ GUI config tool])
113+
AC_MSG_RESULT([yes])
114+
enable_config_gui=yes
115+
], [
116+
AC_MSG_RESULT([missing dependencies])
117+
AS_IF([test "x$enable_config_gui" = xyes], [
118+
AC_MSG_ERROR([missing dependencies for GTK+])
119+
])
120+
enable_config_gui=no
121+
])
122+
], [
123+
AC_MSG_RESULT([no])
124+
enable_config_gui=no
125+
])
126+
AM_CONDITIONAL([ENABLE_CONFIG_GUI], [test "x$enable_config_gui" = xyes])
127+
103128
# Check DRM method
104129
AC_MSG_CHECKING([whether to enable DRM method])
105130
AC_ARG_ENABLE([drm], [AC_HELP_STRING([--enable-drm],
@@ -362,6 +387,7 @@ AC_CONFIG_FILES([
362387
po/Makefile.in
363388
src/Makefile
364389
src/redshift-gtk/Makefile
390+
src/redshift-config-gtk/Makefile
365391
])
366392
AC_OUTPUT
367393

@@ -386,6 +412,7 @@ echo "
386412
CoreLocation (macOS): ${enable_corelocation}
387413

388414
GUI: ${enable_gui}
415+
GUI config tool: ${enable_config_gui}
389416
Ubuntu icons: ${enable_ubuntu}
390417
systemd units: ${enable_systemd} ${systemduserunitdir}
391418
AppArmor profile: ${enable_apparmor}

‎po/POTFILES.in‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
data/appdata/redshift-gtk.appdata.xml.in
44
data/applications/redshift.desktop.in
55
data/applications/redshift-gtk.desktop.in
6+
[type: gettext/glade] src/redshift-config-gtk/gtk/menus.ui
67

78
src/redshift.c
89
src/options.c
@@ -19,4 +20,6 @@ src/location-geoclue2.c
1920
src/location-corelocation.m
2021
src/location-manual.c
2122

23+
src/redshift-config-gtk/redshift-config-gtk.c
24+
2225
src/redshift-gtk/statusicon.py

‎src/Makefile.am‎

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

2-
SUBDIRS = redshift-gtk
2+
SUBDIRS = . redshift-gtk
3+
4+
if ENABLE_CONFIG_GUI
5+
SUBDIRS += redshift-config-gtk
6+
endif
37

48
# I18n
59
localedir = $(datadir)/locale
@@ -8,75 +12,82 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
812
# redshift Program
913
bin_PROGRAMS = redshift
1014

11-
redshift_SOURCES = \
15+
noinst_LTLIBRARIES = libredshift_common.la
16+
libredshift_common_la_LIBADD =
17+
18+
libredshift_common_la_SOURCES = \
1219
colorramp.c colorramp.h \
1320
config-ini.c config-ini.h \
1421
gamma-dummy.c gamma-dummy.h \
15-
hooks.c hooks.h \
1622
location-manual.c location-manual.h \
1723
options.c options.h \
18-
pipeutils.c pipeutils.h \
19-
redshift.c redshift.h \
20-
signals.c signals.h \
21-
solar.c solar.h \
22-
systemtime.c systemtime.h
24+
pipeutils.c pipeutils.h
2325

24-
EXTRA_redshift_SOURCES = \
26+
EXTRA_libredshift_common_la_SOURCES = \
2527
gamma-drm.c gamma-drm.h \
2628
gamma-randr.c gamma-randr.h \
2729
gamma-vidmode.c gamma-vidmode.h \
2830
gamma-quartz.c gamma-quartz.h \
2931
gamma-w32gdi.c gamma-w32gdi.h \
3032
location-geoclue2.c location-geoclue2.h \
31-
location-corelocation.m location-corelocation.h \
33+
location-corelocation.m location-corelocation.h
34+
35+
redshift_SOURCES = \
36+
hooks.c hooks.h \
37+
redshift.c redshift.h \
38+
signals.c signals.h \
39+
solar.c solar.h \
40+
systemtime.c systemtime.h
41+
42+
EXTRA_redshift_SOURCES = \
3243
windows/appicon.rc \
3344
windows/versioninfo.rc
3445

3546
AM_CFLAGS =
36-
redshift_LDADD = @LIBINTL@
47+
redshift_LDADD = @LIBINTL@ libredshift_common.la
3748
EXTRA_DIST = windows/redshift.ico
3849

3950
if ENABLE_DRM
40-
redshift_SOURCES += gamma-drm.c gamma-drm.h
51+
libredshift_common_la_SOURCES += gamma-drm.c gamma-drm.h
4152
AM_CFLAGS += $(DRM_CFLAGS)
42-
redshift_LDADD += \
53+
libredshift_common_la_LIBADD += \
4354
$(DRM_LIBS) $(DRM_CFLAGS)
4455
endif
4556

4657
if ENABLE_RANDR
47-
redshift_SOURCES += gamma-randr.c gamma-randr.h
58+
libredshift_common_la_SOURCES += gamma-randr.c gamma-randr.h
4859
AM_CFLAGS += $(XCB_CFLAGS) $(XCB_RANDR_CFLAGS)
49-
redshift_LDADD += \
60+
libredshift_common_la_LIBADD += \
5061
$(XCB_LIBS) $(XCB_CFLAGS) \
5162
$(XCB_RANDR_LIBS) $(XCB_RANDR_CFLAGS)
5263
endif
5364

5465
if ENABLE_VIDMODE
55-
redshift_SOURCES += gamma-vidmode.c gamma-vidmode.h
66+
libredshift_common_la_SOURCES += gamma-vidmode.c gamma-vidmode.h
5667
AM_CFLAGS += $(X11_CFLAGS) $(XF86VM_CFLAGS)
57-
redshift_LDADD += \
68+
libredshift_common_la_LIBADD += \
5869
$(X11_LIBS) $(X11_CFLAGS) \
5970
$(XF86VM_LIBS) $(XF86VM_CFLAGS)
6071
endif
6172

6273
if ENABLE_QUARTZ
63-
redshift_SOURCES += gamma-quartz.c gamma-quartz.h
74+
libredshift_common_la_SOURCES += gamma-quartz.c gamma-quartz.h
6475
AM_CFLAGS += $(QUARTZ_CFLAGS)
65-
redshift_LDADD += \
76+
libredshift_common_la_LIBADD += \
6677
$(QUARTZ_LIBS) $(QUARTZ_CFLAGS)
6778
endif
6879

6980
if ENABLE_WINGDI
70-
redshift_SOURCES += gamma-w32gdi.c gamma-w32gdi.h
71-
redshift_LDADD += -lgdi32
81+
libredshift_common_la_SOURCES += gamma-w32gdi.c gamma-w32gdi.h
82+
libredshift_common_la_LIBADD += -lgdi32
7283
endif
7384

7485

7586
if ENABLE_GEOCLUE2
76-
redshift_SOURCES += location-geoclue2.c location-geoclue2.h
87+
libredshift_common_la_SOURCES += location-geoclue2.c location-geoclue2.h
7788
AM_CFLAGS += \
7889
$(GEOCLUE2_CFLAGS)
79-
redshift_LDADD += \
90+
libredshift_common_la_LIBADD += \
8091
$(GEOCLUE2_LIBS) $(GEOCLUE2_CFLAGS)
8192
endif
8293

@@ -85,14 +96,14 @@ endif
8596
# (Objective C).
8697

8798
if ENABLE_CORELOCATION
88-
noinst_LTLIBRARIES = liblocation-corelocation.la
99+
noinst_LTLIBRARIES += liblocation-corelocation.la
89100
liblocation_corelocation_la_SOURCES = \
90101
location-corelocation.m location-corelocation.h
91102
liblocation_corelocation_la_OBJCFLAGS = \
92103
$(CORELOCATION_CFLAGS)
93104
liblocation_corelocation_la_LIBADD = \
94105
$(CORELOCATION_CFLAGS) $(CORELOCATION_LIBS)
95-
redshift_LDADD += liblocation-corelocation.la
106+
libredshift_common_la_LIBADD += liblocation-corelocation.la
96107
endif
97108

98109

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
SUFFIXES = .gresource.xml
2+
3+
localedir = $(datadir)/locale
4+
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
5+
6+
bin_PROGRAMS = redshift-config-gtk
7+
8+
redshift_config_gtk_SOURCES = \
9+
redshift-config-gtk.c
10+
11+
nodist_redshift_config_gtk_SOURCES = \
12+
redshift-config-gtk-resource.c
13+
14+
# GLib resources
15+
redshift-config-gtk-resource.c: \
16+
redshift-config-gtk-resource.gresource.xml \
17+
gtk/menus.ui \
18+
icons/48x48/apps/redshift.png
19+
20+
redshift_config_gtk_CFLAGS = $(GTK3_CFLAGS) -I$(top_srcdir)/src
21+
redshift_config_gtk_LDADD = $(GTK3_LIBS) ../libredshift_common.la
22+
23+
EXTRA_DIST = \
24+
redshift-config-gtk-resource.gresource.xml \
25+
gtk/menus.ui \
26+
icons/48x48/apps/redshift.png
27+
28+
.gresource.xml.c:
29+
$(AM_V_GEN)glib-compile-resources \
30+
--sourcedir=`dirname $<` $< --target=$@ --generate-source
31+
32+
CLEANFILES = \
33+
$(nodist_redshift_config_gtk_SOURCES)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
GTK+ menus UI file for redshift-config-gtk.
4+
5+
This file is part of Redshift.
6+
7+
Redshift is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
Redshift is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
19+
20+
Copyright (c) 2018 Masanori Kakura <kakurasan@gmail.com>
21+
-->
22+
<interface>
23+
<menu id="menubar">
24+
<submenu>
25+
<attribute name="label" translatable="yes">_File</attribute>
26+
<section>
27+
<item>
28+
<attribute name="label" translatable="yes">_Save settings</attribute>
29+
<attribute name="action">app.save</attribute>
30+
<attribute name="accel">&lt;Primary&gt;s</attribute>
31+
<attribute name="icon">gtk-save</attribute>
32+
</item>
33+
<item>
34+
<attribute name="label" translatable="yes">_Revert color settings</attribute>
35+
<attribute name="action">app.revert</attribute>
36+
<attribute name="accel">&lt;Primary&gt;r</attribute>
37+
<attribute name="icon">gtk-undo</attribute>
38+
</item>
39+
</section>
40+
<section>
41+
<item>
42+
<attribute name="label" translatable="yes">_Quit</attribute>
43+
<attribute name="action">app.quit</attribute>
44+
<attribute name="accel">&lt;Primary&gt;q</attribute>
45+
<attribute name="icon">gtk-quit</attribute>
46+
</item>
47+
</section>
48+
</submenu>
49+
</menu>
50+
</interface>

‎src/redshift-config-gtk/icons/48x48/apps/redshift.png‎

Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
GLib resource file for redshift-config-gtk.
4+
5+
This file is part of Redshift.
6+
7+
Redshift is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
Redshift is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
19+
20+
Copyright (c) 2018 Masanori Kakura <kakurasan@gmail.com>
21+
-->
22+
<gresources>
23+
<gresource prefix="/dk/jonls/redshift-config-gtk">
24+
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
25+
<file>icons/48x48/apps/redshift.png</file>
26+
</gresource>
27+
</gresources>

0 commit comments

Comments
 (0)