def _import(self, widget, data=None):
        """
        Get the categoey in which the channels will be imported.

        Convert JSON format channels to "Channel" objects.

        Add the channels to category.

        Get the channel data which are to be displayed in IconView in main
        window.

        Properly scale the image thumbnail of the channel.
        Add the channels to the Iconview in the main window.

        Close the Import Dialog Box.
        """

        all_category = Channel_Store.ALL
        if self.imported_data is not None:
            for channel in self.imported_data:
                imported_channel = Channel(self.imported_data[channel])
                all_category.add(channel, imported_channel)
                (channel_name, image_url,
                 desc) = (channel, imported_channel.get_thumbnail_url(),
                          imported_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])
        self.box.import_box.destroy()
Exemplo n.º 2
0
    def _import(self,widget,data=None):

        """
        Get the categoey in which the channels will be imported.

        Convert JSON format channels to "Channel" objects.

        Add the channels to category.

        Get the channel data which are to be displayed in IconView in main
        window.

        Properly scale the image thumbnail of the channel.
        Add the channels to the Iconview in the main window.

        Close the Import Dialog Box.
        """

        all_category = Channel_Store.ALL
        if self.imported_data is not None:
            for channel in self.imported_data:
                imported_channel = Channel(self.imported_data[channel])
                all_category.add(channel,imported_channel)
                (channel_name,image_url,desc) = (channel
                                ,imported_channel.get_thumbnail_url()
                                ,imported_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])
        self.box.import_box.destroy()
Exemplo n.º 3
0
 def show_monitor_channel(self):  #only for testing purpose
     """
     Show default channel in Channel Iconview when app starts.
     """
     monitor_data = channel_store.get_monitor_data()
     channel = Channel(monitor_data["monitor"])
     store = Channel_Store()
     store.get_default().add(channel.name, channel)
     (name, image_url, desc) = (channel.get_name(),
                                channel.get_thumbnail_url(),
                                channel.get_description())
     scaled_image = graphics_util.get_scaled_image(image_url, 180)
     for i in range(0, 1):
         self.app_window.icon_list_store.append([scaled_image, name, desc])
Exemplo n.º 4
0
    def show_monitor_channel(self):#only for testing purpose

        """
        Show default channel in Channel Iconview when app starts.
        """
        monitor_data = channel_store.get_monitor_data()
        channel = Channel(monitor_data["monitor"])
        store = Channel_Store()
        store.get_default().add(channel.name,channel)
        (name,image_url,desc) = (channel.get_name()
                                ,channel.get_thumbnail_url()
                                ,channel.get_description())
        scaled_image = graphics_util.get_scaled_image(image_url,180)
        for i in range(0,1):
            self.app_window.icon_list_store.append([scaled_image,name,desc])
