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
|
#
#This file is part of smart-notifier, a graphical disk health notifier
#
#Copyright (C) 2005, 2006 Brian Sutherland <[email protected]>
#
#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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import os
import smart_notifier
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
here = os.path.dirname(__file__)
warning_window = os.path.join(here, 'smart-notifier.xml')
def warn_user(msg):
#Make the window
ui = Gtk.Builder()
ui.add_from_file(warning_window)
#self.ui.signal_connect('end', Gtk.main_quit)
#Customize message
textbuffer = Gtk.TextBuffer()
textbuffer.set_text(msg)
textbox = ui.get_object('textview1')
textbox.set_buffer(textbuffer)
# Fix the icon size XXX -- this is temporary intil gazpacho works
icon = ui.get_object('image1')
icon.set_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
# Showit
window = ui.get_object('window1')
window.show_all()
def service():
smart_notifier.BUS.add_signal_receiver(warn_user,
'warn_user',
smart_notifier.UD_INTERFACE,
smart_notifier.SERVICE_NAME,
smart_notifier.UD_SERVICE)
Gtk.main()
|