Exemple #1
0
    def build(self):

        self.formats = PAGE_FORMAT_NAMES + [
            _('Custom'),
        ]

        self.combo = wal.ComboBoxEntry(self,
                                       self.formats,
                                       cmd=self.combo_changed)
        self.pack(self.combo)

        self.width_spin = UnitSpin(self, self.width_spin_changed)
        self.pack(self.width_spin, padding=2)

        self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

        self.height_spin = UnitSpin(self, self.height_spin_changed)
        self.pack(self.height_spin, padding=2)

        self.portrait = wal.ImgToggleButton(self,
                                            rc.IMG_CTX_PORTRAIT,
                                            tooltip=_('Portrait'),
                                            cmd=self.portrait_toggled)
        self.pack(self.portrait)

        self.landscape = wal.ImgToggleButton(self,
                                             rc.IMG_CTX_LANDSCAPE,
                                             tooltip=_('Landscape'),
                                             cmd=self.landscape_toggled)
        self.pack(self.landscape)
Exemple #2
0
	def build(self):
		self.pack(wal.ClickableImage(self, rc.IMG_CTX_JUMP,
								tooltip=_('Default object jump')), padding=2)

		self.jump_spin = UnitSpin(self, self.user_changes)
		self.pack(self.jump_spin)
		self.jump_spin.set_point_value(config.obj_jump)

		self.pack(UnitLabel(self), padding=2)
Exemple #3
0
	def build(self):
		self.pack(wal.Label(self, _('Size:')), padding=2)

		self.width_spin = UnitSpin(self, self.user_changes)
		self.pack(self.width_spin)

		self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

		self.height_spin = UnitSpin(self, self.user_changes)
		self.pack(self.height_spin)

		self.pack(UnitLabel(self), padding=2)

		self.keep_ratio = KeepRatioLabel(self)
		self.pack(self.keep_ratio, padding=5)
Exemple #4
0
    def build(self):
        self.pack(wal.Label(self, _('Size:')), padding=2)

        self.width_spin = UnitSpin(self, self.user_changes)
        self.pack(self.width_spin)

        self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

        self.height_spin = UnitSpin(self, self.user_changes)
        self.pack(self.height_spin)

        self.pack(UnitLabel(self), padding=2)

        self.keep_ratio = KeepRatioLabel(self)
        self.pack(self.keep_ratio, padding=5)
Exemple #5
0
class JumpPlugin(GenericPlugin):

	name = 'JumpPlugin'

	def __init__(self, app, master):
		GenericPlugin.__init__(self, app, master)
		events.connect(events.NO_DOCS, self.set_state)
		events.connect(events.CONFIG_MODIFIED, self.config_changed)

	def build(self):
		self.pack(wal.ClickableImage(self, rc.IMG_CTX_JUMP,
								tooltip=_('Default object jump')), padding=2)

		self.jump_spin = UnitSpin(self, self.user_changes)
		self.pack(self.jump_spin)
		self.jump_spin.set_point_value(config.obj_jump)

		self.pack(UnitLabel(self), padding=2)

	def user_changes(self, *args):
		config.obj_jump = self.jump_spin.get_point_value()

	def config_changed(self, attr, value):
		if attr == 'obj_jump':
			val = self.jump_spin.get_point_value()
			if not config.obj_jump == val:
				self.jump_spin.set_point_value(config.obj_jump)
Exemple #6
0
	def build(self):

		self.formats = PAGE_FORMAT_NAMES + [_('Custom'), ]

		self.combo = wal.ComboBoxEntry(self, self.formats,
									cmd=self.combo_changed)
		self.pack(self.combo)

		self.width_spin = UnitSpin(self, self.width_spin_changed)
		self.pack(self.width_spin, padding=2)

		self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

		self.height_spin = UnitSpin(self, self.height_spin_changed)
		self.pack(self.height_spin, padding=2)

		self.portrait = wal.ImgToggleButton(self, rc.IMG_CTX_PORTRAIT,
							tooltip=_('Portrait'), cmd=self.portrait_toggled)
		self.pack(self.portrait)

		self.landscape = wal.ImgToggleButton(self, rc.IMG_CTX_LANDSCAPE,
							tooltip=_('Landscape'), cmd=self.landscape_toggled)
		self.pack(self.landscape)
