diff --git a/cardvault/gui/detailswindow.glade b/cardvault/gui/detailswindow.glade index 865b0be..4f864d3 100644 --- a/cardvault/gui/detailswindow.glade +++ b/cardvault/gui/detailswindow.glade @@ -4,20 +4,28 @@ False + 600 True False + False + False + 5 + 5 True False start + 10 + 5 True False end + start 2 Card Name: right @@ -32,6 +40,7 @@ True False + start Loading... 0.10000000149011612 @@ -49,6 +58,7 @@ True False end + start 2 Type: right @@ -63,6 +73,7 @@ True False + start Loading... 0.10000000149011612 @@ -76,6 +87,7 @@ True False end + start 2 Rarity: right @@ -90,6 +102,7 @@ True False + start Loading... 0.10000000149011612 @@ -103,6 +116,7 @@ True False end + start 2 Release: right @@ -117,6 +131,7 @@ True False + start Loading... 0.10000000149011612 @@ -130,6 +145,7 @@ True False end + start 2 Edition: right @@ -144,6 +160,7 @@ True False + start Loading... 0.10000000149011612 @@ -157,6 +174,7 @@ True False end + start 2 Other Printings: right @@ -171,6 +189,7 @@ True False + start Loading... True 50 @@ -181,12 +200,29 @@ 5 + + + True + False + start + 2 + 2 + + + + + + 1 + 6 + + True False end - Legalities: + start + Legality: right 0.89999997615814209 @@ -195,33 +231,9 @@ 6 - - - True - False - Loading... - 0.10000000149011612 - - - 1 - 6 - - - - - - - - - - - - - - - 1 + 2 0 @@ -239,14 +251,92 @@ - + + True + False + center + vertical + + + 1 + 0 + - + + True + False + True + vertical + + + True + False + Rulings + + + + + + False + True + 0 + + + + + 200 + True + True + True + True + in + + + True + False + True + True + + + True + False + 10 + 20 + + + True + False + start + vertical + + + 0 + 0 + 2 + + + + + + + + + False + True + 1 + + + + + 0 + 1 + 3 + - + diff --git a/cardvault/gui/overlays.glade b/cardvault/gui/overlays.glade index ddb7a29..7f1afd7 100644 --- a/cardvault/gui/overlays.glade +++ b/cardvault/gui/overlays.glade @@ -73,6 +73,7 @@ True False + True center center 10 @@ -81,6 +82,7 @@ True False + True end 100 edit-find-symbolic @@ -94,6 +96,7 @@ True False + True center Search @@ -110,6 +113,7 @@ True False + True start Use the entry on the left to search for cards diff --git a/cardvault/handlers.py b/cardvault/handlers.py index a6f5bdd..d73aa79 100644 --- a/cardvault/handlers.py +++ b/cardvault/handlers.py @@ -26,7 +26,7 @@ class Handlers: container = self.app.ui.get_object("contentPage") new_page = self.app.pages[item.get_name()] if self.app.current_page: - container.remove(self.app.current_page) + container.remove(self.app.current_page) self.app.current_page = new_page container.pack_start(self.app.current_page, True, True, 0) container.show_all() diff --git a/cardvault/util.py b/cardvault/util.py index 76e1f6a..9027069 100644 --- a/cardvault/util.py +++ b/cardvault/util.py @@ -26,6 +26,12 @@ status_bar = None app = None unsaved_changes = False +legality_colors ={ + "Banned": "#C65642", + "Restricted": "#D39F30", + "Legal": "#62B62F" +} + rarity_dict = { "special": 0, "common": 1, diff --git a/cardvault/window.py b/cardvault/window.py index 114eea4..3d8d6f2 100644 --- a/cardvault/window.py +++ b/cardvault/window.py @@ -2,8 +2,9 @@ import config import handlers import util import search_funct +import re import gi -from gi.repository import Gtk +from gi.repository import Gtk, Pango gi.require_version('Gtk', '3.0') @@ -62,8 +63,6 @@ class MainWindow: pixbuf = util.load_card_image(card, 63 * 5, 88 * 5) image = Gtk.Image().new_from_pixbuf(pixbuf) container.add(image) - - # Name builder.get_object("cardName").set_text(card.name) # Types @@ -82,12 +81,58 @@ class MainWindow: prints = [] for set in card.printings: prints.append(util.set_dict[set].name) - builder.get_object("cardPrintings").set_text(", ".join(prints)) # Legalities - #builder.get_object("cardLegalities").set_text(", ".join(card.legalities)) + grid = builder.get_object("legalitiesGrid") + rows = 1 + for legality in card.legalities: + date_label = Gtk.Label() + date_label.set_halign(Gtk.Align.END) + text_label = Gtk.Label() + text_label.set_line_wrap_mode(Pango.WrapMode.WORD) + text_label.set_line_wrap(True) + text_label.set_halign(Gtk.Align.END) + color = util.legality_colors[legality["legality"]] + date_label.set_markup("" + legality["format"] + ":" + "") + text_label.set_markup("" + legality["legality"] + "") + grid.attach(date_label, 0, rows + 2, 1, 1) + grid.attach(text_label, 1, rows + 2, 1, 1) + + rows += 1 + grid.show_all() + + # Rulings + if card.rulings: + grid = builder.get_object("rulesGrid") + rows = 1 + for rule in card.rulings: + date_label = Gtk.Label(rule["date"]) + text_label = Gtk.Label(rule["text"]) + text_label.set_line_wrap_mode(Pango.WrapMode.WORD) + text_label.set_line_wrap(True) + text_label.set_justify(Gtk.Justification.LEFT) + text_label.set_halign(Gtk.Align.START) + + grid.attach(date_label, 0, rows+2, 1, 1) + grid.attach(text_label, 1, rows+2, 1, 1) + + rows += 1 + grid.show_all() + else: + builder.get_object("ruleBox").set_visible(False) + window.show_all() + def eval_key_pressed(widget,event): + key, modifier = Gtk.accelerator_parse('Escape') + keyval = event.keyval + if keyval == key: + window.destroy() + + window.connect("key-press-event", eval_key_pressed) + + + win = MainWindow() Gtk.main()