コード例 #1
0
    def __show_connected_state(self, is_connected):
        self.__actiongroup_connected.set_sensitive(is_connected)
        self.__actiongroup.get_action("Connect").set_visible(not is_connected)
        self.__actiongroup.get_action("Disconnect").set_visible(is_connected)
        self.__getWidget("hbox_device_information").set_sensitive(is_connected)

        if is_connected:
            connected_device = self.__device_engine.get_device().get_name()
        else:
            connected_device = "No device connected"  #TRANSLATE
        self.__getWidget("label_device_name").set_markup("<b>" +
                                                         connected_device +
                                                         "</b>")
        self.__getWidget("label_device_name2").set_markup("<b>" +
                                                          connected_device +
                                                          "</b>")

        if not is_connected:
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            prog_bar = self.__getWidget("progressbar_batterie_level")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            self.__getWidget("label_information").set_text(
                "No device connected")
        else:
            # disk usage
            used = self.__device_engine.get_device().get_diskusage()[0]
            total = self.__device_engine.get_device().get_diskusage()[1]
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(float(used) / float(total))
            prog_bar.set_text(
                "%s of %s" %
                (util.format_filesize(used), util.format_filesize(total)))

            # batterie level
            max = self.__device_engine.get_device().get_batterylevel()[0]
            current = self.__device_engine.get_device().get_batterylevel()[1]
            prog_bar = self.__getWidget("progressbar_batterie_level")
            fraction = float(current) / float(max)
            prog_bar.set_fraction(fraction)
            prog_bar.set_text("%i%%" % (fraction * 100))

            # general information
            infos = self.__device_engine.get_device().get_information()
            text = ""
            for info in infos:
                text += "<b>" + info[0] + ":</b> " + info[1] + "\n"
            self.__getWidget("label_information").set_markup(text)
コード例 #2
0
    def __connect_device(self):
        dev = MTPDevice()
        self.__device_engine = DeviceEngine(dev)
        if not self.__device_engine.connect_device():
            # TODO: notify connection failed
            self.__device_engine = None
            return
        tv = self.__getWidget("treeview_transfer_manager")
        notebook = self.__getWidget("notebook_device_info")
        self.__transferManager = TransferManager(self.__device_engine, tv, notebook)

        # update model
        model = self.__device_engine.get_track_listing_model()
        self.__treeview_track.set_model(model)

        # change menu and toobar label and stock
        #TODO: use gtk.Action and gtk.ActionGroup for menu and toolbutton
        # ou uimanager http://python.developpez.com/cours/pygtktutorial/php/pygtkfr/sec-UIManager.php
        text="Disconnect device"
        stock=gtk.STOCK_DISCONNECT
        #TODO self.__getWidget("button_connect").set_label(text)
        self.__getWidget("button_connect").set_stock_id(stock)
        #TODO self.__getWidget("menuitem_connect").set_label(text)
        img = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_LARGE_TOOLBAR)
        #TODO self.__getWidget("menuitem_connect").set_image(img)
        self.__getWidget("label_device_name").set_markup("<b>" + self.__device_engine.get_device().get_name() + "</b>")
        self.__getWidget("label_device_name2").set_markup("<b>" + self.__device_engine.get_device().get_name() + "</b>")

        # disk usage
        used = self.__device_engine.get_device().get_diskusage()[0]
        total = self.__device_engine.get_device().get_diskusage()[1]
        prog_bar = self.__getWidget("progressbar_disk_usage")
        prog_bar.set_fraction(float(used)/float(total))
        prog_bar.set_text("%s of %s" % (util.format_filesize(used), util.format_filesize(total)))

        # batterie level
        max = self.__device_engine.get_device().get_batterylevel()[0]
        current = self.__device_engine.get_device().get_batterylevel()[1]
        prog_bar = self.__getWidget("progressbar_batterie_level")
        fraction = float(current)/float(max)
        prog_bar.set_fraction(fraction)
        prog_bar.set_text("%i%%" % (fraction * 100))

        infos = self.__device_engine.get_device().get_information()
        text=""
        for info in infos:
            text += "<b>" + info[0] + ":</b> " + info[1] + "\n"
        self.__getWidget("label_information").set_markup(text)
