mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 20:09:23 +00:00
Made is_available and is_enabled properties
This commit is contained in:
parent
aaf07ed67e
commit
1ccd4c9fee
|
@ -108,7 +108,7 @@ public class UIElements<T>
|
|||
var elem = obj as GitgExt.UIElement;
|
||||
|
||||
var wasavail = d_available_elements.lookup(elem.id);
|
||||
bool isavail = elem.is_available();
|
||||
bool isavail = elem.available;
|
||||
|
||||
if (wasavail != null && !isavail)
|
||||
{
|
||||
|
@ -121,16 +121,16 @@ public class UIElements<T>
|
|||
}
|
||||
else if (wasavail != null && wasavail.navigation_button != null)
|
||||
{
|
||||
if (!wasavail.element.is_enabled() && d_current == wasavail)
|
||||
if (!wasavail.element.enabled && d_current == wasavail)
|
||||
{
|
||||
d_current = null;
|
||||
}
|
||||
else if (wasavail.element.is_enabled() && d_current == null)
|
||||
else if (wasavail.element.enabled && d_current == null)
|
||||
{
|
||||
set_current_impl(wasavail.element);
|
||||
}
|
||||
|
||||
wasavail.navigation_button.set_sensitive(wasavail.element.is_enabled());
|
||||
wasavail.navigation_button.set_sensitive(wasavail.element.enabled);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ public class UIElements<T>
|
|||
|
||||
private void set_current_impl(GitgExt.UIElement element)
|
||||
{
|
||||
if (!element.is_available() ||
|
||||
!element.is_enabled() ||
|
||||
if (!element.available ||
|
||||
!element.enabled ||
|
||||
(d_current != null && d_current.element == element))
|
||||
{
|
||||
return;
|
||||
|
@ -221,7 +221,7 @@ public class UIElements<T>
|
|||
|
||||
if (button != null)
|
||||
{
|
||||
button.set_sensitive(e.is_enabled());
|
||||
button.set_sensitive(e.enabled);
|
||||
|
||||
d_toolbar.add(button);
|
||||
}
|
||||
|
@ -234,18 +234,13 @@ public class UIElements<T>
|
|||
});
|
||||
|
||||
d_available_elements.insert(e.id, ae);
|
||||
|
||||
if (d_current == null && e.is_enabled())
|
||||
{
|
||||
set_current_impl(ae.element);
|
||||
}
|
||||
}
|
||||
|
||||
private void add_ui_element(GitgExt.UIElement e)
|
||||
{
|
||||
d_elements.insert(e.id, e);
|
||||
|
||||
if (e.is_available())
|
||||
if (e.available)
|
||||
{
|
||||
add_available(e);
|
||||
}
|
||||
|
|
|
@ -86,12 +86,18 @@ public interface UIElement : Object
|
|||
* This method is used by gitg to verify whether or not a particular ui
|
||||
* element is available given the current state of the application.
|
||||
*
|
||||
* @return ``true`` if the view is available, ``false`` otherwise.
|
||||
*/
|
||||
public abstract bool available { get; }
|
||||
|
||||
/**
|
||||
* Check whether the ui element is enabled in the current application state.
|
||||
*
|
||||
* This method is used by gitg to verify whether or not a particular ui
|
||||
* element is enabled (sensitive) given the current state of the application.
|
||||
*
|
||||
*/
|
||||
public abstract bool is_available();
|
||||
public abstract bool enabled { get; }
|
||||
|
||||
public abstract bool is_enabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,16 +45,19 @@ namespace GitgDiff
|
|||
owned get { return "/org/gnome/gitg/Panels/Diff"; }
|
||||
}
|
||||
|
||||
public bool is_available()
|
||||
public bool available
|
||||
{
|
||||
var view = application.current_view;
|
||||
|
||||
if (view == null)
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var view = application.current_view;
|
||||
|
||||
return (view is GitgExt.ObjectSelection);
|
||||
if (view == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (view is GitgExt.ObjectSelection);
|
||||
}
|
||||
}
|
||||
|
||||
public string display_name
|
||||
|
@ -105,10 +108,12 @@ namespace GitgDiff
|
|||
}
|
||||
}
|
||||
|
||||
public bool is_enabled()
|
||||
public bool enabled
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,16 +48,19 @@ namespace GitgFiles
|
|||
owned get { return "/org/gnome/gitg/Panels/Files"; }
|
||||
}
|
||||
|
||||
public bool is_available()
|
||||
public bool available
|
||||
{
|
||||
var view = application.current_view;
|
||||
|
||||
if (view == null)
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var view = application.current_view;
|
||||
|
||||
return (view is GitgExt.ObjectSelection);
|
||||
if (view == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (view is GitgExt.ObjectSelection);
|
||||
}
|
||||
}
|
||||
|
||||
public string display_name
|
||||
|
@ -278,10 +281,13 @@ namespace GitgFiles
|
|||
set_viewer(wid);
|
||||
}
|
||||
|
||||
public bool is_enabled()
|
||||
public bool enabled
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
get
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,10 +58,13 @@ namespace GitgHistory
|
|||
application.bind_property("repository", d_model, "repository", BindingFlags.DEFAULT);
|
||||
}
|
||||
|
||||
public bool is_available()
|
||||
public bool available
|
||||
{
|
||||
// The history view is available only when there is a repository
|
||||
return application.repository != null;
|
||||
get
|
||||
{
|
||||
// The history view is available only when there is a repository
|
||||
return application.repository != null;
|
||||
}
|
||||
}
|
||||
|
||||
public string display_name
|
||||
|
@ -191,9 +194,12 @@ namespace GitgHistory
|
|||
return ret;
|
||||
}
|
||||
|
||||
public bool is_enabled()
|
||||
public bool enabled
|
||||
{
|
||||
return true;
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue