Example #1
0
 def on_rm_clicked(self, widget):
     x = self.option_combo.get_active()
     current_walls = files.get_file_list()
     if current_walls:
         filename = current_walls[x]
         themer.delete_theme(filename)
         option_list = Gtk.ListStore(str)
         for elem in list(files.get_file_list()):
             option_list.append([elem])
         self.option_combo.set_model(option_list)
         self.option_combo.set_entry_text_column(0)
         self.colorscheme.set_model(option_list)
         self.colorscheme.set_entry_text_column(0)
         self.cpage.update_combo(option_list)
Example #2
0
    def on_add_clicked(self, widget):
        filepath = ""
        filechooser = Gtk.FileChooserDialog(
                      'Select an Image', self,
                      Gtk.FileChooserAction.OPEN,
                      (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                       Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

        filefilter = Gtk.FileFilter()
        filefilter.set_name("Images")
        filefilter.add_mime_type("image/png")
        filefilter.add_mime_type("image/jpg")
        filefilter.add_mime_type("image/jpeg")
        filechooser.add_filter(filefilter)
        response = filechooser.run()

        if response == Gtk.ResponseType.OK:
            filepath = filechooser.get_filename()
        filechooser.destroy()

        themer.create_theme(filepath)
        option_list = Gtk.ListStore(str)

        for elem in list(files.get_file_list()):
            option_list.append([elem])
        self.option_combo.set_model(option_list)
        self.option_combo.set_entry_text_column(0)
        self.colorscheme.set_model(option_list)
        self.colorscheme.set_entry_text_column(0)
        self.cpage.update_combo(option_list)
Example #3
0
    def on_add_clicked(self, widget):
        filechooser = Gtk.FileChooserDialog(
            "Select an Image", self.parent, Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN,
             Gtk.ResponseType.OK))
        filefilter = Gtk.FileFilter()
        filefilter.set_name("Text")
        filefilter.add_mime_type("text/*")
        filechooser.add_filter(filefilter)
        response = filechooser.run()

        if response == Gtk.ResponseType.OK:
            filepath = filechooser.get_filename()
            files.add_template(filepath)
            self.item_names = [
                filen for filen in files.get_file_list(config.OPT_DIR, False)
                if '.base' in filen
            ]
            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()
Example #4
0
 def on_set_clicked(self, widget):
     x = self.option_combo.get_active()
     y = self.colorscheme.get_active()
     current_walls = files.get_file_list()
     if current_walls:
         filename = current_walls[x]
         colorscheme_file = current_walls[y]
         themer.set_theme(filename, colorscheme_file)
Example #5
0
 def colorscheme_box_change(self, widget):
     x = self.colorscheme.get_active()
     selected_file = files.get_file_list()[x]
     samplepath = os.path.join(config.SAMPLE_DIR,
                               (selected_file + '.sample.png'))
     if(os.path.isfile(samplepath)):
         self.pixbuf_sample = GdkPixbuf.Pixbuf.new_from_file_at_size(
                              samplepath, width=500, height=500)
     self.sample.set_from_pixbuf(self.pixbuf_sample)
     self.cpage.set_edit_combo(x)
Example #6
0
    def combo_box_change(self, widget):
        self.set_button.set_sensitive(True)
        x = self.option_combo.get_active()
        self.colorscheme.set_active(x)
        selected_file = files.get_file_list()[x]
        filepath = os.path.join(config.WALL_DIR, selected_file)

        self.pixbuf_preview = GdkPixbuf.Pixbuf.new_from_file_at_scale(
            str(filepath),
            width=500,
            height=333,
            preserve_aspect_ratio=False)
        self.preview.set_from_pixbuf(self.pixbuf_preview)
Example #7
0
    def __init__(self, parent):
        Gtk.Grid.__init__(self)
        self.current = None
        self.sel_file = ''

        self.parent = parent
        self.set_border_width(PAD)
        self.set_column_homogeneous(1)
        self.set_row_spacing(PAD)
        self.set_column_spacing(PAD)

        self.grid_edit = Gtk.Grid()
        self.grid_edit.set_column_homogeneous(1)
        self.grid_edit.set_row_spacing(PAD)
        self.grid_edit.set_column_spacing(PAD)

        self.button_add = Gtk.Button('Add')
        self.button_add.connect('clicked', self.on_add_clicked)
        self.button_rm = Gtk.Button('Remove')
        self.button_rm.connect('clicked', self.on_rm_clicked)
        self.button_open = Gtk.Button('Edit')
        self.button_open.connect('clicked', self.on_open_clicked)

        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(config.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)
Example #8
0
 def combo_box_change(self, widget):
     self.done_lbl.set_text("")
     config.RCC = []
     x = self.option_combo.get_active()
     self.auto_button.set_sensitive(True)
     self.shuffle_button.set_sensitive(True)
     self.ok_button.set_sensitive(True)
     current_walls = files.get_file_list()
     self.selected_file = current_walls[x]
     sample_path = os.path.join(config.SAMPLE_DIR,
                                (self.selected_file + '.sample.png'))
     self.color_list = color.get_color_list(self.selected_file)
     self.render_buttons()
     self.pixbuf_sample = GdkPixbuf.Pixbuf\
         .new_from_file_at_size(sample_path, width=500, height=300)
     self.sample.set_from_pixbuf(self.pixbuf_sample)
Example #9
0
 def on_ok_click(self, widget):
     current_walls = files.get_file_list()
     if len(current_walls) > 0:
         x = self.option_combo.get_active()
         color.write_colors(current_walls[x], self.color_list)
         tmpfile = os.path.join(config.WALL_DIR, ".tmp.sample.png")
         if (os.path.isfile(tmpfile)):
             shutil.move(
                 os.path.join(config.WALL_DIR, ".tmp.sample.png"),
                 os.path.join(config.SAMPLE_DIR,
                              (current_walls[x] + ".sample.png")))
             self.done_lbl.set_text("Changes saved")
             x = self.parent.colorscheme.get_active()
             selected_sample = "sample/" + self.selected_file + ".sample.png"
             sample_path = os.path.join(config.WALL_DIR, selected_sample)
             self.parent.pixbuf_sample = GdkPixbuf.Pixbuf.new_from_file_at_size(
                 sample_path, width=500, height=300)
             self.parent.sample.set_from_pixbuf(self.pixbuf_sample)
Example #10
0
    def __init__(self, args):
        Gtk.Window.__init__(self, title='wpgtk ' + config.__version__)

        image_name = os.path.join(config.WPG_DIR, '.current')
        image_name = os.path.realpath(image_name)
        self.set_default_size(200, 200)
        self.args = args

        # these variables are just to get the image
        # and preview of current wallpaper
        file_name = themer.get_current()
        print('INF::CURRENT WALL: ' + file_name)
        sample_name = os.path.join(config.SAMPLE_DIR,
                                   (file_name + '.sample.png'))

        self.notebook = Gtk.Notebook()
        self.add(self.notebook)

        self.wpage = Gtk.Grid()
        self.wpage.set_border_width(PAD)
        self.wpage.set_column_homogeneous(1)
        self.wpage.set_row_spacing(PAD)
        self.wpage.set_column_spacing(PAD)

        self.cpage = color_grid.ColorGrid(self)
        self.fpage = template_grid.TemplateGrid(self)
        self.optpage = option_grid.OptionsGrid(self)
        self.keypage = keyword_grid.KeywordGrid(self)

        self.notebook.append_page(self.wpage, Gtk.Label('Wallpapers'))
        self.notebook.append_page(self.cpage, Gtk.Label('Colors'))
        self.notebook.append_page(self.fpage, Gtk.Label('Templates'))
        self.notebook.append_page(self.keypage, Gtk.Label('Keywords'))
        self.notebook.append_page(self.optpage, Gtk.Label('Options'))

        option_list = Gtk.ListStore(str)
        for elem in list(files.get_file_list()):
            option_list.append([elem])
        self.option_combo = Gtk.ComboBox.new_with_model(option_list)
        self.renderer_text = Gtk.CellRendererText()
        self.option_combo.pack_start(self.renderer_text, True)
        self.option_combo.add_attribute(self.renderer_text, 'text', 0)
        self.option_combo.set_entry_text_column(0)

        self.textbox = Gtk.Label()
        self.textbox.set_text('Select colorscheme')
        self.colorscheme = Gtk.ComboBox.new_with_model(option_list)
        self.colorscheme.pack_start(self.renderer_text, True)
        self.colorscheme.add_attribute(self.renderer_text, 'text', 0)
        self.colorscheme.set_entry_text_column(0)

        self.set_border_width(10)
        # another container will be added so this will probably change
        # self.add(self.wpage)
        self.preview = Gtk.Image()
        self.sample = Gtk.Image()

        if(os.path.isfile(image_name) and os.path.isfile(sample_name)):
            self.pixbuf_preview = GdkPixbuf.Pixbuf.new_from_file_at_scale(
                                  image_name,
                                  width=500,
                                  height=333, preserve_aspect_ratio=False)
            self.pixbuf_sample = GdkPixbuf.Pixbuf.new_from_file_at_size(
                                 sample_name,
                                 width=500, height=500)
            self.preview.set_from_pixbuf(self.pixbuf_preview)
            self.sample.set_from_pixbuf(self.pixbuf_sample)

        self.add_button = Gtk.Button(label='Add')
        self.set_button = Gtk.Button(label='Set')
        self.set_button.set_sensitive(False)
        self.rm_button = Gtk.Button(label='Remove')
        # adds to first cell in wpage
        self.wpage.attach(self.option_combo, 1, 1, 2, 1)
        self.wpage.attach(self.colorscheme, 1, 2, 2, 1)
        self.wpage.attach(self.set_button, 3, 1, 1, 1)
        self.wpage.attach(self.add_button, 3, 2, 2, 1)
        self.wpage.attach(self.rm_button, 4, 1, 1, 1)
        self.wpage.attach(self.preview, 1, 3, 4, 1)
        self.wpage.attach(self.sample, 1, 4, 4, 1)
        self.add_button.connect('clicked', self.on_add_clicked)
        self.set_button.connect('clicked', self.on_set_clicked)
        self.rm_button.connect('clicked', self.on_rm_clicked)
        self.option_combo.connect('changed', self.combo_box_change)
        self.colorscheme.connect('changed', self.colorscheme_box_change)
        self.entry = Gtk.Entry()
        self.current_walls = Gtk.ComboBox()
Example #11
0
    def __init__(self, parent):
        Gtk.Grid.__init__(self)
        self.parent = parent
        self.set_border_width(PAD)
        self.set_column_homogeneous(1)
        self.set_row_spacing(PAD)
        self.set_column_spacing(PAD)

        self.colorgrid = Gtk.Grid()
        self.colorgrid.set_border_width(PAD)
        self.colorgrid.set_column_homogeneous(1)
        self.colorgrid.set_row_spacing(PAD)
        self.colorgrid.set_column_spacing(PAD)

        self.button_grid = Gtk.Grid()
        self.button_grid.set_column_homogeneous(1)
        self.button_grid.set_column_spacing(PAD)

        self.color_list = []
        self.button_list = []
        self.selected_file = ""
        for x in range(0, 16):
            self.color_list.append('000000')
        for x in range(0, 16):
            self.button_list.append(self.make_button(self.color_list[x]))
            self.button_list[x].connect("pressed", self.on_color_click)
            self.button_list[x].set_sensitive(False)

        cont = 0
        for y in range(0, 8, 2):
            for x in range(0, 4):
                label = Gtk.Label(cont)
                self.colorgrid.attach(label, x, y, 1, 1)
                cont += 1

        cont = 0
        for y in range(1, 9, 2):
            for x in range(0, 4):
                self.colorgrid.attach(self.button_list[cont], x, y, 1, 1)
                cont += 1

        sample_name = os.path.join(config.WALL_DIR, ".no_sample.sample.png")
        self.sample = Gtk.Image()
        if (os.path.isfile(sample_name)):
            self.pixbuf_sample = GdkPixbuf.Pixbuf.new_from_file_at_size(
                sample_name, width=500, height=300)
            self.sample.set_from_pixbuf(self.pixbuf_sample)

        sampler_name = os.path.join(config.WALL_DIR, ".nsampler.sample.png")
        self.sampler = Gtk.Image()
        if (os.path.isfile(sampler_name)):
            self.pixbuf_sampler = GdkPixbuf.Pixbuf.new_from_file_at_size(
                sampler_name, width=500, height=300)
            self.sampler.set_from_pixbuf(self.pixbuf_sampler)

        self.shuffle_button = Gtk.Button("Shuffle colors")
        self.shuffle_button.connect("pressed", self.on_shuffle_click)
        self.shuffle_button.set_sensitive(False)

        self.ok_button = Gtk.Button("Save")
        self.ok_button.connect("pressed", self.on_ok_click)
        self.ok_button.set_sensitive(False)

        self.auto_button = Gtk.Button("Auto-adjust")
        self.auto_button.connect("pressed", self.on_auto_click)
        self.auto_button.set_sensitive(False)

        self.done_lbl = Gtk.Label("")

        option_list = Gtk.ListStore(str)
        for elem in list(files.get_file_list()):
            option_list.append([elem])
        self.option_combo = Gtk.ComboBox.new_with_model(option_list)
        self.renderer_text = Gtk.CellRendererText()
        self.option_combo.pack_start(self.renderer_text, True)
        self.option_combo.add_attribute(self.renderer_text, "text", 0)
        self.option_combo.set_entry_text_column(0)
        self.option_combo.connect("changed", self.combo_box_change)

        self.button_grid.attach(self.ok_button, 0, 0, 1, 1)
        self.button_grid.attach(self.auto_button, 1, 0, 1, 1)
        self.button_grid.attach(self.shuffle_button, 2, 0, 1, 1)

        self.attach(self.option_combo, 0, 0, 1, 1)
        self.attach(self.button_grid, 0, 1, 1, 1)
        self.attach(self.colorgrid, 0, 2, 1, 1)
        self.attach(self.sample, 0, 3, 1, 1)
        self.attach(self.sampler, 0, 4, 1, 1)
        self.attach(self.done_lbl, 0, 5, 1, 1)
Example #12
0
import os
import shutil
import pywal
from wpgtk.data import color, util
from wpgtk.data import config, files, sample
from .color_picker import ColorDialog
from random import shuffle
from gi import require_version
from gi.repository import Gtk, Gdk, GdkPixbuf
require_version("Gtk", "3.0")

current_walls = files.get_file_list()
PAD = 10


class ColorGrid(Gtk.Grid):
    def __init__(self, parent):
        Gtk.Grid.__init__(self)
        self.parent = parent
        self.set_border_width(PAD)
        self.set_column_homogeneous(1)
        self.set_row_spacing(PAD)
        self.set_column_spacing(PAD)

        self.colorgrid = Gtk.Grid()
        self.colorgrid.set_border_width(PAD)
        self.colorgrid.set_column_homogeneous(1)
        self.colorgrid.set_row_spacing(PAD)
        self.colorgrid.set_column_spacing(PAD)

        self.button_grid = Gtk.Grid()
Example #13
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('-s',
                        help='set the wallpaper and colorscheme, apply \
                        changes system-wide',
                        nargs='*')
    parser.add_argument('-r',
                        help='restore the wallpaper and colorscheme',
                        action='store_true')
    parser.add_argument('-m',
                        help='pick a random wallpaper and set it',
                        action='store_true')
    parser.add_argument('-a',
                        help='add images to the wallpaper folder and generate \
                        colorschemes',
                        nargs='*')
    parser.add_argument('-l',
                        help='see which wallpapers are available',
                        action='store_true')
    parser.add_argument('--version',
                        help='print the current version',
                        action='store_true')
    parser.add_argument('-d',
                        help='delete the wallpaper(s) from wallpaper folder',
                        nargs='*')
    parser.add_argument('-c',
                        help='shows the current wallpaper',
                        action='store_true')
    parser.add_argument('-z',
                        help='shuffles the given colorscheme(s)',
                        nargs='*')
    parser.add_argument('-t',
                        help='send color sequences to all terminals VTE true',
                        action='store_true')
    parser.add_argument('-x',
                        help='add, remove and list \
                             templates instead of themes',
                        action='store_true')
    parser.add_argument(
        '-y',
        help='add an existent basefile template [config, basefile]',
        nargs='*')

    config.init()
    args = parser.parse_args()

    if args.m:
        filename = random.choice(files.get_file_list())
        themer.set_theme(filename, filename)
        exit(0)

    if args.s:
        if len(args.s) == 1:
            try:
                themer.set_theme(args.s[0], args.s[0], args.r)
            except TypeError as e:
                print('ERR:: file ' + args.s[0] + ' not found')
                raise e
        elif len(args.s) == 2:
            try:
                themer.set_theme(args.s[0], args.s[1], args.r)
            except TypeError:
                print('ERR:: file  not found')
        elif len(args.s) > 2:
            print('ERR:: Specify just 2 filenames')

    if args.l:
        if args.x:
            templates = files.get_file_list(config.OPT_DIR, False)
            [print(t) for t in templates if '.base' in t]
        else:
            files.show_files()
        exit(0)

    if args.t:
        Popen(['cat', path.join(config.WPG_DIR, 'sequences')])
        exit(0)

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

    if args.d:
        for e in args.d:
            if args.x:
                files.remove_template(e)
            else:
                themer.delete_theme(e)
        exit(0)

    if args.c:
        themer.get_current(show=True)

    if args.a:
        if args.x:
            files.add_template(args.a[0])
        else:
            for e in args.a:
                themer.create_theme(e)
        exit(0)

    if args.z:
        for arg in args.z:
            themer.shuffle_colors(arg)
            themer.auto_adjust_theme(arg)
            print('OK:: shuffled %s' % arg)
        exit(0)

    if args.y:
        files.add_template(args.y[0], args.y[1])
        exit(0)

    if (len(sys.argv) < 2):
        try:
            theme_picker.run(args)
        except NameError:
            print('ERR:: missing pygobject module, use cli', file=sys.stderr)