Ejemplo n.º 1
0
    def on_file_selected(self,widget,data=None):

        """
        Clear the list_store of the list_view of the Import Dialog Box.
        Get the file path selected using Gtk FileChooserButton.

        Create a new JSON_Importer.

        Enable "Import" button.

        Channels are imported in the same order in which they have been written
        in the file.

        Each imported channel is appended in the liSt_view of the Import Box.
        """

        self.box.list_store.clear()
        _file = widget.get_filename()
        if _file == '':
            return
        importer = JSON_Importer()
        self.imported_data = importer.from_JSON(_file)
        if self.imported_data is not None:
            self.box.import_button.set_sensitive(True)
            for channel in self.imported_data:
                channel_data = collections.OrderedDict(
                                   sorted(self.imported_data[channel].items()))
                self.box.list_store.append(channel_data.values())
Ejemplo n.º 2
0
    def on_file_selected(self, widget, data=None):
        """
        Clear the list_store of the list_view of the Import Dialog Box.
        Get the file path selected using Gtk FileChooserButton.

        Create a new JSON_Importer.

        Enable "Import" button.

        Channels are imported in the same order in which they have been written
        in the file.

        Each imported channel is appended in the liSt_view of the Import Box.
        """

        self.box.list_store.clear()
        _file = widget.get_filename()
        if _file == '':
            return
        importer = JSON_Importer()
        self.imported_data = importer.from_JSON(_file)
        if self.imported_data is not None:
            self.box.import_button.set_sensitive(True)
            for channel in self.imported_data:
                channel_data = collections.OrderedDict(
                    sorted(self.imported_data[channel].items()))
                self.box.list_store.append(channel_data.values())
Ejemplo n.º 3
0
 def test_03_import_channels(self):
     importer = JSON_Importer()
     Import_Export_Test.imported_data = importer.from_JSON(path)
     print("\n")
     _print_("importing channels from json file = " 
            + path 
            + "\n"
            +json.dumps(Import_Export_Test.imported_data,indent = 4))
     
     self.assertEqual(Import_Export_Test.exported_data
                     ,Import_Export_Test.imported_data)
     
     print("----------------------------------------------------------------------")
Ejemplo n.º 4
0
 def restore_app_state(self):
     
     """
     Restore channels present in last session of app.
     
     Channels are restored after importing channels from JSON File.
     """
     
     _file =file_util.find_file(__file__,
                                "../data/channels/saved_channels")
     importer = JSON_Importer()
     self.restored_data = importer.from_JSON(_file)
     if self.restored_data is not None:
         all_category = Channel_Store.ALL
         for channel in self.restored_data:
             restored_channel = Channel(self.restored_data[channel])
             all_category.add(channel,restored_channel)
             (channel_name,image_url,desc) = (channel
                             ,restored_channel.get_thumbnail_url()
                             ,restored_channel.get_description())
             scaled_image = graphics_util.get_scaled_image(image_url,180)
             self.app_window.icon_list_store.append([scaled_image,channel_name,desc])
Ejemplo n.º 5
0
    def restore_app_state(self):
        """
        Restore channels present in last session of app.
        
        Channels are restored after importing channels from JSON File.
        """

        _file = file_util.find_file(__file__,
                                    "../data/channels/saved_channels")
        importer = JSON_Importer()
        self.restored_data = importer.from_JSON(_file)
        if self.restored_data is not None:
            all_category = Channel_Store.ALL
            for channel in self.restored_data:
                restored_channel = Channel(self.restored_data[channel])
                all_category.add(channel, restored_channel)
                (channel_name, image_url,
                 desc) = (channel, restored_channel.get_thumbnail_url(),
                          restored_channel.get_description())
                scaled_image = graphics_util.get_scaled_image(image_url, 180)
                self.app_window.icon_list_store.append(
                    [scaled_image, channel_name, desc])