def __init__(self, db):
        Gtk.Window.__init__(self)

        self.db = db
        self.windowStack = None
        self.revealer = None
        self.headerBar = None
        self.searchBar = None
        self.imdbBox = None
        self.searchResults = None

        self.connect("key-press-event", self.key_pressed_cb)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        # stackBox = Gtk.Box()

        self.windowStack = Gtk.Stack(
            interpolate_size=True,
            transition_type=Gtk.StackTransitionType.CROSSFADE)

        self.header = HeaderBar(self, self.db)
        self.header.connect('go-back', self.goBack_cb)
        self.header.connect("random-clicked", self.random_cb)
        self.header.connect("revealer-change", self.reveal_cb)
        self.header.connect('source-change', self.sourceChange_cb)
        self.set_titlebar(self.header)

        self.searchBar = SearchBar(db)
        self.searchBar.connect("search-ran", self.searchRan_cb)

        self.searchResults = SearchResults()
        self.searchResults.connect("row-activated", self.updateIMDB_cb)
        # self.windowStack.add_named(self.searchResults, "search-results")

        # stackBox.pack_start(self.searchResults, False, False, 0)
        self.windowStack.add_named(
            self.searchResults, "search-results"
        )  # what if I implement the infobox on a stack that also includes a start typing page like the search results has right now and a choose a search result to display detailed info page

        self.windowStack.set_visible_child_name("search-results")

        self.imdbBox = InfoPage(db, "Shrek")

        # stackBox.pack_end(self.imdbBox, True, True, 0)
        self.windowStack.add_named(self.imdbBox, "movie-info")

        # credentials = LogIn()
        # locationChooser.connect("location-chosen", self.updateWin)
        # self.windowStack.add_named(credentials, "credentials")

        box.add(self.searchBar)
        box.add(self.windowStack)

        self.add(box)
Esempio n. 2
0
class SearchView(Frame):
    def __init__(self, master, *args, **kw):
        super().__init__(master, *args, **kw)
        # Configure Widget:
        self.grid_propagate(0)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(0, weight=1)
        self.grid(sticky=tkSticky.fill)

        # Create Subwidgets:
        self.treeview = Treeview(self)
        self.searchbar = SearchBar(self)
        self.treeview.grid(row=1, sticky=tkSticky.fill)
        self.searchbar.grid(row=0, sticky=tkSticky.fill)

        # Bind additional keys between widgets:
        self.setBindings()

    def hideSearchBar(self):
        self.searchbar.grid_remove()

    def showSearchBar(self):
        self.searchbar.grid()

    def setBindings(self):
        def handler(event):
            self.searchbar.cancelButton.invoke()

        self.treeview.bind(tkEvent.key.escape, handler)

        find = tkEvent.find
        self.searchbar.bind(tkEvent)
Esempio n. 3
0
    def __init__(self, master, *args, **kw):
        super().__init__(master, *args, **kw)
        # Configure Widget:
        self.grid_propagate(0)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(0, weight=1)
        self.grid(sticky=tkSticky.fill)

        # Create Subwidgets:
        self.treeview = Treeview(self)
        self.searchbar = SearchBar(self)
        self.treeview.grid(row=1, sticky=tkSticky.fill)
        self.searchbar.grid(row=0, sticky=tkSticky.fill)

        # Bind additional keys between widgets:
        self.setBindings()
Esempio n. 4
0
	def DispatchToControl(self, evt):
		evt_id = evt.GetId()
		if evt_id == wx.ID_SAVE:
			self.tx.SaveFile(self.tx.GetFileName())
			self.UpdatePageTitle()
		elif evt_id == wx.ID_FIND:
			if not isinstance(self.commandBar, SearchBar):
				cb = SearchBar( self.panLeft )
				self.panLeft.GetSizer().Replace(self.commandBar, cb)
				self.commandBar.Destroy()
				self.commandBar = cb
			self.commandBar.Show()
			self.commandBar.ctrl.SetFocus()
			self.panLeft.Layout()
			self.Layout()
		elif evt_id == wx.ID_PREVIEW:
			if self.split.IsSplit(): 
				self.LastCbWidth = self.split.GetSashPosition()
				self.split.Unsplit()
			else:
				self.split.SplitVertically( window1=self.panLeft, window2=self.panRight, sashPosition=self.LastCbWidth )
				self.cbrowser.OnUpdateTree(force=True)
			self.Layout()
			self.GetParent().Update()
		elif evt_id == wx.ID_SAVEAS:
			pass
		elif evt_id == wx.ID_FORWARD:
			self.RunCode()
		else:
			self.tx.ControlDispatch(evt)
Esempio n. 5
0
    def __init__(self, search_handler, item_renderer, *columns):

        self.__search_handler = search_handler

        # build bookmarks list
        self.__bookmarks = BookmarkList()
        self.__browser = gtk.VBox()

        # build search bar
        self.__searchbar = SearchBar()
        self.__searchbar.show_all()
        self.__searchbar.add_observer(self.__on_search)
        self.__browser.pack_start(self.__searchbar, False, False, 0)

        # build list view
        scrwin = gtk.ScrolledWindow()
        scrwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.__browser.pack_end(scrwin, True, True, 0)

        self.__list = ListView(columns, item_renderer)
        self.__list.connect("row-activated", self.__on_activate_item)
        scrwin.add(self.__list)
