Display card rulings in treeview instead of grid
This commit is contained in:
@@ -134,21 +134,9 @@ class Application:
|
||||
|
||||
# Rulings
|
||||
if card.rulings:
|
||||
grid = builder.get_object("rulesGrid")
|
||||
rows = 1
|
||||
store = builder.get_object("rulesStore")
|
||||
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()
|
||||
store.append([rule["date"], rule["text"]])
|
||||
else:
|
||||
builder.get_object("ruleBox").set_visible(False)
|
||||
|
||||
@@ -322,6 +310,14 @@ class Application:
|
||||
self.push_status(card.name + " added to library")
|
||||
self.unsaved_changes = True
|
||||
|
||||
def bulk_add_card_to_lib(self, cards: list, tag: str = None):
|
||||
for card in cards:
|
||||
self.add_card_to_lib(card, tag)
|
||||
util.log("Added {} cards to library.".format(str(len(cards))), util.LogLevel.Info)
|
||||
self.push_status("Added {} cards to library.".format(str(len(cards))))
|
||||
|
||||
|
||||
|
||||
def remove_card_from_lib(self, card):
|
||||
# Check if card is tagged
|
||||
for card_ids in self.tags.values():
|
||||
|
||||
@@ -78,7 +78,8 @@ class CardList(Gtk.ScrolledWindow):
|
||||
mana_cost,
|
||||
card.cmc,
|
||||
card.set_name,
|
||||
color]
|
||||
color,
|
||||
card.original_text]
|
||||
self.store.append(item)
|
||||
end = time.time()
|
||||
util.log("Time to build Table: " + str(round(end - start, 3)) + "s", util.LogLevel.Info)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name color -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name original_text -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkTreeModelFilter" id="cardStoreFiltered">
|
||||
@@ -66,6 +68,24 @@
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="col_text">
|
||||
<property name="visible">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="sizing">autosize</property>
|
||||
<property name="title" translatable="yes">Card Text</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="wrap_mode">word-char</property>
|
||||
<property name="wrap_width">400</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="foreground">11</attribute>
|
||||
<attribute name="text">12</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="col_types">
|
||||
<property name="resizable">True</property>
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkListStore" id="rulesStore">
|
||||
<columns>
|
||||
<!-- column-name date -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name rule -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkWindow" id="cardDetails">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="default_width">600</property>
|
||||
@@ -68,29 +76,41 @@
|
||||
<property name="vexpand">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<object class="GtkTreeView" id="rulesTree">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">rulesStore</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="show_expanders">False</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection">
|
||||
<property name="mode">none</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid" id="rulesGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="column_spacing">20</property>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">autosize</property>
|
||||
<property name="title" translatable="yes">Date</property>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Rule</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="wrap_mode">word-char</property>
|
||||
<property name="wrap_width">300</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
Reference in New Issue
Block a user