Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add in support for GIF cover images via the new support in pyifbabel
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b8bb5542ae2b1e31f779cd2d6385cb6925d057f3
User & Date: brandon 2018-11-08 23:22:57
Context
2018-11-08
23:33
Support HTTPS in IFDB URLs check-in: 51383353b7 user: brandon tags: trunk
23:22
Add in support for GIF cover images via the new support in pyifbabel check-in: b8bb5542ae user: brandon tags: trunk
2018-10-31
22:33
Change IFDB connection limit to something slightly more reasonable. check-in: 9a9a4f651b user: brandon tags: trunk
Changes

Changes to src/grotesque/db/addremove.py.

188
189
190
191
192
193
194


195
196
197
198
199
200
201
        if data is None:
            return False
        img_format = _imgfuncs.deduce_img_format(data)
        if img_format == "jpeg":
            width, height = _imgfuncs.get_jpeg_dim(data)
        elif img_format == "png":
            width, height = _imgfuncs.get_png_dim(data)


        else:
            biblio = query.select_story(conn, story_id)
            warnings.warn("unsupported image format for {0}".format(
                biblio["title"]))
            return False
        description = None
        query.insert_cover(







>
>







188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
        if data is None:
            return False
        img_format = _imgfuncs.deduce_img_format(data)
        if img_format == "jpeg":
            width, height = _imgfuncs.get_jpeg_dim(data)
        elif img_format == "png":
            width, height = _imgfuncs.get_png_dim(data)
        elif img_format == "gif":
            width, height = _imgfuncs.get_gif_dim(data)
        else:
            biblio = query.select_story(conn, story_id)
            warnings.warn("unsupported image format for {0}".format(
                biblio["title"]))
            return False
        description = None
        query.insert_cover(

Changes to src/grotesque/ui/gtk3/dialogs/editdialog.py.

486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
....
1131
1132
1133
1134
1135
1136
1137


1138
1139
1140
1141
1142
1143
1144
        button_box.pack_start(import_button, False, False, PADDING)
        button_box.pack_start(remove_button, False, False, PADDING)
        vbox.add(button_box)
        return vbox

    def _refresh_coverart(self):
        cover_row = db.query.select_cover_by_story(self.conn, self.story_id)
        if not cover_row or cover_row["format"] not in ["jpeg", "png"]:
            self._cover_widgets["image"].clear()
            return
        self._cover_widgets["format"].set_text(cover_row["format"])
        self._cover_widgets["dimensions"].set_text(
            "{0}x{1} (pixels)".format(cover_row["width"], cover_row["height"]))
        if cover_row["description"] is not None:
            self._cover_widgets["description"].set_text(
................................................................................
        if not cover_data or cover_data == "No image is available":
            return
        img_format = _imgfuncs.deduce_img_format(cover_data)
        if img_format == "jpeg":
            width, height = _imgfuncs.get_jpeg_dim(cover_data)
        elif img_format == "png":
            width, height = _imgfuncs.get_png_dim(cover_data)


        else:
            d = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.OK)
            d.set_markup("Unknown image format")
            d.run()
            d.destroy()







|







 







>
>







486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
....
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
        button_box.pack_start(import_button, False, False, PADDING)
        button_box.pack_start(remove_button, False, False, PADDING)
        vbox.add(button_box)
        return vbox

    def _refresh_coverart(self):
        cover_row = db.query.select_cover_by_story(self.conn, self.story_id)
        if not cover_row or cover_row["format"] not in ["jpeg", "png", "gif"]:
            self._cover_widgets["image"].clear()
            return
        self._cover_widgets["format"].set_text(cover_row["format"])
        self._cover_widgets["dimensions"].set_text(
            "{0}x{1} (pixels)".format(cover_row["width"], cover_row["height"]))
        if cover_row["description"] is not None:
            self._cover_widgets["description"].set_text(
................................................................................
        if not cover_data or cover_data == "No image is available":
            return
        img_format = _imgfuncs.deduce_img_format(cover_data)
        if img_format == "jpeg":
            width, height = _imgfuncs.get_jpeg_dim(cover_data)
        elif img_format == "png":
            width, height = _imgfuncs.get_png_dim(cover_data)
        elif img_format == "gif":
            width, height = _imgfuncs.get_gif_dim(cover_data)
        else:
            d = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.OK)
            d.set_markup("Unknown image format")
            d.run()
            d.destroy()

Changes to src/grotesque/ui/gtk3/info/infopaned.py.

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

        '''
        if story_id is not None:
            cover_row = db.query.select_cover_by_story(self.conn, story_id)
        # If the file doesn't have coverart, display the label...
        # if not self.coverart_file or not os.path.exists(self.coverart_file):
        if (story_id is None or not cover_row or
                cover_row["format"] not in ["jpeg", "png"]):
            if self.coverart in self.get_children():
                self.remove(self.coverart)
                self.add1(self.no_coverart_label)
            return
        # ...otherwise display the coverart.
        if self.no_coverart_label in self.get_children():
            self.remove(self.no_coverart_label)







|







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

        '''
        if story_id is not None:
            cover_row = db.query.select_cover_by_story(self.conn, story_id)
        # If the file doesn't have coverart, display the label...
        # if not self.coverart_file or not os.path.exists(self.coverart_file):
        if (story_id is None or not cover_row or
                cover_row["format"] not in ["jpeg", "png", "gif"]):
            if self.coverart in self.get_children():
                self.remove(self.coverart)
                self.add1(self.no_coverart_label)
            return
        # ...otherwise display the coverart.
        if self.no_coverart_label in self.get_children():
            self.remove(self.no_coverart_label)