コード例 #3
0
    def append(self, metadata):
        assert type(metadata) is type(Metadata.Metadata())
        m = metadata
        if DEBUG_LOCK: debug_trace("Requesting lock", sender=self)
        self.__lock.acquire()
        if DEBUG_LOCK: debug_trace("Lock acquired", sender=self)
        parent = 0
        if m.parent_id <> 0:
            parent = self.__get_iter(m.parent_id)

        if m.type == Metadata.TYPE_FOLDER:
            row = [m.id, m.parent_id, m.title, "", 0, "folder", m]
        else:
            icon = "gtk-file"
            if Metadata.TYPE_TRACK:
                icon = "audio-x-generic"
            row = [
                m.id, m.parent_id, m.title,
                util.format_filesize(m.filesize), m.filesize, icon, m
            ]

        iter = gtk.TreeStore.append(self, parent, row)
        self.__cache[m.id] = gtk.TreeRowReference(self, self.get_path(iter))
        self.__lock.release()
        if DEBUG_LOCK: debug_trace("Lock released", sender=self)
        return iter
コード例 #4
0
 def __observe_queue_thread(self, signal, *args):
     if signal == ProcessQueueThread.SIGNAL_DEVICE_CONTENT_CHANGED:
         gobject.idle_add(self.__disk_usage_progress_bar.set_fraction, float(args[1])/float(args[2]))
         gobject.idle_add(self.__disk_usage_progress_bar.set_text, "%s of %s" % (util.format_filesize(args[1]), util.format_filesize(args[2])))
         if DEBUG: debug_trace("notified SIGNAL_DEVICE_CONTENT_CHANGED", sender=self)
         job = args[0]
         if job.action==self.ACTION_SEND:
             gobject.idle_add(self.__device_engine.get_object_listing_model().append, job.metadata)
         elif job.action==self.ACTION_DEL:
             if job.metadata.type == Metadata.TYPE_FOLDER:
                 gobject.idle_add(self.__device_engine.get_folder_tree_model().remove_object, job.metadata.id)
             elif job.metadata.type == Metadata.TYPE_PLAYLIST:
                 gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
             elif job.metadata.type == Metadata.TYPE_TRACK:
                 gobject.idle_add(self.__device_engine.get_object_listing_model().remove_object, job.metadata.id)
                 # also try to remove from playlist model if the track belogn a playlist
                 gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
             else:
                gobject.idle_add(self.__device_engine.get_object_listing_model().remove_object, job.metadata.id)
         elif job.action==self.ACTION_CREATE_FOLDER:
             gobject.idle_add(self.__device_engine.get_folder_tree_model().append, job.metadata)
         elif job.action==self.ACTION_CREATE_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
         elif job.action==self.ACTION_REMOVE_FROM_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
         elif job.action==self.ACTION_ADD_TO_PLAYLIST:
             pass #gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
         elif job.action==self.ACTION_MOVE_WITHIN_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
         elif job.action==self.ACTION_SEND_FILE_TO_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_object_listing_model().append, job.metadata)
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
コード例 #5
0
    def __show_connected_state(self, is_connected):
        self.__actiongroup_connected.set_sensitive(is_connected)
        self.__actiongroup.get_action("Connect").set_visible(not is_connected)
        self.__actiongroup.get_action("Disconnect").set_visible(is_connected)
        #self.__getWidget("hbox_device_information").set_sensitive(is_connected)
        self.__getWidget("scrolledwindow_files").set_sensitive(is_connected)
        self.__getWidget("vbox1").set_sensitive(is_connected)

        if is_connected:
            connected_device = self.__device_engine.get_device().get_name()
        else:
            connected_device = "No device connected"  #TRANSLATE
        self.__getWidget("label_device_name").set_markup("<b>" +
                                                         connected_device +
                                                         "</b>")
        self.__getWidget("label_device_name2").set_markup("<b>" +
                                                          connected_device +
                                                          "</b>")

        if not is_connected:
            self.window.set_title(APPLICATION_NAME)
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            prog_bar = self.__getWidget("progressbar_batterie_level")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            self.__getWidget("label_information").set_text(
                "No device connected")
        else:
            self.window.set_title(connected_device + " - " + APPLICATION_NAME)
            # disk usage
            used = self.__device_engine.get_device().get_diskusage()[0]
            total = self.__device_engine.get_device().get_diskusage()[1]
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(float(used) / float(total))
            prog_bar.set_text(
                "%s of %s" %
                (util.format_filesize(used), util.format_filesize(total)))

            # batterie level
            max = self.__device_engine.get_device().get_batterylevel()[0]
            current = self.__device_engine.get_device().get_batterylevel()[1]
            prog_bar = self.__getWidget("progressbar_batterie_level")
            fraction = float(current) / float(max)
            prog_bar.set_fraction(fraction)
            prog_bar.set_text("%i%%" % (fraction * 100))
