Not logged in

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

Overview
Comment:Show releases in the infoview
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2acb6cb32a9ee970df79e50cacae1869c919f509
User & Date: brandon 2018-11-14 21:39:05
Context
2018-11-14
22:12
Decrease right info panel width a bit check-in: 9c8f793655 user: brandon tags: trunk
21:39
Show releases in the infoview check-in: 2acb6cb32a user: brandon tags: trunk
2018-11-13
23:23
Check if a cover exists before trying to import a new one; update the old one if it exists. Also, update the insert_cover query to account for the comments field. check-in: 8f79b7799b user: brandon tags: trunk
Changes

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

235
236
237
238
239
240
241
242
243
244

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
            command = None
        addremove.add_story_release(conn, story_id, ifid, ifformat,
                                        command, os.path.realpath(filename))
    query.update_story(conn, story_id, {"default_release": story_files[0][0]})
    return (story_id, False)


def launch_story(conn, settings, story_id):
    if story_id is None:
        raise ValueError("No story specified")

    story = query.select_story(conn, story_id)
    release_id = story["default_release"]
    if not release_id:
        releases = query.select_releases_by_story(conn, story_id)
        if not releases:
            raise ValueError("No releases found for story")
        release_id = releases[0]["id"]
        if not release_id:
            raise ValueError("No releases found for story")
    launch_release(conn, settings, release_id)


def launch_release(conn, settings, release_id):
    if release_id is None:
        raise ValueError("No story or release specified")
    release = query.select_release(conn, release_id)







|


>
|
|
|
|
|
|
|
|
|







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
            command = None
        addremove.add_story_release(conn, story_id, ifid, ifformat,
                                        command, os.path.realpath(filename))
    query.update_story(conn, story_id, {"default_release": story_files[0][0]})
    return (story_id, False)


def launch_story(conn, settings, story_id, release_id=None):
    if story_id is None:
        raise ValueError("No story specified")
    if release_id is None:
        story = query.select_story(conn, story_id)
        release_id = story["default_release"]
        if not release_id:
            releases = query.select_releases_by_story(conn, story_id)
            if not releases:
                raise ValueError("No releases found for story")
            release_id = releases[0]["id"]
            if not release_id:
                raise ValueError("No releases found for story")
    launch_release(conn, settings, release_id)


def launch_release(conn, settings, release_id):
    if release_id is None:
        raise ValueError("No story or release specified")
    release = query.select_release(conn, release_id)

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

276
277
278
279
280
281
282






















































283
284
285
286
287
288
289
...
364
365
366
367
368
369
370

371
372
373
374
375
376
377
        else:
            forgiveness = "Unknown"
        text_buffer.insert(text_iter, 'Forgiveness: ')
        text_buffer.insert_with_tags(
            text_iter,
            u'{0}\n'.format(forgiveness),
            tag_table.lookup('info'))























































    def _render_urls(self, text_buffer, text_iter, story_row):
        url_added = False
        if story_row["url"]:
            text_buffer.insert(text_iter, "On the web:\n")
            url_anchor = text_buffer.create_child_anchor(text_iter)
            url_label = Gtk.Label()
................................................................................
        self._insert_blank_line(biblio_buffer, biblio_iter)
        info_buffer = self.info_view.get_buffer()
        info_iter = info_buffer.get_start_iter()
        info_tag_table = info_buffer.get_tag_table()
        self._render_rating(info_buffer, info_iter, info_tag_table, story_row)
        self._render_info(info_buffer, info_iter, info_tag_table, story_row)
        self._insert_blank_line(info_buffer, info_iter)

        self._render_urls(info_buffer, info_iter, story_row)
        self._render_resources(info_buffer, info_iter, info_tag_table, story_row)

    def clear(self):
        '''This is a helper method to clear the contents of the view.

        '''







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>







