scalebutton: Update adjustment usage for sealing
Also rename all variables named "adj" to "adjustment", like they're called everywhere else.
This commit is contained in:
@ -577,12 +577,12 @@ gtk_scale_button_new (GtkIconSize size,
|
|||||||
const gchar **icons)
|
const gchar **icons)
|
||||||
{
|
{
|
||||||
GtkScaleButton *button;
|
GtkScaleButton *button;
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adjustment;
|
||||||
|
|
||||||
adj = gtk_adjustment_new (min, min, max, step, 10 * step, 0);
|
adjustment = gtk_adjustment_new (min, min, max, step, 10 * step, 0);
|
||||||
|
|
||||||
button = g_object_new (GTK_TYPE_SCALE_BUTTON,
|
button = g_object_new (GTK_TYPE_SCALE_BUTTON,
|
||||||
"adjustment", adj,
|
"adjustment", adjustment,
|
||||||
"icons", icons,
|
"icons", icons,
|
||||||
"size", size,
|
"size", size,
|
||||||
NULL);
|
NULL);
|
||||||
@ -834,12 +834,12 @@ gtk_scale_button_scroll (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkScaleButton *button;
|
GtkScaleButton *button;
|
||||||
GtkScaleButtonPrivate *priv;
|
GtkScaleButtonPrivate *priv;
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adjustment;
|
||||||
gdouble d;
|
gdouble d;
|
||||||
|
|
||||||
button = GTK_SCALE_BUTTON (widget);
|
button = GTK_SCALE_BUTTON (widget);
|
||||||
priv = button->priv;
|
priv = button->priv;
|
||||||
adj = priv->adjustment;
|
adjustment = priv->adjustment;
|
||||||
|
|
||||||
if (event->type != GDK_SCROLL)
|
if (event->type != GDK_SCROLL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -847,15 +847,15 @@ gtk_scale_button_scroll (GtkWidget *widget,
|
|||||||
d = gtk_scale_button_get_value (button);
|
d = gtk_scale_button_get_value (button);
|
||||||
if (event->direction == GDK_SCROLL_UP)
|
if (event->direction == GDK_SCROLL_UP)
|
||||||
{
|
{
|
||||||
d += adj->step_increment;
|
d += gtk_adjustment_get_step_increment (adjustment);
|
||||||
if (d > adj->upper)
|
if (d > gtk_adjustment_get_upper (adjustment))
|
||||||
d = adj->upper;
|
d = gtk_adjustment_get_upper (adjustment);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d -= adj->step_increment;
|
d -= gtk_adjustment_get_step_increment (adjustment);
|
||||||
if (d < adj->lower)
|
if (d < gtk_adjustment_get_lower (adjustment))
|
||||||
d = adj->lower;
|
d = gtk_adjustment_get_lower (adjustment);
|
||||||
}
|
}
|
||||||
gtk_scale_button_set_value (button, d);
|
gtk_scale_button_set_value (button, d);
|
||||||
|
|
||||||
@ -897,7 +897,7 @@ gtk_scale_popup (GtkWidget *widget,
|
|||||||
GtkAllocation allocation, dock_allocation, scale_allocation;
|
GtkAllocation allocation, dock_allocation, scale_allocation;
|
||||||
GtkScaleButton *button;
|
GtkScaleButton *button;
|
||||||
GtkScaleButtonPrivate *priv;
|
GtkScaleButtonPrivate *priv;
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adjustment;
|
||||||
gint x, y, m, dx, dy, sx, sy, startoff;
|
gint x, y, m, dx, dy, sx, sy, startoff;
|
||||||
gint min_slider_size;
|
gint min_slider_size;
|
||||||
gdouble v;
|
gdouble v;
|
||||||
@ -909,7 +909,7 @@ gtk_scale_popup (GtkWidget *widget,
|
|||||||
is_moved = FALSE;
|
is_moved = FALSE;
|
||||||
button = GTK_SCALE_BUTTON (widget);
|
button = GTK_SCALE_BUTTON (widget);
|
||||||
priv = button->priv;
|
priv = button->priv;
|
||||||
adj = priv->adjustment;
|
adjustment = priv->adjustment;
|
||||||
|
|
||||||
display = gtk_widget_get_display (widget);
|
display = gtk_widget_get_display (widget);
|
||||||
screen = gtk_widget_get_screen (widget);
|
screen = gtk_widget_get_screen (widget);
|
||||||
@ -946,7 +946,7 @@ gtk_scale_popup (GtkWidget *widget,
|
|||||||
priv->timeout = TRUE;
|
priv->timeout = TRUE;
|
||||||
|
|
||||||
/* position (needs widget to be shown already) */
|
/* position (needs widget to be shown already) */
|
||||||
v = gtk_scale_button_get_value (button) / (adj->upper - adj->lower);
|
v = gtk_scale_button_get_value (button) / (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment));
|
||||||
min_slider_size = gtk_range_get_min_slider_size (GTK_RANGE (priv->scale));
|
min_slider_size = gtk_range_get_min_slider_size (GTK_RANGE (priv->scale));
|
||||||
|
|
||||||
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
|
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
|
||||||
@ -1192,7 +1192,7 @@ cb_button_timeout (gpointer user_data)
|
|||||||
{
|
{
|
||||||
GtkScaleButton *button;
|
GtkScaleButton *button;
|
||||||
GtkScaleButtonPrivate *priv;
|
GtkScaleButtonPrivate *priv;
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adjustment;
|
||||||
gdouble val;
|
gdouble val;
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
|
|
||||||
@ -1202,19 +1202,19 @@ cb_button_timeout (gpointer user_data)
|
|||||||
if (priv->click_id == 0)
|
if (priv->click_id == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
adj = priv->adjustment;
|
adjustment = priv->adjustment;
|
||||||
|
|
||||||
val = gtk_scale_button_get_value (button);
|
val = gtk_scale_button_get_value (button);
|
||||||
val += priv->direction;
|
val += priv->direction;
|
||||||
if (val <= adj->lower)
|
if (val <= gtk_adjustment_get_lower (adjustment))
|
||||||
{
|
{
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
val = adj->lower;
|
val = gtk_adjustment_get_lower (adjustment);
|
||||||
}
|
}
|
||||||
else if (val > adj->upper)
|
else if (val > gtk_adjustment_get_upper (adjustment))
|
||||||
{
|
{
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
val = adj->upper;
|
val = gtk_adjustment_get_upper (adjustment);
|
||||||
}
|
}
|
||||||
gtk_scale_button_set_value (button, val);
|
gtk_scale_button_set_value (button, val);
|
||||||
|
|
||||||
@ -1234,19 +1234,19 @@ cb_button_press (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkScaleButton *button;
|
GtkScaleButton *button;
|
||||||
GtkScaleButtonPrivate *priv;
|
GtkScaleButtonPrivate *priv;
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adjustment;
|
||||||
|
|
||||||
button = GTK_SCALE_BUTTON (user_data);
|
button = GTK_SCALE_BUTTON (user_data);
|
||||||
priv = button->priv;
|
priv = button->priv;
|
||||||
adj = priv->adjustment;
|
adjustment = priv->adjustment;
|
||||||
|
|
||||||
if (priv->click_id != 0)
|
if (priv->click_id != 0)
|
||||||
g_source_remove (priv->click_id);
|
g_source_remove (priv->click_id);
|
||||||
|
|
||||||
if (widget == priv->plus_button)
|
if (widget == priv->plus_button)
|
||||||
priv->direction = fabs (adj->page_increment);
|
priv->direction = fabs (gtk_adjustment_get_page_increment (adjustment));
|
||||||
else
|
else
|
||||||
priv->direction = - fabs (adj->page_increment);
|
priv->direction = - fabs (gtk_adjustment_get_page_increment (adjustment));
|
||||||
|
|
||||||
priv->click_id = gdk_threads_add_timeout (priv->click_timeout,
|
priv->click_id = gdk_threads_add_timeout (priv->click_timeout,
|
||||||
cb_button_timeout,
|
cb_button_timeout,
|
||||||
@ -1530,7 +1530,7 @@ gtk_scale_button_update_icon (GtkScaleButton *button)
|
|||||||
{
|
{
|
||||||
GtkScaleButtonPrivate *priv;
|
GtkScaleButtonPrivate *priv;
|
||||||
GtkRange *range;
|
GtkRange *range;
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adjustment;
|
||||||
gdouble value;
|
gdouble value;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
guint num_icons;
|
guint num_icons;
|
||||||
@ -1557,14 +1557,14 @@ gtk_scale_button_update_icon (GtkScaleButton *button)
|
|||||||
}
|
}
|
||||||
|
|
||||||
range = GTK_RANGE (priv->scale);
|
range = GTK_RANGE (priv->scale);
|
||||||
adj = priv->adjustment;
|
adjustment = priv->adjustment;
|
||||||
value = gtk_scale_button_get_value (button);
|
value = gtk_scale_button_get_value (button);
|
||||||
|
|
||||||
/* The 2-icons special case */
|
/* The 2-icons special case */
|
||||||
if (num_icons == 2)
|
if (num_icons == 2)
|
||||||
{
|
{
|
||||||
gdouble limit;
|
gdouble limit;
|
||||||
limit = (adj->upper - adj->lower) / 2 + adj->lower;
|
limit = (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment)) / 2 + gtk_adjustment_get_lower (adjustment);
|
||||||
if (value < limit)
|
if (value < limit)
|
||||||
name = priv->icon_list[0];
|
name = priv->icon_list[0];
|
||||||
else
|
else
|
||||||
@ -1577,11 +1577,11 @@ gtk_scale_button_update_icon (GtkScaleButton *button)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* With 3 or more icons */
|
/* With 3 or more icons */
|
||||||
if (value == adj->lower)
|
if (value == gtk_adjustment_get_lower (adjustment))
|
||||||
{
|
{
|
||||||
name = priv->icon_list[0];
|
name = priv->icon_list[0];
|
||||||
}
|
}
|
||||||
else if (value == adj->upper)
|
else if (value == gtk_adjustment_get_upper (adjustment))
|
||||||
{
|
{
|
||||||
name = priv->icon_list[1];
|
name = priv->icon_list[1];
|
||||||
}
|
}
|
||||||
@ -1590,8 +1590,8 @@ gtk_scale_button_update_icon (GtkScaleButton *button)
|
|||||||
gdouble step;
|
gdouble step;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
step = (adj->upper - adj->lower) / (num_icons - 2);
|
step = (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment)) / (num_icons - 2);
|
||||||
i = (guint) ((value - adj->lower) / step) + 2;
|
i = (guint) ((value - gtk_adjustment_get_lower (adjustment)) / step) + 2;
|
||||||
g_assert (i < num_icons);
|
g_assert (i < num_icons);
|
||||||
name = priv->icon_list[i];
|
name = priv->icon_list[i];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user