Bind available/enabled ui element properties

This commit is contained in:
Jesse van den Kieboom 2012-10-28 18:25:08 +01:00
parent 5aec1b1360
commit 10cd83fbbb
4 changed files with 24 additions and 4 deletions

View file

@ -72,6 +72,8 @@ public class UIElements<T>
button = new Gtk.RadioToolButton(null);
}
e.bind_property("enabled", button, "sensitive", BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE);
button.set_icon_widget(img);
button.set_label(e.display_name);
@ -130,8 +132,6 @@ public class UIElements<T>
{
set_current_impl(wasavail.element);
}
wasavail.navigation_button.set_sensitive(wasavail.element.enabled);
}
});
}
@ -223,8 +223,6 @@ public class UIElements<T>
if (button != null)
{
button.set_sensitive(e.enabled);
d_available_sorted.insert_sorted(ae, (a, b) => {
return a.element.negotiate_order(b.element);
});
@ -243,6 +241,11 @@ public class UIElements<T>
d_available_elements.insert(e.id, ae);
}
private void available_changed(Object o, ParamSpec spec)
{
update();
}
private void add_ui_element(GitgExt.UIElement e)
{
d_elements.insert(e.id, e);
@ -251,11 +254,16 @@ public class UIElements<T>
{
add_available(e);
}
e.notify["available"].connect(available_changed);
}
private void remove_ui_element(GitgExt.UIElement e)
{
remove_available(e);
e.notify["available"].disconnect(available_changed);
d_elements.remove(e.id);
}

View file

@ -38,6 +38,10 @@ namespace GitgDiff
d_diff.show();
d_sw.add(d_diff);
application.notify["current_view"].connect((a, v) => {
notify_property("available");
});
}
public string id

View file

@ -41,6 +41,10 @@ namespace GitgFiles
construct
{
d_model = new TreeStore();
application.notify["current_view"].connect((a, v) => {
notify_property("available");
});
}
public string id

View file

@ -70,6 +70,10 @@ namespace GitgHistory
update_sort_mode();
application.bind_property("repository", d_model, "repository", BindingFlags.DEFAULT);
application.notify["repository"].connect((a, r) => {
notify_property("available");
});
}
private void update_sort_mode()