Exemplo n.º 1
0
def _get_open_fiters():
    result = []
    descr = uc2const.FORMAT_DESCRIPTION
    ext = uc2const.FORMAT_EXTENSION
    items = [] + data.LOADER_FORMATS

    filter = gtk.FileFilter()
    filter.set_name(_('All supported formats'))
    for item in items:
        for extension in ext[item]:
            filter.add_pattern('*.' + extension)
            filter.add_pattern('*.' + extension.upper())
    result.append(filter)

    filter = gtk.FileFilter()
    filter.set_name(_('All files'))
    filter.add_pattern('*')
    result.append(filter)

    for item in items:
        filter = gtk.FileFilter()
        filter.set_name(descr[item])
        for extension in ext[item]:
            filter.add_pattern('*.' + extension)
            filter.add_pattern('*.' + extension.upper())
        result.append(filter)

    return result
Exemplo n.º 2
0
    def save_as(self):
        doc_file = '' + self.current_doc.doc_file
        if not doc_file:
            doc_file = '' + self.current_doc.doc_name
        if not os.path.splitext(doc_file)[1] == "." + \
           uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]:
            doc_file = os.path.splitext(doc_file)[0] + "." + \
              uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]
        if not os.path.lexists(os.path.dirname(doc_file)):
            doc_file = os.path.join(config.save_dir,
                                    os.path.basename(doc_file))
        doc_file = dialogs.get_save_file_name(self.mw, self, doc_file)
        if doc_file:
            old_file = self.current_doc.doc_file
            old_name = self.current_doc.doc_name
            self.current_doc.set_doc_file(doc_file)
            try:
                self.current_doc.save()
            except IOError:
                self.current_doc.set_doc_file(old_file, old_name)
                details = sys.exc_info()[1].__str__() + sys.exc_info(
                )[2].__str__()
                first = _('Cannot save document')
                sec = _('Please check file name and write permissions')
                msg = ("%s '%s'.") % (first, self.current_doc.doc_name)

                dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec,
                                   details)

                return False
            config.save_dir = os.path.dirname(doc_file)
            events.emit(events.APP_STATUS, _('Document saved'))
            return True
        else:
            return False
Exemplo n.º 3
0
def load_icons():
	items = [STOCK_ROTATE_LEFT, STOCK_ROTATE_RIGHT, STOCK_MOVE_TO_ORIGIN,
			STOCK_HOR_MIRROR, STOCK_VERT_MIRROR, STOCK_MULTIPLY]

	path = '' + os.path.join(config.resource_dir, 'icons')
	iconfactory = gtk.IconFactory()

	for item in items:
		gtk.stock_add([(item, '', 0, 0, ''), ])
		pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(path, item + '.png'))
		source = gtk.IconSource()
		source.set_pixbuf(pixbuf)
		source.set_size_wildcarded(True)
		iconset = gtk.IconSet()
		iconset.add_source(source)
		iconfactory.add(item, iconset)

	#Creating aliased icons
	items = [(STOCK_CUTTING, _('_Cutting'), 0, 0, None),
			(STOCK_DONT_SAVE, _("_Don't save"), 0, 0, None), ]

	aliases = [(STOCK_CUTTING, gtk.STOCK_PRINT),
			(STOCK_DONT_SAVE, gtk.STOCK_NO), ]

	gtk.stock_add(items)

	for item, alias in aliases:
		iconset = gtk.icon_factory_lookup_default(alias)
		iconfactory.add(item, iconset)

	iconfactory.add_default()
Exemplo n.º 4
0
	def insert_doc(self, doc_file):
		doc_presenter = None
		loader = get_loader(doc_file)
		if loader is None:
			raise IOError(_('Unknown file format'), doc_file)

		pd = ProgressDialog(_('Importing file...'), self.app.mw)
		ret = pd.run(loader, [self.app.appdata, doc_file])
		if ret == gtk.RESPONSE_OK:
			if pd.result is None:
				pd.destroy()
				raise IOError(*pd.error_info)

			doc_presenter = pd.result
			pd.destroy()
			res = simplify_doc(doc_presenter)
			if not res:
				first = _("File '%s' doesn't contain supported objects.") % (doc_file)
				second = _('It seems all objects are either images or special groups.')
				ret = warning_dialog(self.app.mw, self.app.appdata.app_name,
						first, second,
						[(gtk.STOCK_OK, gtk.RESPONSE_OK)])
				doc_presenter.close()
				return

		else:
			pd.destroy()
			raise IOError(_('Error while opening'), doc_file)

		if not doc_presenter is None:
			self.api.merge_doc(doc_presenter)
			doc_presenter.close()
Exemplo n.º 5
0
	def save_as(self):
		doc_file = '' + self.current_doc.doc_file
		if not doc_file:
			doc_file = '' + self.current_doc.doc_name
		if not os.path.splitext(doc_file)[1] == "." + \
					uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]:
			doc_file = os.path.splitext(doc_file)[0] + "." + \
					uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]
		if not os.path.lexists(os.path.dirname(doc_file)):
			doc_file = os.path.join(config.save_dir,
								os.path.basename(doc_file))
		doc_file = dialogs.get_save_file_name(self.mw, self, doc_file)
		if doc_file:
			old_file = self.current_doc.doc_file
			old_name = self.current_doc.doc_name
			self.current_doc.set_doc_file(doc_file)
			try:
				self.current_doc.save()
			except IOError:
				self.current_doc.set_doc_file(old_file, old_name)
				details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
				first = _('Cannot save document')
				sec = _('Please check file name and write permissions')
				msg = ("%s '%s'.") % (first, self.current_doc.doc_name)

				dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)

				return False
			config.save_dir = os.path.dirname(doc_file)
			events.emit(events.APP_STATUS, _('Document saved'))
			return True
		else:
			return False
Exemplo n.º 6
0
def _get_open_fiters():
	result = []
	descr = uc2const.FORMAT_DESCRIPTION
	ext = uc2const.FORMAT_EXTENSION
	items = [] + data.LOADER_FORMATS

	filter = gtk.FileFilter()
	filter.set_name(_('All supported formats'))
	for item in items:
		for extension in ext[item]:
			filter.add_pattern('*.' + extension)
			filter.add_pattern('*.' + extension.upper())
	result.append(filter)

	filter = gtk.FileFilter()
	filter.set_name(_('All files'))
	filter.add_pattern('*')
	result.append(filter)

	for item in items:
		filter = gtk.FileFilter()
		filter.set_name(descr[item])
		for extension in ext[item]:
			filter.add_pattern('*.' + extension)
			filter.add_pattern('*.' + extension.upper())
		result.append(filter)

	return result
Exemplo n.º 7
0
	def close(self, doc=None):
		if not self.docs:
			return
		if doc is None:
			doc = self.current_doc

		if not self.mw.nb.page_num(doc.docarea) == self.mw.nb.get_current_page():
			self.mw.set_active_tab(doc.docarea)

		if self.inspector.is_doc_not_saved(doc):
			first = _("Document '%s' has been modified.") % (doc.doc_name)
			second = _('Do you want to save your changes?')
			ret = dialogs.warning_dialog(self.mw, self.appdata.app_name,
					first, second,
					[(icons.STOCK_DONT_SAVE, gtk.RESPONSE_NO,),
					(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
					(gtk.STOCK_SAVE, gtk.RESPONSE_OK)])

			if ret == gtk.RESPONSE_OK:
				if not self.save(): return False
			elif ret == gtk.RESPONSE_NO: pass
			else: return False

		if doc in self.docs:
			self.docs.remove(doc)
			doc.close()
			events.emit(events.DOC_CLOSED)
			if not len(self.docs):
				self.current_doc = None
				events.emit(events.NO_DOCS)
				msg = _('To start create new or open existing document')
				events.emit(events.APP_STATUS, msg)
		return True
Exemplo n.º 8
0
    def save(self):
        try:
            if config.make_backup:
                if os.path.lexists(self.doc_file):
                    if os.path.lexists(self.doc_file + '~'):
                        os.remove(self.doc_file + '~')
                    os.rename(self.doc_file, self.doc_file + '~')
            saver = get_saver(self.doc_file)
            if saver is None:
                raise IOError(
                    _('Unknown file format is requested for saving!'),
                    self.doc_file)

            pd = ProgressDialog(_('Saving file...'), self.app.mw)
            ret = pd.run(saver, [self.doc_presenter, self.doc_file])
            if ret == gtk.RESPONSE_OK:
                if not pd.error_info is None:
                    pd.destroy()
                    raise IOError(*pd.error_info)
                pd.destroy()
            else:
                pd.destroy()
                raise IOError(_('Error while saving'), self.doc_file)

        except IOError:
            raise IOError(*sys.exc_info())
        self.reflect_saving()
Exemplo n.º 9
0
    def insert_doc(self, doc_file):
        doc_presenter = None
        loader = get_loader(doc_file)
        if loader is None:
            raise IOError(_('Unknown file format'), doc_file)

        pd = ProgressDialog(_('Importing file...'), self.app.mw)
        ret = pd.run(loader, [self.app.appdata, doc_file])
        if ret == gtk.RESPONSE_OK:
            if pd.result is None:
                pd.destroy()
                raise IOError(*pd.error_info)

            doc_presenter = pd.result
            pd.destroy()
            res = simplify_doc(doc_presenter)
            if not res:
                first = _("File '%s' doesn't contain supported objects.") % (
                    doc_file)
                second = _(
                    'It seems all objects are either images or special groups.'
                )
                ret = warning_dialog(self.app.mw, self.app.appdata.app_name,
                                     first, second,
                                     [(gtk.STOCK_OK, gtk.RESPONSE_OK)])
                doc_presenter.close()
                return

        else:
            pd.destroy()
            raise IOError(_('Error while opening'), doc_file)

        if not doc_presenter is None:
            self.api.merge_doc(doc_presenter)
            doc_presenter.close()
Exemplo n.º 10
0
	def save(self):
		try:
			if config.make_backup:
				if os.path.lexists(self.doc_file):
					if os.path.lexists(self.doc_file + '~'):
						os.remove(self.doc_file + '~')
					os.rename(self.doc_file, self.doc_file + '~')
			saver = get_saver(self.doc_file)
			if saver is None:
				raise IOError(_('Unknown file format is requested for saving!'),
							 self.doc_file)

			pd = ProgressDialog(_('Saving file...'), self.app.mw)
			ret = pd.run(saver, [self.doc_presenter, self.doc_file])
			if ret == gtk.RESPONSE_OK:
				if not pd.error_info is None:
					pd.destroy()
					raise IOError(*pd.error_info)
				pd.destroy()
			else:
				pd.destroy()
				raise IOError(_('Error while saving'), self.doc_file)

		except IOError:
			raise IOError(*sys.exc_info())
		self.reflect_saving()
Exemplo n.º 11
0
	def process_click(self, *args):
		if self.value:
			self.value = False
			self.image.set_from_pixbuf(self.image_false)
			self.set_tooltip_text(_('Don\'t keep aspect ratio'))
		else:
			self.value = True
			self.image.set_from_pixbuf(self.image_true)
			self.set_tooltip_text(_('Keep aspect ratio'))
Exemplo n.º 12
0
	def update(self):
		if not self.objs:
			self.center_offset = [0.0, 0.0]
		self.update_bbox()
		eventloop = self.presenter.eventloop
		eventloop.emit(eventloop.SELECTION_CHANGED)
		if len(self.objs) == 1:
			cid = self.objs[0].cid
			msg = model.CID_TO_NAME[cid] + _(' object in selection')
		else:
			msg = _('objects in selection')
			msg = '%i %s' % (len(self.objs), msg)
		events.emit(events.APP_STATUS, msg)
		events.emit(events.SELECTION_CHANGED, self.presenter)
Exemplo n.º 13
0
 def update(self):
     if not self.objs:
         self.center_offset = [0.0, 0.0]
     self.update_bbox()
     eventloop = self.presenter.eventloop
     eventloop.emit(eventloop.SELECTION_CHANGED)
     if len(self.objs) == 1:
         cid = self.objs[0].cid
         msg = model.CID_TO_NAME[cid] + _(' object in selection')
     else:
         msg = _('objects in selection')
         msg = '%i %s' % (len(self.objs), msg)
     events.emit(events.APP_STATUS, msg)
     events.emit(events.SELECTION_CHANGED, self.presenter)
Exemplo n.º 14
0
	def insert_doc(self):
		doc_file = dialogs.get_open_file_name(self.mw, self, config.import_dir,
											_('Import file...'))
		if os.path.lexists(doc_file) and os.path.isfile(doc_file):
			try:
				self.current_doc.insert_doc(doc_file)
			except:
				details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
				msg = _('Cannot import file')
				msg = "%s '%s'" % (msg, doc_file)
				sec = _('The file may be corrupted or not supported format')
				dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)
				return

			config.import_dir = os.path.dirname(doc_file)
