Пример #1
0
def getSerialPorts():
	ports = ser.scan()
	if config.serial_ports_d != hashlib.sha224(','.join(sorted(ports))).hexdigest():
		if config.serial_ports != -1:
			try:
				newp =  list(set(ports) - set(config.serial_ports))[0]
				misc.statusMessage(sb, _("New device found on '%s'.") % newp)
			except: pass
		populateSerialPortMenu()
		config.serial_ports = ports
		config.serial_ports_d = hashlib.sha224(','.join(sorted(ports))).hexdigest()
	return True
Пример #2
0
def getSerialPorts():
    ports = ser.scan()
    if config.serial_ports_d != hashlib.sha224(','.join(
            sorted(ports))).hexdigest():
        if config.serial_ports != -1:
            try:
                newp = list(set(ports) - set(config.serial_ports))[0]
                misc.statusMessage(sb, _("New device found on '%s'.") % newp)
            except:
                pass
        populateSerialPortMenu()
        config.serial_ports = ports
        config.serial_ports_d = hashlib.sha224(','.join(
            sorted(ports))).hexdigest()
    return True
Пример #3
0
def replaceAll(widget, data=None):
	page = ui.getCurrentPage()
	view = page.get_data("view")
	b = view.get_buffer()
	mark = b.get_insert()
	iter = b.get_iter_at_mark(mark)
	search = widget.get_text()
	flags = 0
	repls=[]
	if data[0].get_active() == False:
		flags = gtksourceview2.SEARCH_CASE_INSENSITIVE
	if config.cur_iter == -1:
		config.cur_iter = iter
	sb = ui.getGui().get_object("statusbar1")
	s = b.get_start_iter()
	b.begin_user_action()
	b.place_cursor(s)
	rpls=0
	config.cur_iter = b.get_iter_at_line(0)
	while config.cur_iter <= b.get_end_iter():
		try:
			s, e = gtksourceview2.iter_forward_search( \
				config.cur_iter, search, flags, limit=None)
			e.forward_line()
		except:
			iter = b.get_iter_at_offset(0)
			config.cur_iter = iter
			try:
				s, e = gtksourceview2.iter_forward_search( \
					config.cur_iter, search, flags=0, limit=None)
				e.forward_line()
			except:
				misc.statusMessage(sb, _("A total of %s replacements made.") % rpls)
				return
		if s.get_line() not in repls:
			repls.append(s.get_line())
			rpls = rpls + 1
			b.delete(s, e)
			b.insert(s, data[5].get_text()+"\n")
			config.cur_iter = s
	b.end_user_action()
	misc.statusMessage(sb, _("A total of %s replacements made.") % rpls)
Пример #4
0
def replaceText(widget, event, data=None):
	if event == -1 or (event.type == gtk.gdk.KEY_RELEASE and \
	(gtk.gdk.keyval_name(event.keyval) == 'Return' or \
	 gtk.gdk.keyval_name(event.keyval) == 'KP_Enter')):
		a = config.cur_iter
		page = ui.getCurrentPage()
		view = page.get_data("view")
		b = view.get_buffer()
		mark = b.get_insert()
		iter = b.get_iter_at_mark(mark)
		search = data[4].get_text()
		flags = 0
		if data[0].get_active() == False:
			flags = gtksourceview2.SEARCH_CASE_INSENSITIVE
		backwards = False
		if data[2].get_active() == True:
			backwards = True
		warp = False
		if data[3].get_active() == True:
			warp = True
		if config.cur_iter == -1:
			config.cur_iter = iter
		sb = ui.getGui().get_object("statusbar1")
		if warp:
			try:
				if backwards:
					s, e = gtksourceview2.iter_backward_search( \
						config.cur_iter, search, flags, limit=None)
					config.cur_iter = s
				else:
					s, e = gtksourceview2.iter_forward_search( \
						config.cur_iter, search, flags, limit=None)
					config.cur_iter = e
			except:
				if backwards:
					iter = b.get_iter_at_offset(-1)
					config.cur_iter = iter
					try:
						s, e = gtksourceview2.iter_backward_search( \
							config.cur_iter, search, flags, limit=None)
						config.cur_iter = s
					except:
						config.cur_iter = a
						return
				else:
					iter = b.get_iter_at_line(0)
					config.cur_iter = iter
					try:
						s, e = gtksourceview2.iter_forward_search( \
							config.cur_iter, search, flags=0, limit=None)
						config.cur_iter = e
					except:
						config.cur_iter = a
						return
		else:
			if backwards:
				try:
					s, e = gtksourceview2.iter_backward_search( \
						config.cur_iter, search, flags, limit=None)
					config.cur_iter = s
				except:
					s = e = b.get_start_iter()
					b.select_range(s, e)
					misc.statusMessage(sb, _("'%s' not found.") % search)
					config.cur_iter = a
					return
			else:
				try:
					s, e = gtksourceview2.iter_forward_search( \
						config.cur_iter, search, flags, limit=None)
					config.cur_iter = e
				except:
					s = e = b.get_end_iter()
					b.select_range(s, e)
					misc.statusMessage(sb, _("'%s' not found.") % search)
					config.cur_iter = a
					return
		b.place_cursor(s)
		b.select_range(s, e)
		b.delete_selection(False, True)
		b.insert_at_cursor(data[5].get_text())