Not logged in

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

Overview
Comment:Fix marking games as played, again
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2755d3986ef7fa7f64773dfabf4f556a01465a27
User & Date: brandon 2018-11-11 21:43:33
Context
2018-11-11
22:29
Explicitly set the locale correctly check-in: c4b4b0b501 user: brandon tags: trunk
21:43
Fix marking games as played, again check-in: 2755d3986e user: brandon tags: trunk
21:28
Fix missing argument to functions check-in: 21481e42af user: brandon tags: trunk
Changes

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

1295
1296
1297
1298
1299
1300
1301


1302
1303
1304
1305
1306
1307
1308
            field = field.replace(" ", "")
        db.query.update_release(self.conn, ifid, {field: new_text})
        self.release_store.set_value(row_iter, col_num, new_text)
        self.edited = True

    def _on_add_resource(self, button):
        story_row = db.query.select_story(self.conn, self.story_id)


        default_rel = story_row["default_release"]
        default_rel_row = db.query.select_release(self.conn, default_rel)
        default_rel_uri = default_rel_row["uri"]
        default_rel_dir = os.path.dirname(default_rel_uri)
        file_chooser = Gtk.FileChooserDialog(
            "Select the location of the resource file", self,
            Gtk.FileChooserAction.OPEN,







>
>







1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
            field = field.replace(" ", "")
        db.query.update_release(self.conn, ifid, {field: new_text})
        self.release_store.set_value(row_iter, col_num, new_text)
        self.edited = True

    def _on_add_resource(self, button):
        story_row = db.query.select_story(self.conn, self.story_id)
        if story_row is None:
            return
        default_rel = story_row["default_release"]
        default_rel_row = db.query.select_release(self.conn, default_rel)
        default_rel_uri = default_rel_row["uri"]
        default_rel_dir = os.path.dirname(default_rel_uri)
        file_chooser = Gtk.FileChooserDialog(
            "Select the location of the resource file", self,
            Gtk.FileChooserAction.OPEN,

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

44
45
46
47
48
49
50


51
52
53
54
55
56
57
...
188
189
190
191
192
193
194
195

196
197
198
199
200

201
202
203
204
205
206
207
...
239
240
241
242
243
244
245
246

247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
        # text, 14: IFDB rating text, 15: star rating float, 16: IFDB
        # rating float, 17: story id, 18: text weight
        self.list_store = Gtk.ListStore(bool, str, str, str, str, str, str,
                                        str, str, int, str, str, str, str, str,
                                        float, float, int, Pango.Weight)
        self.list_store.set_sort_column_id(1, Gtk.SortType.ASCENDING)
        self.list_store.set_sort_func(1, self._sort, None)


        # The following Filterstores keep track of which authors, years, etc
        # are currently represented in the library so the user may filter it by
        # them.
        self.author_store = FilterStore(self.conn, db.query.select_all_authors)
        self.year_store = FilterStore(self.conn, self._all_pub_years)
        self.genre_store = FilterStore(self.conn, db.query.select_all_genres)
        self.group_store = FilterStore(self.conn, db.query.select_all_groups)
................................................................................
        story_id = self.get_story_id(row_iter)
        annot_row = db.query.select_annotation_by_story(self.conn, story_id)
        cur_played = annot_row["played"]
        if cur_played:
            self.list_store.set_value(row_iter, 0, False)
            db.query.update_annotation(self.conn, annot_row["id"],
                                 {"played": False})
            self.list_store.set_value(row_iter, 17, Pango.Weight.BOLD)

        else:
            self.list_store.set_value(row_iter, 0, True)
            db.query.update_annotation(self.conn, annot_row["id"],
                                 {"played": True})
            self.list_store.set_value(row_iter, 17, Pango.Weight.NORMAL)


    def refresh_ifdb(self, row_iter):
        """Refresh a story's IFDB annotation (rating, etc.)."""
        story_id = self.get_story_id(row_iter)
        ifdb_annot_row = db.query.select_ifdb_annotation_by_story(
            self.conn, story_id)
        if not ifdb_annot_row:
................................................................................

    def mark_story_played(self, row_iter):
        """Mark a story as having been played."""
        story_id = self.get_story_id(row_iter)
        annot_row = db.query.select_annotation_by_story(self.conn, story_id)
        db.query.update_annotation(self.conn, annot_row["id"], {"played": True})
        self.list_store.set_value(row_iter, 0, True)
        self.list_store.set_value(row_iter, 17, Pango.Weight.NORMAL)


    def get_story_id(self, row_iter):
        """This is a small helper method to return a story file."""
        if row_iter is None:
            return None
        return self.list_store.get_value(row_iter, 17)

    def _sort(self, model, iter1, iter2, data):
        col, _ = model.get_sort_column_id()
        value1 = model.get_value(iter1, col)
        value2 = model.get_value(iter2, col)
        if value1 is None:
            return 1
        elif value2 is None:
            return -1
        return locale.strcoll(value1, value2)







>
>







 







|
>




|
>







 







|
>





|










44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
        # text, 14: IFDB rating text, 15: star rating float, 16: IFDB
        # rating float, 17: story id, 18: text weight
        self.list_store = Gtk.ListStore(bool, str, str, str, str, str, str,
                                        str, str, int, str, str, str, str, str,
                                        float, float, int, Pango.Weight)
        self.list_store.set_sort_column_id(1, Gtk.SortType.ASCENDING)
        self.list_store.set_sort_func(1, self._sort, None)
        self.story_id_col = 17
        self.weight_col = 18
        # The following Filterstores keep track of which authors, years, etc
        # are currently represented in the library so the user may filter it by
        # them.
        self.author_store = FilterStore(self.conn, db.query.select_all_authors)
        self.year_store = FilterStore(self.conn, self._all_pub_years)
        self.genre_store = FilterStore(self.conn, db.query.select_all_genres)
        self.group_store = FilterStore(self.conn, db.query.select_all_groups)
................................................................................
        story_id = self.get_story_id(row_iter)
        annot_row = db.query.select_annotation_by_story(self.conn, story_id)
        cur_played = annot_row["played"]
        if cur_played:
            self.list_store.set_value(row_iter, 0, False)
            db.query.update_annotation(self.conn, annot_row["id"],
                                 {"played": False})
            self.list_store.set_value(row_iter, self.weight_col,
                                      Pango.Weight.BOLD)
        else:
            self.list_store.set_value(row_iter, 0, True)
            db.query.update_annotation(self.conn, annot_row["id"],
                                 {"played": True})
            self.list_store.set_value(row_iter, self.weight_col,
                                      Pango.Weight.NORMAL)

    def refresh_ifdb(self, row_iter):
        """Refresh a story's IFDB annotation (rating, etc.)."""
        story_id = self.get_story_id(row_iter)
        ifdb_annot_row = db.query.select_ifdb_annotation_by_story(
            self.conn, story_id)
        if not ifdb_annot_row:
................................................................................

    def mark_story_played(self, row_iter):
        """Mark a story as having been played."""
        story_id = self.get_story_id(row_iter)
        annot_row = db.query.select_annotation_by_story(self.conn, story_id)
        db.query.update_annotation(self.conn, annot_row["id"], {"played": True})
        self.list_store.set_value(row_iter, 0, True)
        self.list_store.set_value(row_iter, self.weight_col,
                                  Pango.Weight.NORMAL)

    def get_story_id(self, row_iter):
        """This is a small helper method to return a story file."""
        if row_iter is None:
            return None
        return self.list_store.get_value(row_iter, self.story_id_col)

    def _sort(self, model, iter1, iter2, data):
        col, _ = model.get_sort_column_id()
        value1 = model.get_value(iter1, col)
        value2 = model.get_value(iter2, col)
        if value1 is None:
            return 1
        elif value2 is None:
            return -1
        return locale.strcoll(value1, value2)