Exemplo n.º 15
0
 def run(self):
     events.emit(events.NO_DOCS)
     events.emit(events.APP_STATUS,
                 _('To start create new or open existing document'))
     self.check_release()
     self.process_args()
     gtk.main()
Exemplo n.º 16
0
def text_edit_dialog(parent, text="", caption=_("Enter text")):
    result = "" + text
    dialog = gtk.Dialog(
        caption, parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
    dialog.set_icon(parent.get_icon())
    dialog.set_default_size(570, 350)

    text_buffer = gtk.TextBuffer()
    text_buffer.set_text(text)
    editor = gtk.TextView(text_buffer)

    sw = gtk.ScrolledWindow()
    sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
    sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    sw.add(editor)

    vbox = gtk.VBox(False, 0)
    vbox.pack_start(sw, True, True, 0)

    dialog.vbox.pack_start(vbox)

    dialog.show_all()
    ret = dialog.run()

    if ret == gtk.RESPONSE_OK:
        result = text_buffer.get_text(text_buffer.get_start_iter(),
                                      text_buffer.get_end_iter())

    dialog.destroy()
    return result
Exemplo n.º 17
0
def get_save_file_name(parent, app, path):
	result = ''
	dialog = gtk.FileChooserDialog(_('Save file As...'),
				parent,
				gtk.FILE_CHOOSER_ACTION_SAVE,
				(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
					gtk.STOCK_SAVE, gtk.RESPONSE_OK))
	dialog.set_do_overwrite_confirmation(True)

	dialog.set_default_response(gtk.RESPONSE_OK)
	path = expanduser_unicode(path)

	doc_folder = os.path.dirname(path)
	dialog.set_current_folder(doc_folder)

	doc_name = os.path.basename(path)
	dialog.set_current_name(doc_name)

	for filter in _get_save_fiters():
		dialog.add_filter(filter)

	ret = dialog.run()
	if not ret == gtk.RESPONSE_CANCEL:
		result = dialog.get_filename()
	dialog.destroy()
	if result is None: result = ''
	return result
Exemplo n.º 18
0
	def run(self):
		events.emit(events.NO_DOCS)
		events.emit(events.APP_STATUS,
				_('To start create new or open existing document'))
		self.check_release()
		self.process_args()
		gtk.main()
Exemplo n.º 19
0
def text_edit_dialog(parent, text="", caption=_("Enter text")):
	result = "" + text
	dialog = gtk.Dialog(caption, parent,
						gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
						(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
						gtk.STOCK_OK, gtk.RESPONSE_OK))
	dialog.set_icon(parent.get_icon())
	dialog.set_default_size(570, 350)

	text_buffer = gtk.TextBuffer()
	text_buffer.set_text(text)
	editor = gtk.TextView(text_buffer);

	sw = gtk.ScrolledWindow()
	sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
	sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	sw.add(editor)

	vbox = gtk.VBox(False, 0)
	vbox.pack_start(sw, True, True, 0)

	dialog.vbox.pack_start(vbox)

	dialog.show_all()
	ret = dialog.run()

	if ret == gtk.RESPONSE_OK:
		result = text_buffer.get_text(text_buffer.get_start_iter(),
									text_buffer.get_end_iter())

	dialog.destroy()
	return result
Exemplo n.º 20
0
def get_prefs_dialog(app, page=0):

	parent = app.mw
	title = _('%s Preferences') % (app.appdata.app_name)

	dialog = gtk.Dialog(title, parent,
	                   gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
	                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
	                    gtk.STOCK_APPLY, gtk.RESPONSE_ACCEPT))


	vbox = gtk.VBox()

	nb = PrefsNotebook(app)
	nb.set_property('scrollable', True)
	nb.set_tab_pos(gtk.POS_TOP)
	nb.show_all()
	nb.set_current_page(page)

	vbox.set_border_width(5)
	vbox.pack_start(nb)

	vbox.show_all()

	dialog.vbox.pack_start(vbox)

	ret = dialog.run()
	if ret == gtk.RESPONSE_ACCEPT:
		nb.run_apply()
		app.proxy.force_redraw()
	dialog.destroy()
Exemplo n.º 21
0
def get_save_file_name(parent, app, path):
    result = ''
    dialog = gtk.FileChooserDialog(_('Save file As...'), parent,
                                   gtk.FILE_CHOOSER_ACTION_SAVE,
                                   (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                    gtk.STOCK_SAVE, gtk.RESPONSE_OK))
    dialog.set_do_overwrite_confirmation(True)

    dialog.set_default_response(gtk.RESPONSE_OK)
    path = expanduser_unicode(path)

    doc_folder = os.path.dirname(path)
    dialog.set_current_folder(doc_folder)

    doc_name = os.path.basename(path)
    dialog.set_current_name(doc_name)

    for filter in _get_save_fiters():
        dialog.add_filter(filter)

    ret = dialog.run()
    if not ret == gtk.RESPONSE_CANCEL:
        result = dialog.get_filename()
    dialog.destroy()
    if result is None: result = ''
    return result
Exemplo n.º 22
0
def get_prefs_dialog(app, page=0):

    parent = app.mw
    title = _('%s Preferences') % (app.appdata.app_name)

    dialog = gtk.Dialog(title, parent,
                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                         gtk.STOCK_APPLY, gtk.RESPONSE_ACCEPT))

    vbox = gtk.VBox()

    nb = PrefsNotebook(app)
    nb.set_property('scrollable', True)
    nb.set_tab_pos(gtk.POS_TOP)
    nb.show_all()
    nb.set_current_page(page)

    vbox.set_border_width(5)
    vbox.pack_start(nb)

    vbox.show_all()

    dialog.vbox.pack_start(vbox)

    ret = dialog.run()
    if ret == gtk.RESPONSE_ACCEPT:
        nb.run_apply()
        app.proxy.force_redraw()
    dialog.destroy()
Exemplo n.º 23
0
    def insert_doc(self):
        doc_file = dialogs.get_open_file_name(self.mw, self, config.import_dir,
                                              _('Import file...'))
        if os.path.lexists(doc_file) and os.path.isfile(doc_file):
            try:
                self.current_doc.insert_doc(doc_file)
            except:
                details = sys.exc_info()[1].__str__() + sys.exc_info(
                )[2].__str__()
                msg = _('Cannot import file')
                msg = "%s '%s'" % (msg, doc_file)
                sec = _('The file may be corrupted or not supported format')
                dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec,
                                   details)
                return

            config.import_dir = os.path.dirname(doc_file)
Exemplo n.º 24
0
def upgrade_dialog(parent, title, text, seconary_text=''):
    dlg_type = gtk.MESSAGE_INFO
    buttons = [(_('Visit project site'), gtk.RESPONSE_OK),
               (_('Remind me later'), gtk.RESPONSE_CANCEL)]
    dialog = gtk.MessageDialog(parent,
                               flags=gtk.DIALOG_MODAL,
                               type=dlg_type,
                               message_format=text)
    if seconary_text:
        dialog.format_secondary_text(seconary_text)

    for button in buttons:
        dialog.add_button(button[0], button[1])

    dialog.set_title(title)
    ret = dialog.run()
    dialog.destroy()
    return ret
Exemplo n.º 25
0
	def open(self, doc_file='', silent=False):
		if not doc_file:
			doc_file = dialogs.get_open_file_name(self.mw, self,
												config.open_dir)
		if os.path.lexists(doc_file) and os.path.isfile(doc_file):
			try:
				doc = PD_Presenter(self, doc_file, silent)
			except:
				details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
				msg = _('Cannot open file')
				msg = "%s '%s'" % (msg, doc_file)
				sec = _('The file may be corrupted or not supported format')
				dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)
				return
			self.docs.append(doc)
			self.set_current_doc(doc)
			config.open_dir = os.path.dirname(doc_file)
			events.emit(events.APP_STATUS, _('Document opened'))
Exemplo n.º 26
0
def upgrade_dialog(parent, title, text, seconary_text=''):
	dlg_type = gtk.MESSAGE_INFO
	buttons = [
			(_('Visit project site'), gtk.RESPONSE_OK),
			(_('Remind me later'), gtk.RESPONSE_CANCEL)
			]
	dialog = gtk.MessageDialog(parent,
					flags=gtk.DIALOG_MODAL,
					type=dlg_type,
					message_format=text)
	if seconary_text:
		dialog.format_secondary_text(seconary_text)

	for button in buttons:
		dialog.add_button(button[0], button[1])

	dialog.set_title(title)
	ret = dialog.run()
	dialog.destroy()
	return ret
Exemplo n.º 27
0
	def check_release(self):
		if config.allow_release_check:
			import time
			from datetime import timedelta, date

			today = date.today()
			lastcheck = date.fromtimestamp(config.check_timestamp)
			if today > lastcheck + timedelta(days=10):
				config.check_timestamp = time.time()

				import threading
				threading.Thread(target=self._threaded_check).start()

				if not config.actual_version == self.appdata.version:
					first = _('New LinCutter version is available!')
					sec = _('Installed application version is %s but version %s can be downloaded.')
					sec = sec % (self.appdata.version, config.actual_version)
					ret = dialogs.upgrade_dialog(self.mw, self.appdata.app_name, first, sec)
					if ret == gtk.RESPONSE_OK:
						self.open_url('http://sk1project.org/')