Esempio n. 6
0
class ItemBrowser(Observable):

    OBS_ACTIVATE_ITEM = 0


    def __init__(self, search_handler, item_renderer, *columns):

        self.__search_handler = search_handler

        # build bookmarks list
        self.__bookmarks = BookmarkList()
        self.__browser = gtk.VBox()

        # build search bar
        self.__searchbar = SearchBar()
        self.__searchbar.show_all()
        self.__searchbar.add_observer(self.__on_search)
        self.__browser.pack_start(self.__searchbar, False, False, 0)

        # build list view
        scrwin = gtk.ScrolledWindow()
        scrwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.__browser.pack_end(scrwin, True, True, 0)

        self.__list = ListView(columns, item_renderer)
        self.__list.connect("row-activated", self.__on_activate_item)
        scrwin.add(self.__list)


    #
    # Returns the widgets.
    #
    def get_widgets(self):

        return (self.__bookmarks, self.__browser)


    #
    # Adds a category to the bookmarks list.
    #
    def add_category(self, name, label, items):

        self.__bookmarks.add_category(name, name)

        items = list(set(items))
        items.sort(lambda a,b: cmp(a[1], b[1]))
        for icon, label, expr in items:
            if (icon):
                pixbuf = gtk.gdk.pixbuf_new_from_file(icon)
            else:
                pixbuf = None
            
            self.__bookmarks.add_item(name, pixbuf, label,
                                      self.__on_select_entry, expr)
        #end for
        
        self.__bookmarks.select_category(0) 


    #
    # Sets a search query manually.
    #
    def set_query(self, expr):
        
        self.__searchbar.set_query(expr)


    #
    # Returns the currently selected item.
    #
    def get_selected_item(self):

        return self.__list.get_selected_item()
    

    def __on_select_entry(self, expr):

        self.set_query(expr)


    def __on_search(self, src, cmd, expr):
        assert (self.__search_handler)
        
        self.__list.clear()
        matches = self.__search_handler(expr)

        if (matches):
            for item in matches:
                self.__list.add_item(item)

        return matches


    def __on_activate_item(self, *args):

        item = self.__list.get_selected_item()
        self.update_observer(self.OBS_ACTIVATE_ITEM, item)
class MainWindow(Gtk.ApplicationWindow):
    """
    Window where all the magic happens
    """

    # start with the revealers hidden, then cover up getting started screen with revealers (maybe even hide the background label)
    # ____________________________________
    # | results | getting | info         |
    # | on	  | started | page 		   |
    # | revealer| screen  | on revealer  |
    # |_________|_________|______________|

    def __init__(self, db):
        Gtk.Window.__init__(self)

        self.db = db
        self.windowStack = None
        self.revealer = None
        self.headerBar = None
        self.searchBar = None
        self.imdbBox = None
        self.searchResults = None

        self.connect("key-press-event", self.key_pressed_cb)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        # stackBox = Gtk.Box()

        self.windowStack = Gtk.Stack(
            interpolate_size=True,
            transition_type=Gtk.StackTransitionType.CROSSFADE)

        self.header = HeaderBar(self, self.db)
        self.header.connect('go-back', self.goBack_cb)
        self.header.connect("random-clicked", self.random_cb)
        self.header.connect("revealer-change", self.reveal_cb)
        self.header.connect('source-change', self.sourceChange_cb)
        self.set_titlebar(self.header)

        self.searchBar = SearchBar(db)
        self.searchBar.connect("search-ran", self.searchRan_cb)

        self.searchResults = SearchResults()
        self.searchResults.connect("row-activated", self.updateIMDB_cb)
        # self.windowStack.add_named(self.searchResults, "search-results")

        # stackBox.pack_start(self.searchResults, False, False, 0)
        self.windowStack.add_named(
            self.searchResults, "search-results"
        )  # what if I implement the infobox on a stack that also includes a start typing page like the search results has right now and a choose a search result to display detailed info page

        self.windowStack.set_visible_child_name("search-results")

        self.imdbBox = InfoPage(db, "Shrek")

        # stackBox.pack_end(self.imdbBox, True, True, 0)
        self.windowStack.add_named(self.imdbBox, "movie-info")

        # credentials = LogIn()
        # locationChooser.connect("location-chosen", self.updateWin)
        # self.windowStack.add_named(credentials, "credentials")

        box.add(self.searchBar)
        box.add(self.windowStack)

        self.add(box)

    def goBack_cb(self, headerBar):
        self.windowStack.set_visible_child_name('search-results')

    def key_pressed_cb(self, win, event):
        self.searchBar.set_transition_type(
            Gtk.RevealerTransitionType.SLIDE_DOWN)
        self.searchBar.set_reveal_child(True)
        self.header.search.set_active(True)
        if self.searchBar.entry.has_focus() is False:
            self.searchBar.entry.grab_focus()
        return self.searchBar.entry.handle_event(event)

    def updateSource(self, locationChooser, location):
        # Database.location = location
        self.show_all()

    def random_cb(self, header):
        self.windowStack.set_visible_child_name("movie-info")
        movieResults = self.searchBar.run_search(False)
        movie_position = random.randint(0, len(movieResults) - 1)
        self.imdbBox.update(movieResults[movie_position].title)
        # self.searchBar.run_search()

    def reveal_cb(self, header, toggled):
        if toggled is True:
            self.searchBar.set_transition_type(
                Gtk.RevealerTransitionType.SLIDE_DOWN)
            self.searchBar.set_reveal_child(True)
            if self.searchBar.entry.has_focus() is False:
                self.searchBar.entry.grab_focus()
        else:
            self.searchBar.set_transition_type(
                Gtk.RevealerTransitionType.SLIDE_UP)
            self.searchBar.set_reveal_child(False)
            # self.grab_focus()

    def searchRan_cb(self, searchBar, results):
        self.searchResults.set_search_view(results)
        self.windowStack.set_visible_child_name("search-results")

    def sourceChange_cb(self, header):
        self.windowStack.set_visible_child_name('credentials')

    def updateIMDB_cb(self, searchResults, movieName):
        self.imdbBox.update(movieName)
        self.windowStack.set_visible_child_name("movie-info")