[dconf-editor] Some manual signals disconnections.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Some manual signals disconnections.
- Date: Fri, 22 Jul 2016 23:52:29 +0000 (UTC)
commit a149a101f72754d2058eae332d898d65aa576261
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Jul 23 01:52:15 2016 +0200
Some manual signals disconnections.
editor/dconf-window.vala | 15 ++++++++--
editor/key-list-box-row.vala | 54 ++++++++++++++++++++----------------
editor/modifications-revealer.vala | 3 +-
editor/pathbar.vala | 17 ++++++++++-
editor/registry-info.vala | 1 -
editor/registry-view.vala | 39 ++++++++++++++++++++------
6 files changed, 89 insertions(+), 40 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index aa53a0e..367aee3 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -52,17 +52,20 @@ class DConfWindow : ApplicationWindow
[GtkChild] private Revealer notification_revealer;
[GtkChild] private Label notification_label;
+ private ulong behaviour_changed_handler = 0;
+ private ulong theme_changed_handler = 0;
+
public DConfWindow ()
{
add_action_entries (action_entries, this);
- settings.changed ["behaviour"].connect (invalidate_popovers);
+ behaviour_changed_handler = settings.changed ["behaviour"].connect (invalidate_popovers);
set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
if (settings.get_boolean ("window-is-maximized"))
maximize ();
- settings.changed["theme"].connect (() => {
+ theme_changed_handler = settings.changed ["theme"].connect (() => {
string theme = settings.get_string ("theme");
StyleContext context = get_style_context (); // TODO only check once?
if (theme == "three-twenty-two" && context.has_class ("small-rows"))
@@ -107,8 +110,9 @@ class DConfWindow : ApplicationWindow
checkbutton.margin_top = 5;
box.add (checkbutton);
- dialog.response.connect (() => { if (!checkbutton.active) settings.set_boolean ("show-warning",
false); });
+ ulong dialog_response_handler = dialog.response.connect (() => { if (!checkbutton.active)
settings.set_boolean ("show-warning", false); });
dialog.run ();
+ dialog.disconnect (dialog_response_handler);
dialog.destroy ();
}
@@ -167,10 +171,15 @@ class DConfWindow : ApplicationWindow
{
get_application ().withdraw_notification ("copy");
+ settings.disconnect (behaviour_changed_handler);
+ settings.disconnect (theme_changed_handler);
+
+ settings.delay ();
settings.set_string ("saved-view", current_path);
settings.set_int ("window-width", window_width);
settings.set_int ("window-height", window_height);
settings.set_boolean ("window-is-maximized", window_is_maximized);
+ settings.apply ();
base.destroy ();
}
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 7c9c8aa..7d1fdd7 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -141,10 +141,11 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
key_info_label.get_style_context ().add_class ("italic-label");
key_info_label.set_label (_("No Schema Found"));
- key.value_changed.connect (() => {
+ ulong key_value_changed_handler = key.value_changed.connect (() => {
update ();
destroy_popover ();
});
+ destroy.connect (() => { key.disconnect (key_value_changed_handler); }); // TODO move to
KeyListBoxRow
}
private void update ()
@@ -250,10 +251,11 @@ private class KeyListBoxRowEditable : KeyListBoxRow
key_name_label.label = key.name;
key_info_label.label = key.summary;
- key.value_changed.connect (() => {
+ ulong key_value_changed_handler = key.value_changed.connect (() => {
update ();
destroy_popover ();
});
+ destroy.connect (() => { key.disconnect (key_value_changed_handler); }); // TODO move to
KeyListBoxRow
}
protected override string get_text ()
@@ -350,7 +352,7 @@ private class ContextPopover : Popover
bind_model (menu, null);
- key_press_event.connect (on_key_press_event);
+ key_press_event.connect (on_key_press_event); // TODO should be only for RegistryView popovers,
not for RegistryInfo ones (nullable booleans & enums)
}
private bool on_key_press_event (Widget widget, Gdk.EventKey event)
@@ -375,27 +377,31 @@ private class ContextPopover : Popover
simple_action.activate.connect (() => { action (); });
current_group.add_action (simple_action);
- if (action_action == "customize")
- /* Translators: "open key-editor dialog" action in the right-click menu on the list of keys */
- current_section.append (_("Customize…"), group_dot_action);
- else if (action_action == "default1")
- /* Translators: "reset key value" action in the right-click menu on the list of keys */
- current_section.append (_("Set to default"), group_dot_action);
- else if (action_action == "default2")
- new_multi_default_action (group_dot_action);
- else if (action_action == "dismiss")
- /* Translators: "dismiss change" action in the right-click menu on a key with pending changes */
- current_section.append (_("Dismiss change"), group_dot_action);
- else if (action_action == "open")
- /* Translators: "open folder" action in the right-click menu on a folder */
- current_section.append (_("Open"), group_dot_action);
- else if (action_action == "erase")
- /* Translators: "erase key" action in the right-click menu on a key without schema */
- current_section.append (_("Erase key"), group_dot_action);
- else if (action_action == "unerase")
- /* Translators: "dismiss change" action in the right-click menu on a key without schema planned
to be erased */
- current_section.append (_("Do not erase"), group_dot_action);
- else assert_not_reached ();
+ switch (action_action)
+ {
+ case "customize":
+ /* Translators: "open key-editor dialog" action in the right-click menu on the list of keys
*/
+ current_section.append (_("Customize…"), group_dot_action); return;
+ case "default1":
+ /* Translators: "reset key value" action in the right-click menu on the list of keys */
+ current_section.append (_("Set to default"), group_dot_action); return;
+ case "default2":
+ new_multi_default_action (group_dot_action); return;
+ case "dismiss":
+ /* Translators: "dismiss change" action in the right-click menu on a key with pending
changes */
+ current_section.append (_("Dismiss change"), group_dot_action); return;
+ case "open":
+ /* Translators: "open folder" action in the right-click menu on a folder */
+ current_section.append (_("Open"), group_dot_action); return;
+ case "erase":
+ /* Translators: "erase key" action in the right-click menu on a key without schema */
+ current_section.append (_("Erase key"), group_dot_action); return;
+ case "unerase":
+ /* Translators: "dismiss change" action in the right-click menu on a key without schema
planned to be erased */
+ current_section.append (_("Do not erase"), group_dot_action); return;
+ default:
+ assert_not_reached ();
+ }
}
public void new_copy_action (string text)
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 6d6aba3..a566921 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -197,7 +197,7 @@ class ModificationsRevealer : Revealer
warning (error.message);
}
- /* reload notably the hamburger menu */
+ /* reload the hamburger menu */ /* FIXME should go back to keys list if the key is erased */
reload_menu ();
}
@@ -225,6 +225,7 @@ class ModificationsRevealer : Revealer
/* reload notably key_editor_child */
reload ();
+ reload_menu ();
}
/*\
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index a864384..1af0b88 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -27,7 +27,18 @@ public class PathBar : Box
public void set_path (string path, bool notify = false)
requires (path [0] == '/')
{
- @foreach ((child) => { if (child != root_button) child.destroy (); });
+ @foreach ((child) => {
+ if (child != root_button)
+ {
+ if (child is PathBarItem)
+ {
+ ulong path_bar_item_clicked_handler = ((PathBarItem)
child).path_bar_item_clicked_handler;
+ if (path_bar_item_clicked_handler != 0)
+ child.disconnect (((PathBarItem) child).path_bar_item_clicked_handler);
+ }
+ child.destroy ();
+ }
+ });
string [] split = path.split ("/", 0);
string last = split [split.length - 1];
@@ -73,12 +84,14 @@ public class PathBar : Box
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathbar-item.ui")]
private class PathBarItem : Button
{
+ public ulong path_bar_item_clicked_handler = 0;
+
[GtkChild] private Label text;
public PathBarItem (string label, string path, bool is_clickable)
{
text.set_text (label);
if (is_clickable)
- clicked.connect (() => { ((PathBar) get_parent ()).set_path (path, true); });
+ path_bar_item_clicked_handler = clicked.connect (() => { ((PathBar) get_parent ()).set_path
(path, true); });
}
}
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index 7cedd39..9a36603 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -112,7 +112,6 @@ class RegistryInfo : Grid
bool disable_revealer_for_switch = false;
GSettingsKey gkey = (GSettingsKey) key;
revealer_reload_1_handler = revealer.reload.connect (() => {
- warning ("reload 1");
disable_revealer_for_switch = true;
custom_value_switch.set_active (gkey.is_default);
disable_revealer_for_switch = false; // TODO bad but needed
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 38f79d6..8123cff 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -44,13 +44,20 @@ class RegistryView : Grid
construct
{
- revealer.reload.connect (invalidate_popovers);
- revealer.reload_menu.connect (invalidate_popovers);
+ ulong revealer_reload_menu_handler = revealer.reload_menu.connect (invalidate_popovers);
- search_entry.get_buffer ().deleted_text.connect (() => { search_next_button.set_sensitive (true); });
+ EntryBuffer buffer = search_entry.get_buffer ();
+ ulong search_entry_buffer_deleted_text_handler = buffer.deleted_text.connect (() => {
search_next_button.set_sensitive (true); });
search_bar.connect_entry (search_entry);
bind_property ("show-search-bar", search_bar, "search-mode-enabled", BindingFlags.BIDIRECTIONAL);
// TODO in UI file?
bind_property ("behaviour", revealer, "behaviour",
BindingFlags.BIDIRECTIONAL|BindingFlags.SYNC_CREATE);
+
+ destroy.connect (() => {
+ revealer.disconnect (revealer_reload_menu_handler);
+ buffer.disconnect (search_entry_buffer_deleted_text_handler);
+
+ base.destroy ();
+ });
}
public void init (string path, bool restore_view) // TODO check path format
@@ -198,10 +205,11 @@ class RegistryView : Grid
private Widget new_list_box_row (Object item)
{
ClickableListBoxRow row;
+ ulong on_row_clicked_handler;
if (((SettingObject) item).is_view)
{
row = new FolderListBoxRow (((SettingObject) item).name, ((SettingObject) item).full_name);
- row.on_row_clicked.connect (() => {
+ on_row_clicked_handler = row.on_row_clicked.connect (() => {
if (!scroll_to_path (((SettingObject) item).full_name))
warning ("Something got wrong with this folder.");
});
@@ -214,13 +222,14 @@ class RegistryView : Grid
else
row = new KeyListBoxRowEditableNoSchema ((DConfKey) key);
- ((KeyListBoxRow) row).set_key_value.connect ((variant) => { set_key_value (key, variant);
set_delayed_icon (row, key); });
- ((KeyListBoxRow) row).change_dismissed.connect (() => { revealer.dismiss_change (key); });
+ KeyListBoxRow key_row = ((KeyListBoxRow) row);
+ ulong set_key_value_handler = key_row.set_key_value.connect ((variant) => { set_key_value (key,
variant); set_delayed_icon (row, key); });
+ ulong change_dismissed_handler = key_row.change_dismissed.connect (() => {
revealer.dismiss_change (key); });
- key.notify ["planned-change"].connect (() => { set_delayed_icon (row, key); });
+ ulong key_planned_change_handler = key.notify ["planned-change"].connect (() => {
set_delayed_icon (row, key); });
set_delayed_icon (row, key);
- row.on_row_clicked.connect (() => {
+ on_row_clicked_handler = row.on_row_clicked.connect (() => {
if (!properties_view.populate_properties_list_box (revealer, key)) // TODO unduplicate
return;
@@ -228,8 +237,20 @@ class RegistryView : Grid
stack.set_visible_child (properties_view);
});
// TODO bug: row is always visually activated after the dialog destruction if mouse is over at
this time
+
+ row.destroy.connect (() => {
+ key_row.disconnect (set_key_value_handler);
+ key_row.disconnect (change_dismissed_handler);
+ key.disconnect (key_planned_change_handler);
+ });
}
- row.button_press_event.connect (on_button_pressed);
+ ulong button_press_event_handler = row.button_press_event.connect (on_button_pressed);
+
+ row.destroy.connect (() => {
+ row.disconnect (on_row_clicked_handler);
+ row.disconnect (button_press_event_handler);
+ });
+
return row;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]