-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added drag and drop clipboard example
- Loading branch information
Showing
7 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Drag and Drop Clipboard | ||
|
||
This is a proof-of-concept for a drag and drop clipboard area. | ||
|
||
NOTE: This example makes use of the `loop_widget` and `droptarget` branches | ||
|
||
<p align="center"> | ||
<img src=".github/preview.gif"> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
* { | ||
all: unset; | ||
} | ||
|
||
.clipboard { | ||
background-color: #707070; | ||
padding: 10px; | ||
} | ||
|
||
.files { | ||
background-color: blue; | ||
margin: 10px; | ||
} | ||
.file { | ||
margin: 10px; | ||
background-color: green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; Note: there are definitely some rough edges here, this is just a proof of concept | ||
|
||
(defwindow bar | ||
:monitor 0 | ||
:geometry (geometry :anchor "top left" :x 350 :y 50 :width "200px" :height "100px") | ||
(box :class "top" | ||
(clipboard))) | ||
|
||
(defvar file_list "") | ||
|
||
(defwidget clipboard [] | ||
(eventbox | ||
:class "clipboard" | ||
;:ondropped "${eww_command} update tmp_value={}" | ||
:ondropped "./update-file-list.py {}" | ||
:dragvalue {file_list} | ||
(files :file_list file_list))) | ||
|
||
|
||
(defwidget files [file_list] | ||
(box :class "files" | ||
(for f in file_list | ||
(file :file f)))) | ||
|
||
|
||
(defwidget file [file] | ||
(eventbox :class "file" | ||
:ondropped "./update-file-list.py {}" | ||
:dragvalue {file} | ||
(label :text file))) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/python3 | ||
|
||
import sys | ||
import subprocess | ||
import json | ||
from io import StringIO | ||
|
||
eww_files_var = "file_list" | ||
|
||
# get "file_list" from eww | ||
r = subprocess.run(['eww', 'get', eww_files_var], stdout=subprocess.PIPE) | ||
io = StringIO(r.stdout.decode('utf-8')) | ||
|
||
# try loading file_list as json or initialize a new empty list | ||
try: | ||
file_list = json.load(io) | ||
except json.decoder.JSONDecodeError: | ||
file_list = [] | ||
|
||
# if the file_list is full, pop one file from it | ||
if len(file_list) >= 3: | ||
file_list.pop(0) | ||
|
||
# add the new file to the end of the list | ||
new_file = sys.argv[1] | ||
file_list.append(new_file) | ||
|
||
# update eww's file_list | ||
r = subprocess.run(['eww', 'update', eww_files_var+ '=' + json.dumps(file_list)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters