[dconf-editor] Make paste use set_accels_for_action.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Make paste use set_accels_for_action.
- Date: Fri, 30 Nov 2018 12:13:45 +0000 (UTC)
commit 0a0789165009d454cb0e2c5e8da23acdba0d12ef
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Nov 29 15:45:49 2018 +0100
Make paste use set_accels_for_action.
editor/dconf-editor.vala | 1 +
editor/dconf-window.vala | 73 ++++++++++++++++++++++++++----------------------
2 files changed, 40 insertions(+), 34 deletions(-)
---
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 15f51d3..1f6a4bc 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -310,6 +310,7 @@ private class ConfigurationEditor : Gtk.Application
set_accels_for_action ("kbd.edit-path-last", { "<Shift><Primary>l" });
set_accels_for_action ("app.quit", { "<Primary>q" });
set_accels_for_action ("app.apply-and-quit", { "<Shift><Primary>q" });
+ set_accels_for_action ("kbd.paste", { "<Primary>v" }); // TODO
<Shift><Primary>v something? // https://bugzilla.gnome.org/show_bug.cgi?id=762257 is WONTFIX
set_accels_for_action ("kbd.open-root", { "<Shift><Alt>Up" });
set_accels_for_action ("kbd.open-parent", { "<Alt>Up" });
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index ef661f3..7d6b9cb 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -1031,6 +1031,7 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
{ "modifications", modifications_list }, // <A>i
{ "edit-path-end", edit_path_end }, // <P>l
{ "edit-path-last", edit_path_last }, // <P>L
+ { "paste", paste }, // <P>v
{ "open-root", open_root }, // <S><A>Up
{ "open-parent", open_current_parent }, // <A>Up
@@ -1243,6 +1244,41 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_LAST_WORD);
}
+ private void paste (/* SimpleAction action, Variant? variant */)
+ {
+ if (browser_view.in_window_bookmarks)
+ return;
+ if (browser_view.in_window_modifications)
+ return;
+ if (browser_view.in_window_about)
+ return;
+
+ Widget? focus = get_focus ();
+ if (focus != null)
+ {
+ if ((!) focus is Entry)
+ {
+ ((Entry) (!) focus).paste_clipboard ();
+ return;
+ }
+ if ((!) focus is TextView)
+ {
+ ((TextView) (!) focus).paste_clipboard ();
+ return;
+ }
+ }
+
+ Gdk.Display? display = Gdk.Display.get_default ();
+ if (display == null) // ?
+ return;
+
+ string? clipboard_content = Clipboard.get_default ((!) display).wait_for_text ();
+ if (clipboard_content != null)
+ request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, clipboard_content);
+ else
+ request_search (true, PathEntry.SearchMode.SEARCH);
+ }
+
private void open_root (/* SimpleAction action, Variant? variant */)
{
if (browser_view.in_window_bookmarks)
@@ -1596,40 +1632,6 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
return true;
}
- Widget? focus = get_focus ();
- bool focus_is_text_widget = focus != null && (((!) focus is Entry) || ((!) focus is TextView));
-
- if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
- {
- switch (name)
- {
- case "v": // https://bugzilla.gnome.org/show_bug.cgi?id=762257 is WONTFIX // TODO
<Shift><Primary>v something?
- if (browser_view.in_window_bookmarks)
- return false;
- if (browser_view.in_window_modifications)
- return false;
- if (browser_view.in_window_about)
- return false;
-
- if (focus_is_text_widget)
- return false;
-
- Gdk.Display? display = Gdk.Display.get_default ();
- if (display == null) // ?
- return false;
-
- string? clipboard_content = Clipboard.get_default ((!) display).wait_for_text ();
- if (clipboard_content != null)
- request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, clipboard_content);
- else
- request_search (true, PathEntry.SearchMode.SEARCH);
- return true;
-
- default:
- break;
- }
- }
-
/* for changing row during search; cannot use set_accels_for_action() else popovers are not handled
anymore */
if (name == "Down" && (event.state & Gdk.ModifierType.MOD1_MASK) == 0) // see also <ctrl>g
return _next_match ();
@@ -1643,6 +1645,9 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
if (browser_view.in_window_about)
return false;
+ Widget? focus = get_focus ();
+ bool focus_is_text_widget = focus != null && (((!) focus is Entry) || ((!) focus is TextView));
+
/* don't use "else if", or some widgets will not be hidden on <ctrl>F10 or such things */
if (name == "F10" && (event.state & Gdk.ModifierType.SHIFT_MASK) != 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]