Ejemplo n.º 1
0
 def openbutton(self, widget, data=None):
     response, path = prompts.choose_directory()
     if response == gtk.RESPONSE_OK:
         media_files = []
         formats = self.supported_audio_formats + self.supported_video_formats
         for root, dirs, files in os.walk(path):
             for f in files:
                 for format in formats:
                     if f.lower().endswith(format):
                         file_url = "file://" + os.path.join(root, f)
                         data = {"File" : f,
                                 "url" : file_url,
                                 "format" : format,
                                 }
                         media_files.append(data)
                 for format in self.supported_album_art_formats:
                     if f.lower().endswith(format):
                         self.image_url = os.path.join(root, f)
                         
         #exception if no supported is found..
         if self.image_url is '':
             self.image_url = "background.png"
             
         #print media_files
         scrolledwindow = self.builder.get_object('scrolledwindow1')
         #print scrolledwindow
         for c in scrolledwindow.get_children():
             scrolledwindow.remove(c)
         media_grid = DictionaryGrid(media_files, keys=["File"])
         media_grid.connect("selection_changed", self.play_file)
         media_grid.show()
         #print media_files
         scrolledwindow.add(media_grid)
Ejemplo n.º 2
0
class OpenDialog(Gtk.Dialog):
    __gtype_name__ = "OpenDialog"

    def __new__(cls):
        """Special static method that's automatically called by Python when 
        constructing a new instance of this class.
        
        Returns a fully instantiated OpenDialog object.
        """
        builder = get_builder('OpenDialog')
        new_object = builder.get_object('open_dialog')
        new_object.finish_initializing(builder)
        return new_object

    def finish_initializing(self, builder):
        """Called when we're finished initializing.

        finish_initalizing should be called after parsing the ui definition
        and creating a OpenDialog object with it in order to
        finish initializing the start of the new OpenDialog
        instance.
        """
        # Get a reference to the builder and set up the signals.
        self.builder = builder
        self.ui = builder.get_ui(self)
        
        #get the jotty document names
        data_dir = GLib.get_user_data_dir()
        jotty_dir = os.path.join(data_dir, "jotty")
        filenames = os.listdir(jotty_dir)
        
        #put them into a grid
        dicts = [{'Name': x, 'File': os.path.join(jotty_dir, x)} for x in filenames]
        self.grid = DictionaryGrid(dictionaries=dicts, keys=['Name'])
        
        #add grid to dialog
        self.grid.show()
        self.ui.box1.pack_end(self.grid, True, True, 0)

    def on_btn_ok_clicked(self, widget, data=None):
        """The user has elected to save the changes.

        Called before the dialog returns Gtk.ResponseType.OK from run().
        """
        pass

    def on_btn_cancel_clicked(self, widget, data=None):
        """The user has elected cancel changes.

        Called before the dialog returns Gtk.ResponseType.CANCEL for run()
        """
        pass

    @property
    def selected_file(self):
        rows = self.grid.selected_rows
        if len(rows) < 1:
            return None
        else:
            return rows[0]['Name']
Ejemplo n.º 3
0
    def finish_initializing(self, builder):
        """Called when we're finished initializing.

        finish_initalizing should be called after parsing the ui definition
        and creating a OpenDialog object with it in order to
        finish initializing the start of the new OpenDialog
        instance.
        """
        # Get a reference to the builder and set up the signals.
        self.builder = builder
        self.ui = builder.get_ui(self)

        self.supported_shape_formats = [".shp"]

        #let the user choose a path with the directory chooser
        response, path = prompts.choose_directory()

        #make certain the user said ok before working
        if response == Gtk.ResponseType.OK:
            #make one list of support formats
            formats = self.supported_shape_formats

            #make a list of the supported media files
            media_files = []
            #iterate through root directory
            for files in glob.glob(path + "/*.shp"):
                for format in formats:
                    if files.endswith(format):
                        #create a URI in a format gstreamer likes
                        file_uri = path
                        fileSplit = files.split(path + "/")
                        #add a dictionary to the list of media files
                        media_files.append({
                            "File": fileSplit[1],
                            "uri": file_uri,
                            "format": format
                        })

            #remove any children in scrolled window
            #for c in self.ui.scrolledwindow1.get_children():
            #   self.ui.scrolledwindow1.remove(c)

            #create the grid with list of dictionaries
            #only show the File column
            global media_grid
            media_grid = DictionaryGrid(media_files, keys=["File"])

            #show the grid, and add it to the scrolled window
            media_grid.show()
            self.ui.box1.pack_end(media_grid, True, True, 0)