コード例 #6
0
    def __show_connected_state(self, is_connected):
        self.__actiongroup_connected.set_sensitive(is_connected)
        self.__actiongroup.get_action("Connect").set_visible(not is_connected)
        self.__actiongroup.get_action("Disconnect").set_visible(is_connected)
        self.__getWidget("hbox_device_information").set_sensitive(is_connected)

        if is_connected:
            connected_device = self.__device_engine.get_device().get_name()
        else:
            connected_device = "No device connected" #TRANSLATE
        self.__getWidget("label_device_name").set_markup("<b>" + connected_device + "</b>")
        self.__getWidget("label_device_name2").set_markup("<b>" + connected_device + "</b>")

        if not is_connected:
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            prog_bar = self.__getWidget("progressbar_batterie_level")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            self.__getWidget("label_information").set_text("No device connected")
        else:
            # disk usage
            used = self.__device_engine.get_device().get_diskusage()[0]
            total = self.__device_engine.get_device().get_diskusage()[1]
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(float(used)/float(total))
            prog_bar.set_text("%s of %s" % (util.format_filesize(used), util.format_filesize(total)))

            # batterie level
            max = self.__device_engine.get_device().get_batterylevel()[0]
            current = self.__device_engine.get_device().get_batterylevel()[1]
            prog_bar = self.__getWidget("progressbar_batterie_level")
            fraction = float(current)/float(max)
            prog_bar.set_fraction(fraction)
            prog_bar.set_text("%i%%" % (fraction * 100))

            # general information
            infos = self.__device_engine.get_device().get_information()
            text=""
            for info in infos:
                text += "<b>" + info[0] + ":</b> " + info[1] + "\n"
            self.__getWidget("label_information").set_markup(text)
