Пример #1
0
    def __init__(self):
        UITricks.__init__(self, 'ui/webilder_desktop.glade',
            'WebilderDesktopWindow')
        self.sort_combo.set_active(1)       # date
        renderer = gtk.CellRendererText()
        self.tree.append_column(
            column=gtk.TreeViewColumn("Album", renderer, markup=0))
        self.tree.columns_autosize()
        self.load_collection_tree(config.get('collection.dir'))
        self.iconview.set_pixbuf_column(IV_PIXBUF_COLUMN)
        self.iconview.set_markup_column(IV_TEXT_COLUMN)
        self.on_iconview_handle_selection_changed(self.iconview)
        self.collection_monitor = dict(monitor=None, dir=None)
        self.image_popup = ImagePopup(self)
        self.download_dialog = None

        if gnomevfs:
            self.tree_monitor = gnomevfs.monitor_add(
                config.get('collection.dir'),
                gnomevfs.MONITOR_DIRECTORY,
                self.collection_tree_changed)

        self.restore_window_state()
        self.top_widget.show_all()

        self.hand_cursor = gtk.gdk.Cursor(gtk.gdk.HAND2)
Пример #2
0
    def __init__(self):
        UITricks.__init__(self, 'ui/webilder_desktop.glade',
                          'WebilderDesktopWindow')
        self.sort_combo.set_active(1)  # date
        renderer = gtk.CellRendererText()
        self.tree.append_column(
            column=gtk.TreeViewColumn("Album", renderer, markup=0))
        self.tree.columns_autosize()
        self.load_collection_tree(config.get('collection.dir'))
        self.iconview.set_pixbuf_column(IV_PIXBUF_COLUMN)
        self.iconview.set_markup_column(IV_TEXT_COLUMN)
        self.on_iconview_handle_selection_changed(self.iconview)
        self.collection_monitor = dict(monitor=None, dir=None)
        self.image_popup = ImagePopup(self)
        self.download_dialog = None

        if gnomevfs:
            self.tree_monitor = gnomevfs.monitor_add(
                config.get('collection.dir'), gnomevfs.MONITOR_DIRECTORY,
                self.collection_tree_changed)

        self.restore_window_state()
        self.top_widget.show_all()

        self.hand_cursor = gtk.gdk.Cursor(gtk.gdk.HAND2)
Пример #3
0
 def load_recent_photos(self):
     """Loads the most recent photos (72hrs)."""
     images = glob.glob(
         os.path.join(config.get('collection.dir'), '*', '*.jpg'))
     png_images = glob.glob(
         os.path.join(config.get('collection.dir'), '*', '*.png'))
     images.extend(png_images)
     recent_time = time.time() - 72 * 3600
     images = [(os.path.getmtime(fname), fname) for fname in images]
     images = [pair for pair in images if pair[0] > recent_time]
     images = [pair[1] for pair in sorted(images, reverse=True)]
     self.load_collection(images)
Пример #4
0
 def load_recent_photos(self):
     """Loads the most recent photos (72hrs)."""
     images = glob.glob(
         os.path.join(config.get('collection.dir'), '*', '*.jpg'))
     png_images = glob.glob(
         os.path.join(config.get('collection.dir'), '*', '*.png'))
     images.extend(png_images)
     recent_time = time.time() - 72*3600
     images = [(os.path.getmtime(fname), fname) for fname in images]
     images = [pair for pair in images if pair[0] > recent_time]
     images = [pair[1] for pair in sorted(images, reverse=True)]
     self.load_collection(images)
Пример #5
0
    def next_photo(self, *_args):
        """Changes to the next photo."""
        reload_config()
        croot = config.get('collection.dir')
        if not self.wallpaper_list:
            self.wallpaper_list = glob.glob(
                os.path.join(croot, '*', '*.jpg'))
            png_images = glob.glob(
                os.path.join(croot, '*', '*.png'))
            self.wallpaper_list.extend(png_images)
            random.shuffle(self.wallpaper_list)
        if self.wallpaper_list:
            self.last_rotate = time.time()-15 # to ensure next time...
            wallpaper = self.wallpaper_list.pop()

            image_file = os.path.join(croot, wallpaper)
            dirname, base = os.path.split(image_file)
            basename, _unused_ext = os.path.splitext(base)
            self.info_file = os.path.join(dirname, basename)+'.inf'
            self.image_info = infofile.parse_info_file(self.info_file)
            self.image_file = image_file
            title = self.image_info.get('title', basename)
            set_wallpaper(image_file, title)
            album = self.image_info.get('albumTitle', dirname)
            self.set_tooltip_for_photo('%s - %s' % (title, album))
