Display card rulings in treeview instead of grid

This commit is contained in:
luxick
2017-07-05 15:17:47 +02:00
parent 5d037c764b
commit d33f796772
4 changed files with 71 additions and 34 deletions

View File

@@ -134,21 +134,9 @@ class Application:
# Rulings # Rulings
if card.rulings: if card.rulings:
grid = builder.get_object("rulesGrid") store = builder.get_object("rulesStore")
rows = 1
for rule in card.rulings: for rule in card.rulings:
date_label = Gtk.Label(rule["date"]) store.append([rule["date"], rule["text"]])
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: else:
builder.get_object("ruleBox").set_visible(False) builder.get_object("ruleBox").set_visible(False)
@@ -322,6 +310,14 @@ class Application:
self.push_status(card.name + " added to library") self.push_status(card.name + " added to library")
self.unsaved_changes = True 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): def remove_card_from_lib(self, card):
# Check if card is tagged # Check if card is tagged
for card_ids in self.tags.values(): for card_ids in self.tags.values():

View File

@@ -78,7 +78,8 @@ class CardList(Gtk.ScrolledWindow):
mana_cost, mana_cost,
card.cmc, card.cmc,
card.set_name, card.set_name,
color] color,
card.original_text]
self.store.append(item) self.store.append(item)
end = time.time() end = time.time()
util.log("Time to build Table: " + str(round(end - start, 3)) + "s", util.LogLevel.Info) util.log("Time to build Table: " + str(round(end - start, 3)) + "s", util.LogLevel.Info)

View File

@@ -28,6 +28,8 @@
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name color --> <!-- column-name color -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name original_text -->
<column type="gchararray"/>
</columns> </columns>
</object> </object>
<object class="GtkTreeModelFilter" id="cardStoreFiltered"> <object class="GtkTreeModelFilter" id="cardStoreFiltered">
@@ -66,6 +68,24 @@
</child> </child>
</object> </object>
</child> </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> <child>
<object class="GtkTreeViewColumn" id="col_types"> <object class="GtkTreeViewColumn" id="col_types">
<property name="resizable">True</property> <property name="resizable">True</property>

View File

@@ -2,6 +2,14 @@
<!-- Generated with glade 3.20.0 --> <!-- Generated with glade 3.20.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.20"/> <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"> <object class="GtkWindow" id="cardDetails">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="default_width">600</property> <property name="default_width">600</property>
@@ -68,29 +76,41 @@
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkViewport"> <object class="GtkTreeView" id="rulesTree">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="model">rulesStore</property>
<property name="vexpand">True</property> <property name="headers_clickable">False</property>
<child> <property name="enable_search">False</property>
<object class="GtkGrid" id="rulesGrid"> <property name="show_expanders">False</property>
<property name="visible">True</property> <child internal-child="selection">
<property name="can_focus">False</property> <object class="GtkTreeSelection">
<property name="row_spacing">10</property> <property name="mode">none</property>
<property name="column_spacing">20</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> </object>
<packing> </child>
<property name="left_attach">0</property> <child>
<property name="top_attach">0</property> <object class="GtkTreeViewColumn">
<property name="width">2</property> <property name="sizing">autosize</property>
</packing> <property name="title" translatable="yes">Date</property>
<child>
<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>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child> </child>
</object> </object>
</child> </child>