예제 #1
0
    def activate(self, shell):
        self.prefs = GConfPreferences(PARTY_LOCKDOWN_GCONF_PATH,
                                      self.default_prefs)
        pref_glade = self.find_file(PREFS_DIALOG_GLADE)
        self.pref_dialog = PreferenceDialog(self.prefs, pref_glade)

        uim = shell.get_ui_manager()
        unlock_ui = self.find_file(UNLOCK_BAR_UI)
        self.partymode_lock = PartyModeLock(self.prefs, shell, uim, unlock_ui)

        # Connect callback for Party Mode toggle
        self.partymode_toggle = uim.get_widget('/MenuBar/ViewMenu/ViewPartyModeMenu')
        self.pmt_id = self.partymode_toggle.connect('toggled', self.partymode_toggled)

        # Set up action for Party Mode lock
        self.lock_toggle = gtk.ToggleAction('ToggleLockPartyMode',
                                            _('Lock Party Mode'),
                                            _('Password protect party mode'),
                                            'rb-lock-partymode')
        self.lt_id = self.lock_toggle.connect('toggled', self.lock_toggled)
        self.action_group = gtk.ActionGroup('LockPartyModePluginActions')
        self.action_group.add_action_with_accel(self.lock_toggle, 'F12')
        self.ui_id = uim.add_ui_from_string(LOCK_TOGGLE_UI)
        uim.insert_action_group(self.action_group, 0)
        uim.ensure_update()

        if not shell.get_party_mode():
            self.lock_toggle.set_sensitive(False)
예제 #2
0
class PartyLockdown(rb.Plugin):
    default_prefs = {
        'password': '',
        'hide_menu_bar': False,
        'hide_next_prev': False
    }

    def __init__(self):
        rb.Plugin.__init__(self)

    def activate(self, shell):
        self.prefs = GConfPreferences(PARTY_LOCKDOWN_GCONF_PATH,
                                      self.default_prefs)
        pref_glade = self.find_file(PREFS_DIALOG_GLADE)
        self.pref_dialog = PreferenceDialog(self.prefs, pref_glade)

        uim = shell.get_ui_manager()
        unlock_ui = self.find_file(UNLOCK_BAR_UI)
        self.partymode_lock = PartyModeLock(self.prefs, shell, uim, unlock_ui)

        # Connect callback for Party Mode toggle
        self.partymode_toggle = uim.get_widget('/MenuBar/ViewMenu/ViewPartyModeMenu')
        self.pmt_id = self.partymode_toggle.connect('toggled', self.partymode_toggled)

        # Set up action for Party Mode lock
        self.lock_toggle = gtk.ToggleAction('ToggleLockPartyMode',
                                            _('Lock Party Mode'),
                                            _('Password protect party mode'),
                                            'rb-lock-partymode')
        self.lt_id = self.lock_toggle.connect('toggled', self.lock_toggled)
        self.action_group = gtk.ActionGroup('LockPartyModePluginActions')
        self.action_group.add_action_with_accel(self.lock_toggle, 'F12')
        self.ui_id = uim.add_ui_from_string(LOCK_TOGGLE_UI)
        uim.insert_action_group(self.action_group, 0)
        uim.ensure_update()

        if not shell.get_party_mode():
            self.lock_toggle.set_sensitive(False)

    def deactivate(self, shell):
        self.partymode_lock.shutdown()
        del self.prefs
        del self.pref_dialog
        del self.partymode_lock

        # Clean up UI
        uim = shell.get_ui_manager()
        self.partymode_toggle.disconnect(self.pmt_id)
        self.lock_toggle.disconnect(self.lt_id)
        uim.remove_ui(self.ui_id)
        uim.remove_action_group(self.action_group)
        uim.ensure_update()
        del self.partymode_toggle
        del self.lock_toggle
        del self.action_group

    def create_configure_dialog(self, dialog=None):
        if not dialog:
            dialog = self.pref_dialog.get_dialog()
        dialog.present()
        return dialog

    def partymode_toggled(self, widget):
        if widget.get_active():
            self.lock_toggle.set_sensitive(True)
        else:
            self.lock_toggle.set_sensitive(False)

    def lock_toggled(self, widget):
        if widget.get_active():
            self.partymode_lock.lock()
        else:
            self.partymode_lock.unlock(self.unlock_callback)

    def unlock_callback(self, success):
        if not success:
            self.lock_toggle.set_active(True)