Merge application indicator support from Franesco Marella.
Change GUI configuration parameter in configure.ac to --enable-gui. Distribute defs.py.in and gtk-redshift.in even if GUI is disabled. Update POTFILES.in and update translation files.
This commit is contained in:
+2
-1
@@ -4,7 +4,8 @@ ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
# Icons
|
||||
icondir = @datadir@/icons/hicolor/scalable/apps
|
||||
icon_DATA = data/icons/hicolor/scalable/apps/redshift.svg
|
||||
icon_DATA = data/icons/hicolor/scalable/apps/redshift.svg \
|
||||
data/icons/hicolor/scalable/apps/redshift-idle.svg
|
||||
|
||||
EXTRA_DIST = $(icon_DATA)
|
||||
|
||||
|
||||
+57
-19
@@ -38,6 +38,7 @@ AS_IF([test "x$enable_randr" != xno], [
|
||||
AC_DEFINE([ENABLE_RANDR], 1,
|
||||
[Define to 1 to enable RANDR method])
|
||||
AC_MSG_RESULT([yes])
|
||||
enable_randr=yes
|
||||
], [
|
||||
AC_MSG_RESULT([missing dependencies])
|
||||
AS_IF([test "x$enable_randr" = xyes], [
|
||||
@@ -47,8 +48,9 @@ AS_IF([test "x$enable_randr" != xno], [
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
enable_randr=no
|
||||
])
|
||||
AM_CONDITIONAL([ENABLE_RANDR], [test "x$enable_randr" != xno])
|
||||
AM_CONDITIONAL([ENABLE_RANDR], [test "x$enable_randr" = xyes])
|
||||
|
||||
# Check VidMode method
|
||||
AC_MSG_CHECKING([whether to enable VidMode method])
|
||||
@@ -60,6 +62,7 @@ AS_IF([test "x$enable_vidmode" != xno], [
|
||||
AC_DEFINE([ENABLE_VIDMODE], 1,
|
||||
[Define to 1 to enable VidMode method])
|
||||
AC_MSG_RESULT([yes])
|
||||
enable_vidmode=yes
|
||||
], [
|
||||
AC_MSG_RESULT([missing dependencies])
|
||||
AS_IF([test "x$enable_vidmode" = xyes], [
|
||||
@@ -69,8 +72,9 @@ AS_IF([test "x$enable_vidmode" != xno], [
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
enable_vidmode=no
|
||||
])
|
||||
AM_CONDITIONAL([ENABLE_VIDMODE], [test "x$enable_vidmode" != xno])
|
||||
AM_CONDITIONAL([ENABLE_VIDMODE], [test "x$enable_vidmode" = xyes])
|
||||
|
||||
# Check Windows GDI method
|
||||
AC_MSG_CHECKING([whether to enable WinGDI method])
|
||||
@@ -82,6 +86,7 @@ AS_IF([test "x$enable_wingdi" != xno], [
|
||||
AC_DEFINE([ENABLE_WINGDI], 1,
|
||||
[Define to 1 to enable WinGDI method])
|
||||
AC_MSG_RESULT([yes])
|
||||
enable_wingdi=yes
|
||||
], [
|
||||
AC_MSG_RESULT([missing dependencies])
|
||||
AS_IF([test "x$enable_wingdi" = xyes], [
|
||||
@@ -91,8 +96,9 @@ AS_IF([test "x$enable_wingdi" != xno], [
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
enable_wingdi=no
|
||||
])
|
||||
AM_CONDITIONAL([ENABLE_WINGDI], [test "x$enable_wingdi" != xno])
|
||||
AM_CONDITIONAL([ENABLE_WINGDI], [test "x$enable_wingdi" = xyes])
|
||||
|
||||
# Check that at least one method is enabled
|
||||
AS_IF([test "x$enable_randr" = xno -a "x$enable_vidmode" = xno -a "x$enable_wingdi" = xno], [
|
||||
@@ -109,6 +115,7 @@ AS_IF([test "x$enable_gnome_clock" != xno], [
|
||||
AC_DEFINE([ENABLE_GNOME_CLOCK], 1,
|
||||
[Define to 1 to enable GNOME Clock location provider])
|
||||
AC_MSG_RESULT([yes])
|
||||
enable_gnome_clock=yes
|
||||
], [
|
||||
AC_MSG_RESULT([missing dependencies])
|
||||
AS_IF([test "x$enable_gnome_clock" = xyes], [
|
||||
@@ -118,28 +125,49 @@ AS_IF([test "x$enable_gnome_clock" != xno], [
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
enable_gnome_clock=no
|
||||
])
|
||||
AM_CONDITIONAL([ENABLE_GNOME_CLOCK], [test "x$enable_gnome_clock" != xno])
|
||||
AM_CONDITIONAL([ENABLE_GNOME_CLOCK], [test "x$enable_gnome_clock" = xyes])
|
||||
|
||||
# Check for GTK+ status icon
|
||||
AC_MSG_CHECKING([whether to enable GTK status icon])
|
||||
AC_ARG_ENABLE([gtk], [AC_HELP_STRING([--enable-gtk],
|
||||
[enable GTK status icon])],
|
||||
[enable_gtk=$enableval],[enable_gtk=maybe])
|
||||
AS_IF([test "x$enable_gtk" != xno], [
|
||||
AS_IF([test $have_python = yes], [
|
||||
AC_MSG_RESULT([yes])
|
||||
], [
|
||||
AC_MSG_RESULT([missing dependencies])
|
||||
AS_IF([test "x$enable_gtk" = xyes], [
|
||||
|
||||
# Check for GUI
|
||||
# There doesn't seem to be an easy way of detecting the presence
|
||||
# of a python module. For that reason, statusicon is the default GUI.
|
||||
AC_MSG_CHECKING([which GUI to enable])
|
||||
AC_ARG_ENABLE([gui], [AC_HELP_STRING([--enable-gui],
|
||||
[enable GUI (appindicator, statusicon or none)])],
|
||||
[enable_gui=$enableval],[enable_gui=maybe])
|
||||
|
||||
# Statusicon GUI
|
||||
AS_IF([test "x$enable_gui" = xstatusicon -o "x$enable_gui" = maybe], [
|
||||
AS_IF([test $have_python != yes], [
|
||||
AS_IF([test "x$enable_gui" = xstatusicon], [
|
||||
AC_MSG_ERROR([status icon script requires Python 2.6])
|
||||
])
|
||||
enable_gtk=no
|
||||
enable_gui=maybe
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
AM_CONDITIONAL([ENABLE_GTK], [test "x$enable_gtk" != xno])
|
||||
|
||||
# Appindicator GUI
|
||||
AS_IF([test "x$enable_gui" = xappindicator -o "x$enable_gui" = maybe], [
|
||||
AS_IF([test $have_python != yes], [
|
||||
AS_IF([test "x$enable_gui" = xappindicator], [
|
||||
AC_MSG_ERROR([application indicator script requires Python 2.6])
|
||||
])
|
||||
enable_gui=maybe
|
||||
])
|
||||
])
|
||||
|
||||
# Fall back to no GUI
|
||||
AS_IF([test "x$enable_gui" != xappindicator -a "x$enable_gui" != xstatusicon], [
|
||||
enable_gui=none
|
||||
])
|
||||
|
||||
AC_MSG_RESULT([$enable_gui])
|
||||
|
||||
AM_CONDITIONAL([ENABLE_STATUSICON], [test "x$enable_gui" = xstatusicon])
|
||||
AM_CONDITIONAL([ENABLE_APPINDICATOR], [test "x$enable_gui" = xappindicator])
|
||||
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([locale.h stdint.h stdlib.h string.h unistd.h sys/signal.h])
|
||||
@@ -168,4 +196,14 @@ echo "
|
||||
compiler: ${CC}
|
||||
cflags: ${CFLAGS}
|
||||
ldflags: ${LDFLAGS}
|
||||
|
||||
Adjustment methods:
|
||||
RANDR: ${enable_randr}
|
||||
VidMode: ${enable_vidmode}
|
||||
WinGDI: ${enable_wingdi}
|
||||
|
||||
Location providers:
|
||||
GNOME Clock: ${enable_gnome_clock}
|
||||
|
||||
GUI: ${enable_gui}
|
||||
"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 102 KiB |
@@ -10,3 +10,4 @@ src/location-gnome-clock.c
|
||||
src/location-manual.c
|
||||
|
||||
src/gtk-redshift/statusicon.py
|
||||
src/gtk-redshift/rsappindicator.py
|
||||
|
||||
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: redshift\n"
|
||||
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/redshift\n"
|
||||
"POT-Creation-Date: 2010-06-04 21:58+0200\n"
|
||||
"POT-Creation-Date: 2010-06-06 23:32+0200\n"
|
||||
"PO-Revision-Date: 2010-05-05 22:20+0000\n"
|
||||
"Last-Translator: Jon Lund Steffensen <Unknown>\n"
|
||||
"Language-Team: Danish <da@li.org>\n"
|
||||
@@ -400,7 +400,7 @@ msgstr "Fejl i gamma-argument.\n"
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "Fejl i gamma-argument.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:61
|
||||
#: src/gtk-redshift/statusicon.py:61 src/gtk-redshift/rsappindicator.py:70
|
||||
msgid "Toggle"
|
||||
msgstr "Slå til/fra"
|
||||
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: redshift 1.3\n"
|
||||
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/redshift\n"
|
||||
"POT-Creation-Date: 2010-06-04 21:58+0200\n"
|
||||
"POT-Creation-Date: 2010-06-06 23:32+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -376,6 +376,6 @@ msgstr ""
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:61
|
||||
#: src/gtk-redshift/statusicon.py:61 src/gtk-redshift/rsappindicator.py:70
|
||||
msgid "Toggle"
|
||||
msgstr ""
|
||||
|
||||
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: redshift\n"
|
||||
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/redshift\n"
|
||||
"POT-Creation-Date: 2010-06-04 21:58+0200\n"
|
||||
"POT-Creation-Date: 2010-06-06 23:32+0200\n"
|
||||
"PO-Revision-Date: 2010-02-02 09:20+0000\n"
|
||||
"Last-Translator: Gregory Petrosyan <gregory.petrosyan@gmail.com>\n"
|
||||
"Language-Team: Russian <ru@li.org>\n"
|
||||
@@ -394,7 +394,7 @@ msgstr "Некорректная величина гаммы.\n"
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "Некорректная величина гаммы.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:61
|
||||
#: src/gtk-redshift/statusicon.py:61 src/gtk-redshift/rsappindicator.py:70
|
||||
msgid "Toggle"
|
||||
msgstr "Включить / Выключить"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
if ENABLE_GTK
|
||||
if ENABLE_STATUSICON
|
||||
gui_module=statusicon
|
||||
gtk_redshift_PYTHON = \
|
||||
__init__.py \
|
||||
statusicon.py
|
||||
@@ -7,11 +8,31 @@ nodist_gtk_redshift_PYTHON = \
|
||||
defs.py
|
||||
gtk_redshiftdir = $(pythondir)/gtk_redshift
|
||||
|
||||
dist_bin_SCRIPTS = gtk-redshift
|
||||
EXTRA_DIST = defs.py.in
|
||||
bin_SCRIPTS = gtk-redshift
|
||||
endif
|
||||
|
||||
CLEANFILES = defs.py
|
||||
if ENABLE_APPINDICATOR
|
||||
gui_module=rsappindicator
|
||||
gtk_redshift_PYTHON = \
|
||||
__init__.py \
|
||||
rsappindicator.py
|
||||
nodist_gtk_redshift_PYTHON = \
|
||||
defs.py
|
||||
gtk_redshiftdir = $(pythondir)/gtk_redshift
|
||||
|
||||
bin_SCRIPTS = gtk-redshift
|
||||
endif
|
||||
|
||||
EXTRA_DIST = gtk-redshift.in \
|
||||
defs.py.in
|
||||
|
||||
CLEANFILES = defs.py \
|
||||
gtk-redshift
|
||||
|
||||
|
||||
# Main GUI script
|
||||
gtk-redshift: gtk-redshift.in
|
||||
sed -e "s|\@gui_module\@|$(gui_module)|g" $< > $@
|
||||
|
||||
# Local python definitions
|
||||
defs.py: defs.py.in
|
||||
|
||||
@@ -16,5 +16,3 @@
|
||||
# along with Redshift. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com>
|
||||
|
||||
__all__ = ['statusicon']
|
||||
|
||||
@@ -19,5 +19,5 @@
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from gtk_redshift.statusicon import run_statusicon
|
||||
run_statusicon()
|
||||
from gtk_redshift.@gui_module@ import run
|
||||
run()
|
||||
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python
|
||||
# rsappindicator.py -- Application Panel Indicator source
|
||||
# This file is part of Redshift.
|
||||
|
||||
# Redshift is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# Redshift is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Redshift. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com>
|
||||
|
||||
|
||||
import sys, os
|
||||
import subprocess, signal
|
||||
import gettext
|
||||
|
||||
import pygtk
|
||||
pygtk.require("2.0")
|
||||
|
||||
import gtk, glib
|
||||
try:
|
||||
import appindicator
|
||||
except ImportError as ie:
|
||||
# No module named appindicator
|
||||
sys.exit(str(ie))
|
||||
|
||||
import defs
|
||||
|
||||
|
||||
def run():
|
||||
# Internationalisation
|
||||
gettext.bindtextdomain('redshift', defs.LOCALEDIR)
|
||||
gettext.textdomain('redshift')
|
||||
_ = gettext.gettext
|
||||
|
||||
# Start redshift with arguments from the command line
|
||||
args = sys.argv[1:]
|
||||
args.insert(0, os.path.join(defs.BINDIR, 'redshift'))
|
||||
process = subprocess.Popen(args)
|
||||
|
||||
try:
|
||||
# Create status icon
|
||||
indicator = appindicator.Indicator ("redshift",
|
||||
"redshift",
|
||||
appindicator.CATEGORY_APPLICATION_STATUS)
|
||||
indicator.set_status (appindicator.STATUS_ACTIVE)
|
||||
|
||||
def toggle_cb(widget, data=None):
|
||||
if indicator.get_icon() == 'redshift':
|
||||
indicator.set_icon('redshift-idle')
|
||||
else:
|
||||
indicator.set_icon('redshift')
|
||||
process.send_signal(signal.SIGUSR1)
|
||||
|
||||
def destroy_cb(widget, data=None):
|
||||
gtk.main_quit()
|
||||
return False
|
||||
|
||||
# Create popup menu
|
||||
status_menu = gtk.Menu()
|
||||
|
||||
toggle_item = gtk.ImageMenuItem(_('Toggle'))
|
||||
toggle_item.connect('activate', toggle_cb)
|
||||
status_menu.append(toggle_item)
|
||||
|
||||
quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
|
||||
quit_item.connect('activate', destroy_cb)
|
||||
status_menu.append(quit_item)
|
||||
|
||||
status_menu.show_all()
|
||||
|
||||
# Set the menu
|
||||
indicator.set_menu(status_menu)
|
||||
|
||||
def child_cb(pid, cond, data=None):
|
||||
sys.exit(-1)
|
||||
|
||||
# Add watch on child process
|
||||
glib.child_watch_add(process.pid, child_cb)
|
||||
|
||||
# Run main loop
|
||||
gtk.main()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
# Ignore user interruption
|
||||
pass
|
||||
|
||||
finally:
|
||||
# Always terminate redshift
|
||||
process.terminate()
|
||||
process.wait()
|
||||
@@ -30,7 +30,7 @@ import gtk, glib
|
||||
import defs
|
||||
|
||||
|
||||
def run_statusicon():
|
||||
def run():
|
||||
# Internationalisation
|
||||
gettext.bindtextdomain('redshift', defs.LOCALEDIR)
|
||||
gettext.textdomain('redshift')
|
||||
|
||||
Reference in New Issue
Block a user