[dconf-editor] Make copy use set_accels_for_action.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Make copy use set_accels_for_action.
- Date: Fri, 30 Nov 2018 12:13:40 +0000 (UTC)
commit 89ce029f1c1b22ca90ac33bb7456fceae89213a4
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Nov 29 15:11:29 2018 +0100
Make copy use set_accels_for_action.
editor/dconf-editor.vala | 1 +
editor/dconf-window.vala | 44 +++++++++++++++++++++++++++++---------------
2 files changed, 30 insertions(+), 15 deletions(-)
---
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index d671eea..15f51d3 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -297,6 +297,7 @@ private class ConfigurationEditor : Gtk.Application
add_action_entries (action_entries, this);
set_accels_for_action ("kbd.toggle-bookmark", { "<Primary>b",
"<Shift><Primary>b" });
+ set_accels_for_action ("kbd.copy", { "<Primary>c" });
set_accels_for_action ("kbd.copy-path", { "<Shift><Primary>c" });
set_accels_for_action ("kbd.bookmark", { "<Primary>d" });
set_accels_for_action ("kbd.unbookmark", { "<Shift><Primary>d" });
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 53896b7..ef661f3 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -1020,6 +1020,7 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
{
// keyboard calls
{ "toggle-bookmark", toggle_bookmark }, // <P>b & <P>B
+ { "copy", copy }, // <P>c
{ "copy-path", copy_path }, // <P>C
{ "bookmark", bookmark }, // <P>d
{ "unbookmark", unbookmark }, // <P>D
@@ -1060,6 +1061,34 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
show_in_window_bookmarks ();
}
+ private void copy (/* SimpleAction action, Variant? path_variant */)
+ {
+ Widget? focus = get_focus ();
+ if (focus != null)
+ {
+ if ((!) focus is Entry)
+ {
+ ((Entry) (!) focus).copy_clipboard ();
+ return;
+ }
+ if ((!) focus is TextView)
+ {
+ ((TextView) (!) focus).copy_clipboard ();
+ return;
+ }
+ }
+
+ model.copy_action_called ();
+
+ browser_view.discard_row_popover (); // TODO avoid duplicate get_selected_row () call
+
+ string? selected_row_text = browser_view.get_copy_text ();
+ if (selected_row_text == null && current_type == ViewType.OBJECT)
+ selected_row_text = model.get_suggested_key_copy_text (current_path,
browser_view.last_context_id);
+ ConfigurationEditor application = (ConfigurationEditor) get_application ();
+ application.copy (selected_row_text == null ? current_path : (!) selected_row_text);
+ }
+
private void copy_path (/* SimpleAction action, Variant? path_variant */)
{
if (browser_view.in_window_bookmarks) // TODO better
@@ -1574,21 +1603,6 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
{
switch (name)
{
- case "c":
- if (focus_is_text_widget)
- return false;
-
- model.copy_action_called ();
-
- browser_view.discard_row_popover (); // TODO avoid duplicate get_selected_row () call
-
- string? selected_row_text = browser_view.get_copy_text ();
- if (selected_row_text == null && current_type == ViewType.OBJECT)
- selected_row_text = model.get_suggested_key_copy_text (current_path,
browser_view.last_context_id);
- ConfigurationEditor application = (ConfigurationEditor) get_application ();
- application.copy (selected_row_text == null ? current_path : (!) selected_row_text);
- return true;
-
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]