st: Move slow-down-factor into settings
Now that we have a Settings singleton, we have a better place for the slow-down-factor than an awkward extern variable. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/656
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
5295866eff
commit
12b8fb15b1
@ -21,6 +21,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "st-private.h"
|
||||
@ -41,6 +42,7 @@ enum {
|
||||
PROP_GTK_THEME,
|
||||
PROP_GTK_ICON_THEME,
|
||||
PROP_MAGNIFIER_ACTIVE,
|
||||
PROP_SLOW_DOWN_FACTOR,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@ -59,10 +61,24 @@ struct _StSettings
|
||||
gboolean primary_paste;
|
||||
gboolean magnifier_active;
|
||||
gint drag_threshold;
|
||||
double slow_down_factor;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StSettings, st_settings, G_TYPE_OBJECT)
|
||||
|
||||
#define EPSILON (1e-10)
|
||||
|
||||
static void
|
||||
st_settings_set_slow_down_factor (StSettings *settings,
|
||||
double factor)
|
||||
{
|
||||
if (fabs (settings->slow_down_factor - factor) < EPSILON)
|
||||
return;
|
||||
|
||||
settings->slow_down_factor = factor;
|
||||
g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_SLOW_DOWN_FACTOR]);
|
||||
}
|
||||
|
||||
static void
|
||||
st_settings_finalize (GObject *object)
|
||||
{
|
||||
@ -82,7 +98,16 @@ st_settings_set_property (GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
StSettings *settings = ST_SETTINGS (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SLOW_DOWN_FACTOR:
|
||||
st_settings_set_slow_down_factor (settings, g_value_get_double (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -113,6 +138,9 @@ st_settings_get_property (GObject *object,
|
||||
case PROP_MAGNIFIER_ACTIVE:
|
||||
g_value_set_boolean (value, settings->magnifier_active);
|
||||
break;
|
||||
case PROP_SLOW_DOWN_FACTOR:
|
||||
g_value_set_double (value, settings->slow_down_factor);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
@ -157,6 +185,11 @@ st_settings_class_init (StSettingsClass *klass)
|
||||
"Weather the a11y magnifier is active",
|
||||
FALSE,
|
||||
ST_PARAM_READABLE);
|
||||
props[PROP_SLOW_DOWN_FACTOR] = g_param_spec_double("slow-down-factor",
|
||||
"Slow down factor",
|
||||
"Factor applied to all animation durations",
|
||||
EPSILON, G_MAXDOUBLE, 1.0,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, props);
|
||||
}
|
||||
@ -242,6 +275,7 @@ st_settings_init (StSettings *settings)
|
||||
KEY_DRAG_THRESHOLD);
|
||||
settings->magnifier_active = g_settings_get_boolean (settings->a11y_settings,
|
||||
KEY_MAGNIFIER_ACTIVE);
|
||||
settings->slow_down_factor = 1.;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user