/usr/share/backintime/plugins/gnomeplugin.py is in backintime-gnome 1.0.34-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | # Back In Time
# Copyright (C) 2008-2009 Oprea Dan, Bart de Koning, Richard Bailey
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
import pluginmanager
import tools
import logger
import threading
import time
import gettext
_=gettext.gettext
if len( os.getenv( 'DISPLAY', '' ) ) == 0:
os.putenv( 'DISPLAY', ':0.0' )
class GnomePlugin( pluginmanager.Plugin ):
class Systray( threading.Thread ):
def __init__( self, snapshots ):
import pygtk
pygtk.require("2.0")
import gtk
import gnome
threading.Thread.__init__( self )
self.stop_flag = False
self.snapshots = snapshots
self.config = self.snapshots.config
gnome_props = { gnome.PARAM_APP_DATADIR : '/usr/share' }
gnome.program_init( 'backintime', self.config.VERSION, properties = gnome_props )
def start( self ):
self.stop_flag = False
threading.Thread.start( self )
def stop( self ):
self.stop_flag = True
try:
self.join()
except:
pass
def run( self ):
import gtk
logger.info( '[GnomePlugin.Systray.run]' )
gtk.gdk.threads_init()
display = gtk.gdk.display_get_default()
if display is None:
logger.info( '[GnomePlugin.Systray.run] display KO' )
return
status_icon = None
try:
status_icon = gtk.StatusIcon()
except:
pass
if status_icon is None:
logger.info( '[GnomePlugin.Systray.run] no status_icon' )
return
last_message = None
status_icon.set_from_stock( gtk.STOCK_SAVE )
status_icon.set_visible( True )
logger.info( '[GnomePlugin.Systray.run] begin loop' )
while True:
gtk.main_iteration( False )
if self.stop_flag:
break
if not gtk.events_pending():
message = self.snapshots.get_take_snapshot_message()
if message is None and last_message is None:
message = ( 0, _('Working...') )
if not message is None:
if message != last_message:
last_message = message
status_icon_blinking = False
if last_message[0] != 0:
status_icon_blinking = True
status_icon.set_blinking( status_icon_blinking )
status_icon.set_tooltip( last_message[1] )
time.sleep( 0.2 )
status_icon.set_visible( False )
gtk.main_iteration( False )
logger.info( '[GnomePlugin.Systray.run] end loop' )
def __init__( self ):
return
def init( self, snapshots ):
if not any((tools.process_exists('gnome-settings-daemon'), \
tools.process_exists('mate-settings-daemon'), \
tools.process_exists('xfsettingsd') )):
return False
if not tools.check_x_server():
return False
self.systray = None
try:
self.systray = GnomePlugin.Systray( snapshots )
except:
self.systray = None
return True
def is_gui( self ):
return True
def on_process_begins( self ):
if not self.systray is None:
self.systray.start()
def on_process_ends( self ):
if not self.systray is None:
self.systray.stop()
|