Пример #1
0
gboolean
ce_polkit_button_get_authorized (CEPolkitButton *self)
{
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (CE_IS_POLKIT_BUTTON (self), FALSE);

	return CE_POLKIT_BUTTON_GET_PRIVATE (self)->authorized;
}
Пример #2
0
void
ce_polkit_button_set_master_sensitive (CEPolkitButton *self, gboolean sensitive)
{
	gboolean old_actionable;

	g_return_if_fail (self != NULL);
	g_return_if_fail (CE_IS_POLKIT_BUTTON (self));

	old_actionable = ce_polkit_button_get_actionable (self);
	CE_POLKIT_BUTTON_GET_PRIVATE (self)->master_sensitive = sensitive;
	update_and_emit (self, old_actionable);
}
Пример #3
0
gboolean
ce_polkit_button_get_actionable (CEPolkitButton *self)
{
	CEPolkitButtonPrivate *priv;

	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (CE_IS_POLKIT_BUTTON (self), FALSE);

	priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);

	return priv->master_sensitive && priv->authorized;
}
Пример #4
0
void
ce_polkit_button_set_use_polkit (CEPolkitButton *self, gboolean use_polkit)
{
	gboolean old_actionable;

	g_return_if_fail (self != NULL);
	g_return_if_fail (CE_IS_POLKIT_BUTTON (self));

	old_actionable = ce_polkit_button_get_actionable (self);
	CE_POLKIT_BUTTON_GET_PRIVATE (self)->use_polkit = use_polkit;
	update_and_emit (self, old_actionable);
}
gboolean
ce_polkit_button_get_authorized (CEPolkitButton *self)
{
	CEPolkitButtonPrivate *priv;

	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (CE_IS_POLKIT_BUTTON (self), FALSE);

	priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);

	return    priv->permission_result == NM_CLIENT_PERMISSION_RESULT_YES
	       || priv->permission_result == NM_CLIENT_PERMISSION_RESULT_AUTH;
}
gboolean
ce_polkit_button_get_actionable (CEPolkitButton *self)
{
	CEPolkitButtonPrivate *priv;

	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (CE_IS_POLKIT_BUTTON (self), FALSE);

	priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);

	return    !priv->validation_error
	       && ce_polkit_button_get_authorized (self);
}
Пример #7
0
gboolean
ce_polkit_button_get_actionable (CEPolkitButton *self)
{
	CEPolkitButtonPrivate *priv;

	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (CE_IS_POLKIT_BUTTON (self), FALSE);

	priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);

	if (!priv->master_sensitive)
		return FALSE;

	/* If polkit is in-use, the button is only actionable if the operation is
	 * authorized or able to be authorized via user authentication.  If polkit
	 * isn't in-use, the button will always be actionable unless insensitive.
	 */
	return priv->use_polkit ? priv->authorized : TRUE;
}
void
ce_polkit_button_set_validation_error (CEPolkitButton *self, const char *validation_error)
{
	CEPolkitButtonPrivate *priv;
	gboolean old_actionable;

	g_return_if_fail (self != NULL);
	g_return_if_fail (CE_IS_POLKIT_BUTTON (self));

	priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);

	if (g_strcmp0 (validation_error, priv->validation_error) != 0) {
		old_actionable = ce_polkit_button_get_actionable (self);

		g_free (priv->validation_error);
		priv->validation_error = g_strdup (validation_error);

		update_and_emit (self, old_actionable);
	}
}