Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzy on 'Select Same Page Format' #900

Open
JunglePredator opened this issue Jun 20, 2023 · 1 comment
Open

Fuzzy on 'Select Same Page Format' #900

JunglePredator opened this issue Jun 20, 2023 · 1 comment
Labels
feature Request for a new feature PRs welcome The person setting this label (or assigned to this Issue) is happy to give guidance

Comments

@JunglePredator
Copy link

The Same Page Format selection is very handy & while I haven't needed it yet I thought requesting a fuzzy option to it would be a good idea.

Basically a % or similar of how many pixels the selected images may be off of the original image before it gets selected.

@jeromerobert jeromerobert added feature Request for a new feature PRs welcome The person setting this label (or assigned to this Issue) is happy to give guidance labels Jun 25, 2023
@jeromerobert
Copy link
Member

We currently round the number of points (1/72 inch) to 8 digits. This FR can be implemented by modifying this:

formats = [(round(w, 8), round(h, 8)) for (w, h) in formats]
for row in model:
page = model[row.path][0]
w, h = page.size_in_points()
if (round(w, 8), round(h, 8)) in formats:

One will have to move the code to a dedicated function (on_action_select is already long enough). one will need to create a dialog box to ask for a percentage. Here is an example to adapt:

class PasswordDialog(Gtk.Dialog):
def __init__(self, parent, filename):
super().__init__(
title=_("Password required"),
parent=parent,
flags=Gtk.DialogFlags.MODAL,
buttons=(
"_Cancel",
Gtk.ResponseType.CANCEL,
"_OK",
Gtk.ResponseType.OK,
),
)
self.set_default_response(Gtk.ResponseType.OK)
bottommsg = _("The password will be remembered until you close PDF Arranger.")
topmsg = _("The document “{}” is locked and requires a password before it can be opened.")
label = Gtk.Label(label=topmsg.format(filename))
label.set_max_width_chars(len(bottommsg)-6)
label.set_line_wrap(True)
label.set_size_request(0, -1)
self.vbox.pack_start(label, False, False, 12)
box = Gtk.HBox()
self.entry = Gtk.Entry()
self.entry.set_visibility(False)
self.entry.set_activates_default(True)
box.pack_start(Gtk.Label(label=_("Password")), False, False, 6)
box.pack_start(self.entry, True, True, 6)
self.vbox.pack_start(box, True, True, 0)
self.vbox.pack_start(Gtk.Label(label=bottommsg), False, False, 12)
self.set_resizable(False)
def get_password(self):
self.show_all()
r = self.run()
t = self.entry.props.text
self.destroy()
if r == Gtk.ResponseType.OK:
return t
else:
raise _UnknownPasswordException()
).

@jeromerobert jeromerobert changed the title Feature Request: Fuzzy on 'Select Same Page Format' Fuzzy on 'Select Same Page Format' Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request for a new feature PRs welcome The person setting this label (or assigned to this Issue) is happy to give guidance
Projects
None yet
Development

No branches or pull requests

2 participants