Skip to content

Commit 83ad702

Browse files
committed
feat(settings): add "Enter to paste" toggle to settings window
closes #7
1 parent 2486c9b commit 83ad702

6 files changed

Lines changed: 56 additions & 31 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ install: nuitka
9494
@mkdir -p "$(DESKTOP_DEST_DIR)"
9595
@printf "%s\n" \
9696
"[Desktop Entry]" \
97-
"Version=0.3.0" \
97+
"Version=0.3.1" \
9898
"Type=Application" \
9999
"Name=Clipse GUI" \
100100
"GenericName=Clipboard Manager" \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ These define the external command-line tools used for interacting with the syste
165165
| :----------------------------- | :----- | :------------------------------------ | :------------------------------------------------------------------------------------------------- |
166166
| `copy_tool_cmd` | String | `wl-copy` | Command used to **copy** data **to** the clipboard on Wayland sessions. |
167167
| `x11_copy_tool_cmd` | String | `xclip -i -selection clipboard` | Command used to **copy** data **to** the clipboard on X11 sessions. |
168-
| `paste_simulation_cmd_wayland` | String | `wtype -M ctrl -P v -m ctrl` | Command used to **simulate paste** (e.g., Ctrl+V) on Wayland sessions. Requires `wtype` installed. |
168+
| `paste_simulation_cmd_wayland` | String | `wtype -M ctrl -P v -p v -m ctrl` | Command used to **simulate paste** (e.g., Ctrl+V) on Wayland sessions. Requires `wtype` installed. |
169169
| `paste_simulation_cmd_x11` | String | `xdotool key --clearmodifiers ctrl+v` | Command used to **simulate paste** (e.g., Ctrl+V) on X11 sessions. Requires `xdotool` installed. |
170170
171171
#### `[UI]`

bump_version.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ def get_current_version():
1515
if not init_file.exists():
1616
print("Error: clipse_gui/__init__.py not found")
1717
sys.exit(1)
18-
18+
1919
content = init_file.read_text()
2020
match = re.search(r'__version__ = "([^"]+)"', content)
2121
if not match:
2222
print("Error: Could not find version in __init__.py")
2323
sys.exit(1)
24-
24+
2525
return match.group(1)
2626

2727

2828
def parse_version(version_str):
2929
"""Parse version string into major, minor, patch components"""
3030
try:
31-
parts = version_str.split('.')
31+
parts = version_str.split(".")
3232
if len(parts) != 3:
3333
raise ValueError("Version must have 3 parts")
3434
return [int(part) for part in parts]
@@ -40,7 +40,7 @@ def parse_version(version_str):
4040
def bump_version(current_version, bump_type):
4141
"""Bump version based on type (major, minor, patch)"""
4242
major, minor, patch = parse_version(current_version)
43-
43+
4444
if bump_type == "major":
4545
major += 1
4646
minor = 0
@@ -53,21 +53,19 @@ def bump_version(current_version, bump_type):
5353
else:
5454
print(f"Error: Invalid bump type '{bump_type}'. Use major, minor, or patch")
5555
sys.exit(1)
56-
56+
5757
return f"{major}.{minor}.{patch}"
5858

5959

6060
def update_init_file(new_version):
6161
"""Update version in __init__.py"""
6262
init_file = Path("clipse_gui/__init__.py")
6363
content = init_file.read_text()
64-
64+
6565
new_content = re.sub(
66-
r'__version__ = "[^"]+"',
67-
f'__version__ = "{new_version}"',
68-
content
66+
r'__version__ = "[^"]+"', f'__version__ = "{new_version}"', content
6967
)
70-
68+
7169
init_file.write_text(new_content)
7270
print(f"Updated clipse_gui/__init__.py to version {new_version}")
7371

@@ -78,15 +76,11 @@ def update_makefile(new_version):
7876
if not makefile.exists():
7977
print("Warning: Makefile not found, skipping desktop entry version update")
8078
return
81-
79+
8280
content = makefile.read_text()
83-
84-
new_content = re.sub(
85-
r'"Version=[^"]*"',
86-
f'"Version={new_version}"',
87-
content
88-
)
89-
81+
82+
new_content = re.sub(r'"Version=[^"]*"', f'"Version={new_version}"', content)
83+
9084
makefile.write_text(new_content)
9185
print(f"Updated Makefile desktop entry to version {new_version}")
9286

