1
## -*- coding: utf-8 -*-
3
# «skeletor» - An Example Plugin for showing how to use MCC as a developer
5
# Copyright (C) 2009, Mario Limonciello, for Mythbuntu
8
# Mythbuntu is free software; you can redistribute it and/or modify it under
9
# the terms of the GNU General Public License as published by the Free
10
# Software Foundation; either version 2 of the License, or at your option)
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License along
19
# with this application; if not, write to the Free Software Foundation, Inc., 51
20
# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
##################################################################################
23
from MythbuntuControlCentre.plugin import MCCPlugin
26
class SkeletonPlugin(MCCPlugin):
27
"""An Example Plugin for showing how to use MCC as a developer"""
29
#Load GUI & Calculate Changes
33
#Initialize parent class
35
information["name"] = "Skeletor"
36
information["icon"] = "gtk-stop"
37
information["glade"] = "tab_skeletor"
38
MCCPlugin.__init__(self,information)
40
def captureState(self):
41
"""Determines the state of the items on managed by this plugin
42
and stores it into the plugin's own internal structures"""
45
self.changes['user_file'] = os.path.exists('/tmp/user_file')
46
self.changes['root_file'] = os.path.exists('/tmp/root_file')
47
self.changes['tuxeyes'] = self.query_installed('tuxeyes')
49
def applyStateToGUI(self):
50
"""Takes the current state information and sets the GUI
52
self.user_touch_checkbox.set_active(self.changes['user_file'])
53
self.root_touch_checkbox.set_active(self.changes['root_file'])
54
self.tuxeyes_checkbox.set_active(self.changes['tuxeyes'])
56
def compareState(self):
57
"""Determines what items have been modified on this plugin"""
58
MCCPlugin.clearParentState(self)
59
if self.user_touch_checkbox.get_active() != self.changes['user_file']:
60
self._markReconfigureUser('user_file',self.user_touch_checkbox.get_active())
61
if self.root_touch_checkbox.get_active() != self.changes['root_file']:
62
self._markReconfigureRoot('root_file',self.root_touch_checkbox.get_active())
63
if self.tuxeyes_checkbox.get_active() != self.changes['tuxeyes']:
64
if self.tuxeyes_checkbox.get_active():
65
self._markInstall('tuxeyes')
67
self._markRemove('tuxeyes')
71
def callback_example(self,widget,data=None):
72
"""Shows an example of how a callback can do stuff"""
73
widget_was_visible = self.callback_image.flags() & gtk.VISIBLE
74
if widget_was_visible:
75
self.callback_image.hide()
77
self.callback_image.show()
80
# Process selected activities
83
def root_scripted_changes(self,reconfigure):
84
"""System-wide changes that need root access to be applied.
85
This function is ran by the dbus backend"""
86
for item in reconfigure:
87
if item == "root_file":
89
file = open("/tmp/root_file", "a")
92
os.remove("/tmp/root_file")
94
def user_scripted_changes(self,reconfigure):
95
"""Local changes that can be performed by the user account.
96
This function will be ran by the frontend"""
97
for item in reconfigure:
98
if item == "user_file":
100
file = open("/tmp/user_file", "a")
103
os.remove("/tmp/user_file")