Exemplo n.º 28
0
 def open(self, doc_file='', silent=False):
     if not doc_file:
         doc_file = dialogs.get_open_file_name(self.mw, self,
                                               config.open_dir)
     if os.path.lexists(doc_file) and os.path.isfile(doc_file):
         try:
             doc = PD_Presenter(self, doc_file, silent)
         except:
             details = sys.exc_info()[1].__str__() + sys.exc_info(
             )[2].__str__()
             msg = _('Cannot open file')
             msg = "%s '%s'" % (msg, doc_file)
             sec = _('The file may be corrupted or not supported format')
             dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec,
                                details)
             return
         self.docs.append(doc)
         self.set_current_doc(doc)
         config.open_dir = os.path.dirname(doc_file)
         events.emit(events.APP_STATUS, _('Document opened'))
Exemplo n.º 29
0
    def do_cutting(self):
        cut_bbox = None
        ret = get_cut_dialog(self.app)
        if ret == gtk.RESPONSE_ACCEPT:
            #Collect all objects

            page = self.doc_presenter.methods.get_pages()[-1]
            objs = []
            for layer in page.childs:
                for obj in layer.childs:
                    objs.append(obj)

            if not objs:
                first = _('Cannot cutting in file')
                sec = _('There are no objects in document.')
                msg = ("%s '%s'.") % (first, config.output_file)
                msg_dialog(self.app.mw, self.app.appdata.app_name, msg, sec)
                return

            try:
                saver = get_saver('file.plt')

                if config.cut_bbox:
                    bbox = []
                    bbox += objs[0].cache_bbox
                    for obj in objs:
                        bbox = libgeom.sum_bbox(bbox, obj.cache_bbox)

                    layer = page.childs[-1]
                    cut_bbox = model.Rectangle(layer.config, layer, bbox)
                    layer.childs.append(cut_bbox)
                    cut_bbox.update()

                pd = ProgressDialog(_('Cutting...'), self.app.mw)
                ret = pd.run(saver, [
                    self.doc_presenter, config.output_file, True, {
                        'tolerance': config.tolerance
                    }
                ])
                if ret == gtk.RESPONSE_OK:
                    if not pd.error_info is None:
                        pd.destroy()
                        raise IOError(*pd.error_info)
                    pd.destroy()
                else:
                    pd.destroy()
                    raise IOError(_('Error while saving'), config.output_file)

            except IOError:
                details = sys.exc_info()[1].__str__() + sys.exc_info(
                )[2].__str__()
                first = _('Cannot cutting!')
                sec = _('Please check file name and write permissions')
                msg = ("%s '%s'.") % (first, config.output_file)

                msg_dialog(self.app.mw, self.app.appdata.app_name, msg, sec,
                           details)
        if not cut_bbox is None:
            self.doc_presenter.methods.delete_object(cut_bbox)
Exemplo n.º 30
0
	def save(self, doc=''):
		if not doc:
			doc = self.current_doc
		if not doc.doc_file:
			return self.save_as()
		ext = os.path.splitext(self.current_doc.doc_file)[1]
		if not ext == "." + uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]:
			return self.save_as()
		if not os.path.lexists(os.path.dirname(self.current_doc.doc_file)):
			return self.save_as()

		try:
			doc.save()
			events.emit(events.DOC_SAVED, doc)
		except:
			details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
			msg = _('Cannot save file')
			msg = "%s '%s'" % (msg, self.current_doc.doc_file)
			sec = _('Please check file write permissions')
			dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)
			return False
		events.emit(events.APP_STATUS, _('Document saved'))
		return True
Exemplo n.º 31
0
	def set_container(self, obj):
		if len(obj) == 1 and obj[0].cid > model.PRIMITIVE_CLASS and not \
		obj[0] in self.selection.objs:
			self.pack_container(obj[0])
			return False

		if not len(obj):
			first = _("There is no selected object.")
		elif obj[0] in self.selection.objs:
			first = _("Object from current selection cannot be container.")
		else:
			first = _("Selected object cannot be container.")

		second = _('Do you want to try again?')

		ret = dialogs.warning_dialog(self.app.mw, self.app.appdata.app_name,
				first, second,
				[(gtk.STOCK_NO, gtk.RESPONSE_CANCEL),
				(gtk.STOCK_YES, gtk.RESPONSE_OK)])

		if ret == gtk.RESPONSE_OK:
			return True
		return False
Exemplo n.º 32
0
    def set_container(self, obj):
        if len(obj) == 1 and obj[0].cid > model.PRIMITIVE_CLASS and not \
        obj[0] in self.selection.objs:
            self.pack_container(obj[0])
            return False

        if not len(obj):
            first = _("There is no selected object.")
        elif obj[0] in self.selection.objs:
            first = _("Object from current selection cannot be container.")
        else:
            first = _("Selected object cannot be container.")

        second = _('Do you want to try again?')

        ret = dialogs.warning_dialog(self.app.mw, self.app.appdata.app_name,
                                     first, second,
                                     [(gtk.STOCK_NO, gtk.RESPONSE_CANCEL),
                                      (gtk.STOCK_YES, gtk.RESPONSE_OK)])

        if ret == gtk.RESPONSE_OK:
            return True
        return False
Exemplo n.º 33
0
	def do_cutting(self):
		cut_bbox = None
		ret = get_cut_dialog(self.app)
		if ret == gtk.RESPONSE_ACCEPT:
			#Collect all objects

			page = self.doc_presenter.methods.get_pages()[-1]
			objs = []
			for layer in page.childs:
				for obj in layer.childs:
					objs.append(obj)

			if not objs:
				first = _('Cannot cutting in file')
				sec = _('There are no objects in document.')
				msg = ("%s '%s'.") % (first, config.output_file)
				msg_dialog(self.app.mw, self.app.appdata.app_name, msg, sec)
				return

			try:
				saver = get_saver('file.plt')

				if config.cut_bbox:
					bbox = []
					bbox += objs[0].cache_bbox
					for obj in objs:
						bbox = libgeom.sum_bbox(bbox, obj.cache_bbox)

					layer = page.childs[-1]
					cut_bbox = model.Rectangle(layer.config, layer, bbox)
					layer.childs.append(cut_bbox)
					cut_bbox.update()

				pd = ProgressDialog(_('Cutting...'), self.app.mw)
				ret = pd.run(saver, [self.doc_presenter,
									config.output_file,
									True,
									{'tolerance':config.tolerance}])
				if ret == gtk.RESPONSE_OK:
					if not pd.error_info is None:
						pd.destroy()
						raise IOError(*pd.error_info)
					pd.destroy()
				else:
					pd.destroy()
					raise IOError(_('Error while saving'), config.output_file)

			except IOError:
				details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
				first = _('Cannot cutting!')
				sec = _('Please check file name and write permissions')
				msg = ("%s '%s'.") % (first, config.output_file)

				msg_dialog(self.app.mw, self.app.appdata.app_name, msg, sec, details)
		if not cut_bbox is None:
			self.doc_presenter.methods.delete_object(cut_bbox)
Exemplo n.º 34
0
    def save(self, doc=''):
        if not doc:
            doc = self.current_doc
        if not doc.doc_file:
            return self.save_as()
        ext = os.path.splitext(self.current_doc.doc_file)[1]
        if not ext == "." + uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]:
            return self.save_as()
        if not os.path.lexists(os.path.dirname(self.current_doc.doc_file)):
            return self.save_as()

        try:
            doc.save()
            events.emit(events.DOC_SAVED, doc)
        except:
            details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
            msg = _('Cannot save file')
            msg = "%s '%s'" % (msg, self.current_doc.doc_file)
            sec = _('Please check file write permissions')
            dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec,
                               details)
            return False
        events.emit(events.APP_STATUS, _('Document saved'))
        return True
Exemplo n.º 35
0
    def check_release(self):
        if config.allow_release_check:
            import time
            from datetime import timedelta, date

            today = date.today()
            lastcheck = date.fromtimestamp(config.check_timestamp)
            if today > lastcheck + timedelta(days=10):
                config.check_timestamp = time.time()

                import threading
                threading.Thread(target=self._threaded_check).start()

                if not config.actual_version == self.appdata.version:
                    first = _('New LinCutter version is available!')
                    sec = _(
                        'Installed application version is %s but version %s can be downloaded.'
                    )
                    sec = sec % (self.appdata.version, config.actual_version)
                    ret = dialogs.upgrade_dialog(self.mw,
                                                 self.appdata.app_name, first,
                                                 sec)
                    if ret == gtk.RESPONSE_OK:
                        self.open_url('http://sk1project.org/')
