示例#1
0
	def create_rings_combobox(self):
		sounds = os.listdir(os.path.join(DATA_PATH, 'sound'))	
		sounds_dict = list(enumerate(sounds))
		rings_combobox = Gtk.ComboBoxText()
		for sound in sounds:
			sound = sound.split('.')[0]
			rings_combobox.append_text(sound)

		alarm_ring = WorkListSettings.get_value('alarm-ring')
		alarm_ring_id = [x[0] for x in sounds_dict if x[1] == alarm_ring][0]
		rings_combobox.set_active(alarm_ring_id)

		return rings_combobox
示例#2
0
	def __init__(self):
		Gtk.Window.__init__(self)

		self.set_title('Preference')

		try:
			self.set_icon_from_file(os.path.join(DATA_PATH, 'icons', 'WorkList.png'))
		except Exception:
			print 'No that picture at all.'

		self.set_default_size(300, 400)
		self.set_border_width(10)
		self.set_position(Gtk.WindowPosition.CENTER)

		self.main_box = Gtk.Box(orientation = Gtk.Orientation.VERTICAL)

		self.settings = Gtk.Notebook()

		self.advanced_grid = Gtk.Grid()
		self.advanced_grid.set_margin_top(8)
		self.advanced_grid.set_margin_left(8)
		self.advanced_grid.set_margin_right(8)
		self.advanced_grid.set_margin_bottom(8)

		self.start_label = Gtk.Label()
		self.start_label.set_markup('<b>Start</b>')
		self.auto_start_label = Gtk.Label('Auto Start : ')
		self.auto_start_switch = Gtk.Switch()
		switch = WorkListSettings.get_value('auto-start')
		self.auto_start_switch.set_active(switch)
		self.auto_start_switch.connect('notify::active', self.auto_start_set)
		self.advanced_grid.attach(self.start_label, 0, 0, 1, 1)
		self.advanced_grid.attach(self.auto_start_label, 1, 1, 1, 1)
		self.advanced_grid.attach(self.auto_start_switch, 2, 1, 1, 1)

		self.common_grid = Gtk.Grid()
		self.common_grid.set_margin_top(8)
		self.common_grid.set_margin_left(8)
		self.common_grid.set_margin_right(8)
		self.common_grid.set_margin_bottom(8)
		self.common_grid.set_column_homogeneous(False)

		self.font_and_colors_label = Gtk.Label()
		self.font_and_colors_label.set_markup('<b>Fonts and Colors</b>')
		self.editor_font_label = Gtk.Label('Editor Font : ')
		self.editor_font_button = Gtk.FontButton()
		self.editor_font_button.set_font_name(WorkListSettings.get_value('editor-font'))
		self.editor_font_button.set_show_style(True)
		self.editor_font_button.set_show_size(True)
		self.editor_font_button.set_use_font(True)
		self.editor_font_button.set_use_size(True)
		self.editor_font_button.connect('font-set', self.editor_font_set)
		self.common_grid.attach(self.font_and_colors_label, 0, 0, 1, 1)
		self.common_grid.attach(self.editor_font_label, 0, 1, 1, 1)
		self.common_grid.attach(self.editor_font_button, 1, 1, 1, 1)

		self.popup_font_label = Gtk.Label('Popup Font : ')
		self.popup_font_button = Gtk.FontButton()
		self.popup_font_button.set_font_name(WorkListSettings.get_value('popup-font'))
		self.popup_font_button.set_show_style(True)
		self.popup_font_button.set_show_size(True)
		self.popup_font_button.set_use_font(True)
		self.popup_font_button.set_use_size(True)
		self.popup_font_button.connect('font-set', self.popup_font_set)
		self.common_grid.attach(self.popup_font_label, 0, 2, 1, 1)
		self.common_grid.attach(self.popup_font_button, 1, 2, 1, 1)

		self.sound_label = Gtk.Label()
		self.sound_label.set_markup("<b>Sounds</b>")
		self.alarm_ring_label = Gtk.Label("Alarm Ring: ")
		self.rings_combobox = self.create_rings_combobox()
		self.rings_combobox.connect('changed', self.rings_combobox_changed)
		self.common_grid.attach(Gtk.Label(), 0, 3, 1, 1)
		self.common_grid.attach(self.sound_label, 0, 4, 1, 1)
		self.common_grid.attach(self.alarm_ring_label, 0, 5, 1, 1)
		self.common_grid.attach(self.rings_combobox, 1, 5, 1, 1)


		self.settings.append_page(self.common_grid, Gtk.Label('Common'))
		self.settings.append_page(self.advanced_grid, Gtk.Label('Advanced'))

		self.button_grid = Gtk.Grid()
		self.button_grid.set_margin_top(5)
		self.button_grid.set_column_homogeneous(True)
		self.apply_button = Gtk.Button.new_from_stock(Gtk.STOCK_APPLY)
		self.apply_button.connect('clicked', self.apply_clicked)
		self.close_button = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE)
		self.close_button.connect('clicked', self.close_clicked)
		self.button_grid.attach(Gtk.Label(), 0, 0, 3, 1)
		self.button_grid.attach(self.apply_button, 5, 0, 2, 1)
		self.button_grid.attach(self.close_button, 7, 0, 2, 1)

		self.main_box.pack_start(self.settings, True, True, 0)
		self.main_box.pack_start(self.button_grid, False, True, 0)
		self.add(self.main_box)
		self.connect('delete-event', self.close_clicked)
		self.show_all()
