changeset 19412:1096aea98217

merge of '0fc7f6e97f5dab2cfc59a71a0aba499d560220b2' and '9e054d6dc9f395a8e2026e8c6babc6faf51ec4cd'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 25 Aug 2007 01:14:56 +0000
parents b8cbc7659a5a (current diff) b80379b1f3c6 (diff)
children deb9471d7142 4fced00fdc9f
files
diffstat 3 files changed, 92 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntsound.c	Fri Aug 24 21:25:30 2007 +0000
+++ b/finch/gntsound.c	Sat Aug 25 01:14:56 2007 +0000
@@ -996,6 +996,8 @@
 
 	pref_dialog->volume = slider = gnt_slider_new(FALSE, 100, 0);
 	gnt_slider_set_step(GNT_SLIDER(slider), 5);
+	gnt_slider_set_small_step(GNT_SLIDER(slider), 1);
+	gnt_slider_set_large_step(GNT_SLIDER(slider), 20);
 	label = gnt_label_new("");
 	gnt_slider_reflect_label(GNT_SLIDER(slider), GNT_LABEL(label));
 	gnt_box_set_pad(GNT_BOX(tmpbox), 1);
--- a/finch/libgnt/gntslider.c	Fri Aug 24 21:25:30 2007 +0000
+++ b/finch/libgnt/gntslider.c	Sat Aug 25 01:14:56 2007 +0000
@@ -125,22 +125,66 @@
 step_back(GntBindable *bindable, GList *null)
 {
 	GntSlider *slider = GNT_SLIDER(bindable);
-	if (slider->current <= slider->min)
-		return FALSE;
 	gnt_slider_advance_step(slider, -1);
 	return TRUE;
 }
 
 static gboolean
+small_step_back(GntBindable *bindable, GList *null)
+{
+	GntSlider *slider = GNT_SLIDER(bindable);
+	gnt_slider_set_value(slider, slider->current - slider->smallstep);
+	return TRUE;
+}
+
+static gboolean
+large_step_back(GntBindable *bindable, GList *null)
+{
+	GntSlider *slider = GNT_SLIDER(bindable);
+	gnt_slider_set_value(slider, slider->current - slider->largestep);
+	return TRUE;
+}
+
+static gboolean
 step_forward(GntBindable *bindable, GList *list)
 {
 	GntSlider *slider = GNT_SLIDER(bindable);
-	if (slider->current >= slider->max)
-		return FALSE;
 	gnt_slider_advance_step(slider, 1);
 	return TRUE;
 }
 
+static gboolean
+small_step_forward(GntBindable *bindable, GList *null)
+{
+	GntSlider *slider = GNT_SLIDER(bindable);
+	gnt_slider_set_value(slider, slider->current + slider->smallstep);
+	return TRUE;
+}
+
+static gboolean
+large_step_forward(GntBindable *bindable, GList *null)
+{
+	GntSlider *slider = GNT_SLIDER(bindable);
+	gnt_slider_set_value(slider, slider->current + slider->largestep);
+	return TRUE;
+}
+
+static gboolean
+move_min_value(GntBindable *bindable, GList *null)
+{
+	GntSlider *slider = GNT_SLIDER(bindable);
+	gnt_slider_set_value(slider, slider->min);
+	return TRUE;
+}
+
+static gboolean
+move_max_value(GntBindable *bindable, GList *null)
+{
+	GntSlider *slider = GNT_SLIDER(bindable);
+	gnt_slider_set_value(slider, slider->max);
+	return TRUE;
+}
+
 static void
 gnt_slider_class_init(GntSliderClass *klass)
 {
@@ -165,8 +209,14 @@
 	gnt_bindable_register_binding(bindable, "step-backward", GNT_KEY_DOWN, NULL);
 	gnt_bindable_class_register_action(bindable, "step-forward", step_forward, GNT_KEY_RIGHT, NULL);
 	gnt_bindable_register_binding(bindable, "step-forward", GNT_KEY_UP, NULL);
-
-	/* XXX: how would home/end work? */
+	gnt_bindable_class_register_action(bindable, "small-step-backward", small_step_back, GNT_KEY_CTRL_LEFT, NULL);
+	gnt_bindable_register_binding(bindable, "small-step-backward", GNT_KEY_CTRL_DOWN, NULL);
+	gnt_bindable_class_register_action(bindable, "small-step-forward", small_step_forward, GNT_KEY_CTRL_RIGHT, NULL);
+	gnt_bindable_register_binding(bindable, "small-step-forward", GNT_KEY_CTRL_UP, NULL);
+	gnt_bindable_class_register_action(bindable, "large-step-backward", large_step_back, GNT_KEY_PGDOWN, NULL);
+	gnt_bindable_class_register_action(bindable, "large-step-forward", large_step_forward, GNT_KEY_PGUP, NULL);
+	gnt_bindable_class_register_action(bindable, "min-value", move_min_value, GNT_KEY_HOME, NULL);
+	gnt_bindable_class_register_action(bindable, "max-value", move_max_value, GNT_KEY_END, NULL);
 
 	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
 }
@@ -233,10 +283,14 @@
 
 void gnt_slider_set_value(GntSlider *slider, int value)
 {
+	int old;
 	if (slider->current == value)
 		return;
+	old = slider->current;
 	slider->current = value;
 	sanitize_value(slider);
+	if (old == slider->current)
+		return;
 	redraw_slider(slider);
 	slider_value_changed(slider);
 }
@@ -248,10 +302,7 @@
 
 int gnt_slider_advance_step(GntSlider *slider, int steps)
 {
-	slider->current += steps * slider->step;
-	sanitize_value(slider);
-	redraw_slider(slider);
-	slider_value_changed(slider);
+	gnt_slider_set_value(slider, slider->current + steps * slider->step);
 	return slider->current;
 }
 
@@ -260,6 +311,16 @@
 	slider->step = step;
 }
 
+void gnt_slider_set_small_step(GntSlider *slider, int step)
+{
+	slider->smallstep = step;
+}
+
+void gnt_slider_set_large_step(GntSlider *slider, int step)
+{
+	slider->largestep = step;
+}
+
 void gnt_slider_set_range(GntSlider *slider, int max, int min)
 {
 	slider->max = MAX(max, min);
--- a/finch/libgnt/gntslider.h	Fri Aug 24 21:25:30 2007 +0000
+++ b/finch/libgnt/gntslider.h	Sat Aug 25 01:14:56 2007 +0000
@@ -56,6 +56,8 @@
 	int min;        /* minimum value */
 	int step;       /* amount to change at each step */
 	int current;    /* current value */
+	int smallstep;
+	int largestep;
 };
 
 struct _GntSliderClass
@@ -103,11 +105,27 @@
  * Sets the amount of change at each step.
  * 
  * @param slider  The slider
- * @param step    The amount for each ste
+ * @param step    The amount for each step
  */
 void gnt_slider_set_step(GntSlider *slider, int step);
 
 /**
+ * Sets the amount of change a small step.
+ * 
+ * @param slider  The slider
+ * @param step    The amount for a small step (for the slider)
+ */
+void gnt_slider_set_small_step(GntSlider *slider, int step);
+
+/**
+ * Sets the amount of change a large step.
+ * 
+ * @param slider  The slider
+ * @param step    The amount for a large step (for the slider)
+ */
+void gnt_slider_set_large_step(GntSlider *slider, int step);
+
+/**
  * Advance the slider forward or backward.
  *
  * @param slider   The slider