Merge GUI autostart feature from Francesco Marella.
This commit is contained in:
@@ -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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-13 20:24+0000\n"
|
||||
"Last-Translator: clever_fox <clever_fox@seznam.cz>\n"
|
||||
"Language-Team: Czech <cs@li.org>\n"
|
||||
@@ -401,6 +401,10 @@ msgstr "Nevhodný argument.\n"
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "Příliš mnoho argumentů.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr "Přepnout"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-13 20:24+0000\n"
|
||||
"Last-Translator: Jon Lund Steffensen <Unknown>\n"
|
||||
"Language-Team: Danish <da@li.org>\n"
|
||||
@@ -416,10 +416,14 @@ msgstr "Fejl i parameteren.\n"
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "For mange parametre.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr "Slå til/fra"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "Malformed location argument.\n"
|
||||
#~ msgstr "Fejl i placeringsargument.\n"
|
||||
|
||||
|
||||
@@ -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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-13 20:24+0000\n"
|
||||
"Last-Translator: Jan-Christoph Borchardt <inquata@gmail.com>\n"
|
||||
"Language-Team: German <de@li.org>\n"
|
||||
@@ -413,6 +413,10 @@ msgstr "Fehlerhaftes Kommando.\n"
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "Zu viele Kommandos.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr "Umschalten"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-14 17:15+0000\n"
|
||||
"Last-Translator: Fernando Ossandon <ferossan@gmail.com>\n"
|
||||
"Language-Team: Spanish <es@li.org>\n"
|
||||
@@ -418,6 +418,10 @@ msgstr "Parámetro no válido.\n"
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "Demasiados parámetros.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr "Cambiar"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-13 20:24+0000\n"
|
||||
"Last-Translator: Ilari Oras <happo1472583@gmail.com>\n"
|
||||
"Language-Team: Finnish <fi@li.org>\n"
|
||||
@@ -399,6 +399,10 @@ msgstr ""
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr "Kytke"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-13 20:24+0000\n"
|
||||
"Last-Translator: Andrea Amoroso <andrea.amoroso@alice.it>\n"
|
||||
"Language-Team: Italian <it@li.org>\n"
|
||||
@@ -419,6 +419,10 @@ msgstr "Argomento malformato.\n"
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "Troppi argomenti.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr "Verifica"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
msgstr ""
|
||||
|
||||
+6
-2
@@ -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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-13 20:24+0000\n"
|
||||
"Last-Translator: Jon Lund Steffensen <Unknown>\n"
|
||||
"Language-Team: Brazilian Portuguese <pt_BR@li.org>\n"
|
||||
@@ -393,6 +393,10 @@ msgstr ""
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr ""
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
msgstr ""
|
||||
|
||||
+6
-2
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: redshift 1.4.1\n"
|
||||
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/redshift\n"
|
||||
"POT-Creation-Date: 2010-06-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+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"
|
||||
@@ -392,6 +392,10 @@ msgstr ""
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr ""
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
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-15 13:00+0200\n"
|
||||
"POT-Creation-Date: 2010-06-30 19:54+0200\n"
|
||||
"PO-Revision-Date: 2010-06-14 11:22+0000\n"
|
||||
"Last-Translator: Чистый <klaider@yandex.ru>\n"
|
||||
"Language-Team: Russian <ru@li.org>\n"
|
||||
@@ -408,10 +408,14 @@ msgstr ""
|
||||
msgid "Too many arguments.\n"
|
||||
msgstr "Слишком много аргументов.\n"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:65 src/gtk-redshift/rsappindicator.py:70
|
||||
#: src/gtk-redshift/statusicon.py:69 src/gtk-redshift/rsappindicator.py:74
|
||||
msgid "Toggle"
|
||||
msgstr "Включить / Выключить"
|
||||
|
||||
#: src/gtk-redshift/statusicon.py:73 src/gtk-redshift/rsappindicator.py:78
|
||||
msgid "Autostart"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "Malformed location argument.\n"
|
||||
#~ msgstr "Некорректное значение местоположения.\n"
|
||||
|
||||
|
||||
@@ -3,24 +3,34 @@ if ENABLE_STATUSICON
|
||||
gui_module=statusicon
|
||||
gtk_redshift_PYTHON = \
|
||||
__init__.py \
|
||||
utils.py \
|
||||
statusicon.py
|
||||
nodist_gtk_redshift_PYTHON = \
|
||||
defs.py
|
||||
gtk_redshiftdir = $(pythondir)/gtk_redshift
|
||||
|
||||
bin_SCRIPTS = gtk-redshift
|
||||
|
||||
# Desktop file
|
||||
desktopdir = ${datadir}/applications
|
||||
desktop_DATA = gtk-redshift.desktop
|
||||
endif
|
||||
|
||||
if ENABLE_APPINDICATOR
|
||||
gui_module=rsappindicator
|
||||
gtk_redshift_PYTHON = \
|
||||
__init__.py \
|
||||
utils.py \
|
||||
rsappindicator.py
|
||||
nodist_gtk_redshift_PYTHON = \
|
||||
defs.py
|
||||
gtk_redshiftdir = $(pythondir)/gtk_redshift
|
||||
|
||||
bin_SCRIPTS = gtk-redshift
|
||||
|
||||
# Desktop file
|
||||
desktopdir = ${datadir}/applications
|
||||
desktop_DATA = gtk-redshift.desktop
|
||||
endif
|
||||
|
||||
EXTRA_DIST = gtk-redshift.in \
|
||||
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=Redshift
|
||||
GenericName=Color temperature adjustment
|
||||
Comment=Color temperature adjustment tool
|
||||
Exec=gtk-redshift
|
||||
Icon=redshift
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Utility;
|
||||
StartupNotify=true
|
||||
@@ -33,6 +33,7 @@ except ImportError as ie:
|
||||
sys.exit(str(ie))
|
||||
|
||||
import defs
|
||||
import utils
|
||||
|
||||
|
||||
def run():
|
||||
@@ -60,6 +61,9 @@ def run():
|
||||
indicator.set_icon('redshift')
|
||||
process.send_signal(signal.SIGUSR1)
|
||||
|
||||
def autostart_cb(widget, data=None):
|
||||
utils.set_autostart(widget.get_active())
|
||||
|
||||
def destroy_cb(widget, data=None):
|
||||
gtk.main_quit()
|
||||
return False
|
||||
@@ -71,6 +75,17 @@ def run():
|
||||
toggle_item.connect('activate', toggle_cb)
|
||||
status_menu.append(toggle_item)
|
||||
|
||||
autostart_item = gtk.CheckMenuItem(_('Autostart'))
|
||||
try:
|
||||
autostart_item.set_active(utils.get_autostart())
|
||||
except IOError as strerror:
|
||||
print strerror
|
||||
autostart_item.set_property('sensitive', False)
|
||||
else:
|
||||
autostart_item.connect('activate', autostart_cb)
|
||||
finally:
|
||||
status_menu.append(autostart_item)
|
||||
|
||||
quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
|
||||
quit_item.connect('activate', destroy_cb)
|
||||
status_menu.append(quit_item)
|
||||
|
||||
@@ -28,6 +28,7 @@ pygtk.require("2.0")
|
||||
import gtk, glib
|
||||
|
||||
import defs
|
||||
import utils
|
||||
|
||||
|
||||
def run():
|
||||
@@ -54,6 +55,9 @@ def run():
|
||||
else:
|
||||
status_icon.set_from_icon_name('redshift')
|
||||
|
||||
def autostart_cb(widget, data=None):
|
||||
utils.set_autostart(widget.get_active())
|
||||
|
||||
def destroy_cb(widget, data=None):
|
||||
status_icon.set_visible(False)
|
||||
gtk.main_quit()
|
||||
@@ -66,6 +70,17 @@ def run():
|
||||
toggle_item.connect('activate', toggle_cb)
|
||||
status_menu.append(toggle_item)
|
||||
|
||||
autostart_item = gtk.CheckMenuItem(_('Autostart'))
|
||||
try:
|
||||
autostart_item.set_active(utils.get_autostart())
|
||||
except IOError as strerror:
|
||||
print strerror
|
||||
autostart_item.set_property('sensitive', False)
|
||||
else:
|
||||
autostart_item.connect('activate', autostart_cb)
|
||||
finally:
|
||||
status_menu.append(autostart_item)
|
||||
|
||||
quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
|
||||
quit_item.connect('activate', destroy_cb)
|
||||
status_menu.append(quit_item)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# utils.py -- utility functions 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 Francesco Marella <francesco.marella@gmail.com>
|
||||
|
||||
import os
|
||||
from xdg import BaseDirectory as base
|
||||
from xdg import DesktopEntry as desktop
|
||||
|
||||
REDSHIFT_DESKTOP = 'gtk-redshift.desktop'
|
||||
|
||||
|
||||
def get_autostart():
|
||||
AUTOSTART_KEY = "X-GNOME-Autostart-enabled"
|
||||
autostart_dir = base.save_config_path("autostart")
|
||||
autostart_file = os.path.join(autostart_dir, REDSHIFT_DESKTOP)
|
||||
if not os.path.exists(autostart_file):
|
||||
desktop_files = list(base.load_data_paths("applications",
|
||||
REDSHIFT_DESKTOP))
|
||||
if not desktop_files:
|
||||
raise IOError("Installed redshift desktop file not found!")
|
||||
desktop_file_path = desktop_files[0]
|
||||
# Read installed file and modify it
|
||||
dfile = desktop.DesktopEntry(desktop_file_path)
|
||||
dfile.set(AUTOSTART_KEY, "false")
|
||||
dfile.write(filename=autostart_file)
|
||||
return False
|
||||
else:
|
||||
dfile = desktop.DesktopEntry(autostart_file)
|
||||
if dfile.get(AUTOSTART_KEY) == 'false':
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def set_autostart(active):
|
||||
AUTOSTART_KEY = "X-GNOME-Autostart-enabled"
|
||||
autostart_dir = base.save_config_path("autostart")
|
||||
autostart_file = os.path.join(autostart_dir, REDSHIFT_DESKTOP)
|
||||
if not os.path.exists(autostart_file):
|
||||
desktop_files = list(base.load_data_paths("applications",
|
||||
REDSHIFT_DESKTOP))
|
||||
if not desktop_files:
|
||||
raise IOError("Installed redshift desktop file not found!")
|
||||
return
|
||||
desktop_file_path = desktop_files[0]
|
||||
# Read installed file and modify it
|
||||
dfile = desktop.DesktopEntry(desktop_file_path)
|
||||
else:
|
||||
dfile = desktop.DesktopEntry(autostart_file)
|
||||
activestr = str(bool(active)).lower()
|
||||
# print "Setting autostart to %s" % activestr
|
||||
dfile.set(AUTOSTART_KEY, activestr)
|
||||
dfile.write(filename=autostart_file)
|
||||
Reference in New Issue
Block a user