Exemple #7
0
class ResizePlugin(GenericPlugin):

	name = 'ResizePlugin'


	def __init__(self, app, master):
		GenericPlugin.__init__(self, app, master)
		events.connect(events.NO_DOCS, self.set_state)
		events.connect(events.DOC_CHANGED, self.set_state)
		events.connect(events.SELECTION_CHANGED, self.set_state)

	def build(self):
		self.pack(wal.Label(self, _('Size:')), padding=2)

		self.width_spin = UnitSpin(self, self.user_changes)
		self.pack(self.width_spin)

		self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

		self.height_spin = UnitSpin(self, self.user_changes)
		self.pack(self.height_spin)

		self.pack(UnitLabel(self), padding=2)

		self.keep_ratio = KeepRatioLabel(self)
		self.pack(self.keep_ratio, padding=5)

	def set_state(self, *args):
		if self.app.current_doc is None:
			self.deactivate()
		else:
			if self.app.current_doc.selection.objs:
				self.activate()
			else:
				self.deactivate()

	def deactivate(self):
		self.width_spin.set_point_value(0)
		self.height_spin.set_point_value(0)
		self.set_sensitive(False)

	def activate(self):
		bbox = self.app.current_doc.selection.bbox
		w = bbox[2] - bbox[0]
		h = bbox[3] - bbox[1]
		self.width_spin.set_point_value(w)
		self.height_spin.set_point_value(h)
		self.set_sensitive(True)

	def user_changes(self, *args):
		doc = self.app.current_doc
		if not doc is None and doc.selection.objs:
			bbox = doc.selection.bbox
			w = bbox[2] - bbox[0]
			h = bbox[3] - bbox[1]
			center_x = bbox[0] + w / 2.0
			center_y = bbox[1] + h / 2.0

			new_w = self.width_spin.get_point_value()
			new_h = self.height_spin.get_point_value()

			if not round(w, 4) == round(new_w, 4) or not round(h, 4) == round(new_h, 4):
				if not new_w: self.width_spin.set_point_value(w);return
				if not new_h: self.height_spin.set_point_value(h);return

				m11 = round(new_w / w, 4)
				m22 = round(new_h / h, 4)

				if m11 == m22 == 1.0:return

				trafo = []

				if self.keep_ratio.value:
					if m11 == 1.0:
						dx = center_x * (1 - m22)
						dy = center_y * (1 - m22)
						trafo = [m22, 0.0, 0.0, m22, dx, dy]
					if m22 == 1.0:
						dx = center_x * (1 - m11)
						dy = center_y * (1 - m11)
						trafo = [m11, 0.0, 0.0, m11, dx, dy]
				else:
					dx = center_x * (1 - m11)
					dy = center_y * (1 - m22)
					trafo = [m11, 0.0, 0.0, m22, dx, dy]

				if trafo:
					doc.api.transform_selected(trafo)