@@ -96,19 +90,19 @@ def interactive_bump():
9690
current_version = get_current_version()
9791
print(f"Current version: {current_version}")
9892
print()
99-
93+
10094
# Show what each bump type would result in
10195
major_version = bump_version(current_version, "major")
10296
minor_version = bump_version(current_version, "minor")
10397
patch_version = bump_version(current_version, "patch")
104-
98+
10599
print("Select bump type:")
106100
print(f"1. Major: {current_version}{major_version}")
107101
print(f"2. Minor: {current_version}{minor_version}")
108102
print(f"3. Patch: {current_version}{patch_version}")
109103
print("4. Cancel")
110104
print()
111-
105+
112106
while True:
113107
try:
114108
choice = input("Enter choice (1-4): ").strip()
@@ -137,28 +131,28 @@ def main():
137131
print("Usage: python bump_version.py [major|minor|patch]")
138132
print("Or run without arguments for interactive mode")
139133
sys.exit(1)
140-
134+
141135
current_version = get_current_version()
142136
new_version = bump_version(current_version, bump_type)
143137
print(f"Bumping {bump_type} version: {current_version}{new_version}")
144138
else:
145139
# Interactive mode
146140
bump_type, new_version = interactive_bump()
147141
print(f"Bumping {bump_type} version to {new_version}")
148-
142+
149143
# Confirm the change
150144
confirm = input("Proceed with version bump? (y/N): ").strip().lower()
151145
if confirm not in ["y", "yes"]:
152146
print("Cancelled")
153147
sys.exit(0)
154-
148+
155149
# Update files
156150
update_init_file(new_version)
157151
update_makefile(new_version)
158-
152+
159153
print(f"Version successfully bumped to {new_version}")
160154
print("Don't forget to commit the changes!")
161155

162156

163157
if __name__ == "__main__":
164-
main()
158+
main()

clipse_gui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.0"
1+
__version__ = "0.3.1"

clipse_gui/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"Commands": {
3131
"copy_tool_cmd": "wl-copy",
3232
"x11_copy_tool_cmd": "xclip -i -selection clipboard",
33-
"paste_simulation_cmd_wayland": "wtype -M ctrl -P v -m ctrl",
33+
"paste_simulation_cmd_wayland": "wtype -M ctrl -P v -p v -m ctrl",
3434
"paste_simulation_cmd_x11": "xdotool key --clearmodifiers ctrl+v",
3535
},
3636
"UI": {
@@ -82,7 +82,7 @@
8282
"Commands", "x11_copy_tool_cmd", fallback="xclip -i -selection clipboard"
8383
)
8484
PASTE_SIMULATION_CMD_WAYLAND = config.get(
85-
"Commands", "paste_simulation_cmd_wayland", fallback="wtype -M ctrl -P v -m ctrl"
85+
"Commands", "paste_simulation_cmd_wayland", fallback="wtype -M ctrl -P v -p v -m ctrl"
8686
)
8787
PASTE_SIMULATION_CMD_X11 = config.get(
8888
"Commands",

clipse_gui/ui_components.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
PROTECT_PINNED_ITEMS,
1616
COMPACT_MODE,
1717
HOVER_TO_SELECT,
18+
ENTER_TO_PASTE,
1819
config,
1920
)
2021

@@ -311,6 +312,16 @@ def show_settings_window(parent_window, close_cb, restart_app_cb=None):
311312
hover_switch.set_active(HOVER_TO_SELECT)
312313
hover_switch.set_halign(Gtk.Align.END)
313314

315+
# Enter to Paste setting
316+
enter_paste_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
317+
enter_paste_label = Gtk.Label(label="Enter to paste:")
318+
enter_paste_label.set_halign(Gtk.Align.START)
319+
enter_paste_label.set_hexpand(True)
320+
321+
enter_paste_switch = Gtk.Switch()
322+
enter_paste_switch.set_active(ENTER_TO_PASTE)
323+
enter_paste_switch.set_halign(Gtk.Align.END)
324+
314325
settings_changed = False
315326

316327
# Buttons (need to define apply_btn before callback functions)
@@ -377,9 +388,25 @@ def on_hover_switch_toggled(switch, state):
377388

378389
# Note: Hover-to-select requires restart to take effect since it affects row creation
379390

391+
def on_enter_paste_switch_toggled(switch, state):
392+
nonlocal settings_changed
393+
settings_changed = True
394+
update_button_states()
395+
# Save to config
396+
if not config.config.has_section("General"):
397+
config.config.add_section("General")
398+
config.config.set("General", "enter_to_paste", str(switch.get_active()))
399+
config._save_config()
400+
401+
# Update the global for current session
402+
import clipse_gui.constants as constants
403+
404+
constants.ENTER_TO_PASTE = switch.get_active()
405+
380406
protect_switch.connect("state-set", on_protect_switch_toggled)
381407
compact_switch.connect("state-set", on_compact_switch_toggled)
382408
hover_switch.connect("state-set", on_hover_switch_toggled)
409+
enter_paste_switch.connect("state-set", on_enter_paste_switch_toggled)
383410

384411
protect_box.pack_start(protect_label, True, True, 0)
385412
protect_box.pack_start(protect_switch, False, False, 0)
@@ -390,9 +417,13 @@ def on_hover_switch_toggled(switch, state):
390417
hover_box.pack_start(hover_label, True, True, 0)
391418
hover_box.pack_start(hover_switch, False, False, 0)
392419

420+
enter_paste_box.pack_start(enter_paste_label, True, True, 0)
421+
enter_paste_box.pack_start(enter_paste_switch, False, False, 0)
422+
393423
settings_box.pack_start(protect_box, False, False, 0)
394424
settings_box.pack_start(compact_box, False, False, 0)
395425
settings_box.pack_start(hover_box, False, False, 0)
426+
settings_box.pack_start(enter_paste_box, False, False, 0)
396427

397428
main_box.pack_start(settings_box, True, True, 0)
398429

0 commit comments

Comments
 (0)