Skip to content

Commit

Permalink
Fix #31
Browse files Browse the repository at this point in the history
  • Loading branch information
gnunn1 committed Jan 17, 2016
1 parent b4a670a commit eb9166e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
12 changes: 12 additions & 0 deletions data/gsettings/com.gexperts.Terminix.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,17 @@
<default>'disabled'</default>
<summary>Keyboard shortcut to toggle whether the terminal is read-only</summary>
</key>
<key name="terminal-copy" type="s">
<default>'&lt;Ctrl&gt;&lt;Shift&gt;c'</default>
<summary>Keyboard shortcut to copy selected text in terminal</summary>
</key>
<key name="terminal-paste" type="s">
<default>'&lt;Ctrl&gt;&lt;Shift&gt;v'</default>
<summary>Keyboard shortcut to paste text in terminal from clipboard</summary>
</key>
<key name="terminal-select-all" type="s">
<default>'&lt;Ctrl&gt;&lt;Shift&gt;a'</default>
<summary>Keyboard shortcut to select all text in terminal</summary>
</key>
</schema>
</schemalist>
5 changes: 4 additions & 1 deletion source/gx/terminix/terminal/actions.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ enum ACTION_CLOSE = "close";
enum ACTION_PROFILE_SELECT = "profile-select";
enum ACTION_ENCODING_SELECT = "encoding-select";
enum ACTION_PROFILE_PREFERENCE = "profile-preference";
enum ACTION_READ_ONLY = "read-only";
enum ACTION_READ_ONLY = "read-only";
enum ACTION_COPY = "copy";
enum ACTION_PASTE = "paste";
enum ACTION_SELECT_ALL = "select-all";
19 changes: 13 additions & 6 deletions source/gx/terminix/terminal/terminal.d
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ private:
registerActionWithSettings(group, ACTION_PREFIX, ACTION_FIND_PREVIOUS, gsShortcuts, delegate(GVariant, SimpleAction) { vte.searchFindPrevious(); });
registerActionWithSettings(group, ACTION_PREFIX, ACTION_FIND_NEXT, gsShortcuts, delegate(GVariant, SimpleAction) { vte.searchFindNext(); });

//Clipboard actions
registerActionWithSettings(group, ACTION_PREFIX, ACTION_COPY, gsShortcuts, delegate(GVariant, SimpleAction) { vte.copyClipboard(); });
registerActionWithSettings(group, ACTION_PREFIX, ACTION_PASTE, gsShortcuts, delegate(GVariant, SimpleAction) { pasteClipboard(); });
registerActionWithSettings(group, ACTION_PREFIX, ACTION_SELECT_ALL, gsShortcuts, delegate(GVariant, SimpleAction) { vte.selectAll(); });

//Override terminal title
registerActionWithSettings(group, ACTION_PREFIX, ACTION_TITLE, gsShortcuts, delegate(GVariant, SimpleAction) {
string terminalTitle = overrideTitle is null ? gsProfile.getString(SETTINGS_PROFILE_TITLE_KEY) : overrideTitle;
Expand Down Expand Up @@ -497,11 +502,11 @@ private:
});

mContext = new Menu();
miCopy = new MenuItem(delegate(MenuItem item) { vte.copyClipboard(); }, _("Copy"), null);
miCopy = new MenuItem(null, _("Copy"), getActionDetailedName(ACTION_PREFIX, ACTION_COPY));
mContext.add(miCopy);
miPaste = new MenuItem(delegate(MenuItem item) { pasteClipboard(); }, _("Paste"), null);
miPaste = new MenuItem(null, _("Paste"), getActionDetailedName(ACTION_PREFIX, ACTION_PASTE));
mContext.add(miPaste);
miSelectAll = new MenuItem(delegate(MenuItem item) {vte.selectAll(); }, _("Select All"), null);
miSelectAll = new MenuItem(null, _("Select All"), getActionDetailedName(ACTION_PREFIX, ACTION_SELECT_ALL));
mContext.add(new SeparatorMenuItem());
mContext.add(miSelectAll);

Expand Down Expand Up @@ -556,7 +561,7 @@ private:
string pasteText = Clipboard.get(null).waitForText();
if ((pasteText.indexOf("sudo") > -1) && (pasteText.indexOf ("\n") != 0)) {
if (!unsafePasteIgnored && gsSettings.getBoolean(SETTINGS_UNSAFE_PASTE_ALERT_KEY)) {
UnsafePasteDialog dialog = new UnsafePasteDialog(cast(Window)getToplevel());
UnsafePasteDialog dialog = new UnsafePasteDialog(cast(Window)getToplevel(), pasteText);
scope(exit) {dialog.destroy();}
if (dialog.run() == 1) return;
else unsafePasteIgnored = true;
Expand Down Expand Up @@ -754,6 +759,7 @@ private:
} else {
desc = PgFontDescription.fromString(gsProfile.getString(SETTINGS_PROFILE_FONT_KEY));
}
if (desc.getSize() == 0) desc.setSize(10);
vte.setFont(desc);
break;
default:
Expand Down Expand Up @@ -1330,15 +1336,16 @@ package class UnsafePasteDialog: MessageDialog {

public:

this(Window parent) {
this(Window parent, string cmd) {
super(parent, DialogFlags.MODAL, MessageType.WARNING, ButtonsType.NONE, null, null);
setTransientFor(parent);
getMessageArea().setMarginLeft(0);
getMessageArea().setMarginRight(0);
setMarkup("<span weight='bold' size='larger'>" ~
_("This command is asking for Administrative access to your computer") ~ "</span>\n\n" ~
_("Copying commands from the internet can be dangerous. ") ~ "\n" ~
_("Be sure you understand what each part of this command does."));
_("Be sure you understand what each part of this command does.") ~ "\n\n" ~
"<tt><b>" ~ chomp(cmd) ~ "</b></tt>");
setImage(new Image("dialog-warning", IconSize.DIALOG));
Button btnCancel = new Button(_("Don't Paste"));
Button btnIgnore = new Button(_("Paste Anyway"));
Expand Down

0 comments on commit eb9166e

Please sign in to comment.