diff --git a/src/ImageInsert.py b/src/ImageInsert.py index fb0e4c6..13dcebc 100644 --- a/src/ImageInsert.py +++ b/src/ImageInsert.py @@ -2,10 +2,9 @@ class ImageDialogue(Gtk.Window): - def __init__(self, url_source, file_source, wikimedia_source, web_source, cache_support, scale_support): + def __init__(self, url_source, file_source, wikimedia_source, web_source, cache_support): super().__init__() self.cache_support = cache_support - self.scale_support = scale_support self.set_title("Insert Image") self.page = Adw.PreferencesPage() @@ -80,17 +79,16 @@ def __init__(self, url_source, file_source, wikimedia_source, web_source, cache_ # endregion # region Scale slider - # TODO: Actually do this - if self.scale_support: - self.scale_row = Adw.ActionRow(visible=False) - self.scale_slider = Gtk.Scale(round_digits=1) - self.scale_slider.set_range(0, 10) - for i in range(1, 10): - self.scale_slider.add_mark(i, Gtk.PositionType.BOTTOM) - # self.scale_slider.add_mark(1, Gtk.PositionType.BOTTOM) - # # self.scale_slider = Gtk.Range() - # self.scale_row.add_suffix(self.scale_slider) - self.group.add(self.scale_slider) + self.scale_row = Adw.ActionRow(visible=False) + self.scale_slider = Gtk.Scale(round_digits=1) + self.scale_slider.set_range(0, 1.5) + self.scale_slider.set_digits(True) + for i in range(0, 15): + self.scale_slider.add_mark(i/10, Gtk.PositionType.BOTTOM) + # self.scale_slider.add_mark(1, Gtk.PositionType.BOTTOM) + # # self.scale_slider = Gtk.Range() + # self.scale_row.add_suffix(self.scale_slider) + self.group.add(self.scale_slider) # region Tooltip self.tooltip_row = Adw.ActionRow(title="Description", @@ -127,8 +125,7 @@ def change_source(self, text): self.file_row.hide() self.wikipedia_row.hide() self.web_embed_row.hide() - if self.scale_support: - self.scale_slider.hide() + self.scale_slider.hide() if self.cache_support: self.cache_image_row.hide() self.tooltip_row.show() @@ -137,7 +134,6 @@ def change_source(self, text): self.url_row.show() if self.cache_support: self.cache_image_row.show() - if self.scale_support: self.scale_slider.show() case "Local File": self.file_row.show() @@ -165,13 +161,13 @@ def get_values(self): file = self.file_entry.get_text() tooltip = self.tooltip_entry.get_text() scale = self.scale_slider.get_value() - cache = self.cache_image_switch.get_state() + # cache = self.cache_image_switch.get_state() sources = {"URL": "url", "Local File": "file", "Wikipedia": "wikimedia"} data = {"type": "image" if source_dropdown != "Web Embed" else "iframe", "source": sources[source_dropdown], "url": url, "file": file, "scale": scale, - "tooltip": tooltip, - "cache": cache} + "tooltip": tooltip} + # "cache": cache} return data diff --git a/src/NoteView.py b/src/NoteView.py index ec07378..aa82e23 100644 --- a/src/NoteView.py +++ b/src/NoteView.py @@ -284,7 +284,6 @@ class Image(Gtk.Box): def __init__(self, data, read_only): super().__init__() if data["source"] == "url": - print(f"Has scale {data['scale']}") self.data = data self.main = Gtk.Spinner(hexpand=True) self.append(self.main) @@ -307,15 +306,17 @@ def get_image_from_url(self): loader.close() self.remove(self.main) self.main = Gtk.Image.new_from_pixbuf(loader.get_pixbuf()) - self.main.set_size_request((loader.get_pixbuf().get_width() / self.data["scale"]).__floor__(), - (loader.get_pixbuf().get_height() / self.data["scale"]).__floor__()) - # self.main.set_hexpand(True) - # self.main.set_vexpand(True) - except requests.exceptions.ConnectionError: + self.main.set_size_request((loader.get_pixbuf().get_width() * self.data["scale"]).__floor__(), + (loader.get_pixbuf().get_height() * self.data["scale"]).__floor__()) + self.main.set_vexpand(True) + except (requests.exceptions.ConnectionError, requests.exceptions.MissingSchema) as err: + self.remove(self.main) self.main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, hexpand=True) self.main.append(Gtk.Image(icon_name="auth-sim-missing-symbolic")) - self.main.append(Gtk.Label(label="Unable to get image")) + self.main.append(Gtk.Label(label="Unable to get image" + (" - No internet connection" + if isinstance(err, requests.exceptions.ConnectionError) + else " - Invalid URL"))) self.append(self.main) def save(self): diff --git a/src/Queue.py b/src/Queue.py index b73e108..1b627b3 100644 --- a/src/Queue.py +++ b/src/Queue.py @@ -21,7 +21,7 @@ def __iter__(self): return self._data def en_queue(self, item): - if not self.size == len(self._data): + if self.size != len(self._data): self._data.append(item) else: raise self.FullQueue diff --git a/src/configuration-default.toml b/src/configuration-default.toml index a9d31f2..addb385 100644 --- a/src/configuration-default.toml +++ b/src/configuration-default.toml @@ -36,5 +36,4 @@ url_source = true file_source = true wikimedia_source = false # Not implamented yet web_source = false # Not implamented yet -cache_support = false -scale_support = false \ No newline at end of file +cache_support = false \ No newline at end of file diff --git a/src/ui.py b/src/ui.py index ec06b7b..5e3a608 100644 --- a/src/ui.py +++ b/src/ui.py @@ -108,7 +108,7 @@ def new_image_dialogue(self, *args): log("Opening image dialogue") sources = self.config["image-configuration"] dialogue = ImageDialogue(sources["url_source"], sources["file_source"], sources["wikimedia_source"], - sources["web_source"], sources["cache_support"], sources["scale_support"]) + sources["web_source"], sources["cache_support"]) dialogue.present() self.inserting_image = True