コード例 #7
0
    def __show_connected_state(self, is_connected):
        self.__actiongroup_connected.set_sensitive(is_connected)
        self.__actiongroup.get_action("Connect").set_visible(not is_connected)
        self.__actiongroup.get_action("Disconnect").set_visible(is_connected)
        #self.__getWidget("hbox_device_information").set_sensitive(is_connected)
        self.__getWidget("scrolledwindow_files").set_sensitive(is_connected)
        self.__getWidget("vbox1").set_sensitive(is_connected)

        if is_connected:
            connected_device = self.__device_engine.get_device().get_name()
        else:
            connected_device = "No device connected" #TRANSLATE
        self.__getWidget("label_device_name").set_markup("<b>" + connected_device + "</b>")
        self.__getWidget("label_device_name2").set_markup("<b>" + connected_device + "</b>")

        if not is_connected:
            self.window.set_title(APPLICATION_NAME)
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            prog_bar = self.__getWidget("progressbar_batterie_level")
            prog_bar.set_fraction(0)
            prog_bar.set_text("")
            self.__getWidget("label_information").set_text("No device connected")
        else:
            self.window.set_title(connected_device + " - " + APPLICATION_NAME )
            # disk usage
            used = self.__device_engine.get_device().get_diskusage()[0]
            total = self.__device_engine.get_device().get_diskusage()[1]
            prog_bar = self.__getWidget("progressbar_disk_usage")
            prog_bar.set_fraction(float(used)/float(total))
            prog_bar.set_text("%s of %s" % (util.format_filesize(used), util.format_filesize(total)))

            # batterie level
            max = self.__device_engine.get_device().get_batterylevel()[0]
            current = self.__device_engine.get_device().get_batterylevel()[1]
            prog_bar = self.__getWidget("progressbar_batterie_level")
            fraction = float(current)/float(max)
            prog_bar.set_fraction(fraction)
            prog_bar.set_text("%i%%" % (fraction * 100))
コード例 #8
0
 def append(self, metadata):
     assert type(metadata) is type(Metadata.Metadata())
     m = metadata
     if DEBUG: debug_trace("Requesting lock", sender=self)
     self.__lock.acquire()
     if DEBUG: debug_trace("Lock acquired", sender=self)
     iter = gtk.ListStore.append(self, [
         m.id, m.title, m.artist, m.album, m.genre,
         util.format_filesize(m.duration), m.duration, m.date, m
     ])
     self.__cache[m.id] = gtk.TreeRowReference(self, self.get_path(iter))
     self.__lock.release()
     if DEBUG: debug_trace("Lock released", sender=self)
     return iter
コード例 #9
0
 def __observe_queue_thread(self, signal, *args):
     if signal == ProcessQueueThread.SIGNAL_DEVICE_CONTENT_CHANGED:
         gobject.idle_add(self.__disk_usage_progress_bar.set_fraction, float(args[1]) / float(args[2]))
         gobject.idle_add(
             self.__disk_usage_progress_bar.set_text,
             "%s of %s" % (util.format_filesize(args[1]), util.format_filesize(args[2])),
         )
         if DEBUG:
             debug_trace("notified SIGNAL_DEVICE_CONTENT_CHANGED", sender=self)
         job = args[0]
         if job.action == self.ACTION_SEND:
             gobject.idle_add(self.__device_engine.get_object_listing_model().append, job.metadata)
         elif job.action == self.ACTION_DEL:
             if job.metadata.type == Metadata.TYPE_FOLDER:
                 gobject.idle_add(self.__device_engine.get_folder_tree_model().remove_object, job.metadata.id)
             elif job.metadata.type == Metadata.TYPE_PLAYLIST:
                 gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
             elif job.metadata.type == Metadata.TYPE_TRACK:
                 gobject.idle_add(self.__device_engine.get_object_listing_model().remove_object, job.metadata.id)
                 # also try to remove from playlist model if the track belogn a playlist
                 gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
             else:
                 gobject.idle_add(self.__device_engine.get_object_listing_model().remove_object, job.metadata.id)
         elif job.action == self.ACTION_CREATE_FOLDER:
             gobject.idle_add(self.__device_engine.get_folder_tree_model().append, job.metadata)
         elif job.action == self.ACTION_CREATE_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
         elif job.action == self.ACTION_REMOVE_FROM_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
         elif job.action == self.ACTION_ADD_TO_PLAYLIST:
             pass  # gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
         elif job.action == self.ACTION_MOVE_WITHIN_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().remove_object, job.metadata.id)
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
         elif job.action == self.ACTION_SEND_FILE_TO_PLAYLIST:
             gobject.idle_add(self.__device_engine.get_object_listing_model().append, job.metadata)
             gobject.idle_add(self.__device_engine.get_playlist_tree_model().append, job.metadata)
