Rename collection view to library. Show owned cards in library
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
|
import gi
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
|
|
||||||
# Title of the Program Window
|
# Title of the Program Window
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import gi
|
import gi
|
||||||
import collection
|
import library
|
||||||
import search
|
import search
|
||||||
import config
|
import config
|
||||||
import util
|
import util
|
||||||
@@ -84,18 +84,18 @@ class MainWindow(Gtk.Window):
|
|||||||
vbox.pack_start(self.notebook, True, True, 0)
|
vbox.pack_start(self.notebook, True, True, 0)
|
||||||
vbox.pack_start(self.status_bar, False, False, 0)
|
vbox.pack_start(self.status_bar, False, False, 0)
|
||||||
|
|
||||||
self.collectionView = Gtk.Box()
|
self.library = Gtk.Box()
|
||||||
self.collectionView.add(collection.CollectionView())
|
self.library.add(library.LibraryView())
|
||||||
|
|
||||||
self.searchView = Gtk.Box()
|
self.search = Gtk.Box()
|
||||||
self.searchView.add(search.SearchView())
|
self.search.add(search.SearchView())
|
||||||
|
|
||||||
self.deckView = Gtk.Box()
|
self.decks = Gtk.Box()
|
||||||
self.deckView.add(Gtk.Label("View and organize your Decklists!"))
|
self.decks.add(Gtk.Label("View and organize your Decklists!"))
|
||||||
|
|
||||||
self.notebook.append_page(self.searchView, Gtk.Label("Search"))
|
self.notebook.append_page(self.search, Gtk.Label("Search"))
|
||||||
self.notebook.append_page(self.collectionView, Gtk.Label("Collection"))
|
self.notebook.append_page(self.library, Gtk.Label("Library"))
|
||||||
self.notebook.append_page(self.deckView, Gtk.Label("Decks"))
|
self.notebook.append_page(self.decks, Gtk.Label("Decks"))
|
||||||
|
|
||||||
self.add(vbox)
|
self.add(vbox)
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
import os
|
import os
|
||||||
|
import util
|
||||||
|
import details
|
||||||
import gi
|
import gi
|
||||||
from psutil._compat import xrange
|
from psutil._compat import xrange
|
||||||
|
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gtk, GdkPixbuf
|
from gi.repository import Gtk, GdkPixbuf
|
||||||
|
|
||||||
|
|
||||||
class CollectionView(Gtk.Grid):
|
class LibraryView(Gtk.Grid):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Gtk.Grid.__init__(self)
|
Gtk.Grid.__init__(self)
|
||||||
|
self.set_column_spacing(5)
|
||||||
|
|
||||||
|
# Dictionary to keep link IDs in Flowbox to IDs of Cards
|
||||||
|
self.flowbox_ids = {}
|
||||||
|
|
||||||
|
# region Demo left bar
|
||||||
# Search Box
|
# Search Box
|
||||||
self.searchbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
self.searchbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
||||||
self.searchEntry = Gtk.Entry()
|
self.searchEntry = Gtk.Entry()
|
||||||
@@ -28,46 +33,52 @@ class CollectionView(Gtk.Grid):
|
|||||||
self.testRow.add(hbox)
|
self.testRow.add(hbox)
|
||||||
|
|
||||||
self.filterBox.add(self.testRow)
|
self.filterBox.add(self.testRow)
|
||||||
|
# endregion
|
||||||
|
|
||||||
# The Small Card Flow
|
# The Small Card Flow
|
||||||
self.cardScroller = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
|
self.cardScroller = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
|
||||||
self.cardScroller.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
self.cardScroller.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||||
|
|
||||||
self.cardFlow = Gtk.FlowBox()
|
self.cardFlow = Gtk.FlowBox()
|
||||||
self.cardFlow.set_valign(Gtk.Align.START)
|
self.cardFlow.set_valign(Gtk.Align.START)
|
||||||
self.cardFlow.set_max_children_per_line(50)
|
self.cardFlow.set_max_children_per_line(50)
|
||||||
self.cardFlow.set_selection_mode(Gtk.SelectionMode.NONE)
|
self.cardFlow.set_selection_mode(Gtk.SelectionMode.SINGLE)
|
||||||
self.create_flowbox(self.cardFlow)
|
self.cardFlow.connect("child-activated", self.card_clicked)
|
||||||
self.cardScroller.add(self.cardFlow)
|
self.cardScroller.add(self.cardFlow)
|
||||||
|
|
||||||
# Detailed Card View
|
# Detailed Card View
|
||||||
self.detailBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
self.details = details.DetailBar()
|
||||||
|
|
||||||
# Big Picture of the selected Card
|
|
||||||
self.image_area = Gtk.Box()
|
|
||||||
self.bigCard = Gtk.Image()
|
|
||||||
self.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.dirname(__file__) + '/resources/images/demo.jpg', 63 * 4, 88 * 4)
|
|
||||||
self.bigCard.set_from_pixbuf(self.pixbuf)
|
|
||||||
self.image_area.add(self.bigCard)
|
|
||||||
self.detailBox.add(self.image_area)
|
|
||||||
|
|
||||||
# Sta-ts and Details about the selected Card
|
|
||||||
self.stat_listbox = Gtk.ListBox()
|
|
||||||
self.stat_listbox.set_selection_mode(Gtk.SelectionMode.NONE)
|
|
||||||
self.test_statrow = Gtk.ListBoxRow()
|
|
||||||
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
|
|
||||||
hbox.add(Gtk.Label("Detail about the selected Card goes here", xalign=0))
|
|
||||||
self.test_statrow.add(hbox)
|
|
||||||
self.stat_listbox.add(self.test_statrow)
|
|
||||||
|
|
||||||
self.detailBox.add(self.stat_listbox)
|
|
||||||
|
|
||||||
|
left_pane = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
left_pane.pack_start(self.searchbox, False, False, 0)
|
||||||
|
left_pane.pack_start(self.filterBox, False, False, 0)
|
||||||
|
|
||||||
# Bring it all together
|
# Bring it all together
|
||||||
self.attach(self.searchbox, 0, 0, 1, 1)
|
self.attach(left_pane, 0, 0, 1, 1)
|
||||||
self.attach(self.filterBox, 0, 1, 1, 1)
|
self.attach(Gtk.VSeparator(), 1, 0, 1, 1)
|
||||||
self.attach(self.cardScroller, 1, 0, 1, 2)
|
self.attach(self.cardScroller, 2, 0, 1, 1)
|
||||||
self.attach(self.detailBox, 2, 0, 1, 2)
|
self.attach(Gtk.VSeparator(), 3, 0, 1, 1)
|
||||||
|
self.attach(self.details, 4, 0, 1, 1)
|
||||||
|
|
||||||
|
self.fill_flowbox()
|
||||||
|
|
||||||
|
def fill_flowbox(self):
|
||||||
|
id_counter = 0
|
||||||
|
for id, card in util.library.items():
|
||||||
|
image = Gtk.Image()
|
||||||
|
pixbuf = util.load_card_image(card, 63 * 2, 88 * 2)
|
||||||
|
image.set_from_pixbuf(pixbuf)
|
||||||
|
|
||||||
|
self.cardFlow.insert(image, id_counter)
|
||||||
|
|
||||||
|
self.flowbox_ids[id_counter] = card.multiverse_id
|
||||||
|
id_counter += 1
|
||||||
|
|
||||||
|
def card_clicked(self, flowbox, flowboxchild):
|
||||||
|
card_id = self.flowbox_ids[flowboxchild.get_index()]
|
||||||
|
card = util.library[card_id]
|
||||||
|
|
||||||
|
self.details.set_card_detail(card)
|
||||||
|
|
||||||
|
|
||||||
def add_test_image(self):
|
def add_test_image(self):
|
||||||
image = Gtk.Image()
|
image = Gtk.Image()
|
||||||
@@ -3,12 +3,11 @@ import details
|
|||||||
import config
|
import config
|
||||||
import threading
|
import threading
|
||||||
import gi
|
import gi
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
from mtgsdk import Card
|
from mtgsdk import Card
|
||||||
from gi.repository import Gtk, Gdk, GdkPixbuf, GObject, Pango
|
from gi.repository import Gtk, Gdk, GdkPixbuf, GObject, Pango
|
||||||
|
|
||||||
gi.require_version('Gtk', '3.0')
|
|
||||||
|
|
||||||
|
|
||||||
class SearchView(Gtk.Grid):
|
class SearchView(Gtk.Grid):
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ import gi
|
|||||||
import re
|
import re
|
||||||
import config
|
import config
|
||||||
import network
|
import network
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import GdkPixbuf, Gtk
|
from gi.repository import GdkPixbuf, Gtk
|
||||||
from PIL import Image as PImage
|
from PIL import Image as PImage
|
||||||
from urllib import request
|
from urllib import request
|
||||||
import six.moves.cPickle as pickle
|
import six.moves.cPickle as pickle
|
||||||
gi.require_version('Gtk', '3.0')
|
|
||||||
|
|
||||||
# Locally stored images for faster loading times
|
# Locally stored images for faster loading times
|
||||||
imagecache = []
|
imagecache = []
|
||||||
|
|||||||
Reference in New Issue
Block a user