Exemple #8
0
class PageFormatPlugin(GenericPlugin):

    name = 'PageFormatPlugin'
    my_changes = False
    update_flag = False
    format = []

    def __init__(self, app, master):
        GenericPlugin.__init__(self, app, master)
        events.connect(events.DOC_CHANGED, self.update)
        events.connect(events.DOC_MODIFIED, self.update)

    def build(self):

        self.formats = PAGE_FORMAT_NAMES + [
            _('Custom'),
        ]

        self.combo = wal.ComboBoxEntry(self,
                                       self.formats,
                                       cmd=self.combo_changed)
        self.pack(self.combo)

        self.width_spin = UnitSpin(self, self.width_spin_changed)
        self.pack(self.width_spin, padding=2)

        self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

        self.height_spin = UnitSpin(self, self.height_spin_changed)
        self.pack(self.height_spin, padding=2)

        self.portrait = wal.ImgToggleButton(self,
                                            rc.IMG_CTX_PORTRAIT,
                                            tooltip=_('Portrait'),
                                            cmd=self.portrait_toggled)
        self.pack(self.portrait)

        self.landscape = wal.ImgToggleButton(self,
                                             rc.IMG_CTX_LANDSCAPE,
                                             tooltip=_('Landscape'),
                                             cmd=self.landscape_toggled)
        self.pack(self.landscape)

    def combo_changed(self, *args):
        if self.update_flag: return
        if not self.format[0] == self.formats[self.combo.get_active()]:
            self.update_flag = True
            if not self.formats[self.combo.get_active()] == self.formats[-1]:
                w, h = PAGE_FORMATS[self.formats[self.combo.get_active()]]
                if self.portrait.get_active() and w > h:
                    self.width_spin.set_point_value(w)
                    self.height_spin.set_point_value(h)
                    self.portrait.set_active(False)
                    self.landscape.set_active(True)
                elif self.landscape.get_active() and w > h:
                    self.width_spin.set_point_value(w)
                    self.height_spin.set_point_value(h)
                elif self.portrait.get_active() and w < h:
                    self.width_spin.set_point_value(w)
                    self.height_spin.set_point_value(h)
                else:
                    self.width_spin.set_point_value(h)
                    self.height_spin.set_point_value(w)
            self.update_flag = False
            self.changes()

    def width_spin_changed(self, *args):
        if self.update_flag: return
        if not self.format[1][0] == self.width_spin.get_point_value():
            self.update_flag = True
            w = self.width_spin.get_point_value()
            h = self.height_spin.get_point_value()
            if w > h and self.portrait.get_active():
                self.portrait.set_active(False)
                self.landscape.set_active(True)
            elif w < h and self.landscape.get_active():
                self.portrait.set_active(True)
                self.landscape.set_active(False)
            self.update_flag = False
            self.changes()

    def height_spin_changed(self, *args):
        if self.update_flag: return
        if not self.format[1][1] == self.height_spin.get_point_value():
            self.update_flag = True
            w = self.width_spin.get_point_value()
            h = self.height_spin.get_point_value()
            if w > h and self.portrait.get_active():
                self.portrait.set_active(False)
                self.landscape.set_active(True)
            elif w < h and self.landscape.get_active():
                self.portrait.set_active(True)
                self.landscape.set_active(False)
            self.update_flag = False
            self.changes()

    def portrait_toggled(self, *args):
        if self.update_flag: return
        if self.portrait.get_active():
            self.update_flag = True
            self.landscape.set_active(False)
            h = self.width_spin.get_point_value()
            w = self.height_spin.get_point_value()
            self.width_spin.set_point_value(w)
            self.height_spin.set_point_value(h)
            self.update_flag = False
            self.changes()

    def landscape_toggled(self, *args):
        if self.update_flag: return
        if self.landscape.get_active():
            self.update_flag = True
            self.portrait.set_active(False)
            h = self.width_spin.get_point_value()
            w = self.height_spin.get_point_value()
            self.width_spin.set_point_value(w)
            self.height_spin.set_point_value(h)
            self.update_flag = False
            self.changes()

    def changes(self):
        new_format = [
            self.formats[self.combo.get_active()],
        ]
        new_format += [(self.width_spin.get_point_value(),
                        self.height_spin.get_point_value())]
        if self.portrait.get_active():
            new_format += [
                PORTRAIT,
            ]
        else:
            new_format += [
                LANDSCAPE,
            ]
        self.app.current_doc.api.set_page_format(new_format)

    def update(self, *args):
        if self.insp.is_doc():
            self.update_flag = True
            page = self.app.current_doc.active_page
            page_format = [page.format, page.size, page.orientation]
            self.format = page_format
            width, height = page_format[1]
            if page_format[0] in PAGE_FORMAT_NAMES:
                self.combo.set_active(self.formats.index(page_format[0]))
                if page_format[2] == PORTRAIT:
                    self.portrait.set_active(True)
                    self.landscape.set_active(False)
                else:
                    self.portrait.set_active(False)
                    self.landscape.set_active(True)
                self.width_spin.set_point_value(width)
                self.height_spin.set_point_value(height)
                self.width_spin.set_sensitive(False)
                self.height_spin.set_sensitive(False)
            else:
                self.combo.set_active(self.formats.index(_('Custom')))
                if page_format[2] == PORTRAIT:
                    self.portrait.set_active(True)
                    self.landscape.set_active(False)
                else:
                    self.portrait.set_active(False)
                    self.landscape.set_active(True)
                self.width_spin.set_point_value(width)
                self.height_spin.set_point_value(height)
                self.width_spin.set_sensitive(True)
                self.height_spin.set_sensitive(True)
            self.update_flag = False
