Пример #1
0
    def get_property_pages(self, files):

        if len(files) != 1:
            return

        file = files[0]
        if file.get_uri_scheme() != 'file':
            return

        if file.is_directory():
            return

        filename = unquote(file.get_uri()[7:]).decode(
            sys.getfilesystemencoding())

        MI = MediaInfo()
        MI.Option_Static("Complete")
        MI.Option_Static("Inform", "Nothing")
        MI.Option_Static("Language", "file://{}".format(locale_file))
        MI.Open(filename)
        info = MI.Inform().splitlines()
        MI.Close()
        if len(info) < 8:
            return

        self.property_label = Gtk.Label('Media Info')
        self.property_label.show()

        self.builder = Gtk.Builder()
        self.builder.add_from_string(GUI)

        self.mainWindow = self.builder.get_object("mainWindow")
        self.grid = self.builder.get_object("grid")

        top = 0
        for line in info:
            tag = line[:41].strip()
            if tag not in excludeList:
                label = Gtk.Label()
                label.set_markup("<b>" + tag + "</b>")
                label.set_justify(Gtk.Justification.LEFT)
                label.set_halign(Gtk.Align.START)
                label.show()
                self.grid.attach(label, 0, top, 1, 1)
                label = Gtk.Label()
                label.set_text(line[42:].strip())
                label.set_justify(Gtk.Justification.LEFT)
                label.set_halign(Gtk.Align.START)
                label.set_selectable(True)
                label.set_line_wrap(True)
                label.show()
                self.grid.attach(label, 1, top, 1, 1)
                top += 1

        return Caja.PropertyPage(name="CajaPython::mediainfo",
                                 label=self.property_label,
                                 page=self.mainWindow),
Пример #2
0
    def get_property_pages(self, files):

        if len(files) != 1:
            return

        file = files[0]
        if file.get_uri_scheme() != 'file':
            return

        if file.is_directory():
            return

        filename = unquote(file.get_uri()[7:])

        MI = MediaInfo()
        MI.Open(filename.decode("utf-8"))
        MI.Option_Static("Complete")
        info = MI.Inform().splitlines()
        if len(info) < 8:
            return

        self.property_label = Gtk.Label('Media Info')
        self.property_label.show()

        self.builder = Gtk.Builder()
        self.builder.add_from_string(GUI)

        self.mainWindow = self.builder.get_object("mainWindow")
        self.viewport = self.builder.get_object("viewport1")
        self.grid = Gtk.VBox()
        self.grid.show()
        self.viewport.add(self.grid)

        for line in info:
            box = Gtk.HBox(homogeneous=True, spacing=8)
            box.show()
            label = Gtk.Label()
            label.set_markup("<b>" + line[:41].strip() + "</b>")
            label.set_justify(Gtk.Justification.LEFT)
            label.set_alignment(0, 0.5)
            label.show()
            box.pack_start(label, True, True, 0)
            label = Gtk.Label()
            label.set_text(line[42:].strip())
            label.set_justify(Gtk.Justification.LEFT)
            label.set_alignment(0, 0.5)
            label.set_selectable(True)
            label.set_line_wrap(True)
            label.show()
            box.pack_start(label, True, True, 0)
            self.grid.pack_start(box, True, True, 0)

        return Caja.PropertyPage(name="CajaPython::mediainfo",
                                 label=self.property_label,
                                 page=self.mainWindow),
Пример #3
0
    def get_property_pages(self, items):
        paths = []

        for item in items:
            if self.valid_uri(item.get_uri()):
                path = self.get_local_path(item)

                if self.vcs_client.is_in_a_or_a_working_copy(path):
                    paths.append(path)
                    self.VFSFile_table[path] = item

        if len(paths) == 0: return []

        label = rabbitvcs.ui.property_page.PropertyPageLabel(claim_domain=False).get_widget()
        page = rabbitvcs.ui.property_page.PropertyPage(paths, claim_domain=False).get_widget()

        ppage = Caja.PropertyPage(name='RabbitVCS::PropertyPage',
            label=label,
            page=page)

        return [ppage]
Пример #4
0
    def get_property_pages(self, cajafiles):
        pages = []
        if len(cajafiles) == 1:
            for cajafile in cajafiles:
                if self._file_has_mixed_name(cajafile):
                    page_label = Gtk.Label('Mixed')
                    page_label.show()
                    hbox = Gtk.HBox(homogeneous=False, spacing=4)
                    hbox.show()
                    name_label = Gtk.Label(cajafile.get_name())
                    name_label.show()
                    comment_label = Gtk.Label('has a mixed-case name')
                    comment_label.show()
                    hbox.pack_start(name_label, False, False, 0)
                    hbox.pack_start(comment_label, False, False, 0)
                    pages.append(
                        Caja.PropertyPage(name='Mixed::PropertyPage',
                                          label=page_label,
                                          page=hbox))

        return pages
Пример #5
0
    def get_property_pages(self, files):
        if len(files) != 1:
            return
        
        file = files[0]
        if file.get_uri_scheme() != 'file':
            return

        if file.is_directory():
            return

        filename = file.get_location().get_path()

        self.property_label = Gtk.Label('MD5Sum')
        self.property_label.show()

        self.hbox = Gtk.HBox(homogeneous=False, spacing=0)
        self.hbox.show()

        label = Gtk.Label('MD5Sum:')
        label.show()
        self.hbox.pack_start(label, False, False, 0)

        self.value_label = Gtk.Label()
        self.hbox.pack_start(self.value_label, False, False, 0)

        md5sum = hashlib.md5()
        with open(filename,'rb') as f: 
            for chunk in iter(lambda: f.read(8192), b''): 
                md5sum.update(chunk)
        f.close()       

        self.value_label.set_text(md5sum.hexdigest())
        self.value_label.show()
        
        return Caja.PropertyPage(name="CajaPython::md5_sum",
                                     label=self.property_label, 
                                     page=self.hbox),