diff --git a/Makefile.am b/Makefile.am index 70df15e..b2ba5d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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) diff --git a/configure.ac b/configure.ac index 89cb47a..10637f0 100644 --- a/configure.ac +++ b/configure.ac @@ -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} " diff --git a/data/icons/hicolor/scalable/apps/redshift-idle.svg b/data/icons/hicolor/scalable/apps/redshift-idle.svg new file mode 100644 index 0000000..9125a20 --- /dev/null +++ b/data/icons/hicolor/scalable/apps/redshift-idle.svg @@ -0,0 +1,2395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/po/POTFILES.in b/po/POTFILES.in index a46a9d4..6bd7210 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -10,3 +10,4 @@ src/location-gnome-clock.c src/location-manual.c src/gtk-redshift/statusicon.py +src/gtk-redshift/rsappindicator.py diff --git a/po/da.po b/po/da.po index 8e64a74..a4184a9 100644 --- a/po/da.po +++ b/po/da.po @@ -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 \n" "Language-Team: Danish \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" diff --git a/po/redshift.pot b/po/redshift.pot index 866118a..35901dc 100644 --- a/po/redshift.pot +++ b/po/redshift.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/po/ru.po b/po/ru.po index 2163259..f227316 100644 --- a/po/ru.po +++ b/po/ru.po @@ -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 \n" "Language-Team: Russian \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 "Включить / Выключить" diff --git a/src/gtk-redshift/Makefile.am b/src/gtk-redshift/Makefile.am index d0d8695..ddeafd6 100644 --- a/src/gtk-redshift/Makefile.am +++ b/src/gtk-redshift/Makefile.am @@ -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 diff --git a/src/gtk-redshift/__init__.py b/src/gtk-redshift/__init__.py index 30205ca..51ab2ef 100644 --- a/src/gtk-redshift/__init__.py +++ b/src/gtk-redshift/__init__.py @@ -16,5 +16,3 @@ # along with Redshift. If not, see . # Copyright (c) 2010 Jon Lund Steffensen - -__all__ = ['statusicon'] diff --git a/src/gtk-redshift/gtk-redshift b/src/gtk-redshift/gtk-redshift.in similarity index 91% rename from src/gtk-redshift/gtk-redshift rename to src/gtk-redshift/gtk-redshift.in index f62c6f1..120e05c 100644 --- a/src/gtk-redshift/gtk-redshift +++ b/src/gtk-redshift/gtk-redshift.in @@ -19,5 +19,5 @@ if __name__ == '__main__': - from gtk_redshift.statusicon import run_statusicon - run_statusicon() + from gtk_redshift.@gui_module@ import run + run() diff --git a/src/gtk-redshift/rsappindicator.py b/src/gtk-redshift/rsappindicator.py new file mode 100644 index 0000000..59fa725 --- /dev/null +++ b/src/gtk-redshift/rsappindicator.py @@ -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 . + +# Copyright (c) 2010 Jon Lund Steffensen + + +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() diff --git a/src/gtk-redshift/statusicon.py b/src/gtk-redshift/statusicon.py index 9925c35..2295963 100644 --- a/src/gtk-redshift/statusicon.py +++ b/src/gtk-redshift/statusicon.py @@ -30,7 +30,7 @@ import gtk, glib import defs -def run_statusicon(): +def run(): # Internationalisation gettext.bindtextdomain('redshift', defs.LOCALEDIR) gettext.textdomain('redshift')