[gimp] app: allow setting handle-bar limits explicitly
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: allow setting handle-bar limits explicitly
- Date: Tue, 2 Jun 2020 20:30:18 +0000 (UTC)
commit fa5dd99559079cbf58a1224c04cab0a6fbe7afd8
Author: Ell <ell_se yahoo com>
Date: Tue Jun 2 18:28:27 2020 +0300
app: allow setting handle-bar limits explicitly
In GimpHandleBar, add gimp_handle_bar_{set,unset,get}_limits(), to
allow settings the handle-bar limits explicitly, rather than
inheriting the adjustment limits.
app/widgets/gimphandlebar.c | 52 +++++++++++++++++++++++++++++++++++++++++----
app/widgets/gimphandlebar.h | 9 ++++++++
2 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/app/widgets/gimphandlebar.c b/app/widgets/gimphandlebar.c
index be13601d7b..dfe4ae5f90 100644
--- a/app/widgets/gimphandlebar.c
+++ b/app/widgets/gimphandlebar.c
@@ -97,6 +97,8 @@ gimp_handle_bar_init (GimpHandleBar *bar)
gtk_event_box_set_visible_window (GTK_EVENT_BOX (bar), FALSE);
bar->orientation = GTK_ORIENTATION_HORIZONTAL;
+
+ bar->limits_set = FALSE;
bar->lower = 0.0;
bar->upper = 1.0;
}
@@ -344,6 +346,45 @@ gimp_handle_bar_set_adjustment (GimpHandleBar *bar,
gimp_handle_bar_adjustment_changed (bar->slider_adj[handle_no], bar);
}
+void
+gimp_handle_bar_set_limits (GimpHandleBar *bar,
+ gdouble lower,
+ gdouble upper)
+{
+ g_return_if_fail (GIMP_IS_HANDLE_BAR (bar));
+
+ bar->limits_set = TRUE;
+ bar->lower = lower;
+ bar->upper = upper;
+
+ gtk_widget_queue_draw (GTK_WIDGET (bar));
+}
+
+void
+gimp_handle_bar_unset_limits (GimpHandleBar *bar)
+{
+ g_return_if_fail (GIMP_IS_HANDLE_BAR (bar));
+
+ bar->limits_set = FALSE;
+ bar->lower = 0.0;
+ bar->upper = 1.0;
+
+ gimp_handle_bar_adjustment_changed (NULL, bar);
+}
+
+gboolean
+gimp_handle_bar_get_limits (GimpHandleBar *bar,
+ gdouble *lower,
+ gdouble *upper)
+{
+ g_return_val_if_fail (GIMP_IS_HANDLE_BAR (bar), FALSE);
+
+ if (lower) *lower = bar->lower;
+ if (upper) *upper = bar->upper;
+
+ return bar->limits_set;
+}
+
void
gimp_handle_bar_connect_events (GimpHandleBar *bar,
GtkWidget *event_source)
@@ -375,11 +416,14 @@ static void
gimp_handle_bar_adjustment_changed (GtkAdjustment *adjustment,
GimpHandleBar *bar)
{
- if (bar->slider_adj[0])
- bar->lower = gtk_adjustment_get_lower (bar->slider_adj[0]);
+ if (! bar->limits_set)
+ {
+ if (bar->slider_adj[0])
+ bar->lower = gtk_adjustment_get_lower (bar->slider_adj[0]);
- if (bar->slider_adj[2])
- bar->upper = gtk_adjustment_get_upper (bar->slider_adj[2]);
+ if (bar->slider_adj[2])
+ bar->upper = gtk_adjustment_get_upper (bar->slider_adj[2]);
+ }
gtk_widget_queue_draw (GTK_WIDGET (bar));
}
diff --git a/app/widgets/gimphandlebar.h b/app/widgets/gimphandlebar.h
index 1cca177926..6007d50c04 100644
--- a/app/widgets/gimphandlebar.h
+++ b/app/widgets/gimphandlebar.h
@@ -36,6 +36,7 @@ struct _GimpHandleBar
GtkOrientation orientation;
GtkAdjustment *slider_adj[3];
+ gboolean limits_set;
gdouble lower;
gdouble upper;
@@ -57,6 +58,14 @@ void gimp_handle_bar_set_adjustment (GimpHandleBar *bar,
gint handle_no,
GtkAdjustment *adjustment);
+void gimp_handle_bar_set_limits (GimpHandleBar *bar,
+ gdouble lower,
+ gdouble upper);
+void gimp_handle_bar_unset_limits (GimpHandleBar *bar);
+gboolean gimp_handle_bar_get_limits (GimpHandleBar *bar,
+ gdouble *lower,
+ gdouble *upper);
+
void gimp_handle_bar_connect_events (GimpHandleBar *bar,
GtkWidget *event_source);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]