コード例 #10
0
 def __observe_queue_thread(self, signal, *args):
     if signal == ProcessQueueThread.SIGNAL_DEVICE_CONTENT_CHANGED:
         self.__disk_usage_progress_bar.set_fraction(float(args[1])/float(args[2]))
         self.__disk_usage_progress_bar.set_text("%s of %s" % (util.format_filesize(args[1]), util.format_filesize(args[2])))
         if DEBUG: debug_trace("notified SIGNAL_DEVICE_CONTENT_CHANGED", sender=self)
         job = args[0]
         if job.action==self.ACTION_SEND:
             self.__device_engine.get_track_listing_model().append(job.metadata)
             self.__device_engine.get_file_tree_model().append(job.metadata)
             # TODO: expand parent
         elif job.action==self.ACTION_DEL:
             self.__device_engine.get_track_listing_model().remove_object(job.metadata.id)
             self.__device_engine.get_file_tree_model().remove_object(job.metadata.id)
         elif job.action==self.ACTION_CREATE_FOLDER:
             self.__device_engine.get_file_tree_model().append(job.metadata)
コード例 #11
0
    def append(self, metadata):
        assert type(metadata) is type(Metadata.Metadata())
        m = metadata
        date_str = ""
        if metadata.date:
            date_str = datetime.datetime.fromtimestamp(
                metadata.date).strftime('%a %d %b %Y')

        row = [
            m.id, m.parent_id, m.type, m.filename, m.title, m.artist, m.album,
            m.genre,
            util.format_filesize(m.filesize), m.filesize, date_str, m.date,
            m.get_icon(), m
        ]
        iter = gtk.ListStore.append(self, row)

        return False  # needed by idle_add
コード例 #12
0
 def append(self, metadata):
     assert type(metadata) is type(Metadata.Metadata())
     m = metadata
     date_str = ""
     if metadata.date:
         date_str = datetime.datetime.fromtimestamp(
             metadata.date).strftime('%a %d %b %Y')
     if DEBUG_LOCK: debug_trace("Requesting lock", sender=self)
     self.__lock.acquire()
     if DEBUG_LOCK: debug_trace("Lock acquired", sender=self)
     iter = gtk.ListStore.append(self, [
         m.id, m.parent_id, m.title, m.artist, m.album, m.genre,
         util.format_filesize(m.filesize), m.filesize, date_str, m.date, m
     ])
     self.__cache[m.id] = gtk.TreeRowReference(self, self.get_path(iter))
     self.__lock.release()
     if DEBUG_LOCK: debug_trace("Lock released", sender=self)
     return iter
コード例 #13
0
 def append(self, metadata):
     assert type(metadata) is type(Metadata.Metadata())
     m=metadata
     if DEBUG: debug_trace("Requesting lock", sender=self)
     self.__lock.acquire()
     if DEBUG: debug_trace("Lock acquired", sender=self)
     iter = gtk.ListStore.append(self, [m.id, m.title, m.artist, m.album, m.genre, util.format_filesize(m.duration), m.duration, m.date, m])
     self.__cache[m.id] = gtk.TreeRowReference(self, self.get_path(iter))
     self.__lock.release()
     if DEBUG: debug_trace("Lock released", sender=self)
     return iter
コード例 #14
0
    def append(self, metadata):
        assert type(metadata) is type(Metadata.Metadata())
        m=metadata
        date_str=""
        if metadata.date:
            date_str = datetime.datetime.fromtimestamp(metadata.date).strftime('%a %d %b %Y')

        row = [m.id, m.parent_id, m.type, m.filename, m.title, m.artist, m.album, m.genre, util.format_filesize(m.filesize), m.filesize, date_str, m.date, m.get_icon(), m]
        iter = gtk.ListStore.append(self, row)

        return False # needed by idle_add