276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
...
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
        else:
            forgiveness = "Unknown"
        text_buffer.insert(text_iter, 'Forgiveness: ')
        text_buffer.insert_with_tags(
            text_iter,
            u'{0}\n'.format(forgiveness),
            tag_table.lookup('info'))

    def _render_releases(self, text_buffer, text_iter, story_row):
        story_id = story_row["id"]
        story_releases_full = db.query.select_releases_by_story(self.conn,
                                                                story_id)
        story_releases = [release for release in story_releases_full
                          if release["uri"]]
        text_buffer.insert(text_iter, "Releases:\n")
        for release in story_releases:
            default = release["ifid"] == story_row["default_release"]
            rel_format_id = release["format_id"]
            rel_format_rec = db.query.select_format(self.conn, rel_format_id)
            if rel_format_rec is None:
                continue
            rel_format = rel_format_rec["name"]
            rel_uri = release["uri"]
            rel_comment = release["comment"]
            if rel_comment:
                rel_note = ", ".join([rel_format, rel_comment])
            else:
                rel_note = rel_format
            rel_filename = os.path.basename(rel_uri)
            rel_anchor = text_buffer.create_child_anchor(text_iter)
            rel_label = Gtk.Label()
            rel_label.set_track_visited_links(False)
            if default:
                rel_label.set_markup(
                    '\t<b><a href="{0}">{1} ({2})</a></b>'.format(
                        cgi.escape(rel_uri), cgi.escape(rel_filename),
                        cgi.escape(rel_note)))
            else:
                rel_label.set_markup(
                    '\t<a href="{0}">{1} ({2})</a>'.format(
                        cgi.escape(rel_uri), cgi.escape(rel_filename),
                        cgi.escape(rel_note)))
            rel_label.connect("activate-link", self._on_release_clicked)
            self.info_view.add_child_at_anchor(rel_label, rel_anchor)
            rel_label.show()
            text_buffer.insert(text_iter, "\n")

    def _on_release_clicked(self, widget, uri):
        release_rec = db.query.select_release_by_uri(self.conn, uri)
        story_id = release_rec["story_id"]
        try:
            db.launch_story(self.conn, self.settings, story_id,
                            release_rec["ifid"])
        except ValueError as e:
            d = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.OK)
            d.set_markup(str(e))
            d.run()
            d.destroy()
            return

    def _render_urls(self, text_buffer, text_iter, story_row):
        url_added = False
        if story_row["url"]:
            text_buffer.insert(text_iter, "On the web:\n")
            url_anchor = text_buffer.create_child_anchor(text_iter)
            url_label = Gtk.Label()
................................................................................
        self._insert_blank_line(biblio_buffer, biblio_iter)
        info_buffer = self.info_view.get_buffer()
        info_iter = info_buffer.get_start_iter()
        info_tag_table = info_buffer.get_tag_table()
        self._render_rating(info_buffer, info_iter, info_tag_table, story_row)
        self._render_info(info_buffer, info_iter, info_tag_table, story_row)
        self._insert_blank_line(info_buffer, info_iter)
        self._render_releases(info_buffer, info_iter, story_row)
        self._render_urls(info_buffer, info_iter, story_row)
        self._render_resources(info_buffer, info_iter, info_tag_table, story_row)

    def clear(self):
        '''This is a helper method to clear the contents of the view.

        '''

Changes to src/grotesque/ui/gtk3/mainwindow.py.

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
GROTESQUE_VERSION = "0.10"


class MainWindow(Gtk.Window):
    '''This class implements the main Grotesque window.

    '''
    biblio_width = 640
    info_width = 240


    def __init__(self, conn, settings):
        super(MainWindow, self).__init__(type=Gtk.WindowType.TOPLEVEL)
        self.conn = conn
        # init_complete is used to block certain callbacks from happening while
        # the window is still being constructed.







|
|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
GROTESQUE_VERSION = "0.10"


class MainWindow(Gtk.Window):
    '''This class implements the main Grotesque window.

    '''
    biblio_width = 560
    info_width = 320


    def __init__(self, conn, settings):
        super(MainWindow, self).__init__(type=Gtk.WindowType.TOPLEVEL)
        self.conn = conn
        # init_complete is used to block certain callbacks from happening while
        # the window is still being constructed.