Exemplo n.º 1
0
	def __init__(self, app):
		Gtk.ApplicationWindow.__init__(self,
		                               application=app,
		                               title=app.fullname)
		self.set_wmclass (app.fullname, app.fullname)
		self.set_default_icon_name(app.simplename)
		
		self.app = app
		
		self.set_size_request(887, 640)
		self.set_position(Gtk.WindowPosition.CENTER)
		
		
		self.headerbar = HeaderBar ()
		
		allgames = self.app.gamesdb.get_games ()
		self.gamelist = GameList(allgames)
		
		mostusedgames = self.app.gamesdb.get_most_used_games ()[:20]
		self.mostusedgamelist = GameList(mostusedgames)
		
		self.gameview = GameView()
		
		self.set_titlebar (self.headerbar)
		
		self.stack = Gtk.Stack ()
		self.stack.set_transition_type (Gtk.StackTransitionType.CROSSFADE)
		self.stack.show ()
		
		self.stack.add_titled (self.mostusedgamelist, 'frequent', 'Frequently used')
		self.stack.add_titled (self.gamelist, 'all', 'All')
		self.stack.add (self.gameview)
		
		self.add(self.stack)
		
		self.switcher = Gtk.StackSwitcher()
		self.switcher.set_stack(self.stack)
		
		self.headerbar.previous_button.connect('clicked', self.on_previous_clicked)
		self.headerbar.add_games_button.connect('clicked', self.on_add_games_clicked)
		self.headerbar.play_game_button.connect('clicked', self.on_play_game_clicked)
		self.gamelist.connect('game_clicked', self.on_game_clicked)
		self.mostusedgamelist.connect('game_clicked', self.on_game_clicked)
		
		self.headerbar.show ()
		self.switcher.show()
		self.gamelist.show ()
		self.mostusedgamelist.show ()
		self.gameview.show ()
		
		self.set_mode ('list')
Exemplo n.º 2
0
class Window(Gtk.ApplicationWindow):
	__gsignals__ = {
		'play_clicked': (GObject.SIGNAL_RUN_FIRST, None, (object,))
	}
	
	def __init__(self, app):
		Gtk.ApplicationWindow.__init__(self,
		                               application=app,
		                               title=app.fullname)
		self.set_wmclass (app.fullname, app.fullname)
		self.set_default_icon_name(app.simplename)
		
		self.app = app
		
		self.set_size_request(887, 640)
		self.set_position(Gtk.WindowPosition.CENTER)
		
		
		self.headerbar = HeaderBar ()
		
		allgames = self.app.gamesdb.get_games ()
		self.gamelist = GameList(allgames)
		
		mostusedgames = self.app.gamesdb.get_most_used_games ()[:20]
		self.mostusedgamelist = GameList(mostusedgames)
		
		self.gameview = GameView()
		
		self.set_titlebar (self.headerbar)
		
		self.stack = Gtk.Stack ()
		self.stack.set_transition_type (Gtk.StackTransitionType.CROSSFADE)
		self.stack.show ()
		
		self.stack.add_titled (self.mostusedgamelist, 'frequent', 'Frequently used')
		self.stack.add_titled (self.gamelist, 'all', 'All')
		self.stack.add (self.gameview)
		
		self.add(self.stack)
		
		self.switcher = Gtk.StackSwitcher()
		self.switcher.set_stack(self.stack)
		
		self.headerbar.previous_button.connect('clicked', self.on_previous_clicked)
		self.headerbar.add_games_button.connect('clicked', self.on_add_games_clicked)
		self.headerbar.play_game_button.connect('clicked', self.on_play_game_clicked)
		self.gamelist.connect('game_clicked', self.on_game_clicked)
		self.mostusedgamelist.connect('game_clicked', self.on_game_clicked)
		
		self.headerbar.show ()
		self.switcher.show()
		self.gamelist.show ()
		self.mostusedgamelist.show ()
		self.gameview.show ()
		
		self.set_mode ('list')
	
	def on_previous_clicked(self, button):
		self.set_mode ('list')
	
	def on_add_games_clicked(self, button):
		print ("add games clicked")
	
	def on_play_game_clicked(self, button):
		self.emit("play_clicked", self.game)
	
	def on_game_clicked(self, view, game):
		self.game = game
		self.gameview.set_game (game, self.app.gamesdb.get_play_info (game))
		self.set_mode ('game')
	
	def set_mode (self, mode):
		if mode == 'list':
			self.stack.set_visible_child (self.gamelist)
			
			self.headerbar.previous_button.hide ()
			self.headerbar.add_games_button.show ()
			self.headerbar.play_game_button.hide ()
			
			self.headerbar.set_title (self.app.fullname)
			self.headerbar.set_custom_title (self.switcher)
		
		elif mode == 'game':
			self.stack.set_visible_child (self.gameview)
			
			self.headerbar.previous_button.show ()
			self.headerbar.add_games_button.hide ()
			self.headerbar.play_game_button.show ()
			
			self.headerbar.set_title (self.game.get_info ('common_title').get_property ('common_title'))
			self.headerbar.set_custom_title (None)