Skip to content

Commit

Permalink
Use sample directory to create temp sample too
Browse files Browse the repository at this point in the history
  • Loading branch information
deviantfero committed Aug 19, 2021
1 parent b9193d1 commit 4854f42
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion wpgtk/data/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import logging

__version__ = '6.5.1'
__version__ = '6.5.2'


settings = None
Expand Down
4 changes: 2 additions & 2 deletions wpgtk/data/sample.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
import pywal

from .config import WALL_DIR
from .config import SAMPLE_DIR

try:
import Image
except ImportError:
from PIL import Image


def create_sample(colors, f=os.path.join(WALL_DIR, ".tmp.sample.png")):
def create_sample(colors, f=os.path.join(SAMPLE_DIR, ".tmp.sample.png")):
"""Creates sample image from a pywal color dictionary"""
im = Image.new("RGB", (480, 50), "white")
pix = im.load()
Expand Down
12 changes: 6 additions & 6 deletions wpgtk/gui/color_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil
import pywal

from ..data.config import WALL_DIR
from ..data.config import SAMPLE_DIR
from ..data import color
from ..data import util
from ..data import files
Expand Down Expand Up @@ -86,7 +86,7 @@ def __init__(self, parent):
self.colorgrid.attach(self.button_list[cont], x, y + 1, 1, 1)
cont += 1

sample_name = os.path.join(WALL_DIR, ".no_sample.sample.png")
sample_name = os.path.join(SAMPLE_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(
Expand Down Expand Up @@ -197,20 +197,20 @@ def hls_change(self, widget, *gparam):

def render_sample(self):
sample.create_sample(self.color_list)
sample_path = os.path.join(WALL_DIR, ".tmp.sample.png")
sample_path = os.path.join(SAMPLE_DIR, ".tmp.sample.png")
self.pixbuf_sample = GdkPixbuf.Pixbuf.new_from_file_at_size(
str(sample_path),
sample_path,
width=500,
height=300)
self.sample.set_from_pixbuf(self.pixbuf_sample)

def on_ok_click(self, widget):
color.write_colors(self.selected_file, self.color_list)
tmpfile = os.path.join(WALL_DIR, ".tmp.sample.png")
tmpfile = os.path.join(SAMPLE_DIR, ".tmp.sample.png")

if(os.path.isfile(tmpfile)):
shutil.move(
os.path.join(WALL_DIR, ".tmp.sample.png"),
os.path.join(SAMPLE_DIR, ".tmp.sample.png"),
files.get_sample_path(self.selected_file))

self.done_lbl.set_text("Changes saved")
Expand Down

0 comments on commit 4854f42

Please sign in to comment.