def _on_mgr_clicked_edit(self, sender, row_path, data=None): row_iter = self._presets_store.get_model().get_iter(row_path) (name, hours, minutes, seconds, command, next_timer, auto_start) = \ self._presets_store.get_preset(row_iter) edit_dialog = ui.AddEditPresetDialog(config.GLADE_PATH, _('Edit Preset'), lambda name: utils.is_valid_preset_name(name, self._presets_store, (name,)), name, hours, minutes, seconds, command, next_timer, auto_start ) result = edit_dialog.get_preset() if result is not None: (name, hours, minutes, seconds, command, next_timer, auto_start) = result self._presets_store.modify_preset(row_iter, name, hours, minutes, seconds, command, next_timer, auto_start)
def on_mgr_clicked_edit(self, sender, row_path, data=None): row_iter = self._presets_store.get_model().get_iter(row_path) (name, hours, minutes, seconds, command, next_timer, auto_start) = \ self.presets_store.get_preset(row_iter) edit_dialog = AddEditPresetDialog( _('Edit Preset'), lambda name: utils.is_valid_preset_name(name, self.presets_store, (name,)), name, hours, minutes, seconds, command, next_timer, auto_start ) result = edit_dialog.get_preset() if result is not None: (name, hours, minutes, seconds, command, next_timer, auto_start) = result self.presets_store.modify_preset(row_iter, name, hours, minutes, seconds, command, next_timer, auto_start)
def on_mgr_clicked_add(self, sender, data=None): add_dialog = AddEditPresetDialog( _('Add Preset'), lambda name: utils.is_valid_preset_name(name, self.presets_store)) result = add_dialog.get_preset() if result is not None: (name, hours, minutes, seconds, command, next_timer, auto_start) = result self.presets_store.add_preset(name, hours, minutes, seconds, command, next_timer, auto_start)
def _on_mgr_clicked_add(self, sender, data=None): add_dialog = ui.AddEditPresetDialog( config.GLADE_PATH, _('Add Preset'), lambda name: utils.is_valid_preset_name(name, self._presets_store)) result = add_dialog.get_preset() if result is not None: (name, hours, minutes, seconds, command, next_timer, auto_start) = result self._presets_store.add_preset(name, hours, minutes, seconds, command, next_timer, auto_start)
def __init__(self, presets_store, manage_presets_dialog, applet, timer, gsettings): self.presets_store = presets_store self.manage_presets_dialog = manage_presets_dialog self.applet = applet self.timer = timer self.gsettings = gsettings self.gst_playbin = gst.element_factory_make('playbin', 'player') def bus_event(bus, message): t = message.type if t == gst.MESSAGE_EOS: self.gst_playbin.set_state(gst.STATE_NULL) elif t == gst.MESSAGE_ERROR: self.gst_playbin.set_state(gst.STATE_NULL) err, debug = message.parse_error() print 'Error playing sound: %s' % err, debug return True self.gst_playbin.get_bus().add_watch(bus_event) self.status_button = StatusButton() self.notifier = Notifier('TimerApplet', Gtk.STOCK_DIALOG_INFO, self.status_button) self.start_next_timer_dialog = StartNextTimerDialog( "Start next timer", "Would you like to start the next timer?") self.start_timer_dialog = StartTimerDialog( lambda name: utils.is_valid_preset_name(name, self._presets_store), self.presets_store.get_model(), lambda row_iter: utils.get_preset_display_text(self._presets_store, row_iter)) self.continue_dialog = ContinueTimerDialog(_('Continue timer countdown?'), _('The timer is currently paused. Would you like to continue countdown?')) self.preferences_dialog = PreferencesDialog() self.about_dialog = AboutDialog() # FIX ME: this needs to fix #self.applet.set_applet_flags(mateapplet.EXPAND_MINOR) # FIX ME: need a Gtk.ActionGroup here! # Learn how to add an ActionGroup action_group = Gtk.ActionGroup("applet_actions") action_group.add_actions( [('PauseTimer', Gtk.STOCK_MEDIA_PAUSE, _("PauseTimer"), None, None, lambda action: self.timer.stop()), ('ContinueTimer', Gtk.STOCK_MEDIA_PLAY, _("ContinueTimer"), None, None, lambda action: self.timer.start()), ('StopTimer', Gtk.STOCK_MEDIA_STOP, _("StopTimer"), None, None, lambda action: self.timer.reset()), ('RestartTimer', Gtk.STOCK_REFRESH, _("RestartTimer"), None, None, lambda action: self._restart_timer()), ('StartNextTimer', Gtk.STOCK_MEDIA_NEXT, _("StartNextTimer"), None, None, lambda action: self._start_next_timer()), ('ManagePresets', Gtk.STOCK_INFO, _("ManagePresets"), None, None, lambda action: self.manage_presets_dialog.show()), ('Preferences', Gtk.STOCK_PREFERENCES, _("Preferences"), None, None, lambda action: self.preferences_dialog.show()), ('About', Gtk.STOCK_ABOUT, _("About"), None, None, lambda action: self.about_dialog.show())] ) self.applet.setup_menu_from_file( config.POPUP_MENU_FILE_PATH, action_group ) self.applet.add(self.status_button) # Remove padding around button contents. force_no_focus_padding(self.status_button) # TODO: # Fix bug in which button would not propogate middle-clicks # and right-clicks to the applet. self.status_button.connect('button-press-event', on_widget_button_press_event) self.status_button.set_relief(Gtk.ReliefStyle.NONE) #self.status_button.set_icon(config.ICON_PATH); self.applet.set_tooltip_text(_("Timer Applet")) self._connect_signals() #self._update_status_button() #self._update_popup_menu() #self._update_preferences_dialog() self.status_button.show() self.applet.show_all()
def __init__(self, presets_store, manage_presets_dialog, applet, timer, mateconf_wrapper): self._presets_store = presets_store self._manage_presets_dialog = manage_presets_dialog self._applet = applet self._timer = timer self._gst_playbin = gst.element_factory_make('playbin', 'player') def bus_event(bus, message): t = message.type if t == gst.MESSAGE_EOS: self._gst_playbin.set_state(gst.STATE_NULL) elif t == gst.MESSAGE_ERROR: self._gst_playbin.set_state(gst.STATE_NULL) err, debug = message.parse_error() print 'Error playing sound: %s' % err, debug return True self._gst_playbin.get_bus().add_watch(bus_event) self._status_button = ui.StatusButton() self._notifier = ui.Notifier('TimerApplet', gtk.STOCK_DIALOG_INFO, self._status_button) self._start_next_timer_dialog = ui.StartNextTimerDialog( config.GLADE_PATH, "Start next timer", "Would you like to start the next timer?") self._start_timer_dialog = ui.StartTimerDialog(config.GLADE_PATH, lambda name: utils.is_valid_preset_name(name, self._presets_store), self._presets_store.get_model(), lambda row_iter: utils.get_preset_display_text(self._presets_store, row_iter)) self._continue_dialog = ui.ContinueTimerDialog(config.GLADE_PATH, _('Continue timer countdown?'), _('The timer is currently paused. Would you like to continue countdown?')) self._preferences_dialog = ui.PreferencesDialog(config.GLADE_PATH) self._mateconf = mateconf_wrapper self._about_dialog = glade.XML(config.GLADE_PATH, 'about_dialog').get_widget('about_dialog') self._about_dialog.set_version(config.VERSION) self._applet.set_applet_flags(mateapplet.EXPAND_MINOR) self._applet.setup_menu_from_file( None, config.POPUP_MENU_FILE_PATH, None, [('PauseTimer', lambda component, verb: self._timer.stop()), ('ContinueTimer', lambda component, verb: self._timer.start()), ('StopTimer', lambda component, verb: self._timer.reset()), ('RestartTimer', lambda component, verb: self._restart_timer()), ('StartNextTimer', lambda component, verb: self._start_next_timer()), ('ManagePresets', lambda component, verb: self._manage_presets_dialog.show()), ('Preferences', lambda component, verb: self._preferences_dialog.show()), ('About', lambda component, verb: self._about_dialog.show())] ) self._applet.add(self._status_button) # Remove padding around button contents. force_no_focus_padding(self._status_button) # TODO: # Fix bug in which button would not propogate middle-clicks # and right-clicks to the applet. self._status_button.connect('button-press-event', on_widget_button_press_event) self._status_button.set_relief(gtk.RELIEF_NONE) self._status_button.set_icon(config.ICON_PATH); self._applet.set_tooltip_text(_("Timer Applet")) self._connect_signals() self._update_status_button() self._update_popup_menu() self._update_preferences_dialog() self._status_button.show() self._applet.show()
def __init__(self, presets_store, manage_presets_dialog, applet, timer, mateconf_wrapper): self._presets_store = presets_store self._manage_presets_dialog = manage_presets_dialog self._applet = applet self._timer = timer self._gst_playbin = gst.element_factory_make('playbin', 'player') def bus_event(bus, message): t = message.type if t == gst.MESSAGE_EOS: self._gst_playbin.set_state(gst.STATE_NULL) elif t == gst.MESSAGE_ERROR: self._gst_playbin.set_state(gst.STATE_NULL) err, debug = message.parse_error() print 'Error playing sound: %s' % err, debug return True self._gst_playbin.get_bus().add_watch(bus_event) self._status_button = ui.StatusButton() self._notifier = ui.Notifier('TimerApplet', gtk.STOCK_DIALOG_INFO, self._status_button) self._start_next_timer_dialog = ui.StartNextTimerDialog( config.GLADE_PATH, "Start next timer", "Would you like to start the next timer?") self._start_timer_dialog = ui.StartTimerDialog( config.GLADE_PATH, lambda name: utils.is_valid_preset_name(name, self._presets_store), self._presets_store.get_model(), lambda row_iter: utils.get_preset_display_text( self._presets_store, row_iter)) self._continue_dialog = ui.ContinueTimerDialog( config.GLADE_PATH, _('Continue timer countdown?'), _('The timer is currently paused. Would you like to continue countdown?' )) self._preferences_dialog = ui.PreferencesDialog(config.GLADE_PATH) self._mateconf = mateconf_wrapper self._about_dialog = glade.XML( config.GLADE_PATH, 'about_dialog').get_widget('about_dialog') self._about_dialog.set_version(config.VERSION) self._applet.set_applet_flags(mateapplet.EXPAND_MINOR) self._applet.setup_menu_from_file( None, config.POPUP_MENU_FILE_PATH, None, [('PauseTimer', lambda component, verb: self._timer.stop()), ('ContinueTimer', lambda component, verb: self._timer.start()), ('StopTimer', lambda component, verb: self._timer.reset()), ('RestartTimer', lambda component, verb: self._restart_timer()), ('StartNextTimer', lambda component, verb: self._start_next_timer()), ('ManagePresets', lambda component, verb: self._manage_presets_dialog.show()), ('Preferences', lambda component, verb: self._preferences_dialog.show()), ('About', lambda component, verb: self._about_dialog.show())]) self._applet.add(self._status_button) # Remove padding around button contents. force_no_focus_padding(self._status_button) # TODO: # Fix bug in which button would not propogate middle-clicks # and right-clicks to the applet. self._status_button.connect('button-press-event', on_widget_button_press_event) self._status_button.set_relief(gtk.RELIEF_NONE) self._status_button.set_icon(config.ICON_PATH) self._applet.set_tooltip_text(_("Timer Applet")) self._connect_signals() self._update_status_button() self._update_popup_menu() self._update_preferences_dialog() self._status_button.show() self._applet.show()