[dconf-editor] Remove new_copy_action().
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Remove new_copy_action().
- Date: Fri, 26 Jan 2018 22:36:51 +0000 (UTC)
commit 57094112536a17dbf65a96c3285bdf552880777d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Jan 26 23:34:03 2018 +0100
Remove new_copy_action().
editor/browser-view.vala | 2 +-
editor/dconf-model.vala | 13 ++++++++++---
editor/dconf-window.vala | 6 +++---
editor/key-list-box-row.vala | 25 +++++++++++--------------
4 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 4fbf885..2f4275d 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -20,7 +20,7 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-view.ui")]
class BrowserView : Grid
{
- private string last_context = "";
+ public string last_context { get; private set; default = ""; }
[GtkChild] private BrowserInfoBar info_bar;
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index ff0e6f7..706fd75 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -148,7 +148,7 @@ public class SettingsModel : Object
return get_directory (path) != null;
}
- private static Key? get_key_from_path_and_name (GLib.ListStore? key_model, string key_name, string
schema_id = "")
+ private static Key? get_key_from_path_and_name (GLib.ListStore? key_model, string key_name, string
context = "")
{
if (key_model == null)
return null;
@@ -159,8 +159,15 @@ public class SettingsModel : Object
if (object == null)
assert_not_reached ();
if ((!) object is Key && ((!) object).name == key_name)
- if (schema_id == "" || object is GSettingsKey && (!) schema_id == (!) ((GSettingsKey)
object).schema_id)
+ {
+ // assumes for now you cannot have both a dconf key and a gsettings key with the same name
+ if (context == "")
+ return (Key) (!) object;
+ if ((!) object is GSettingsKey && context == ((GSettingsKey) (!) object).schema_id)
return (Key) (!) object;
+ if ((!) object is DConfKey && context == ".dconf") // return key even if not DConfKey?
+ return (Key) (!) object;
+ }
position++;
}
return null;
@@ -370,7 +377,7 @@ public class SettingsModel : Object
* * Key value methods
\*/
- public string get_key_copy_text (string full_name, string context = "")
+ public string get_key_copy_text (string full_name, string context)
{
Key? key = get_key (full_name, context);
if (key == null)
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 3ae5748..918ee83 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -568,8 +568,8 @@ class DConfWindow : ApplicationWindow
if (SettingsModel.is_key_path (current_path)) // mainly here for ensuring menu is never empty
{
- Variant variant = new Variant.string (model.get_key_copy_text (current_path));
- menu.append (_("Copy descriptor"), "app.copy(" + variant.print (false) + ")"); // TODO what
happens on multiple schemas defining one key?..
+ Variant variant = new Variant.string (model.get_key_copy_text (current_path,
browser_view.last_context));
+ menu.append (_("Copy descriptor"), "app.copy(" + variant.print (false) + ")");
}
else
{
@@ -690,7 +690,7 @@ class DConfWindow : ApplicationWindow
string? selected_row_text = browser_view.get_copy_text ();
if (selected_row_text == null && SettingsModel.is_key_path (current_path))
- selected_row_text = model.get_key_copy_text (current_path);
+ selected_row_text = model.get_key_copy_text (current_path,
browser_view.last_context);
ConfigurationEditor application = (ConfigurationEditor) get_application ();
application.copy (selected_row_text == null ? current_path : (!) selected_row_text);
return true;
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index f7cbfb3..a6c0385 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -79,6 +79,7 @@ private abstract class ClickableListBoxRow : EventBox
public signal void on_popover_disappear ();
public abstract string get_text ();
+ protected Variant get_text_variant () { return new Variant.string (get_text ()); }
public bool search_result_mode { protected get; construct; default = false; }
@@ -188,7 +189,7 @@ private class FolderListBoxRow : ClickableListBoxRow
}
popover.new_gaction ("open", "ui.open-folder(" + variant.print (false) + ")");
- popover.new_copy_action (get_text ());
+ popover.new_gaction ("copy", "app.copy(" + get_text_variant ().print (false) + ")");
popover.new_section ();
popover.new_gaction ("recursivereset", "ui.reset-recursive(" + variant.print (false) + ")");
@@ -339,7 +340,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
protected override string get_text ()
{
SettingsModel model = modifications_handler.model;
- return model.get_key_copy_text (key.full_name);
+ return model.get_key_copy_text (key.full_name, ".dconf");
}
protected override bool generate_popover (ContextPopover popover)
@@ -350,7 +351,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
if (model.is_key_ghost (key))
{
- popover.new_copy_action (get_text ());
+ popover.new_gaction ("copy", "app.copy(" + get_text_variant ().print (false) + ")");
return true;
}
@@ -361,7 +362,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
}
popover.new_gaction ("customize", "ui.open-object(" + variant_ss.print (false) + ")");
- popover.new_copy_action (get_text ());
+ popover.new_gaction ("copy", "app.copy(" + get_text_variant ().print (false) + ")");
if (key.type_string == "b" || key.type_string == "mb")
{
@@ -486,7 +487,7 @@ private class KeyListBoxRowEditable : KeyListBoxRow
protected override string get_text ()
{
SettingsModel model = modifications_handler.model;
- return model.get_key_copy_text (key.full_name);
+ return model.get_key_copy_text (key.full_name, key.schema_id);
}
protected override bool generate_popover (ContextPopover popover)
@@ -504,7 +505,7 @@ private class KeyListBoxRowEditable : KeyListBoxRow
if (key.error_hard_conflicting_key)
{
popover.new_gaction ("detail", "ui.open-object(" + variant_ss.print (false) + ")");
- popover.new_copy_action (get_text ());
+ popover.new_gaction ("copy", "app.copy(" + get_text_variant ().print (false) + ")");
return true; // anything else is value-related, so we are done
}
@@ -513,7 +514,7 @@ private class KeyListBoxRowEditable : KeyListBoxRow
Variant? planned_value = modifications_handler.get_key_planned_value (key.full_name);
popover.new_gaction ("customize", "ui.open-object(" + variant_ss.print (false) + ")");
- popover.new_copy_action (get_text ());
+ popover.new_gaction ("copy", "app.copy(" + get_text_variant ().print (false) + ")");
if (key.type_string == "b" || key.type_string == "<enum>" || key.type_string == "mb"
|| (
@@ -597,6 +598,9 @@ private class ContextPopover : Popover
string action_text;
switch (action_name)
{
+ /* Translators: "copy to clipboard" action in the right-click menu on the list of keys */
+ case "copy": action_text = _("Copy"); break;
+
/* Translators: "open key-editor page" action in the right-click menu on the list of keys */
case "customize": action_text = _("Customize…"); break;
@@ -631,13 +635,6 @@ private class ContextPopover : Popover
current_section.append (action_text, action_action);
}
- public void new_copy_action (string text)
- {
- Variant variant = new Variant.string (text);
- /* Translators: "copy to clipboard" action in the right-click menu on the list of keys */
- current_section.append (_("Copy"), "app.copy(" + variant.print (false) + ")");
- }
-
public void set_group (string group_name)
{
GLib.ActionGroup? group = get_action_group (group_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]