示例#3
0
	def __init__(self, master):
		

		self.parser = master.work_dataparser
		self.worklist = self.parser._works

		builder = Gtk.Builder()
		builder.add_from_file(os.path.join(DATA_PATH, 'ui/WorkList.glade'))

		self.win = builder.get_object('window1')
		self.win.set_default_size(800, 400)
		try:
			self.win.set_icon_from_file(os.path.join(DATA_PATH, 'icons', 'WorkList.png'))
		except Exception:
			print "There's no picture at all."

		agr = Gtk.AccelGroup()
		self.win.add_accel_group(agr)

		#self.toolbar = builder.get_object('toolbar')
		#context = self.toolbar.get_style_context()
		#context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
		self.tool_new = builder.get_object('toolbutton1')
		self.tool_new.connect('clicked', self.tool_new_clicked)
		key_new, mod_new = Gtk.accelerator_parse("<Control>N")
		self.tool_new.add_accelerator('clicked', agr, key_new, mod_new, Gtk.AccelFlags.VISIBLE)
		self.tool_save = builder.get_object('toolbutton2')
		self.tool_save.connect('clicked', self.tool_save_clicked)
		key_save, mod_save = Gtk.accelerator_parse("<Control>S")
		self.tool_save.add_accelerator('clicked', agr, key_save, mod_save, Gtk.AccelFlags.VISIBLE)

		self.tool_preference = builder.get_object('preference')
		self.tool_preference.connect('clicked', self.tool_preference_clicked)
		key_preference, mod_preference = Gtk.accelerator_parse("<Control>P")
		self.tool_preference.add_accelerator('clicked', agr, key_preference, mod_preference, Gtk.AccelFlags.VISIBLE)

		self.tool_about = builder.get_object('about')
		self.tool_about.connect('clicked', self.tool_about_clicked)
		key_about, mod_about = Gtk.accelerator_parse("<Control>A")
		self.tool_about.add_accelerator('clicked', agr, key_about, mod_about, Gtk.AccelFlags.VISIBLE)



		self.unlock_button = builder.get_object('unlock')
		self.unlock_button.connect('toggled', self.unlock_button_toggled)


		paned = builder.get_object('paned')
		paned.set_position(200)

		self.his_scroll = Gtk.ScrolledWindow()
		self.his_align = builder.get_object('alignment1')
		self.his_align.add(self.his_scroll)

		self.treeview = self.create_tree_view()
		self.his_scroll.add(self.treeview)

		self.title_entry = builder.get_object('entry1')
		self.title_entry.set_editable(False)
		self.title_entry.set_alignment(0.5)
		self.delete_button = builder.get_object('delete')
		self.delete_button.connect('clicked', self.delete_button_clicked)

		self.alarm_entry = builder.get_object('alarm')
		self.alarm_entry .set_editable(False)
		self.alarm_entry .set_alignment(0.5)
		self.reset_button = builder.get_object('reset')
		self.reset_button.connect('clicked', self.reset_button_clicked)

		self.text_view = Gtk.TextView()
		self.text_view.set_editable(False)
		font_name = WorkListSettings.get_value('editor-font')
		self.view_font = Pango.FontDescription(font_name)
		self.text_view.modify_font(self.view_font)
		self.con_scroll = Gtk.ScrolledWindow()
		self.con_scroll.set_property('margin-right', 5)
		self.con_scroll.add(self.text_view)
		self.con_box = builder.get_object('box3')
		self.con_box.pack_start(self.con_scroll, True, True, 3)

		self.status_bar = builder.get_object('statusbar')

		try:
			self.show_work(self.worklist[0])
			self.current_work = self.worklist[0]
		except IndexError:
			self.show_nothing()
			self.current_work = None

		self.win.connect('delete-event', self.win_destroy)
		self.win.show_all()
示例#4
0
文件: daemon.py 项目: hualet/worklist
 def play_sound(self):
     alarm_ring = WorkListSettings.get_value("alarm-ring")
     call(["paplay", os.path.join(DATA_PATH, "sound", alarm_ring)])