Exemple #9
0
class PageFormatPlugin(GenericPlugin):

	name = 'PageFormatPlugin'
	my_changes = False
	update_flag = False
	format = []


	def __init__(self, app, master):
		GenericPlugin.__init__(self, app, master)
		events.connect(events.DOC_CHANGED, self.update)
		events.connect(events.DOC_MODIFIED, self.update)

	def build(self):

		self.formats = PAGE_FORMAT_NAMES + [_('Custom'), ]

		self.combo = wal.ComboBoxEntry(self, self.formats,
									cmd=self.combo_changed)
		self.pack(self.combo)

		self.width_spin = UnitSpin(self, self.width_spin_changed)
		self.pack(self.width_spin, padding=2)

		self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

		self.height_spin = UnitSpin(self, self.height_spin_changed)
		self.pack(self.height_spin, padding=2)

		self.portrait = wal.ImgToggleButton(self, rc.IMG_CTX_PORTRAIT,
							tooltip=_('Portrait'), cmd=self.portrait_toggled)
		self.pack(self.portrait)

		self.landscape = wal.ImgToggleButton(self, rc.IMG_CTX_LANDSCAPE,
							tooltip=_('Landscape'), cmd=self.landscape_toggled)
		self.pack(self.landscape)

	def combo_changed(self, *args):
		if self.update_flag: return
		if not self.format[0] == self.formats[self.combo.get_active()]:
			self.update_flag = True
			if not self.formats[self.combo.get_active()] == self.formats[-1]:
				w, h = PAGE_FORMATS[self.formats[self.combo.get_active()]]
				if self.portrait.get_active() and w > h:
					self.width_spin.set_point_value(w)
					self.height_spin.set_point_value(h)
					self.portrait.set_active(False)
					self.landscape.set_active(True)
				elif self.landscape.get_active() and w > h:
					self.width_spin.set_point_value(w)
					self.height_spin.set_point_value(h)
				elif self.portrait.get_active() and w < h:
					self.width_spin.set_point_value(w)
					self.height_spin.set_point_value(h)
				else:
					self.width_spin.set_point_value(h)
					self.height_spin.set_point_value(w)
			self.update_flag = False
			self.changes()

	def width_spin_changed(self, *args):
		if self.update_flag: return
		if not self.format[1][0] == self.width_spin.get_point_value():
			self.update_flag = True
			w = self.width_spin.get_point_value()
			h = self.height_spin.get_point_value()
			if w > h and self.portrait.get_active():
				self.portrait.set_active(False)
				self.landscape.set_active(True)
			elif w < h and self.landscape.get_active():
				self.portrait.set_active(True)
				self.landscape.set_active(False)
			self.update_flag = False
			self.changes()

	def height_spin_changed(self, *args):
		if self.update_flag: return
		if not self.format[1][1] == self.height_spin.get_point_value():
			self.update_flag = True
			w = self.width_spin.get_point_value()
			h = self.height_spin.get_point_value()
			if w > h and self.portrait.get_active():
				self.portrait.set_active(False)
				self.landscape.set_active(True)
			elif w < h and self.landscape.get_active():
				self.portrait.set_active(True)
				self.landscape.set_active(False)
			self.update_flag = False
			self.changes()

	def portrait_toggled(self, *args):
		if self.update_flag: return
		if self.portrait.get_active():
			self.update_flag = True
			self.landscape.set_active(False)
			h = self.width_spin.get_point_value()
			w = self.height_spin.get_point_value()
			self.width_spin.set_point_value(w)
			self.height_spin.set_point_value(h)
			self.update_flag = False
			self.changes()

	def landscape_toggled(self, *args):
		if self.update_flag: return
		if self.landscape.get_active():
			self.update_flag = True
			self.portrait.set_active(False)
			h = self.width_spin.get_point_value()
			w = self.height_spin.get_point_value()
			self.width_spin.set_point_value(w)
			self.height_spin.set_point_value(h)
			self.update_flag = False
			self.changes()

	def changes(self):
		new_format = [self.formats[self.combo.get_active()], ]
		new_format += [(self.width_spin.get_point_value(),
					self.height_spin.get_point_value())]
		if self.portrait.get_active():
			new_format += [PORTRAIT, ]
		else:
			new_format += [LANDSCAPE, ]
		self.app.current_doc.api.set_page_format(new_format)

	def update(self, *args):
		if self.insp.is_doc():
			self.update_flag = True
			page = self.app.current_doc.active_page
			page_format = [page.format, page.size, page.orientation]
			self.format = page_format
			width, height = page_format[1]
			if page_format[0] in PAGE_FORMAT_NAMES:
				self.combo.set_active(self.formats.index(page_format[0]))
				if page_format[2] == PORTRAIT:
					self.portrait.set_active(True)
					self.landscape.set_active(False)
				else:
					self.portrait.set_active(False)
					self.landscape.set_active(True)
				self.width_spin.set_point_value(width)
				self.height_spin.set_point_value(height)
				self.width_spin.set_sensitive(False)
				self.height_spin.set_sensitive(False)
			else:
				self.combo.set_active(self.formats.index(_('Custom')))
				if page_format[2] == PORTRAIT:
					self.portrait.set_active(True)
					self.landscape.set_active(False)
				else:
					self.portrait.set_active(False)
					self.landscape.set_active(True)
				self.width_spin.set_point_value(width)
				self.height_spin.set_point_value(height)
				self.width_spin.set_sensitive(True)
				self.height_spin.set_sensitive(True)
			self.update_flag = False
