Skip to content

Commit

Permalink
Merge pull request #512 from Vulcalien/mouse-paste
Browse files Browse the repository at this point in the history
Add 'Disable mouse paste'
  • Loading branch information
mattrose committed Sep 13, 2021
2 parents 28a2b03 + 2251a34 commit 5f8dabf
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 62 deletions.
1 change: 1 addition & 0 deletions terminatorlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
'always_split_with_profile': False,
'putty_paste_style' : False,
'putty_paste_style_source_clipboard': False,
'disable_mouse_paste' : False,
'smart_copy' : True,
'clear_select_on_copy' : False,
'line_height' : 1.0,
Expand Down
109 changes: 56 additions & 53 deletions terminatorlib/preferences.glade
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
</packing>
</child>
<child>
<!-- n-columns=4 n-rows=8 -->
<!-- n-columns=4 n-rows=9 -->
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -679,8 +679,8 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="width">3</property>
<property name="top-attach">5</property>
<property name="width">4</property>
</packing>
</child>
<child>
Expand All @@ -694,53 +694,6 @@
<property name="draw-indicator">True</property>
<signal name="toggled" handler="on_use_custom_url_handler_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="left-padding">12</property>
<child>
<object class="GtkBox" id="hbox11">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label33">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Custom URL handler:</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom_url_handler_entry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="invisible-char">•</property>
<property name="primary-icon-activatable">False</property>
<property name="secondary-icon-activatable">False</property>
<signal name="changed" handler="on_custom_url_handler_entry_changed" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
Expand Down Expand Up @@ -808,15 +761,65 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
<property name="top-attach">6</property>
<property name="width">4</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkCheckButton" id="disable_mouse_paste">
<property name="label" translatable="yes">Disable mouse paste</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="xalign">0.5</property>
<property name="draw-indicator">True</property>
<signal name="toggled" handler="on_disable_mouse_paste_toggled" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="width">4</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkBox" id="hbox11">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">12</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label33">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Custom URL handler:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom_url_handler_entry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="invisible-char">•</property>
<property name="primary-icon-activatable">False</property>
<property name="secondary-icon-activatable">False</property>
<signal name="changed" handler="on_custom_url_handler_entry_changed" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
<property name="width">4</property>
</packing>
</child>
<child>
<placeholder/>
Expand Down
8 changes: 8 additions & 0 deletions terminatorlib/prefseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ def set_values(self):
# Clear selection on copy
widget = guiget('clear_select_on_copy')
widget.set_active(self.config['clear_select_on_copy'])
# Disable mouse paste
widget = guiget('disable_mouse_paste')
widget.set_active(self.config['disable_mouse_paste'])

## Profile tab
# Populate the profile list
Expand Down Expand Up @@ -842,6 +845,11 @@ def on_clear_select_on_copy_toggled(self,widget):
self.config['clear_select_on_copy'] = widget.get_active()
self.config.save()

def on_disable_mouse_paste_toggled(self, widget):
"""Disable mouse paste"""
self.config['disable_mouse_paste'] = widget.get_active()
self.config.save()

def on_cursor_blink_toggled(self, widget):
"""Cursor blink setting changed"""
self.config['cursor_blink'] = widget.get_active()
Expand Down
19 changes: 10 additions & 9 deletions terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,9 +978,9 @@ def on_buttonpress(self, widget, event):

if self.config['putty_paste_style']:
middle_click = [self.popup_menu, (widget, event)]
right_click = [self.paste_clipboard, (not self.config['putty_paste_style_source_clipboard'], )]
right_click = [self.paste_clipboard, (not self.config['putty_paste_style_source_clipboard'], True)]
else:
middle_click = [self.paste_clipboard, (True, )]
middle_click = [self.paste_clipboard, (True, True)]
right_click = [self.popup_menu, (widget, event)]

# Ctrl-click event here.
Expand Down Expand Up @@ -1621,14 +1621,15 @@ def open_url(self, url, prepare=False):
webbrowser.open(url)


def paste_clipboard(self, primary=False):
def paste_clipboard(self, primary=False, mouse=False):
"""Paste one of the two clipboards"""
for term in self.terminator.get_target_terms(self):
if primary:
term.vte.paste_primary()
else:
term.vte.paste_clipboard()
self.vte.grab_focus()
if not (mouse and self.config['disable_mouse_paste']):
for term in self.terminator.get_target_terms(self):
if primary:
term.vte.paste_primary()
else:
term.vte.paste_clipboard()
self.vte.grab_focus()

def feed(self, text):
"""Feed the supplied text to VTE"""
Expand Down

0 comments on commit 5f8dabf

Please sign in to comment.