Ejemplo n.º 4
0
    def finish_initializing(self, builder):
        """Called when we're finished initializing.

        finish_initalizing should be called after parsing the ui definition
        and creating a OpenDialog object with it in order to
        finish initializing the start of the new OpenDialog
        instance.
        """
        # Get a reference to the builder and set up the signals.
        self.builder = builder
        self.ui = builder.get_ui(self)

	
        self.supported_shape_formats = [".shp"]

        #let the user choose a path with the directory chooser
        response, path = prompts.choose_directory()

        #make certain the user said ok before working
        if response == Gtk.ResponseType.OK:
           #make one list of support formats
           formats = self.supported_shape_formats

           #make a list of the supported media files
           media_files = []
           #iterate through root directory
           for files in glob.glob(path + "/*.shp"):
                for format in formats:
                    if files.endswith(format):
                        #create a URI in a format gstreamer likes
                        file_uri = path
                        fileSplit = files.split(path + "/")
                        #add a dictionary to the list of media files
                        media_files.append({"File":fileSplit[1],"uri":file_uri, "format":format})

           #remove any children in scrolled window
           #for c in self.ui.scrolledwindow1.get_children():
            #   self.ui.scrolledwindow1.remove(c)

           #create the grid with list of dictionaries
           #only show the File column
           global media_grid
           media_grid = DictionaryGrid(media_files, keys=["File"])

           #show the grid, and add it to the scrolled window
           media_grid.show()
           self.ui.box1.pack_end(media_grid, True, True, 0)
Ejemplo n.º 5
0
    def openbutton_clicked_event(self, widget, data=None):
        #let the user choose a path with the directory chooser
        response, path = prompts.choose_directory()

        #make certain the user said ok before working
        if response == gtk.RESPONSE_OK:
            #make one list of support formats
            formats = self.allowed_formats

            #make a list of the supported media files
            media_files = []
            #iterate through root directory
            for root, dirs, files in os.walk(path):
                #iterate through each file
                for f in files:
                    #check if the file is a supported formats
                    for format in formats:
                        if f.lower().endswith(format):
                            #create a URI in a format gstreamer likes
                            file_uri = "file://" + os.path.join(root, f)

                            #add a dictionary to the list of media files
                            media_files.append({
                                "File": f,
                                "uri": file_uri,
                                "format": format
                            })

            #remove any children in scrolled window
            for c in self.ui.scrolledwindow1.get_children():
                self.ui.scrolledwindow1.remove(c)

            #create the grid with list of dictionaries
            #only show the File column
            media_grid = DictionaryGrid(media_files, keys=["File"])

            #hook up to the selection_changed event
            media_grid.connect("selection_changed", self.play_file)

            #show the grid, and add it to the scrolled window
            media_grid.show()
            self.ui.scrolledwindow1.add(media_grid)
Ejemplo n.º 6
0
    def openbutton_clicked_event(self, widget, data=None):
        #let the user choose a path with the directory chooser
        response, path = prompts.choose_directory()
    
        #make certain the user said ok before working
        if response == gtk.RESPONSE_OK:
            #make one list of support formats
            formats = self.allowed_formats

            #make a list of the supported media files
            media_files = []
            #iterate through root directory 
            for root, dirs, files in os.walk(path):
                #iterate through each file
                for f in files:
                    #check if the file is a supported formats
                    for format in formats:
                        if f.lower().endswith(format):
                            #create a URI in a format gstreamer likes
                            file_uri = "file://" + os.path.join(root,f)

                            #add a dictionary to the list of media files
                            media_files.append({"File":f,"uri":file_uri, "format":format})

            #remove any children in scrolled window
            for c in self.ui.scrolledwindow1.get_children():
                self.ui.scrolledwindow1.remove(c)

            #create the grid with list of dictionaries
            #only show the File column
            media_grid = DictionaryGrid(media_files, keys=["File"])

            #hook up to the selection_changed event
            media_grid.connect("selection_changed", self.play_file)

            #show the grid, and add it to the scrolled window
            media_grid.show()
            self.ui.scrolledwindow1.add(media_grid)
Ejemplo n.º 7
0
class OpenDialog(Gtk.Dialog):
    __gtype_name__ = "OpenDialog"

    def __new__(cls):
        """Special static method that's automatically called by Python when 
        constructing a new instance of this class.
        
        Returns a fully instantiated OpenDialog object.
        """
        builder = get_builder('OpenDialog')
        new_object = builder.get_object('open_dialog')
        new_object.finish_initializing(builder)
        return new_object

    def finish_initializing(self, builder):
        """Called when we're finished initializing.

        finish_initalizing should be called after parsing the ui definition
        and creating a OpenDialog object with it in order to
        finish initializing the start of the new OpenDialog
        instance.
        """
        # Get a reference to the builder and set up the signals.
        self.builder = builder
        self.ui = builder.get_ui(self)

        #get the jotty document names
        data_dir = GLib.get_user_data_dir()
        jotty_dir = os.path.join(data_dir, "jotty")
        filenames = os.listdir(jotty_dir)

        #put them into a grid
        dicts = [{
            'Name': x,
            'File': os.path.join(jotty_dir, x)
        } for x in filenames]
        self.grid = DictionaryGrid(dictionaries=dicts, keys=['Name'])

        #add grid to dialog
        self.grid.show()
        self.ui.box1.pack_end(self.grid, True, True, 0)

    def on_btn_ok_clicked(self, widget, data=None):
        """The user has elected to save the changes.

        Called before the dialog returns Gtk.ResponseType.OK from run().
        """
        pass

    def on_btn_cancel_clicked(self, widget, data=None):
        """The user has elected cancel changes.

        Called before the dialog returns Gtk.ResponseType.CANCEL for run()
        """
        pass

    @property
    def selected_file(self):
        rows = self.grid.selected_rows
        if len(rows) < 1:
            return None
        else:
            return rows[0]['Name']