Exemple #10
0
class ResizePlugin(GenericPlugin):

    name = 'ResizePlugin'

    def __init__(self, app, master):
        GenericPlugin.__init__(self, app, master)
        events.connect(events.NO_DOCS, self.set_state)
        events.connect(events.DOC_CHANGED, self.set_state)
        events.connect(events.SELECTION_CHANGED, self.set_state)

    def build(self):
        self.pack(wal.Label(self, _('Size:')), padding=2)

        self.width_spin = UnitSpin(self, self.user_changes)
        self.pack(self.width_spin)

        self.pack(wal.Image(self, rc.IMG_CTX_W_ON_H))

        self.height_spin = UnitSpin(self, self.user_changes)
        self.pack(self.height_spin)

        self.pack(UnitLabel(self), padding=2)

        self.keep_ratio = KeepRatioLabel(self)
        self.pack(self.keep_ratio, padding=5)

    def set_state(self, *args):
        if self.app.current_doc is None:
            self.deactivate()
        else:
            if self.app.current_doc.selection.objs:
                self.activate()
            else:
                self.deactivate()

    def deactivate(self):
        self.width_spin.set_point_value(0)
        self.height_spin.set_point_value(0)
        self.set_sensitive(False)

    def activate(self):
        bbox = self.app.current_doc.selection.bbox
        w = bbox[2] - bbox[0]
        h = bbox[3] - bbox[1]
        self.width_spin.set_point_value(w)
        self.height_spin.set_point_value(h)
        self.set_sensitive(True)

    def user_changes(self, *args):
        doc = self.app.current_doc
        if not doc is None and doc.selection.objs:
            bbox = doc.selection.bbox
            w = bbox[2] - bbox[0]
            h = bbox[3] - bbox[1]
            center_x = bbox[0] + w / 2.0
            center_y = bbox[1] + h / 2.0

            new_w = self.width_spin.get_point_value()
            new_h = self.height_spin.get_point_value()

            if not round(w, 4) == round(new_w, 4) or not round(h, 4) == round(
                    new_h, 4):
                if not new_w:
                    self.width_spin.set_point_value(w)
                    return
                if not new_h:
                    self.height_spin.set_point_value(h)
                    return

                m11 = round(new_w / w, 4)
                m22 = round(new_h / h, 4)

                if m11 == m22 == 1.0: return

                trafo = []

                if self.keep_ratio.value:
                    if m11 == 1.0:
                        dx = center_x * (1 - m22)
                        dy = center_y * (1 - m22)
                        trafo = [m22, 0.0, 0.0, m22, dx, dy]
                    if m22 == 1.0:
                        dx = center_x * (1 - m11)
                        dy = center_y * (1 - m11)
                        trafo = [m11, 0.0, 0.0, m11, dx, dy]
                else:
                    dx = center_x * (1 - m11)
                    dy = center_y * (1 - m22)
                    trafo = [m11, 0.0, 0.0, m22, dx, dy]

                if trafo:
                    doc.api.transform_selected(trafo)