Exemplo 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])
Exemplo n.º 6
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])
Exemplo n.º 7
0
    def add(self, widget, data=None):

        #verify thumbnil url,address,port validity
        #if not verified show proper message.
        #elif verified:
        #currently implemented only for local thumbnail images.
        #get texts from all the entries.
        #create channel with given data.
        #add the channel to store
        #get channel data and display it in iconview
        """
        Verify channel configuration and add it to the iconview where channels
        are listed and to the channel store.
        """

        name = self.box.name.get_text()
        desc = self.box.description.get_text()
        thumbnail = self.box.thumbnail.get_text()
        address = str(self.box.address.get_text())
        port = self.box.port.get_value_as_int()
        if name == "":
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0,
                                           Gtk.MessageType.ERROR,
                                           Gtk.ButtonsType.CLOSE,
                                           "CHANNEL NAME IS EMPTY")
            msg_dialog.format_secondary_text(
                "A proper name for channel should be provided.")
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif desc == "":
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0,
                                           Gtk.MessageType.ERROR,
                                           Gtk.ButtonsType.CLOSE,
                                           "CHANNEL DESCRIPTION IS EMPTY")
            msg_dialog.format_secondary_text(
                "Channel's details should be provided.")
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif url_util.verify_url(str(thumbnail)) == False:
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0,
                                           Gtk.MessageType.ERROR,
                                           Gtk.ButtonsType.CLOSE,
                                           "INVALID URL")
            msg_dialog.format_secondary_text(str(thumbnail))
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif url_util.validate_ip(str(address)) == False:
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0,
                                           Gtk.MessageType.ERROR,
                                           Gtk.ButtonsType.CLOSE, "INVALID IP")
            msg_dialog.format_secondary_text(str(address))
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif int(port) == 0:
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0,
                                           Gtk.MessageType.ERROR,
                                           Gtk.ButtonsType.CLOSE,
                                           "INVALID PORT")
            msg_dialog.format_secondary_text(str(port))
            msg_dialog.run()
            msg_dialog.destroy()
            return
        else:
            channel_data = {
                "name": name,
                "thumbnail_url": url_util.get_path(str(thumbnail)),
                "description": desc,
                "splitter_addr": address,
                "splitter_port": port
            }
            channel = Channel(channel_data)
            store = Channel_Store()
            store.get_default().add(channel.name, channel)
            (name, image_url, desc) = (channel.get_name(),
                                       channel.get_thumbnail_url(),
                                       channel.get_description())
            scaled_image = graphics_util.get_scaled_image(image_url, 180)
            self.app_view.icon_list_store.append([scaled_image, name, desc])
            self.box.dialog.destroy()
Exemplo n.º 8
0
    def add(self,widget,data=None):

        #verify thumbnil url,address,port validity
        #if not verified show proper message.
        #elif verified:
        #currently implemented only for local thumbnail images.
        #get texts from all the entries.
        #create channel with given data.
        #add the channel to store
        #get channel data and display it in iconview
        
        """
        Verify channel configuration and add it to the iconview where channels
        are listed and to the channel store.
        """
        
        name = self.box.name.get_text()
        desc = self.box.description.get_text()
        thumbnail = self.box.thumbnail.get_text()
        address = str(self.box.address.get_text())
        port = self.box.port.get_value_as_int()
        if name == "":
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0, Gtk.MessageType.ERROR,
            Gtk.ButtonsType.CLOSE, "CHANNEL NAME IS EMPTY")
            msg_dialog.format_secondary_text("A proper name for channel should be provided.")
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif desc == "":
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0, Gtk.MessageType.ERROR,
            Gtk.ButtonsType.CLOSE, "CHANNEL DESCRIPTION IS EMPTY")
            msg_dialog.format_secondary_text("Channel's details should be provided.")
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif url_util.verify_url(str(thumbnail)) == False:
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0, Gtk.MessageType.ERROR,
            Gtk.ButtonsType.CLOSE, "INVALID URL")
            msg_dialog.format_secondary_text(str(thumbnail))
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif url_util.validate_ip(str(address)) == False:
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0, Gtk.MessageType.ERROR,
            Gtk.ButtonsType.CLOSE, "INVALID IP")
            msg_dialog.format_secondary_text(str(address))
            msg_dialog.run()
            msg_dialog.destroy()
            return
        elif int(port) == 0:
            msg_dialog = Gtk.MessageDialog(self.parent_window, 0, Gtk.MessageType.ERROR,
            Gtk.ButtonsType.CLOSE, "INVALID PORT")
            msg_dialog.format_secondary_text(str(port))
            msg_dialog.run()
            msg_dialog.destroy()
            return
        else :
            channel_data = {"name" : name
            ,"thumbnail_url" : url_util.get_path(str(thumbnail))
            ,"description"   : desc
            ,"splitter_addr" : address
            ,"splitter_port" : port
            }
            channel = Channel(channel_data)
            store = Channel_Store()
            store.get_default().add(channel.name,channel)
            (name,image_url,desc) = (channel.get_name()
                                    ,channel.get_thumbnail_url()
                                    ,channel.get_description())
            scaled_image = graphics_util.get_scaled_image(image_url,180)
            self.app_view.icon_list_store.append([scaled_image
                                                          ,name
                                                          ,desc])
            self.box.dialog.destroy()