How to use the wpgtk.data.config.OPT_DIR function in wpgtk

To help you get started, we’ve selected a few wpgtk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deviantfero / wpgtk / wpgtk / data / color.py View on Github external
def change_templates(colors):
    """call change_colors on each custom template
    installed or defined by the user"""
    templates = files.get_file_list(OPT_DIR, images=False)
    templates = [x for x in templates if ".base" in x]

    try:
        for template in templates:
            original = template.split(".base").pop(0)
            args = (colors, os.path.join(OPT_DIR, original))
            t = threading.Thread(target=change_colors, args=args)
            t.start()

    except Exception as e:
        logging.error(str(e))
        logging.error("optional file " + original, file=sys.stderr)
github deviantfero / wpgtk / wpgtk / __main__.py View on Github external
themer.set_theme(filename, filename, args.r)
            exit(0)
        else:
            logging.error("you have no themes")
            exit(1)

    if args.s:
        if len(args.s) == 1:
            themer.set_theme(args.s[0], args.s[0], args.r)
        elif len(args.s) == 2:
            themer.set_theme(args.s[0], args.s[1], args.r)
        exit(0)

    if args.l:
        if args.t:
            templates = files.get_file_list(OPT_DIR, False)
            any(print(t) for t in templates if ".base" in t)
        else:
            print("\n".join(files.get_file_list()))
        exit(0)

    if args.version:
        print("current version: " + __version__)
        exit(0)

    if args.d:
        delete_action = files.delete_template if args.t \
                        else themer.delete_theme
        try:
            any(delete_action(x) for x in args.d)
        except IOError:
            logging.error("file not found")
github deviantfero / wpgtk / wpgtk / data / color.py View on Github external
def change_templates(colors):
    """call change_colors on each custom template
    installed or defined by the user"""
    templates = files.get_file_list(OPT_DIR, images=False)
    templates = [x for x in templates if ".base" in x]

    try:
        for template in templates:
            original = template.split(".base").pop(0)
            args = (colors, os.path.join(OPT_DIR, original))
            t = threading.Thread(target=change_colors, args=args)
            t.start()

    except Exception as e:
        logging.error(str(e))
        logging.error("optional file " + original, file=sys.stderr)
github deviantfero / wpgtk / wpgtk / data / files.py View on Github external
"""adds a new base file from a config file to wpgtk
    or re-establishes link with config file for a
    previously generated base file"""
    cfile = os.path.realpath(cfile)

    if bfile:
        template_name = basename(bfile)
    else:
        clean_atoms = [atom.lstrip(".") for atom in cfile.split("/")[-3::]]
        template_name = "_".join(clean_atoms) + ".base"

    try:
        shutil.copy2(cfile, cfile + ".bak")
        src_file = bfile if bfile else cfile

        shutil.copy2(src_file, join(OPT_DIR, template_name))
        os.symlink(cfile, join(OPT_DIR,
                               template_name.replace(".base", "")))

        logging.info("created backup %s.bak" % cfile)
        logging.info("added %s @ %s" % (template_name, cfile))
    except Exception as e:
        logging.error(str(e.strerror))
github deviantfero / wpgtk / wpgtk / gui / template_grid.py View on Github external
(Gtk.STOCK_CANCEL,
                                             Gtk.ResponseType.CANCEL,
                                             Gtk.STOCK_OPEN,
                                             Gtk.ResponseType.OK))
        filefilter = Gtk.FileFilter()
        filechooser.set_select_multiple(True)
        filefilter.set_name("Text")
        filefilter.add_mime_type("text/*")
        filechooser.add_filter(filefilter)
        response = filechooser.run()

        if response == Gtk.ResponseType.OK:
            for f in filechooser.get_filenames():
                files.add_template(f)
            self.item_names = [f for f in
                               files.get_file_list(OPT_DIR, False)
                               if '.base' in f]
            self.liststore = Gtk.ListStore(Pixbuf, str)
            for filen in self.item_names:
                pixbuf = Gtk.IconTheme.get_default().load_icon(icon, 64, 0)
                self.liststore.append([pixbuf, filen])
            self.file_view.set_model(self.liststore)
        filechooser.destroy()
        self.file_view.unselect_all()
github deviantfero / wpgtk / wpgtk / gui / template_grid.py View on Github external
self.liststore = Gtk.ListStore(Pixbuf, str)
        self.file_view = Gtk.IconView.new()
        self.file_view.set_model(self.liststore)
        self.file_view.set_activate_on_single_click(True)
        self.file_view.set_pixbuf_column(0)
        self.file_view.set_text_column(1)
        self.file_view.connect('item-activated', self.on_file_click)

        self.scroll = Gtk.ScrolledWindow()
        self.scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.scroll.set_min_content_height(400)
        self.scroll.add(self.file_view)

        self.item_names = [filen for filen in
                           files.get_file_list(OPT_DIR, False)
                           if '.base' in filen]

        for filen in self.item_names:
            pixbuf = Gtk.IconTheme.get_default().load_icon(icon, 64, 0)
            self.liststore.append([pixbuf, filen])

        self.grid_edit.attach(self.button_add, 0, 0, 2, 1)
        self.grid_edit.attach(self.button_rm, 0, 1, 1, 1)
        self.grid_edit.attach(self.button_open, 1, 1, 1, 1)
        self.grid_edit.attach(self.scroll, 0, 2, 2, 1)

        self.attach(self.grid_edit, 0, 0, 1, 1)
github deviantfero / wpgtk / wpgtk / data / files.py View on Github external
def delete_template(basefile):
    """delete a template in wpgtk with the given
    base file name"""
    base_file = join(OPT_DIR, basefile)
    conf_file = base_file.replace(".base", "")

    try:
        os.remove(base_file)
        if os.path.islink(conf_file):
            os.remove(conf_file)
    except Exception as e:
        logging.error(str(e.strerror))