Пример #6
0
    def __init__(self):
        UITricks.__init__(self, 'ui/webilder.glade', 'DonateDialog')
        text = _('''
Webilder is trying hard to make your desktop the coolest in town.

Since you installed it on %(inst_date)s, it downloaded <b>%(downloads)d photos</b>
for you and changed your wallpaper <b>%(rotations)d times</b>.

It takes a lot of time and hard work to develop and maintain Webilder.

If you'd like to see Webilder becomes even better, you can help us
a lot by making a small donation.

Any donation will be GREATLY appreciated. You can even donate $5.

After clicking on the <i>Yes</i> button below you'll be taken to
the donation page. If the page does not appear, please visit:
%(url)s

Would you like to donate to Webilder?
''')

        stats = config.get('webilder.stats')
        self.url = 'http://www.webilder.org/donate.html'
        context = dict(
                downloads = stats['downloads'],
                rotations = stats['rotations'],
                inst_date = time.strftime('%B %Y'),
                url = self.url
                )

        self.donate_copy.set_markup(text % context)
Пример #7
0
    def __init__(self):
        UITricks.__init__(self, 'ui/webilder.glade', 'DonateDialog')
        text = _('''
Webilder is trying hard to make your desktop the coolest in town.

Since you installed it on %(inst_date)s, it downloaded <b>%(downloads)d photos</b>
for you and changed your wallpaper <b>%(rotations)d times</b>.

It takes a lot of time and hard work to develop and maintain Webilder.

If you'd like to see Webilder becomes even better, you can help us
a lot by making a small donation.

Any donation will be GREATLY appreciated. You can even donate $5.

After clicking on the <i>Yes</i> button below you'll be taken to
the donation page. If the page does not appear, please visit:
%(url)s

Would you like to donate to Webilder?
''')

        stats = config.get('webilder.stats')
        self.url = 'http://www.webilder.org/donate.html'
        context = dict(downloads=stats['downloads'],
                       rotations=stats['rotations'],
                       inst_date=time.strftime('%B %Y'),
                       url=self.url)

        self.donate_copy.set_markup(text % context)
Пример #8
0
    def next_photo(self, *_args):
        """Changes to the next photo."""
        reload_config()
        croot = config.get('collection.dir')
        if not self.wallpaper_list:
            self.wallpaper_list = glob.glob(os.path.join(croot, '*', '*.jpg'))
            png_images = glob.glob(os.path.join(croot, '*', '*.png'))
            self.wallpaper_list.extend(png_images)
            random.shuffle(self.wallpaper_list)
        if self.wallpaper_list:
            self.last_rotate = time.time() - 15  # to ensure next time...
            wallpaper = self.wallpaper_list.pop()

            image_file = os.path.join(croot, wallpaper)
            set_wallpaper(image_file)

            dirname, base = os.path.split(image_file)
            basename, _unused_ext = os.path.splitext(base)
            info_file = os.path.join(dirname, basename) + '.inf'
            try:
                fileobj = open(info_file, 'r')
                inf = parse_metadata(fileobj.read())
                fileobj.close()
            except IOError:
                inf = {}
            self.image_file = image_file
            self.info_file = info_file
            title = inf.get('title', basename)
            album = inf.get('albumTitle', dirname)
            self.set_tooltip_for_photo('%s - %s' % (title, album))
Пример #9
0
 def __init__(self):
     self.wallpaper_list = []
     self.last_rotate = time.time()
     self.last_autodownload = (config.get('autodownload.last_time')
                               or (time.time() - 50 * 3600))
     self.last_version_check = time.time() - 9 * 3600
     self.leech_thread = None
     self._tt_photo = self._tt_announce = self.image_file = ''
     self.info_file = ''
Пример #10
0
 def __init__(self):
     self.wallpaper_list = []
     self.last_rotate = time.time()
     self.last_autodownload = (config.get('autodownload.last_time') or
                               (time.time() - 50*3600))
     self.last_version_check = time.time()-9*3600
     self.leech_thread = None
     self._tt_photo = self._tt_announce = self.image_file = ''
     self.info_file = ''
Пример #11
0
 def restore_window_state(self):
     """Restores windows location and layout from config."""
     d = config.get('webilder.layout')
     if d.has_key('window_position'):
         self.top_widget.move(*d['window_position'])
     if d.has_key('window_size'):
         self.top_widget.resize(*d['window_size'])
     if d.has_key('hpaned_position'):
         self.hpaned.set_position(d['hpaned_position'])
     if d.has_key('info_expander'):
         self.photo_info_expander.set_expanded(d['info_expander'])
Пример #12
0
 def restore_window_state(self):
     """Restores windows location and layout from config."""
     d = config.get('webilder.layout')
     if d.has_key('window_position'):
         self.top_widget.move(*d['window_position'])
     if d.has_key('window_size'):
         self.top_widget.resize(*d['window_size'])
     if d.has_key('hpaned_position'):
         self.hpaned.set_position(d['hpaned_position'])
     if d.has_key('info_expander'):
         self.photo_info_expander.set_expanded(d['info_expander'])
