Example #1
0
    def write_creation_time_callback(self, provider, handle, closure, fileinfo):
        """
        Callback to update the creation time for a file.
        """
        filename = fileinfo.get_location().get_path()
        try:
            crtime = get_crtime(filename)
        except:
            traceback.print_exc()  # Log exceptions
        else:
            # get_crtime() returns None if on an unsupported file system
            if crtime is not None:
                struct_time = time.gmtime(crtime)
                # Respect Nemo's time formatting. XXX: can we get this data from Nemo directly?
                settings = Gio.Settings.new('org.nemo.preferences')
                timeformat = settings.get_enum('date-format')

                if timeformat == NEMO_DATE_FORMAT_LOCALE:
                    formatted_time = time.strftime('%c', struct_time)
                else:  # XXX: no support for "informal" time format yet
                    formatted_time = time.strftime('%Y-%m-%d %H:%M:%S', struct_time)
                fileinfo.invalidate_extension_info()
                fileinfo.add_string_attribute('creation_time', formatted_time)

        # Tell nemo that we're done processing.
        Nemo.info_provider_update_complete_invoke(closure, provider,
                                                  handle, Nemo.OperationResult.COMPLETE)
        return False
Example #2
0
    def update_cb(self, provider, handle, closure, file):
        self.current_idle_id = 0

        self.do_update_file_info(file)

        Nemo.info_provider_update_complete_invoke(
            closure, provider, handle, Nemo.OperationResult.COMPLETE)

        return False
    def update_cb(self, provider, handle, closure, file):
        self.do_update_file_info(file)

        if handle in self.ids_by_handle.keys():
            del self.ids_by_handle[handle]

        Nemo.info_provider_update_complete_invoke(closure, provider, handle, Nemo.OperationResult.COMPLETE)

        return False
Example #4
0
    def _update_file_info(self, provider, handle, closure, item):
        path = self.uri_to_path(item.get_uri())
        state = self.file_states.get(path)
        item.connect('changed', self.changed_cb)

        self.fetch_file_state(path)
        Nemo.info_provider_update_complete_invoke(
            closure, provider, handle, Nemo.OperationResult.COMPLETE)

        return False
Example #5
0
    def update_cb(self, provider, handle, closure, file):
        self.do_update_file_info(file)

        if handle in self.ids_by_handle.keys():
            del self.ids_by_handle[handle]

        Nemo.info_provider_update_complete_invoke(
            closure, provider, handle, Nemo.OperationResult.COMPLETE)

        return False
    def _update_file_info(self, provider, handle, closure, item):
        path = self.uri_to_path(item.get_uri())
        state = self.file_states.get(path)
        item.connect('changed', self.changed_cb)

        self.fetch_file_state(path)
        Nemo.info_provider_update_complete_invoke(
            closure, provider, handle, Nemo.OperationResult.COMPLETE)

        return False
    def update_cb(self, provider, handle, closure, file):
        # stopit uses threads, so don't give it anything that isn't safe

        mimetype = file.get_mime_type()
        # Recent and Favorites set the G_FILE_ATTRIBUTE_STANDARD_TARGET_URI attribute
        # to their real files' locations. Use that uri in those cases.
        uri = file.get_activation_uri()
        info = None

        if uri.startswith("file"):
            try:
                with stopit.ThreadingTimeout(.1):
                    info = self.get_media_info(uri, mimetype)
            except stopit.utils.TimeoutException:
                print(
                    "nemo-media-columns failed to process '%s' within a reasonable amount of time"
                    % (gfile.get_uri(), e))

        # TODO: we shouldn't set attributes on files that didn't match any of our mimetypes.
        # we do currently so the given columns can be set to '' - we should maybe do this in
        # nemo (https://github.com/linuxmint/nemo/blob/master/libnemo-private/nemo-file.c#L6811-L6814)
        # so that here we only set files that we support.
        #
        # get_media_info can return None if nothing matched, or there was an error, instead of always
        # adding the attributes to a file whether it's useful or not.

        if info == None:
            info = FileExtensionInfo()

        # if info:
        self.set_file_attributes(file, info)
        del info

        if handle in self.ids_by_handle.keys():
            del self.ids_by_handle[handle]

        Nemo.info_provider_update_complete_invoke(
            closure, provider, handle, Nemo.OperationResult.COMPLETE)

        return False
 def update_cb(self, provider, handle, closure):
     print "update_cb"
     Nemo.info_provider_update_complete_invoke(closure, provider, handle,
                                               Nemo.OperationResult.FAILED)
 def update_cb(self, provider, handle, closure):
     print "update_cb"
     Nemo.info_provider_update_complete_invoke(closure, provider, handle, Nemo.OperationResult.FAILED)