Exemplo n.º 36
0
    def close(self, doc=None):
        if not self.docs:
            return
        if doc is None:
            doc = self.current_doc

        if not self.mw.nb.page_num(
                doc.docarea) == self.mw.nb.get_current_page():
            self.mw.set_active_tab(doc.docarea)

        if self.inspector.is_doc_not_saved(doc):
            first = _("Document '%s' has been modified.") % (doc.doc_name)
            second = _('Do you want to save your changes?')
            ret = dialogs.warning_dialog(
                self.mw, self.appdata.app_name, first, second,
                [(
                    icons.STOCK_DONT_SAVE,
                    gtk.RESPONSE_NO,
                ), (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
                 (gtk.STOCK_SAVE, gtk.RESPONSE_OK)])

            if ret == gtk.RESPONSE_OK:
                if not self.save(): return False
            elif ret == gtk.RESPONSE_NO: pass
            else: return False

        if doc in self.docs:
            self.docs.remove(doc)
            doc.close()
            events.emit(events.DOC_CLOSED)
            if not len(self.docs):
                self.current_doc = None
                events.emit(events.NO_DOCS)
                msg = _('To start create new or open existing document')
                events.emit(events.APP_STATUS, msg)
        return True
Exemplo n.º 37
0
	def __init__(self):
		path_true = 'object-keep-ratio.png'
		path_false = 'object-dont-keep-ratio.png'

		loader = gtk.gdk.pixbuf_new_from_file
		self.image_true = loader(os.path.join(config.resource_dir, path_true))

		loader = gtk.gdk.pixbuf_new_from_file
		self.image_false = loader(os.path.join(config.resource_dir, path_false))

		gtk.EventBox.__init__(self)
		self.image = gtk.Image()
		self.image.set_from_pixbuf(self.image_true)
		self.add(self.image)
		self.connect('button-press-event', self.process_click)
		self.set_tooltip_text(_('Keep aspect ratio'))
Exemplo n.º 38
0
	def build(self):
		label = gtk.Label(_('Units:'))
		self.pack_start(label, False, False, 3)

		self.combo = gtk.combo_box_new_text()
		self.pack_start(self.combo, False, False, 0)

		for item in unit_names:
			self.combo.append_text(unit_full_names[item])

		self.combo.set_active(unit_names.index(config.default_unit))
		self.combo.connect('changed', self.combo_changed)

		events.connect(events.NO_DOCS, self.set_state)
		events.connect(events.DOC_CHANGED, self.set_state)
		events.connect(events.CONFIG_MODIFIED, self.config_changed)
Exemplo n.º 39
0
def get_open_file_name(parent, app, start_dir, caption=_('Open file...')):
    result = ''
    dialog = gtk.FileChooserDialog(caption, parent,
                                   gtk.FILE_CHOOSER_ACTION_OPEN,
                                   (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                    gtk.STOCK_OPEN, gtk.RESPONSE_OK))

    dialog.set_default_response(gtk.RESPONSE_OK)
    start_dir = expanduser_unicode(start_dir)
    dialog.set_current_folder(start_dir)

    for filter in _get_open_fiters():
        dialog.add_filter(filter)

    ret = dialog.run()
    if not ret == gtk.RESPONSE_CANCEL:
        result = dialog.get_filename()
    dialog.destroy()
    if result is None: result = ''
    return result
Exemplo n.º 40
0
def get_open_file_name(parent, app, start_dir, caption=_('Open file...')):
	result = ''
	dialog = gtk.FileChooserDialog(caption,
				parent,
				gtk.FILE_CHOOSER_ACTION_OPEN,
				(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
					gtk.STOCK_OPEN, gtk.RESPONSE_OK))

	dialog.set_default_response(gtk.RESPONSE_OK)
	start_dir = expanduser_unicode(start_dir)
	dialog.set_current_folder(start_dir)

	for filter in _get_open_fiters():
		dialog.add_filter(filter)

	ret = dialog.run()
	if not ret == gtk.RESPONSE_CANCEL:
		result = dialog.get_filename()
	dialog.destroy()
	if result is None: result = ''
	return result
Exemplo n.º 41
0
def get_cut_dialog(app):

	parent = app.mw
	title = _('Cutting')

	dialog = gtk.Dialog(title, parent,
	                   gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)

	dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
	cut_button = dialog.add_button(icons.STOCK_CUTTING, gtk.RESPONSE_ACCEPT)

	cut_panel = CuttingPanel(app, cut_button)
	cut_panel.set_border_width(5)
	cut_panel.show_all()

	dialog.vbox.pack_start(cut_panel)

	ret = dialog.run()
	if ret == gtk.RESPONSE_ACCEPT:
		cut_panel.do_apply()
	dialog.destroy()
	return ret
Exemplo n.º 42
0
def get_cut_dialog(app):

    parent = app.mw
    title = _('Cutting')

    dialog = gtk.Dialog(title, parent,
                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)

    dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
    cut_button = dialog.add_button(icons.STOCK_CUTTING, gtk.RESPONSE_ACCEPT)

    cut_panel = CuttingPanel(app, cut_button)
    cut_panel.set_border_width(5)
    cut_panel.show_all()

    dialog.vbox.pack_start(cut_panel)

    ret = dialog.run()
    if ret == gtk.RESPONSE_ACCEPT:
        cut_panel.do_apply()
    dialog.destroy()
    return ret
Exemplo n.º 43
0
def multiply_dialog(parent):

    result = []

    caption = _("Multiply selection")
    dialog = gtk.Dialog(
        caption,
        parent,
        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK),
    )
    dialog.set_icon(parent.get_icon())
    dialog.set_default_size(200, 300)
    dialog.set_resizable(False)

    vbox = gtk.VBox(False, 5)
    vbox.set_border_width(5)
    dialog.vbox.pack_start(vbox, 15)

    # =========QUANTITY======================

    frame1 = gtk.Frame(" Quantity ")
    frame1.set_border_width(5)

    tab1 = gtk.Table(2, 3, False)
    tab1.set_row_spacings(10)
    tab1.set_col_spacings(10)
    tab1.set_border_width(5)

    # --------------------------

    label = gtk.Label(_("Horizontal:"))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    hu_adj = gtk.Adjustment(1.0, 1.0, 1000.0, 1.0, 1.0, 0.0)
    spinner = gtk.SpinButton(hu_adj, 0, 0)
    spinner.set_numeric(True)
    tab1.attach(spinner, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = gtk.Label(_("units"))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 2, 3, 0, 1, gtk.FILL, gtk.SHRINK)

    # --------------------------

    label = gtk.Label(_("Vertical:"))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    vu_adj = gtk.Adjustment(1.0, 1.0, 1000.0, 1.0, 1.0, 0.0)
    spinner = gtk.SpinButton(vu_adj, 0, 0)
    spinner.set_numeric(True)
    tab1.attach(spinner, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = gtk.Label(_("units"))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK)

    frame1.add(tab1)
    vbox.pack_start(frame1, 5)

    # ===========SPACING====================

    def callback():
        pass

    frame2 = gtk.Frame(" Spacing ")
    frame2.set_border_width(5)

    tab2 = gtk.Table(2, 3, False)
    tab2.set_row_spacings(10)
    tab2.set_col_spacings(10)
    tab2.set_border_width(5)

    # --------------------------

    label = gtk.Label(_("Horizontal:"))
    label.set_alignment(0, 0.5)
    tab2.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    h_spinner = UnitSpin(callback)
    tab2.attach(h_spinner, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = UnitLabel()
    label.set_alignment(0, 0.5)
    tab2.attach(label, 2, 3, 0, 1, gtk.FILL, gtk.SHRINK)

    # --------------------------

    label = gtk.Label(_("Vertical:"))
    label.set_alignment(0, 0.5)
    tab2.attach(label, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    v_spinner = UnitSpin(callback)
    tab2.attach(v_spinner, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = UnitLabel()
    label.set_alignment(0, 0.5)
    tab2.attach(label, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK)

    frame2.add(tab2)
    vbox.pack_start(frame2, 5)

    # ===============================

    dialog.show_all()
    ret = dialog.run()

    if ret == gtk.RESPONSE_OK:
        result = [
            int(hu_adj.get_value()),
            int(vu_adj.get_value()),
            h_spinner.get_point_value(),
            v_spinner.get_point_value(),
        ]

    dialog.destroy()
    return result
Exemplo n.º 44
0
def multiply_dialog(parent):

    result = []

    caption = _("Multiply selection")
    dialog = gtk.Dialog(
        caption, parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
    dialog.set_icon(parent.get_icon())
    dialog.set_default_size(200, 300)
    dialog.set_resizable(False)

    vbox = gtk.VBox(False, 5)
    vbox.set_border_width(5)
    dialog.vbox.pack_start(vbox, 15)

    #=========QUANTITY======================

    frame1 = gtk.Frame(' Quantity ')
    frame1.set_border_width(5)

    tab1 = gtk.Table(2, 3, False)
    tab1.set_row_spacings(10)
    tab1.set_col_spacings(10)
    tab1.set_border_width(5)

    #--------------------------

    label = gtk.Label(_('Horizontal:'))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    hu_adj = gtk.Adjustment(1.0, 1.0, 1000.0, 1.0, 1.0, 0.0)
    spinner = gtk.SpinButton(hu_adj, 0, 0)
    spinner.set_numeric(True)
    tab1.attach(spinner, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = gtk.Label(_('units'))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 2, 3, 0, 1, gtk.FILL, gtk.SHRINK)

    #--------------------------

    label = gtk.Label(_('Vertical:'))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    vu_adj = gtk.Adjustment(1.0, 1.0, 1000.0, 1.0, 1.0, 0.0)
    spinner = gtk.SpinButton(vu_adj, 0, 0)
    spinner.set_numeric(True)
    tab1.attach(spinner, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = gtk.Label(_('units'))
    label.set_alignment(0, 0.5)
    tab1.attach(label, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK)

    frame1.add(tab1)
    vbox.pack_start(frame1, 5)

    #===========SPACING====================

    def callback():
        pass

    frame2 = gtk.Frame(' Spacing ')
    frame2.set_border_width(5)

    tab2 = gtk.Table(2, 3, False)
    tab2.set_row_spacings(10)
    tab2.set_col_spacings(10)
    tab2.set_border_width(5)

    #--------------------------

    label = gtk.Label(_('Horizontal:'))
    label.set_alignment(0, 0.5)
    tab2.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    h_spinner = UnitSpin(callback)
    tab2.attach(h_spinner, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = UnitLabel()
    label.set_alignment(0, 0.5)
    tab2.attach(label, 2, 3, 0, 1, gtk.FILL, gtk.SHRINK)

    #--------------------------

    label = gtk.Label(_('Vertical:'))
    label.set_alignment(0, 0.5)
    tab2.attach(label, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    v_spinner = UnitSpin(callback)
    tab2.attach(v_spinner, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

    label = UnitLabel()
    label.set_alignment(0, 0.5)
    tab2.attach(label, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK)

    frame2.add(tab2)
    vbox.pack_start(frame2, 5)

    #===============================

    dialog.show_all()
    ret = dialog.run()

    if ret == gtk.RESPONSE_OK:
        result = [
            int(hu_adj.get_value()),
            int(vu_adj.get_value()),
            h_spinner.get_point_value(),
            v_spinner.get_point_value()
        ]

    dialog.destroy()
    return result
Exemplo n.º 45
0
    def __init__(self, app):

        gtk.VBox.__init__(self)
        self.app = app
        self.caption_label = gtk.Label(self.caption)

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(15)
        self.set_size_request(385, 200)

        tab = gtk.Table(6, 2, False)
        tab.set_row_spacings(10)
        tab.set_col_spacings(10)
        spacer.add(tab)

        #---------------------------

        label = gtk.Label(_('Desktop color:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        self.cb1 = gtk.ColorButton()
        self.cb1.set_size_request(100, -1)
        self.cb1.set_title(_('Select desktop color'))
        self.cb1.set_color(gtk.gdk.Color(rgb_to_hexcolor(
            config.desktop_color)))
        tab.attach(self.cb1, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK)

        #---------------------------

        label = gtk.Label(_('Axes color:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        self.cb2 = gtk.ColorButton()
        self.cb2.set_size_request(100, -1)
        self.cb2.set_title(_('Select axes color'))
        self.cb2.set_color(gtk.gdk.Color(rgb_to_hexcolor(config.axes_color)))
        tab.attach(self.cb2, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK)

        #---------------------------

        label = gtk.Label(_('Page background color:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        self.cb3 = gtk.ColorButton()
        self.cb3.set_size_request(100, -1)
        self.cb3.set_title(_('Select page background color'))
        self.cb3.set_color(gtk.gdk.Color(rgb_to_hexcolor(config.page_color)))
        tab.attach(self.cb3, 1, 2, 2, 3, gtk.SHRINK, gtk.SHRINK)

        #---------------------------

        label = gtk.Label(_('Page border color:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 3, 4, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        self.cb4 = gtk.ColorButton()
        self.cb4.set_size_request(100, -1)
        self.cb4.set_title(_('Select page border color'))
        self.cb4.set_color(
            gtk.gdk.Color(rgb_to_hexcolor(config.page_border_color)))
        tab.attach(self.cb4, 1, 2, 3, 4, gtk.SHRINK, gtk.SHRINK)

        #---------------------------

        label = gtk.Label(_('Paths color:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 4, 5, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        self.cb5 = gtk.ColorButton()
        self.cb5.set_size_request(100, -1)
        self.cb5.set_title(_('Select paths color'))
        self.cb5.set_color(gtk.gdk.Color(rgb_to_hexcolor(config.paths_color)))
        tab.attach(self.cb5, 1, 2, 4, 5, gtk.SHRINK, gtk.SHRINK)

        self.show_all()
Exemplo n.º 46
0
    def __init__(self, app):

        gtk.VBox.__init__(self)
        self.app = app
        self.caption_label = gtk.Label(self.caption)

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(15)
        self.set_size_request(385, 220)

        tab = gtk.Table(3, 2, False)
        tab.set_row_spacings(10)
        tab.set_col_spacings(10)
        spacer.add(tab)

        #---------------------------

        label = gtk.Label(_('Plotter model:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        self.combo = gtk.combo_box_new_text()
        self.combo.connect('changed', self.combo_changed)

        items = plt_data.keys()
        items.sort()
        for item in items:
            self.combo.append_text(item)

        tab.attach(self.combo, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK)

        #---------------------------

        self.radiobut1 = gtk.RadioButton(None, _("Predefined model"))
        tab.attach(self.radiobut1, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK)
        self.radiobut1.connect("toggled", self.radio_changed)

        self.radiobut2 = gtk.RadioButton(self.radiobut1, _("Custom model"))
        tab.attach(self.radiobut2, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK)
        self.radiobut2.connect("toggled", self.radio_changed)

        #---------------------------

        self.data_frame = gtk.Frame(_('Plotter data'))
        tab.attach(self.data_frame, 0, 2, 2, 3, gtk.FILL | gtk.EXPAND,
                   gtk.SHRINK)

        data_tab = gtk.Table(3, 3, False)
        data_tab.set_border_width(15)
        data_tab.set_row_spacings(10)
        data_tab.set_col_spacings(10)
        self.data_frame.add(data_tab)

        #===========================

        label = gtk.Label(_('Plotter model:'))
        label.set_alignment(1, 0.5)
        data_tab.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK)

        self.plt_name = gtk.Entry()
        self.plt_name.set_text(config.plotter_name)
        data_tab.attach(self.plt_name, 1, 3, 0, 1, gtk.FILL | gtk.EXPAND,
                        gtk.SHRINK)

        #===========================

        label = gtk.Label(_('Cutting width:'))
        label.set_alignment(1, 0.5)
        data_tab.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK)

        self.height_spin = UnitSpin(self.user_changes)
        self.height_spin.set_point_value(config.plotter_page_height)
        data_tab.attach(self.height_spin, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK)

        unit_label = UnitLabel()
        unit_label.set_alignment(0, 0.5)
        data_tab.attach(unit_label, 2, 3, 1, 2, gtk.FILL | gtk.EXPAND,
                        gtk.SHRINK)

        #===========================
        label = gtk.Label(_('Cutting length:'))
        label.set_alignment(1, 0.5)

        data_tab.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK)

        self.width_spin = UnitSpin(self.user_changes)
        self.width_spin.set_point_value(config.plotter_page_width)
        data_tab.attach(self.width_spin, 1, 2, 2, 3, gtk.SHRINK, gtk.SHRINK)

        unit_label = UnitLabel()
        unit_label.set_alignment(0, 0.5)
        data_tab.attach(unit_label, 2, 3, 2, 3, gtk.FILL | gtk.EXPAND,
                        gtk.SHRINK)

        #===========================

        if config.plotter_name in items and \
        round(plt_data[config.plotter_name][0], 6) == round(config.plotter_page_height, 6) and \
        round(plt_data[config.plotter_name][1], 6) == round(config.plotter_page_width, 6):
            self.combo.set_active(items.index(config.plotter_name))
            self.radiobut1.set_active(True)
            self.data_frame.set_sensitive(False)
        else:
            self.radiobut2.set_active(True)
Exemplo n.º 47
0
def create_actions(app):
    insp = app.inspector
    proxy = app.proxy
    accelgroup = app.accelgroup
    actiongroup = app.actiongroup
    actions = {}
    entries = [

        #	name, label, tooltip, icon, shortcut, callable, [channels], validator, args
        #gtk.accelerator_name(ord('+'),gtk.gdk.CONTROL_MASK)

        #SELECT_MODE = 0
        #SHAPER_MODE = 1
        #ZOOM_MODE = 2
        #FLEUR_MODE = 3
        #LINE_MODE = 10
        #CURVE_MODE = 11
        #RECT_MODE = 12
        #ELLIPSE_MODE = 13
        #TEXT_MODE = 14
        #POLYGON_MODE = 15
        #ZOOM_OUT_MODE = 16
        #MOVE_MODE = 17
        #COPY_MODE = 18
        [
            'SELECT_MODE',
            _('Selection mode'),
            _('Selection mode'), None, None, proxy.set_select_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'SHAPER_MODE',
            _('Edit mode'),
            _('Edit mode'), None, None, proxy.set_shaper_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'ZOOM_MODE',
            _('Zoom mode'),
            _('Zoom mode'), None, None, proxy.set_zoom_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'FLEUR_MODE',
            _('Fleur mode'),
            _('Fleur mode'), None, None, proxy.set_fleur_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'LINE_MODE',
            _('Create polyline'),
            _('Create polyline'), None, None, proxy.set_line_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'CURVE_MODE',
            _('Create paths'),
            _('Create paths'), None, None, proxy.set_curve_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'RECT_MODE',
            _('Create rectangle'),
            _('Create rectangle'), None, None, proxy.set_rect_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'ELLIPSE_MODE',
            _('Create ellipse'),
            _('Create ellipse'), None, None, proxy.set_ellipse_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'TEXT_MODE',
            _('Create text'),
            _('Create text'), None, None, proxy.set_text_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'POLYGON_MODE',
            _('Create polygon'),
            _('Create polygon'), None, None, proxy.set_polygon_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'ZOOM_OUT_MODE',
            _('Zoom out mode'),
            _('Zoom out mode'), None, None, proxy.set_zoom_out_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'MOVE_MODE',
            _('Move mode'),
            _('Move mode'), None, None, proxy.set_move_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'COPY_MODE',
            _('Copy mode'),
            _('Copy mode'), None, None, proxy.set_copy_mode,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'NEW',
            _('_New'),
            _('New'), gtk.STOCK_NEW, '<Control>N', proxy.new, None, None
        ],
        [
            'OPEN',
            _('_Open'),
            _('Open'), gtk.STOCK_OPEN, '<Control>O', proxy.open, None, None
        ],
        [
            'SAVE',
            _('_Save'),
            _('Save'), gtk.STOCK_SAVE, '<Control>S', proxy.save,
            [NO_DOCS, DOC_CHANGED, DOC_MODIFIED, DOC_SAVED],
            insp.is_doc_not_saved
        ],
        [
            'SAVE_AS',
            _('Save _As...'),
            _('Save As...'), gtk.STOCK_SAVE_AS, None, proxy.save_as,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'SAVE_ALL',
            _('Save All'),
            _('Save All'), None, None, proxy.save_all,
            [NO_DOCS, DOC_CHANGED, DOC_MODIFIED, DOC_SAVED],
            insp.is_any_doc_not_saved
        ],
        [
            'CLOSE',
            _('_Close'),
            _('Close'), gtk.STOCK_CLOSE, '<Control>W', proxy.close,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'CLOSE_ALL',
            _('Close All'),
            _('Close All'), None, None, proxy.close_all,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'IMPORT',
            _('_Import...'),
            _('Import...'), gtk.STOCK_REVERT_TO_SAVED, None, proxy.insert_doc,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'CUTTING',
            _('C_utting...'),
            _('Cutting'), icons.STOCK_CUTTING, '<Control>P', proxy.do_cutting,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'PLOTTER_SETUP',
            _('Plotter Setup...'),
            _('Plotter Setup'), gtk.STOCK_PRINT_PREVIEW, None,
            proxy.do_plotter_setup, None, None
        ],
        [
            'UNDO',
            _('_Undo'),
            _('Undo'), gtk.STOCK_UNDO, '<Control>Z', proxy.undo,
            [
                events.NO_DOCS, events.DOC_CHANGED, events.DOC_MODIFIED,
                events.DOC_CLOSED
            ], insp.is_undo
        ],
        [
            'REDO',
            _('_Redo'),
            _('Redo'), gtk.STOCK_REDO, '<Control><Shift>Z', proxy.redo,
            [
                events.NO_DOCS, events.DOC_CHANGED, events.DOC_MODIFIED,
                events.DOC_CLOSED
            ], insp.is_redo
        ],
        [
            'CLEAR_HISTORY',
            _('Clear undo history'),
            _('Clear undo history'), None, None, proxy.clear_history,
            [
                events.NO_DOCS, events.DOC_CHANGED, events.DOC_MODIFIED,
                events.DOC_CLOSED
            ], insp.is_history
        ],
        [
            'CUT',
            _('Cu_t'),
            _('Cut'), gtk.STOCK_CUT, '<Control>X', proxy.cut,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_selection
        ],
        [
            'COPY',
            _('_Copy'),
            _('Copy'), gtk.STOCK_COPY, '<Control>C', proxy.copy,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_selection
        ],
        [
            'PASTE',
            _('_Paste'),
            _('Paste'), gtk.STOCK_PASTE, '<Control>V', proxy.paste,
            [events.NO_DOCS, events.CLIPBOARD], insp.is_clipboard
        ],
        [
            'DELETE',
            _('_Delete'),
            _('Delete'), gtk.STOCK_DELETE, 'Delete', proxy.delete,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_selection
        ],
        [
            'SELECT_ALL',
            _('_Select All'),
            _('Select All'), gtk.STOCK_SELECT_ALL, '<Control>A',
            proxy.select_all, [events.NO_DOCS, events.DOC_CHANGED], insp.is_doc
        ],
        [
            'DESELECT',
            _('_Deselect'),
            _('Deselect'), None, '<Control><Shift>A', proxy.deselect,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_selection
        ],
        [
            'STROKE_VIEW',
            _('Stroke View'),
            _('Stroke View'), None, None, proxy.stroke_view,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'DRAFT_VIEW',
            _('Draft View'),
            _('Draft View'), None, None, proxy.draft_view,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'ZOOM_IN',
            _('Zoom in'),
            _('Zoom in'), gtk.STOCK_ZOOM_IN, '<Control>equal', proxy.zoom_in,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'ZOOM_OUT',
            _('Zoom out'),
            _('Zoom out'), gtk.STOCK_ZOOM_OUT, '<Control>minus',
            proxy.zoom_out, [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'ZOOM_PAGE',
            _('Fit zoom to start'),
            _('Fit zoom to start'), gtk.STOCK_ORIENTATION_LANDSCAPE,
            '<Shift>F4', proxy.fit_zoom_to_page, [NO_DOCS,
                                                  DOC_CHANGED], insp.is_doc
        ],
        [
            'ZOOM_100',
            _('Zoom 100%'),
            _('Zoom 100%'), gtk.STOCK_ZOOM_100, None, proxy.zoom_100,
            [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'ZOOM_SELECTED',
            _('Zoom selected'),
            _('Zoom selected'), gtk.STOCK_ZOOM_FIT, 'F4', proxy.zoom_selected,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_selection
        ],
        [
            'FORCE_REDRAW',
            _('Redraw document'),
            _('Redraw document'), gtk.STOCK_REFRESH, '<Alt>R',
            proxy.force_redraw, [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'COMBINE',
            _('_Combine'),
            _('Combine'), None, '<Control>L', proxy.combine_selected,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.can_be_combined
        ],
        [
            'BREAK_APART',
            _('_Break apart'),
            _('Break apart'), None, '<Control>K', proxy.break_apart_selected,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.can_be_breaked
        ],
        [
            'GROUP',
            _('_Group'),
            _('Group'), None, '<Control>G', proxy.group,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.can_be_grouped
        ],
        [
            'UNGROUP',
            _('_Ungroup'),
            _('Ungroup'), None, '<Control>U', proxy.ungroup,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.can_be_ungrouped
        ],
        [
            'UNGROUP_ALL',
            _('U_ngroup all'),
            _('Ungroup all'), None, None, proxy.ungroup_all,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.can_be_ungrouped_all
        ],
        [
            'CONVERT_TO_CURVES',
            _('_Convert to curves'),
            _('Convert to curves'), None, '<Control>Q', proxy.convert_to_curve,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.can_be_curve
        ],
        [
            'EDIT_TEXT',
            _('_Edit text...'),
            _('Edit text'), None, 'F8', proxy.edit_text,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_text_selected
        ],
        [
            'SET_CONTAINER',
            _('_Place into container'),
            _('Place into container'), None, None, proxy.set_container,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_selection
        ],
        [
            'UNPACK_CONTAINER',
            _('_Extract from container'),
            _('Extract from container'), None, None, proxy.unpack_container,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_container_selected
        ],
        [
            'PROPERTIES',
            _('Document Properties...'),
            _('Document Properties...'), gtk.STOCK_PROPERTIES, None,
            proxy.properties, [NO_DOCS, DOC_CHANGED], insp.is_doc
        ],
        [
            'PREFERENCES',
            _('Preferences...'),
            _('Preferences...'), gtk.STOCK_PREFERENCES, None,
            proxy.preferences, None, None
        ],
        [
            'QUIT',
            _('_Exit'),
            _('Exit'), gtk.STOCK_QUIT, '<Alt>F4', proxy.exit, None, None
        ],
        [
            'REPORT_BUG',
            _('_Report bug'),
            _('Report bug'), gtk.STOCK_DIALOG_WARNING, None, proxy.report_bug,
            None, None
        ],
        [
            'PROJECT_WEBSITE',
            _('Project _web site'),
            _('Project web site'), None, None, proxy.project_website, None,
            None
        ],
        [
            'PROJECT_FORUM',
            _('Project _forum'),
            _('Project forum'), None, None, proxy.project_forum, None, None
        ],
        [
            'ABOUT',
            _('_About LinCutter'),
            _('About LinCutter'), gtk.STOCK_ABOUT, None, proxy.about, None,
            None
        ],
        [
            'ROTATE_LEFT',
            _('Rotate _Left'),
            _('Rotate Left'), icons.STOCK_ROTATE_LEFT, None, proxy.rotate_left,
            [events.NO_DOCS, events.DOC_CHANGED, events.SELECTION_CHANGED],
            insp.is_selection
        ],
        [
            'ROTATE_RIGHT',
            _('Rotate _Right'),
            _('Rotate Right'), icons.STOCK_ROTATE_RIGHT, None,
            proxy.rotate_right,
            [events.NO_DOCS, events.DOC_CHANGED,
             events.SELECTION_CHANGED], insp.is_selection
        ],
        [
            'VERT_MIRROR',
            _('Flip _vertically'),
            _('Flip vertically'), icons.STOCK_VERT_MIRROR, None,
            proxy.vertical_mirror,
            [events.NO_DOCS, events.DOC_CHANGED,
             events.SELECTION_CHANGED], insp.is_selection
        ],
        [
            'HOR_MIRROR',
            _('Flip _horizontally'),
            _('Flip horizontally'), icons.STOCK_HOR_MIRROR, None,
            proxy.horizontal_mirror,
            [events.NO_DOCS, events.DOC_CHANGED,
             events.SELECTION_CHANGED], insp.is_selection
        ],
        [
            'MOVE_TO_ORIGIN',
            _('_Move to origin'),
            _('Move to origin'), icons.STOCK_MOVE_TO_ORIGIN, '<Control>B',
            proxy.move_to_origin,
            [events.NO_DOCS, events.DOC_CHANGED,
             events.SELECTION_CHANGED], insp.is_selection
        ],
        [
            'MULTIPLY',
            _('Multipl_y selection'),
            _('Multiply selection'), icons.STOCK_MULTIPLY, None,
            proxy.multiply_selected,
            [events.NO_DOCS, events.DOC_CHANGED,
             events.SELECTION_CHANGED], insp.is_selection
        ],
    ]

    for entry in entries:
        action = AppAction(entry[0], entry[1], entry[2], entry[3], entry[4],
                           entry[5], entry[6], entry[7])

        actions[entry[0]] = action
        if not action.shortcut is None:
            actiongroup.add_action_with_accel(action, action.shortcut)
            action.set_accel_group(accelgroup)
        else:
            actiongroup.add_action(action)

    return actions
Exemplo n.º 48
0
def create_actions(app):
	insp = app.inspector
	proxy = app.proxy
	accelgroup = app.accelgroup
	actiongroup = app.actiongroup
	actions = {}
	entries = [

#	name, label, tooltip, icon, shortcut, callable, [channels], validator, args 
#gtk.accelerator_name(ord('+'),gtk.gdk.CONTROL_MASK)

#SELECT_MODE = 0
#SHAPER_MODE = 1
#ZOOM_MODE = 2
#FLEUR_MODE = 3
#LINE_MODE = 10
#CURVE_MODE = 11
#RECT_MODE = 12
#ELLIPSE_MODE = 13
#TEXT_MODE = 14
#POLYGON_MODE = 15
#ZOOM_OUT_MODE = 16
#MOVE_MODE = 17
#COPY_MODE = 18

	['SELECT_MODE', _('Selection mode'), _('Selection mode'), None, None,
	 proxy.set_select_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['SHAPER_MODE', _('Edit mode'), _('Edit mode'), None, None,
	 proxy.set_shaper_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['ZOOM_MODE', _('Zoom mode'), _('Zoom mode'), None, None,
	 proxy.set_zoom_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['FLEUR_MODE', _('Fleur mode'), _('Fleur mode'), None, None,
	 proxy.set_fleur_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['LINE_MODE', _('Create polyline'), _('Create polyline'), None, None,
	 proxy.set_line_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['CURVE_MODE', _('Create paths'), _('Create paths'), None, None,
	 proxy.set_curve_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['RECT_MODE', _('Create rectangle'), _('Create rectangle'), None, None,
	 proxy.set_rect_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['ELLIPSE_MODE', _('Create ellipse'), _('Create ellipse'), None, None,
	 proxy.set_ellipse_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['TEXT_MODE', _('Create text'), _('Create text'), None, None,
	 proxy.set_text_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['POLYGON_MODE', _('Create polygon'), _('Create polygon'), None, None,
	 proxy.set_polygon_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['ZOOM_OUT_MODE', _('Zoom out mode'), _('Zoom out mode'), None, None,
	 proxy.set_zoom_out_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['MOVE_MODE', _('Move mode'), _('Move mode'), None, None,
	 proxy.set_move_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['COPY_MODE', _('Copy mode'), _('Copy mode'), None, None,
	 proxy.set_copy_mode, [NO_DOCS, DOC_CHANGED], insp.is_doc],

	['NEW', _('_New'), _('New'), gtk.STOCK_NEW, '<Control>N',
	 proxy.new, None, None],
	['OPEN', _('_Open'), _('Open'), gtk.STOCK_OPEN, '<Control>O',
	 proxy.open, None, None],
	['SAVE', _('_Save'), _('Save'), gtk.STOCK_SAVE, '<Control>S',
	 proxy.save, [NO_DOCS, DOC_CHANGED, DOC_MODIFIED, DOC_SAVED],
	 insp.is_doc_not_saved],
	['SAVE_AS', _('Save _As...'), _('Save As...'), gtk.STOCK_SAVE_AS, None,
	 proxy.save_as, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['SAVE_ALL', _('Save All'), _('Save All'), None, None,
	 proxy.save_all, [NO_DOCS, DOC_CHANGED, DOC_MODIFIED, DOC_SAVED],
	 insp.is_any_doc_not_saved],
	['CLOSE', _('_Close'), _('Close'), gtk.STOCK_CLOSE, '<Control>W',
	 proxy.close, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['CLOSE_ALL', _('Close All'), _('Close All'), None, None,
	 proxy.close_all, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['IMPORT', _('_Import...'), _('Import...'), gtk.STOCK_REVERT_TO_SAVED, None,
	 proxy.insert_doc, [NO_DOCS, DOC_CHANGED], insp.is_doc],


	['CUTTING', _('C_utting...'), _('Cutting'), icons.STOCK_CUTTING, '<Control>P',
	 proxy.do_cutting, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['PLOTTER_SETUP', _('Plotter Setup...'), _('Plotter Setup'), gtk.STOCK_PRINT_PREVIEW, None,
	 proxy.do_plotter_setup, None, None],


	['UNDO', _('_Undo'), _('Undo'), gtk.STOCK_UNDO, '<Control>Z',
	 proxy.undo, [events.NO_DOCS, events.DOC_CHANGED, events.DOC_MODIFIED,
	 events.DOC_CLOSED], insp.is_undo],
	['REDO', _('_Redo'), _('Redo'), gtk.STOCK_REDO, '<Control><Shift>Z',
	 proxy.redo, [events.NO_DOCS, events.DOC_CHANGED, events.DOC_MODIFIED,
	 events.DOC_CLOSED], insp.is_redo],
	['CLEAR_HISTORY', _('Clear undo history'), _('Clear undo history'),
	None, None, proxy.clear_history, [events.NO_DOCS, events.DOC_CHANGED,
	 events.DOC_MODIFIED, events.DOC_CLOSED], insp.is_history],


	['CUT', _('Cu_t'), _('Cut'), gtk.STOCK_CUT, '<Control>X',
	 proxy.cut, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['COPY', _('_Copy'), _('Copy'), gtk.STOCK_COPY, '<Control>C',
	 proxy.copy, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['PASTE', _('_Paste'), _('Paste'), gtk.STOCK_PASTE, '<Control>V',
	 proxy.paste, [events.NO_DOCS, events.CLIPBOARD], insp.is_clipboard],
	['DELETE', _('_Delete'), _('Delete'), gtk.STOCK_DELETE, 'Delete',
	 proxy.delete, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],

	['SELECT_ALL', _('_Select All'), _('Select All'), gtk.STOCK_SELECT_ALL, '<Control>A',
	 proxy.select_all, [events.NO_DOCS, events.DOC_CHANGED], insp.is_doc],
	['DESELECT', _('_Deselect'), _('Deselect'), None, '<Control><Shift>A',
	 proxy.deselect, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],

	['STROKE_VIEW', _('Stroke View'), _('Stroke View'), None, None,
	 proxy.stroke_view, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['DRAFT_VIEW', _('Draft View'), _('Draft View'), None, None,
	 proxy.draft_view, [NO_DOCS, DOC_CHANGED], insp.is_doc],

	['ZOOM_IN', _('Zoom in'), _('Zoom in'), gtk.STOCK_ZOOM_IN, '<Control>equal',
	 proxy.zoom_in, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['ZOOM_OUT', _('Zoom out'), _('Zoom out'), gtk.STOCK_ZOOM_OUT, '<Control>minus',
	 proxy.zoom_out, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['ZOOM_PAGE', _('Fit zoom to start'), _('Fit zoom to start'),
	 gtk.STOCK_ORIENTATION_LANDSCAPE, '<Shift>F4',
	 proxy.fit_zoom_to_page, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['ZOOM_100', _('Zoom 100%'), _('Zoom 100%'), gtk.STOCK_ZOOM_100, None,
	 proxy.zoom_100, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['ZOOM_SELECTED', _('Zoom selected'), _('Zoom selected'), gtk.STOCK_ZOOM_FIT, 'F4',
	 proxy.zoom_selected, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['FORCE_REDRAW', _('Redraw document'), _('Redraw document'),
	gtk.STOCK_REFRESH, '<Alt>R', proxy.force_redraw,
	[NO_DOCS, DOC_CHANGED], insp.is_doc],


	['COMBINE', _('_Combine'), _('Combine'), None, '<Control>L',
	 proxy.combine_selected, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_be_combined],
	['BREAK_APART', _('_Break apart'), _('Break apart'), None, '<Control>K',
	 proxy.break_apart_selected, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_be_breaked],

	['GROUP', _('_Group'), _('Group'), None, '<Control>G',
	 proxy.group, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_be_grouped],
	['UNGROUP', _('_Ungroup'), _('Ungroup'), None, '<Control>U',
	 proxy.ungroup, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_be_ungrouped],
	['UNGROUP_ALL', _('U_ngroup all'), _('Ungroup all'), None, None,
	 proxy.ungroup_all, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_be_ungrouped_all],
	['CONVERT_TO_CURVES', _('_Convert to curves'), _('Convert to curves'), None, '<Control>Q',
	 proxy.convert_to_curve, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_be_curve],

	['EDIT_TEXT', _('_Edit text...'), _('Edit text'), None, 'F8',
	 proxy.edit_text, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_text_selected],

	['SET_CONTAINER', _('_Place into container'), _('Place into container'), None, None,
	 proxy.set_container, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],

	['UNPACK_CONTAINER', _('_Extract from container'), _('Extract from container'), None, None,
	 proxy.unpack_container, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_container_selected],

	['PROPERTIES', _('Document Properties...'), _('Document Properties...'), gtk.STOCK_PROPERTIES, None,
	 proxy.properties, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['PREFERENCES', _('Preferences...'), _('Preferences...'), gtk.STOCK_PREFERENCES, None,
	 proxy.preferences, None, None],
	['QUIT', _('_Exit'), _('Exit'), gtk.STOCK_QUIT, '<Alt>F4',
	 proxy.exit, None, None],

	['REPORT_BUG', _('_Report bug'), _('Report bug'), gtk.STOCK_DIALOG_WARNING, None,
	 proxy.report_bug, None, None],
	['PROJECT_WEBSITE', _('Project _web site'), _('Project web site'), None, None,
	 proxy.project_website, None, None],
	['PROJECT_FORUM', _('Project _forum'), _('Project forum'), None, None,
	 proxy.project_forum, None, None],
	['ABOUT', _('_About LinCutter'), _('About LinCutter'), gtk.STOCK_ABOUT, None,
	 proxy.about, None, None],

	['ROTATE_LEFT', _('Rotate _Left'), _('Rotate Left'), icons.STOCK_ROTATE_LEFT, None,
	 proxy.rotate_left, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['ROTATE_RIGHT', _('Rotate _Right'), _('Rotate Right'), icons.STOCK_ROTATE_RIGHT, None,
	 proxy.rotate_right, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['VERT_MIRROR', _('Flip _vertically'), _('Flip vertically'), icons.STOCK_VERT_MIRROR, None,
	 proxy.vertical_mirror, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['HOR_MIRROR', _('Flip _horizontally'), _('Flip horizontally'), icons.STOCK_HOR_MIRROR, None,
	 proxy.horizontal_mirror, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['MOVE_TO_ORIGIN', _('_Move to origin'), _('Move to origin'), icons.STOCK_MOVE_TO_ORIGIN, '<Control>B',
	 proxy.move_to_origin, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],
	['MULTIPLY', _('Multipl_y selection'), _('Multiply selection'), icons.STOCK_MULTIPLY, None,
	 proxy.multiply_selected, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.is_selection],

	]

	for entry in entries:
		action = AppAction(entry[0], entry[1], entry[2], entry[3],
						   entry[4], entry[5], entry[6], entry[7])

		actions[entry[0]] = action
		if not action.shortcut is None:
			actiongroup.add_action_with_accel(action, action.shortcut)
			action.set_accel_group(accelgroup)
		else:
			actiongroup.add_action(action)

	return actions
Exemplo n.º 49
0
    def __init__(self, mw):
        gtk.MenuBar.__init__(self)
        self.mw = mw
        self.app = mw.app
        self.actions = self.app.actions

        #----FILE MENU
        self.file_item, self.file_menu = self.create_menu(_("_File"))
        items = [
            'NEW', None, 'OPEN', 'SAVE', 'SAVE_AS', 'SAVE_ALL', None, 'IMPORT',
            None, 'CLOSE', 'CLOSE_ALL', None, 'PLOTTER_SETUP', 'CUTTING', None,
            'QUIT'
        ]
        self.add_items(self.file_menu, items)

        #----EDIT MENU
        self.edit_item, self.edit_menu = self.create_menu(_("_Edit"))
        items = [
            'UNDO',
            'REDO',
            'CLEAR_HISTORY',
            None,
            'CUT',
            'COPY',
            'PASTE',
            'DELETE',
            None,
            'SELECT_ALL',
            'DESELECT',
            None,
            'PREFERENCES',
        ]
        self.add_items(self.edit_menu, items)

        #----VIEW MENU
        self.view_item, self.view_menu = self.create_menu(_("_View"))
        items = [
            ('DRAFT_VIEW', ),
            None,
            'ZOOM_100',
            'ZOOM_IN',
            'ZOOM_OUT',
            None,
            'ZOOM_PAGE',
            'ZOOM_SELECTED',
            None,
            'FORCE_REDRAW',
        ]
        self.add_items(self.view_menu, items)

        #----LAYOUT MENU
        self.layout_item, self.effects_menu = self.create_menu(_("_Layout"))

        #----ARRANGE MENU
        self.arrange_item, self.arrange_menu = self.create_menu(_("_Object"))
        items = [
            'MOVE_TO_ORIGIN',
            'MULTIPLY',
            None,
            'HOR_MIRROR',
            'VERT_MIRROR',
            'ROTATE_LEFT',
            'ROTATE_RIGHT',
            None,
            'COMBINE',
            'BREAK_APART',
            None,
            'GROUP',
            'UNGROUP',
            'UNGROUP_ALL',
            None,
            'CONVERT_TO_CURVES',
        ]
        self.add_items(self.arrange_menu, items)

        #----HELP MENU
        self.help_item, self.help_menu = self.create_menu(_("_Help"))
        items = [
            'REPORT_BUG',
            None,
            'PROJECT_WEBSITE',
            'PROJECT_FORUM',
            None,
            'ABOUT',
        ]
        self.add_items(self.help_menu, items)

        self.append(self.file_item)
        self.append(self.edit_item)
        self.append(self.view_item)
        self.append(self.arrange_item)
        self.append(self.help_item)
Exemplo n.º 50
0
	def __init__(self, app):

		gtk.VBox.__init__(self)
		self.app = app
		self.caption_label = gtk.Label(self.caption)

		spacer = gtk.VBox()
		self.add(spacer)
		self.set_border_width(15)
		self.set_size_request(500, 200)

		tab = gtk.Table(8, 2, False)
		tab.set_row_spacings(10)
		tab.set_col_spacings(10)
		spacer.pack_start(tab)

		#---------------------------

		label = gtk.Label(_('Application units:'))
		label.set_alignment(0, 0.5)
		tab.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		self.combo = gtk.combo_box_new_text()

		for item in unit_names:
			self.combo.append_text(unit_full_names[item])

		self.combo.set_active(unit_names.index(config.default_unit))
		tab.attach(self.combo, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK)


		#---------------------------
		hline = gtk.HSeparator()
		tab.attach(hline, 0, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
		#---------------------------

		label = gtk.Label(_('Curves flattening tolerance:'))
		label.set_alignment(0, 0.5)
		tab.attach(label, 0, 1, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		self.tolerance_adj = gtk.Adjustment(config.tolerance,
										0.01, 10.0, 0.01, 1.0, 0.0)
		spinner = gtk.SpinButton(self.tolerance_adj, 0.1, 2)
		spinner.set_numeric(True)
		tab.attach(spinner, 1, 2, 2, 3, gtk.FILL, gtk.SHRINK)

		markup = _('Flattening tolerance affects on curve flattening quality.\n\
Lower value means better cutting quality and slower cutting speed.\n\
Default flattening tolerance value is 0,5')
		label = gtk.Label()
		label.set_markup(markup)
		label.set_alignment(0, 0.5)
		label.set_sensitive(False)
		tab.attach(label, 0, 2, 3, 4, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		#---------------------------
		hline = gtk.HSeparator()
		tab.attach(hline, 0, 2, 4, 5, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
		#---------------------------

		self.new_doc = gtk.CheckButton(label=_('Create new document on start'))
		self.new_doc.set_active(config.new_doc_on_start)
		tab.attach(self.new_doc, 0, 2, 5, 6, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
		#---------------------------

		self.backup_check = gtk.CheckButton(label=_('Make backup when save'))
		self.backup_check.set_active(config.make_backup)
		tab.attach(self.backup_check, 0, 2, 6, 7, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
		#---------------------------

		self.release_check = gtk.CheckButton(label=_('Allow release check'))
		self.release_check.set_active(config.allow_release_check)
		tab.attach(self.release_check, 0, 2, 7, 8, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
Exemplo n.º 51
0
	def __init__(self, app, doc_file='', silent=False):
		self.app = app
		self.eventloop = EventLoop(self)
		self.selection = Selection(self)


		if doc_file:
			loader = get_loader(doc_file)
			if loader is None:
				raise IOError(_('Unknown file format'), doc_file)

			if silent:
				self.doc_presenter = loader(app.appdata, doc_file)
				simplify_doc(self.doc_presenter)
			else:
				pd = ProgressDialog(_('Opening file...'), self.app.mw)
				ret = pd.run(loader, [app.appdata, doc_file])
				if ret == gtk.RESPONSE_OK:
					if pd.result is None:
						pd.destroy()
						raise IOError(*pd.error_info)

					self.doc_presenter = pd.result
					pd.destroy()
					res = simplify_doc(self.doc_presenter)
					if not res:
						first = _("File '%s' doesn't contain supported objects.") % (doc_file)
						second = _('It seems all objects are either images or special groups.')
						ret = warning_dialog(self.app.mw, self.app.appdata.app_name,
								first, second,
								[(gtk.STOCK_OK, gtk.RESPONSE_OK)])
				else:
					pd.destroy()
					raise IOError(_('Error while opening'), doc_file)

			self.doc_file = self.doc_presenter.doc_file
			self.doc_name = os.path.basename(self.doc_file)
			self.doc_name = change_file_extension(self.doc_name,
									uc2const.FORMAT_EXTENSION[uc2const.PDXF][0])
		else:
			self.doc_presenter = PDXF_Presenter(app.appdata)
			self.doc_presenter.new()
			self.doc_name = self.app.get_new_docname()

		self.methods = self.doc_presenter.methods
		self.model = self.doc_presenter.model
		self.set_active_page()


		self.cms = self.doc_presenter.cms
		self.cms.use_cms = False

		self.api = PresenterAPI(self)
		self.docarea = DocArea(self.app, self)
		self.canvas = self.docarea.canvas
		self.api.view = self.canvas
		self.app.mw.add_tab(self.docarea)
		self.eventloop.connect(self.eventloop.DOC_MODIFIED, self.modified)
		self.traced_objects = [
							self.eventloop,
							self.api,
							self.docarea.hruler,
							self.docarea.vruler,
							self.docarea.corner,
							self.docarea,
							self.canvas.renderer,
							self.canvas,
							self.selection,
							self
							]
Exemplo n.º 52
0
	def __init__(self, app):

		gtk.VBox.__init__(self)
		self.app = app
		self.caption_label = gtk.Label(self.caption)

		spacer = gtk.VBox()
		self.add(spacer)
		self.set_border_width(15)
		self.set_size_request(385, 220)

		tab = gtk.Table(3, 2, False)
		tab.set_row_spacings(10)
		tab.set_col_spacings(10)
		spacer.add(tab)


		#---------------------------

		label = gtk.Label(_('Plotter model:'))
		label.set_alignment(0, 0.5)
		tab.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		self.combo = gtk.combo_box_new_text()
		self.combo.connect('changed', self.combo_changed)

		items = plt_data.keys()
		items.sort()
		for item in items:
			self.combo.append_text(item)

		tab.attach(self.combo, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK)

		#---------------------------

		self.radiobut1 = gtk.RadioButton(None, _("Predefined model"))
		tab.attach(self.radiobut1, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK)
		self.radiobut1.connect("toggled", self.radio_changed)

		self.radiobut2 = gtk.RadioButton(self.radiobut1, _("Custom model"))
		tab.attach(self.radiobut2, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK)
		self.radiobut2.connect("toggled", self.radio_changed)

		#---------------------------

		self.data_frame = gtk.Frame(_('Plotter data'))
		tab.attach(self.data_frame, 0, 2, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK)


		data_tab = gtk.Table(3, 3, False)
		data_tab.set_border_width(15)
		data_tab.set_row_spacings(10)
		data_tab.set_col_spacings(10)
		self.data_frame.add(data_tab)

		#===========================

		label = gtk.Label(_('Plotter model:'))
		label.set_alignment(1, 0.5)
		data_tab.attach(label, 0, 1, 0, 1, gtk.FILL , gtk.SHRINK)

		self.plt_name = gtk.Entry()
		self.plt_name.set_text(config.plotter_name)
		data_tab.attach(self.plt_name, 1, 3, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		#===========================

		label = gtk.Label(_('Cutting width:'))
		label.set_alignment(1, 0.5)
		data_tab.attach(label, 0, 1, 1, 2, gtk.FILL , gtk.SHRINK)

		self.height_spin = UnitSpin(self.user_changes)
		self.height_spin.set_point_value(config.plotter_page_height)
		data_tab.attach(self.height_spin, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK)

		unit_label = UnitLabel()
		unit_label.set_alignment(0, 0.5)
		data_tab.attach(unit_label, 2, 3, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		#===========================		
		label = gtk.Label(_('Cutting length:'))
		label.set_alignment(1, 0.5)

		data_tab.attach(label, 0, 1, 2, 3, gtk.FILL , gtk.SHRINK)

		self.width_spin = UnitSpin(self.user_changes)
		self.width_spin.set_point_value(config.plotter_page_width)
		data_tab.attach(self.width_spin, 1, 2, 2, 3, gtk.SHRINK, gtk.SHRINK)

		unit_label = UnitLabel()
		unit_label.set_alignment(0, 0.5)
		data_tab.attach(unit_label, 2, 3, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		#===========================

		if config.plotter_name in items and \
		round(plt_data[config.plotter_name][0], 6) == round(config.plotter_page_height, 6) and \
		round(plt_data[config.plotter_name][1], 6) == round(config.plotter_page_width, 6):
			self.combo.set_active(items.index(config.plotter_name))
			self.radiobut1.set_active(True)
			self.data_frame.set_sensitive(False)
		else:
			self.radiobut2.set_active(True)
Exemplo n.º 53
0
	def get_new_docname(self):
		self.doc_counter += 1
		return _('New job') + ' ' + str(self.doc_counter)
Exemplo n.º 54
0
	def build(self):
		self.set_size_request(385, 200)

		tab = gtk.Table(7, 2, False)
		tab.set_row_spacings(10)
		tab.set_col_spacings(10)
		self.pack_start(tab)

		#---------------------------

		label = gtk.Label(_('Plotter:'))
		label.set_alignment(1, 0.5)
		tab.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK)


		label = gtk.Label()
		markup = '<b>' + config.plotter_name + '</b>'
		label.set_markup(markup)
		label.set_alignment(0, 0.5)
		tab.attach(label, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		#---------------------------

		check = gtk.CheckButton(label=_('Output to file'))
		check.set_active(True)
		check.set_sensitive(False)
		tab.attach(check, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK)

		self.output_file = gtk.FileChooserButton(_('Select file for output'))
		filename = os.path.expanduser(config.output_file)
		if not os.path.lexists(filename):
			file = open(filename, 'wb')
			file.close()
		self.output_file.set_filename(filename)
		self.output_file.connect('file-set', self.combo_changed)
		tab.attach(self.output_file, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		#---------------------------

		self.bbox = gtk.CheckButton(label=_('Cut bounding box'))
		self.bbox.set_active(config.cut_bbox)
		tab.attach(self.bbox, 0, 2, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

		#---------------------------
		hline = gtk.HSeparator()
		tab.attach(hline, 0, 2, 3, 4, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
		#---------------------------

		label = gtk.Label(_('Flattening tolerance:'))
		label.set_alignment(0, 0.5)
		tab.attach(label, 0, 1, 4, 5, gtk.FILL , gtk.SHRINK)

		self.tolerance_adj = gtk.Adjustment(config.tolerance,
										0.01, 10.0, 0.01, 1.0, 0.0)
		spinner = gtk.SpinButton(self.tolerance_adj, 0.1, 2)
		spinner.set_numeric(True)
		hbox = gtk.HBox()
		hbox.pack_start(spinner, False)
		tab.attach(hbox, 1, 2, 4, 5, gtk.FILL, gtk.SHRINK)

		markup = _('Flattening tolerance affects on curve flattening quality.\n\
Lower value means better cutting quality and slower cutting speed.\n\
Default flattening tolerance value is 0,5')
		label = gtk.Label()
		label.set_markup(markup)
		label.set_alignment(0, 0.5)
		label.set_sensitive(False)
		tab.attach(label, 0, 2, 5, 6, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
Exemplo n.º 55
0
    def build(self):
        self.set_size_request(385, 200)

        tab = gtk.Table(7, 2, False)
        tab.set_row_spacings(10)
        tab.set_col_spacings(10)
        self.pack_start(tab)

        #---------------------------

        label = gtk.Label(_('Plotter:'))
        label.set_alignment(1, 0.5)
        tab.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK)

        label = gtk.Label()
        markup = '<b>' + config.plotter_name + '</b>'
        label.set_markup(markup)
        label.set_alignment(0, 0.5)
        tab.attach(label, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        #---------------------------

        check = gtk.CheckButton(label=_('Output to file'))
        check.set_active(True)
        check.set_sensitive(False)
        tab.attach(check, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK)

        self.output_file = gtk.FileChooserButton(_('Select file for output'))
        filename = os.path.expanduser(config.output_file)
        if not os.path.lexists(filename):
            file = open(filename, 'wb')
            file.close()
        self.output_file.set_filename(filename)
        self.output_file.connect('file-set', self.combo_changed)
        tab.attach(self.output_file, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND,
                   gtk.SHRINK)

        #---------------------------

        self.bbox = gtk.CheckButton(label=_('Cut bounding box'))
        self.bbox.set_active(config.cut_bbox)
        tab.attach(self.bbox, 0, 2, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK)

        #---------------------------
        hline = gtk.HSeparator()
        tab.attach(hline, 0, 2, 3, 4, gtk.FILL | gtk.EXPAND, gtk.SHRINK)
        #---------------------------

        label = gtk.Label(_('Flattening tolerance:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 4, 5, gtk.FILL, gtk.SHRINK)

        self.tolerance_adj = gtk.Adjustment(config.tolerance, 0.01, 10.0, 0.01,
                                            1.0, 0.0)
        spinner = gtk.SpinButton(self.tolerance_adj, 0.1, 2)
        spinner.set_numeric(True)
        hbox = gtk.HBox()
        hbox.pack_start(spinner, False)
        tab.attach(hbox, 1, 2, 4, 5, gtk.FILL, gtk.SHRINK)

        markup = _(
            'Flattening tolerance affects on curve flattening quality.\n\
Lower value means better cutting quality and slower cutting speed.\n\
Default flattening tolerance value is 0,5')
        label = gtk.Label()
        label.set_markup(markup)
        label.set_alignment(0, 0.5)
        label.set_sensitive(False)
        tab.attach(label, 0, 2, 5, 6, gtk.FILL | gtk.EXPAND, gtk.SHRINK)