Ejemplo n.º 1
0
 def create_window(self, filename=None, template=None):
     """Creates a new strip and stores its configuration in the directory
     path."""
     if filename is None:
         f, filename = tempfile.mkstemp('.strip', '', STRIPS_DIR, True)
         os.close(f)
     settings = Settings(filename)
     if template:
         settings.update(template)
     settings['cache-file'] = filename.rsplit('.', 1)[0] + '.cache'
     window = comics_view.ComicsViewer(self, settings, self.visible)
     self.windows.append(window)
     window.connect('removed', self.on_window_removed)
     window.connect('updated', self.on_window_updated)
     settings.save()
Ejemplo n.º 2
0
 def create_window(self, filename=None, template=None):
     """Creates a new strip and stores its configuration in the directory
     path."""
     if filename is None:
         f, filename = tempfile.mkstemp('.strip', '', STRIPS_DIR, True)
         os.close(f)
     settings = Settings(filename)
     if template:
         settings.update(template)
     settings['cache-file'] = filename.rsplit('.', 1)[0] + '.cache'
     window = comics_view.ComicsViewer(self, settings, self.visible)
     self.windows.append(window)
     window.connect('removed', self.on_window_removed)
     window.connect('updated', self.on_window_updated)
     settings.save()
Ejemplo n.º 3
0
    def on_add_assistant_apply(self, widget):
        try:
            os.mkdir(USER_FEEDS_DIR)
        except Exception:
            pass

        if self.from_list:
            model, paths = self.sys_list.get_selection().get_selected_rows()
            for path in paths:
                self.name = model.get_value(model.get_iter(path), 0)
                src = model.get_value(model.get_iter(path), 1)
                filename = USER_FEEDS_DIR + src[len(SYS_FEEDS_DIR):]
                with open(src, 'r') as fp:
                    src_content = fp.read()
                try:
                    with open(filename, 'r') as fp:
                        f = fp.read()
                except IOError:
                    f = None
                if f:
                    if cmp(src_content, f) == 0:
                        continue
                    msg = _("Overwrite comic \"%s\"?") % self.name
                    sec = _(
                 "This comic is already installed with different settings.")
                    dialog = gtk.MessageDialog(parent=self.assistant,
                                   flags=gtk.DIALOG_DESTROY_WITH_PARENT,
                                   type=gtk.MESSAGE_WARNING,
                                   message_format=msg)
                    dialog.format_secondary_markup(sec)
                    if path != paths[-1]:
                        dialog.add_buttons(
                                       gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
                    dialog.add_buttons(gtk.STOCK_NO, gtk.RESPONSE_NO,
                                       gtk.STOCK_YES, gtk.RESPONSE_YES)
                    response = dialog.run()
                    dialog.destroy()
                    if response == gtk.RESPONSE_NO:
                        continue
                    if response != gtk.RESPONSE_YES:
                        return
                with open(filename, 'w') as fp:
                    fp.write(src_content)
                self.feeds.add_feed(filename)
                self.feeds.update()
                self.__parent.toggle_feed(self.name, True)
        else:
            self.name = self.ui.get_object('name_entry').get_text()
            f, filename = tempfile.mkstemp('.feed', '', USER_FEEDS_DIR, True)
            os.close(f)
            settings = Settings(filename)
            settings.description = 'Automatically generated by comics'
            settings[NAME] = self.name
            settings[URL] = self.url
            settings[IMG_INDEX] = self.image[0] + 1
            settings.comments[IMG_INDEX] = \
                'The index of the image in the HTML-code'
            if self.feed.__module__.startswith('feed.plugins.'):
                settings[PLUGIN] = self.feed.__module__[13:]
            settings.save()
            self.feeds.add_feed(filename)
            self.feeds.update()
            self.__parent.toggle_feed(self.name, True)
Ejemplo n.º 4
0
    def on_add_assistant_apply(self, widget):
        try:
            os.mkdir(USER_FEEDS_DIR)
        except Exception:
            pass

        if self.from_list:
            model, paths = self.sys_list.get_selection().get_selected_rows()
            for path in paths:
                self.name = model.get_value(model.get_iter(path), 0)
                src = model.get_value(model.get_iter(path), 1)
                filename = USER_FEEDS_DIR + src[len(SYS_FEEDS_DIR):]
                with open(src, 'r') as fp:
                    src_content = fp.read()
                try:
                    with open(filename, 'r') as fp:
                        f = fp.read()
                except IOError:
                    f = None
                if f:
                    if cmp(src_content, f) == 0:
                        continue
                    msg = _("Overwrite comic \"%s\"?") % self.name
                    sec = _(
                        "This comic is already installed with different settings."
                    )
                    dialog = gtk.MessageDialog(
                        parent=self.assistant,
                        flags=gtk.DIALOG_DESTROY_WITH_PARENT,
                        type=gtk.MESSAGE_WARNING,
                        message_format=msg)
                    dialog.format_secondary_markup(sec)
                    if path != paths[-1]:
                        dialog.add_buttons(gtk.STOCK_CANCEL,
                                           gtk.RESPONSE_CANCEL)
                    dialog.add_buttons(gtk.STOCK_NO, gtk.RESPONSE_NO,
                                       gtk.STOCK_YES, gtk.RESPONSE_YES)
                    response = dialog.run()
                    dialog.destroy()
                    if response == gtk.RESPONSE_NO:
                        continue
                    if response != gtk.RESPONSE_YES:
                        return
                with open(filename, 'w') as fp:
                    fp.write(src_content)
                self.feeds.add_feed(filename)
                self.feeds.update()
                self.__parent.toggle_feed(self.name, True)
        else:
            self.name = self.ui.get_object('name_entry').get_text()
            f, filename = tempfile.mkstemp('.feed', '', USER_FEEDS_DIR, True)
            os.close(f)
            settings = Settings(filename)
            settings.description = 'Automatically generated by comics'
            settings[NAME] = self.name
            settings[URL] = self.url
            settings[IMG_INDEX] = self.image[0] + 1
            settings.comments[IMG_INDEX] = \
                'The index of the image in the HTML-code'
            if self.feed.__module__.startswith('feed.plugins.'):
                settings[PLUGIN] = self.feed.__module__[13:]
            settings.save()
            self.feeds.add_feed(filename)
            self.feeds.update()
            self.__parent.toggle_feed(self.name, True)