# Copyright (C) 2009, Tutorius.org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import logging import TutorialStoreCategories import TutorialStoreSearch import TutorialStoreSuggestion from TutorialStoreDetails import TutorialStoreDetails from TutorialStoreResults import TutorialStoreResults from WorkshopController import StoreController from dialogs import StoreInformationDialog import sys, os import gtk class TutorialStore(gtk.Alignment): """ Main container for the Tutorial Store part of the workshop """ def __init__(self,model): gtk.Alignment.__init__(self,0.0,0.0,1.0,1.0) self.controller = StoreController(self,model) model.set_store_view(self) self.store_home = TutorialStoreHome(self.controller) self.add(self.store_home) self.store_home.show() self.controller.get_categories() self.controller.get_popular() self.controller.get_also_like() def set_categories(self,categories): self.store_home.set_categories(categories) def set_tutorial_list(self,tutorial_list): self.store_home.set_tutorial_list(tutorial_list) def show_details(self,tutorial): self.store_home.show_details(tutorial) def set_popular(self,tutorials): self.store_home.set_popular(tutorials) def set_also_like(self,tutorials): self.store_home.set_also_like(tutorials) def display_infos(self,tutorial): self.store_home.display_infos(tutorial) def set_button_sensitive(self,back,next): self.store_home.set_button_sensitive(back,next) def show_search_result(self): self.store_home.show_search_result() class TutorialStoreHome(gtk.HBox): def __init__(self,controller): gtk.HBox.__init__(self,False,5) self.controller = controller self.categories = TutorialStoreCategories.TutorialStoreCategories(self.controller) self.search = TutorialStoreSearch.TutorialStoreSearch(self.controller) self.suggestion = TutorialStoreSuggestion.TutorialStoreSuggestion(controller) self.center_container = gtk.Alignment(0.0,0.0,1.0,1.0) self.search_result = TutorialStoreResults(self.controller) self.center_container.add(self.suggestion) tut_store_home_base = gtk.VBox(False, 5) tut_store_home_base.pack_start(self.search, False, False,10) sep = gtk.HSeparator() tut_store_home_base.pack_start(sep, False, False) tut_store_home_base.pack_start(self.center_container,True,True) self.pack_start(self.categories, True, True, 5) self.pack_start(tut_store_home_base, True, True, 5) #self.pack_start(tut_store_home_base, True, True, 5) #tut_store_suggestion.show() self.categories.show() tut_store_home_base.show() self.search.show() sep.show() self.center_container.show_all() self.suggestion.show_all() def set_categories(self,categories): self.categories.set_categories(categories) self.search.set_categories(categories) def display_infos(self,tutorial): dialog = StoreInformationDialog(tutorial) dialog.run() dialog.destroy() def set_popular(self,tutorials): self.suggestion.set_popular(tutorials) def set_also_like(self,tutorials): self.suggestion.set_also_like(tutorials) def set_tutorial_list(self,tutorial_list): self.search_result.set_tutorial_list(tutorial_list) for child in self.center_container: self.center_container.remove(child) self.center_container.add(self.search_result) self.search_result.show() def show_details(self,tutorial): self.details = TutorialStoreDetails(tutorial,self.controller) for child in self.center_container: self.center_container.remove(child) self.center_container.add(self.details) self.details.show() def show_search_result(self): for child in self.center_container: self.center_container.remove(child) self.center_container.add(self.search_result) self.search_result.show() def get_results_widget(self): self.search = TutorialStoreSearch.TutorialStoreSearch() tutorial_store_search = self.search.tutorial_store_search self.results = TutorialStoreResults.TutorialStoreResults() tutorial_store_results = self.results.tutorial_store_results self.categories = TutorialStoreCategories.TutorialStoreCategories() categories_frame = self.categories.categorie_box_frame tut_store_home_base = gtk.VBox(False, 5) tut_store_home_base.pack_start(tutorial_store_search, False, False, 25) tut_store_home_base.pack_start(tutorial_store_results, False, False, 0) self.tutorial_store_home = gtk.HBox(False, 5) self.tutorial_store_home.pack_start(categories_frame, True, True, 5) self.tutorial_store_home.pack_start(tut_store_home_base, True, True, 5) tut_store_home_base.show() tutorial_store_search.show() tutorial_store_results.show() categories_frame.show() self.tutorial_store_home.show() return self.tutorial_store_home def get_details_widget(self): self.search = TutorialStoreSearch.TutorialStoreSearch() tutorial_store_search = self.search.tutorial_store_search self.details = TutorialStoreDetails.TutorialStoreDetails() tutorial_store_details = self.details.tutorial_store_details self.categories = TutorialStoreCategories.TutorialStoreCategories() categories_frame = self.categories.categorie_box_frame tut_store_home_base = gtk.VBox(False, 5) tut_store_home_base.pack_start(tutorial_store_search, False, False, 25) tut_store_home_base.pack_start(tutorial_store_details, False, False, 0) self.tutorial_store_home = gtk.HBox(False, 5) self.tutorial_store_home.pack_start(categories_frame, True, True, 5) self.tutorial_store_home.pack_start(tut_store_home_base, True, True, 5) tut_store_home_base.show() tutorial_store_search.show() tutorial_store_details.show() categories_frame.show() self.tutorial_store_home.show() return self.tutorial_store_home def set_button_sensitive(self,back,next): self.search_result.set_button_sensitive(back,next)