Пример #13
0
    def timer_event(self, *_args):
        """Called on regular basis to check if it is time to download photos
        or change wallpaper."""
        try:
            reload_config()
            now = time.time()
            rotate_interval = (config.get('rotate.enabled')
                               and config.get('rotate.interval') * 60)
            autodownload_interval = (config.get('autodownload.enabled')
                                     and config.get('autodownload.interval') *
                                     3600)
            if rotate_interval:
                # check if we have to rotate
                if now - self.last_rotate >= rotate_interval:
                    print "Rotating..."
                    self.next_photo()

            if CHECK_FOR_UPDATES and now - self.last_version_check >= 8 * 3600:
                self.last_version_check = now
                response = VersionCheckerOpener().open(CHECK_URL)
                latest = response.readlines()
                response.close()
                if latest[0].strip() != __version__:
                    self.set_tooltip_announce(''.join(latest[1:]))
                else:
                    pass

            if autodownload_interval:
                if now - self.last_autodownload >= autodownload_interval:
                    print "Time to autodownload."
                    self.last_autodownload = now
                    self.leech_thread = threading.Thread(
                        target=downloader.download_all)
                    self.leech_thread.setDaemon(True)
                    self.leech_thread.start()
                    config.set('autodownload.last_time', now)
                    config.save_config()
        finally:
            return True  # pylint: disable=W0150
Пример #14
0
    def timer_event(self, *_args):
        """Called on regular basis to check if it is time to download photos
        or change wallpaper."""
        try:
            reload_config()
            now = time.time()
            rotate_interval = (config.get('rotate.enabled') and
                               config.get('rotate.interval')*60)
            autodownload_interval = (config.get('autodownload.enabled') and
                                     config.get('autodownload.interval')*3600)
            if rotate_interval:
                # check if we have to rotate
                if now-self.last_rotate >= rotate_interval:
                    print "Rotating..."
                    self.next_photo()

            if CHECK_FOR_UPDATES and now-self.last_version_check >= 8*3600:
                self.last_version_check = now
                response = VersionCheckerOpener().open(CHECK_URL)
                latest = response.readlines()
                response.close()
                if latest[0].strip() != __version__:
                    self.set_tooltip_announce(''.join(latest[1:]))
                else:
                    pass

            if autodownload_interval:
                if now-self.last_autodownload >= autodownload_interval:
                    print "Time to autodownload."
                    self.last_autodownload = now
                    self.leech_thread = threading.Thread(
                        target=downloader.download_all)
                    self.leech_thread.setDaemon(True)
                    self.leech_thread.start()
                    config.set('autodownload.last_time', now)
                    config.save_config()
        finally:
            return True  # pylint: disable=W0150
Пример #15
0
        except LeechPremiumOnlyPhotoError:
            print _("   Photo is available only to premium members. Skipping.")
            continue  # skip this photo (goes back to for)

        if terminate():
            break
        try:
            image, metadata = photo['_plugin']['module'].process_photo(
                config, photo, memfile)
            save_photo(config, photo, image, metadata)
        except IOError, exc:
            print "IOError: ", str(exc)
        else:
            completed += 1

    stats = config.get('webilder.stats')
    stats['downloads'] += completed
    config.set('webilder.stats', stats)
    config.save_config()


import socket

socket.setdefaulttimeout(120)


def main():
    """Command line interface for photo downloader."""
    def notify(_fraction, status, message):
        """Called when the download logic wants to notify us."""
        print message, status
Пример #16
0
 def current(self, _action):
     """Opens the current dialog."""
     reload_config()
     CurrentDialog.show_current_dialog(config.get('wallpaper.title'), config.get('wallpaper.path'))
Пример #17
0
            continue # skip this photo (goes back to for)
        except:
            continue

        if terminate():
            break
        try:
            image, metadata = photo['_plugin']['module'].process_photo(
                config, photo, memfile)
            save_photo(config, photo, image, metadata)
        except IOError, exc:
            print "IOError: ", str(exc)
        else:
            completed += 1

    stats = config.get('webilder.stats')
    stats['downloads'] += completed
    config.set('webilder.stats', stats)
    config.save_config()


import socket
socket.setdefaulttimeout(120)

def main():
    """Command line interface for photo downloader."""
    def notify(_fraction, status, message):
        """Called when the download logic wants to notify us."""
        print message, status
    download_all(notify)
Пример #18
0
 def collection_tree_changed(self, *_args):
     """Called when the collection tree changes."""
     self.load_collection_tree(config.get('collection.dir'))
Пример #19
0
 def collection_tree_changed(self, *_args):
     """Called when the collection tree changes."""
     self.load_collection_tree(config.get('collection.dir'))