Exemple #1
0
/*
 * gets the sheets parent adjustments
 * returns TRUE on success
 */
gboolean
sheet_get_adjustments (const Sheet *sheet, GtkAdjustment **hadj, GtkAdjustment **vadj)
{
	GtkWidget *parent;
	GtkScrolledWindow *scrolled;

	if (__unlikely (!sheet))
		return FALSE;
	if (__unlikely (!vadj || !hadj))
		return FALSE;

	parent = gtk_widget_get_parent (GTK_WIDGET (sheet));
	if (__unlikely (!parent || !GTK_IS_SCROLLED_WINDOW (parent)))
		return FALSE;
	scrolled = GTK_SCROLLED_WINDOW (parent);

	*hadj = gtk_scrolled_window_get_hadjustment (scrolled);
	if (__unlikely (!*hadj || !GTK_IS_ADJUSTMENT (*hadj)))
		return FALSE;

	*vadj = gtk_scrolled_window_get_vadjustment (scrolled);
	if (__unlikely (!*vadj || !GTK_IS_ADJUSTMENT (*vadj)))
		return FALSE;

	return TRUE;
}
Exemple #2
0
/**
 * @brief   Tie a marker's position to a pair of GtkAdjustments
 *
 * @param   marker        HosMarker for which to set adjustments
 * @param   adjustment_x  The GtkAdjustment to tie to the X position of 'marker'
 * @param   adjustment_y  The GtkAdjustment to tie to the Y position of 'marker'
 */
void
marker_set_adjustments(HosMarker *marker, GtkAdjustment *adjustment_x, GtkAdjustment *adjustment_y)
{
  gboolean need_configure = FALSE;

  g_return_if_fail(HOS_IS_MARKER(marker));
  if (GTK_IS_ADJUSTMENT(adjustment_x) && (marker->adjustment_x != adjustment_x))
    {
      need_configure = TRUE;
      if (marker->adjustment_x)
        {
	  g_signal_handlers_disconnect_by_func (marker->adjustment_x,
						marker_adjustment_value_changed,
						marker);
	  g_object_unref (marker->adjustment_x);
        }
      marker->adjustment_x = adjustment_x;
      if (adjustment_x)
        {
	  g_object_ref (adjustment_x);
	  gtk_object_sink (GTK_OBJECT (adjustment_x));
	  g_signal_connect (adjustment_x, "value_changed",
			    G_CALLBACK (marker_adjustment_value_changed),
			    marker);
        }

    }
  if (GTK_IS_ADJUSTMENT(adjustment_y) && (marker->adjustment_y != adjustment_y))
    {
      need_configure = TRUE;
      if (marker->adjustment_y)
        {
	  g_signal_handlers_disconnect_by_func (marker->adjustment_y,
						marker_adjustment_value_changed,
						marker);
	  g_object_unref (marker->adjustment_y);
        }
      marker->adjustment_y = adjustment_y;
      if (adjustment_y)
        {
	  g_object_ref (adjustment_y);
	  gtk_object_sink (GTK_OBJECT (adjustment_y));
	  g_signal_connect (adjustment_y, "value_changed",
			    G_CALLBACK (marker_adjustment_value_changed),
			    marker);
        }
    }
  if (need_configure) canvas_item_configure(HOS_CANVAS_ITEM(marker));
}
Exemple #3
0
void gtk_vscrollbutton_set_adjustment(GtkVScrollbutton *scrollbutton,
				      GtkAdjustment *adjustment)
{
    cm_return_if_fail(scrollbutton != NULL);
    cm_return_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton));

    if (!adjustment)
	    adjustment =
	    GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
    else
	cm_return_if_fail(GTK_IS_ADJUSTMENT(adjustment));

    if (scrollbutton->adjustment != adjustment) {
	if (scrollbutton->adjustment) {
	    g_signal_handlers_disconnect_matched(scrollbutton->adjustment,
	    					 G_SIGNAL_MATCH_DATA,
	    					 0, 0, NULL, NULL, 
						 (gpointer) scrollbutton);
	    g_object_unref(G_OBJECT(scrollbutton->adjustment));
	}

	scrollbutton->adjustment = adjustment;
	g_object_ref(G_OBJECT(adjustment));
	g_object_ref_sink (G_OBJECT(adjustment));
    }
}
Exemple #4
0
static void
git_source_view_set_scroll_adjustments (GtkWidget *widget,
                                        GtkAdjustment *hadjustment,
                                        GtkAdjustment *vadjustment)
{
  GitSourceView *sview = (GitSourceView *) widget;
  GitSourceViewPrivate *priv = sview->priv;

  if (hadjustment)
    g_return_if_fail (GTK_IS_ADJUSTMENT (hadjustment));
  else
    hadjustment
      = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
  if (vadjustment)
    g_return_if_fail (GTK_IS_ADJUSTMENT (vadjustment));
  else
    vadjustment
      = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));

  g_object_ref_sink (hadjustment);
  g_object_ref_sink (vadjustment);

  git_source_view_unref_hadjustment (sview);
  priv->hadjustment = hadjustment;
  priv->hadjustment_changed_handler
    = g_signal_connect (hadjustment, "changed",
                        G_CALLBACK (git_source_view_on_adj_changed),
                        sview);
  priv->hadjustment_value_changed_handler
    = g_signal_connect (hadjustment, "value-changed",
                        G_CALLBACK (git_source_view_on_adj_value_changed),
                        sview);

  git_source_view_unref_vadjustment (sview);
  priv->vadjustment = vadjustment;
  priv->vadjustment_changed_handler
    = g_signal_connect (vadjustment, "changed",
                        G_CALLBACK (git_source_view_on_adj_changed),
                        sview);
  priv->vadjustment_value_changed_handler
    = g_signal_connect (vadjustment, "value-changed",
                        G_CALLBACK (git_source_view_on_adj_value_changed),
                        sview);


  git_source_view_update_scroll_adjustments (sview);
}
Exemple #5
0
gdouble
marker_get_y(HosMarker *self)
{
  g_return_val_if_fail(HOS_IS_MARKER(self), 0);
  g_return_val_if_fail(GTK_IS_ADJUSTMENT(self->adjustment_y), 0);

  return gtk_adjustment_get_value(self->adjustment_y);
}
Exemple #6
0
/* Clamp a value if the minimum or maximum has changed. */
void
eel_gtk_adjustment_clamp_value (GtkAdjustment *adjustment)
{
    g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

    eel_gtk_adjustment_set_value (adjustment,
                                  gtk_adjustment_get_value (adjustment));
}
Exemple #7
0
// Public functions
GtkWidget *dtgtk_slider_new(GtkAdjustment *adjustment)
{
  GtkDarktableSlider *slider;
  g_return_val_if_fail(adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment), NULL);
  slider = g_object_new(dtgtk_slider_get_type(), NULL);
  slider->adjustment = adjustment;
  slider->labelwidth = slider->labelheight = 0;
  return (GtkWidget *)slider;
}
Exemple #8
0
/**
 * gtk_layout_set_vadjustment:
 * @layout: a #GtkLayout
 * @adjustment: (allow-none): new scroll adjustment
 *
 * Sets the vertical scroll adjustment for the layout.
 *
 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
 *
 * Deprecated: 3.0: Use gtk_scrollable_set_vadjustment()
 **/
void
gtk_layout_set_vadjustment (GtkLayout     *layout,
                            GtkAdjustment *adjustment)
{
  g_return_if_fail (GTK_IS_LAYOUT (layout));
  g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));

  gtk_layout_do_set_vadjustment (layout, adjustment);
}
Exemple #9
0
/**
 * gtk_scrollable_set_vadjustment:
 * @scrollable: a #GtkScrollable
 * @vadjustment: (allow-none): a #GtkAdjustment
 *
 * Sets the vertical adjustment of the #GtkScrollable.
 *
 * Since: 3.0
 **/
void
gtk_scrollable_set_vadjustment (GtkScrollable *scrollable,
                                GtkAdjustment *vadjustment)
{
  g_return_if_fail (GTK_IS_SCROLLABLE (scrollable));
  g_return_if_fail (vadjustment == NULL || GTK_IS_ADJUSTMENT (vadjustment));

  g_object_set (scrollable, "vadjustment", vadjustment, NULL);
}
Exemple #10
0
gdouble
cursor_get_position(HosCursor *cursor)
{

  if (!HOS_IS_CURSOR(cursor)) return 0;
  if (!GTK_IS_ADJUSTMENT(cursor->adjustment)) return 0;

  return gtk_adjustment_get_value(cursor->adjustment);
}
Exemple #11
0
/*
 * x, y in world coordinates
 */
static void
cursor_move_relative(HosOrnament *self, gdouble x, gdouble y)
{
  HosCursor *cursor = HOS_CURSOR(self);
  gdouble delta = cursor->orientation == HOS_VERTICAL ? x : y;
  if (GTK_IS_ADJUSTMENT(cursor->adjustment))
    gtk_adjustment_set_value(cursor->adjustment,
			     gtk_adjustment_get_value(cursor->adjustment) +
			     delta);
}
Exemple #12
0
void
cursor_set_pos(HosCursor *cursor, gdouble position)
{

  g_return_if_fail(HOS_IS_CURSOR(cursor));
  g_return_if_fail(GTK_IS_ADJUSTMENT(cursor->adjustment));

  gtk_adjustment_set_value(cursor->adjustment, position);

}
void
my_timeline_index_changed (MyTimelineModel * self, GtkAdjustment * adjust)
{
    MyTimelineModelPrivate *priv =
        my_timeline_model_get_instance_private (MY_TIMELINE_MODEL (self));

    g_return_if_fail (MY_IS_TIMELINE_MODEL (self));
    g_return_if_fail (GTK_IS_ADJUSTMENT (adjust));

    g_signal_emit (G_OBJECT (self), signals[SIG_CURRENT_POS_CHANGED], 0);
}
guint
my_timeline_model_get_current_pos (MyTimelineModel * self)
{
    MyTimelineModelPrivate *priv =
        my_timeline_model_get_instance_private (self);

    g_return_if_fail (MY_IS_TIMELINE_MODEL (self));
    g_return_if_fail (GTK_IS_ADJUSTMENT (priv->adjust));

    return gtk_adjustment_get_value (priv->adjust);
}
Exemple #15
0
static gboolean
marker_get_pos(HosMarker *self, gdouble *x, gdouble *y)
{
  g_return_if_fail(HOS_IS_MARKER(self));
  if (x)
    {
      if (GTK_IS_ADJUSTMENT(self->adjustment_x))
	*x = gtk_adjustment_get_value(self->adjustment_x);
      else
	return FALSE;
    }
  if (y)
    {
      if (GTK_IS_ADJUSTMENT(self->adjustment_y))
	*y = gtk_adjustment_get_value(self->adjustment_y);
      else
	return FALSE;
    }
  return TRUE;
}
Exemple #16
0
static void
photos_utils_adjustment_scroll (GtkAdjustment *adjustment, gdouble delta)
{
  gdouble value;

  g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

  value = gtk_adjustment_get_value (adjustment);
  value += delta;
  gtk_adjustment_set_value (adjustment, value);
}
Exemple #17
0
/*****************************************************************************
 * set_session_io_start()
 *****************************************************************************/
void
set_session_io_start(GtkWidget *widget, gpointer UNUSED(data))
{
    if (GTK_IS_ADJUSTMENT(widget)) {
        session_io_start =
            (unsigned int) gtk_adjustment_get_value(GTK_ADJUSTMENT(widget)) - 1;
    }
    else if (GTK_IS_SPIN_BUTTON(widget)) {
        session_io_start =
            (unsigned int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)) - 1;
    }
}
Exemple #18
0
/**
 * gwy_scroller_set_vadjustment:
 * @scroller: A scroller.
 * @adjustment: Adjustment to use for the vertical position.
 *
 * Sets the adjustment a scroller will use for the vertical position.
 **/
void
gwy_scroller_set_vadjustment(GwyScroller *scroller,
                             GtkAdjustment *adjustment)
{
    g_return_if_fail(GWY_IS_SCROLLER(scroller));
    g_return_if_fail(!adjustment || GTK_IS_ADJUSTMENT(adjustment));
    if (!adjustment)
        adjustment = g_object_newv(GTK_TYPE_ADJUSTMENT, 0, NULL);
    if (!set_vadjustment(scroller, adjustment))
        return;

    g_object_notify_by_pspec(G_OBJECT(scroller), properties[PROP_VADJUSTMENT]);
}
/**
 * gtk_clutter_scrollable_set_adjustments:
 * @scrollable: a #GtkClutterScrollable
 * @h_adjust: (allow-none): a #GtkAdjustment, or %NULL
 * @v_adjust: (allow-none): a #GtkAdjustment, or %NULL
 *
 * Sets the horizontal and vertical adjustments used to determine
 * the position of the scrollable actor.
 *
 * Since: 0.10
 */
void
gtk_clutter_scrollable_set_adjustments (GtkClutterScrollable *scrollable,
                                        GtkAdjustment        *h_adjust,
                                        GtkAdjustment        *v_adjust)
{
  GtkClutterScrollableIface *iface;

  g_return_if_fail (GTK_CLUTTER_IS_SCROLLABLE (scrollable));
  g_return_if_fail (h_adjust == NULL || GTK_IS_ADJUSTMENT (h_adjust));

  iface = GTK_CLUTTER_SCROLLABLE_GET_IFACE (scrollable);
  if (iface->set_adjustments)
    iface->set_adjustments (scrollable, h_adjust, v_adjust);
}
Exemple #20
0
static gboolean
photos_utils_adjustment_can_scroll (GtkAdjustment *adjustment)
{
  gdouble lower;
  gdouble page_size;
  gdouble upper;

  g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), FALSE);

  lower = gtk_adjustment_get_lower (adjustment);
  page_size = gtk_adjustment_get_page_size (adjustment);
  upper = gtk_adjustment_get_upper (adjustment);

  return upper - lower > page_size;
}
Exemple #21
0
/**
 * ppg_rt_graph_adjustment_changed:
 * @graph: (in): A #PpgRtGraph.
 * @adjustment: (in): A #GtkAdjustment.
 *
 * Handle the "changed" signal for the adjustment encapsulating the vertical
 * range of the graph.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
ppg_rt_graph_adjustment_changed (PpgRtGraph    *graph,
                                 GtkAdjustment *adjustment)
{
	PpgRtGraphPrivate *priv;

	g_return_if_fail(PPG_IS_RT_GRAPH(graph));
	g_return_if_fail(GTK_IS_ADJUSTMENT(adjustment));

	priv = graph->priv;

	g_object_get(adjustment,
	             "lower", &priv->lower_value,
	             "upper", &priv->upper_value,
	             NULL);
}
Exemple #22
0
/* The standard gtk_adjustment_set_value ignores page size, which
 * disagrees with the logic used by scroll bars, for example.
 */
void
eel_gtk_adjustment_set_value (GtkAdjustment *adjustment,
                              float value)
{
    float upper_page_start, clamped_value;

    g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

    upper_page_start = MAX (gtk_adjustment_get_upper (adjustment) -
                            gtk_adjustment_get_page_size (adjustment),
                            gtk_adjustment_get_lower (adjustment));
    clamped_value = CLAMP (value, gtk_adjustment_get_lower (adjustment), upper_page_start);
    if (clamped_value != gtk_adjustment_get_value (adjustment))
    {
        gtk_adjustment_set_value (adjustment, clamped_value);
        gtk_adjustment_value_changed (adjustment);
    }
}
Exemple #23
0
static void
cvw_update_adjustment_allocation(GtkAdjustment* adjustment, gdouble size, gboolean update_adjustment) {
	if(!GTK_IS_ADJUSTMENT(adjustment)) {
		return;
	}

	g_object_set(adjustment,
		     "page-size",      size,
		     "page-increment", size,
		     "step-increment", size > 20 ? 10.0 : 1.0,
		     NULL);

	if(update_adjustment) {
		gtk_adjustment_changed(adjustment);
	}

	gtk_adjustment_set_value(adjustment, MIN(adjustment->value, adjustment->upper - adjustment->page_size));
}
Exemple #24
0
/**
 * gimp_scale_entry_set_sensitive:
 * @adjustment: a #GtkAdjustment returned by gimp_scale_entry_new()
 * @sensitive:  a boolean value with the same semantics as the @sensitive
 *              parameter of gtk_widget_set_sensitive()
 *
 * Sets the sensitivity of the scale_entry's #GtkLabel, #GtkHScale and
 * #GtkSpinButton.
 **/
void
gimp_scale_entry_set_sensitive (GtkObject *adjustment,
                                gboolean   sensitive)
{
  GtkWidget *widget;

  g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

  widget = GIMP_SCALE_ENTRY_LABEL (adjustment);
  if (widget)
    gtk_widget_set_sensitive (widget, sensitive);

  widget = GIMP_SCALE_ENTRY_SCALE (adjustment);
  if (widget)
    gtk_widget_set_sensitive (widget, sensitive);

  widget = GIMP_SCALE_ENTRY_SPINBUTTON (adjustment);
  if (widget)
    gtk_widget_set_sensitive (widget, sensitive);
}
Exemple #25
0
static void
copy_to_counterpart (app_t *app, GObject *object)
{
    static const char *xy_map[] =
    {
	"reconstruct_x_combo_box", "reconstruct_y_combo_box",
	"sample_x_combo_box",      "sample_y_combo_box",
	"scale_x_adjustment",      "scale_y_adjustment",
    };
    GObject *counterpart = NULL;
    int i;

    for (i = 0; i < G_N_ELEMENTS (xy_map); i += 2)
    {
	GObject *x = gtk_builder_get_object (app->builder, xy_map[i]);
	GObject *y = gtk_builder_get_object (app->builder, xy_map[i + 1]);

	if (object == x)
	    counterpart = y;
	if (object == y)
	    counterpart = x;
    }

    if (!counterpart)
	return;
    
    if (GTK_IS_COMBO_BOX (counterpart))
    {
	gtk_combo_box_set_active (
	    GTK_COMBO_BOX (counterpart),
	    gtk_combo_box_get_active (
		GTK_COMBO_BOX (object)));
    }
    else if (GTK_IS_ADJUSTMENT (counterpart))
    {
	gtk_adjustment_set_value (
	    GTK_ADJUSTMENT (counterpart),
	    gtk_adjustment_get_value (
		GTK_ADJUSTMENT (object)));
    }
}
/**
 * gtk_scale_button_set_adjustment:
 * @button: a #GtkScaleButton
 * @adjustment: a #GtkAdjustment
 *
 * Sets the #GtkAdjustment to be used as a model
 * for the #GtkScaleButton's scale.
 * See gtk_range_set_adjustment() for details.
 *
 * Since: 2.12
 */
void
gtk_scale_button_set_adjustment	(GtkScaleButton *button,
				 GtkAdjustment  *adjustment)
{
  g_return_if_fail (GTK_IS_SCALE_BUTTON (button));
  if (!adjustment)
    adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  else
    g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

  if (button->priv->adjustment != adjustment)
    {
      if (button->priv->adjustment)
        g_object_unref (button->priv->adjustment);
      button->priv->adjustment = g_object_ref_sink (adjustment);

      if (button->priv->scale)
        gtk_range_set_adjustment (GTK_RANGE (button->priv->scale), adjustment);

      g_object_notify (G_OBJECT (button), "adjustment");
    }
}
Exemple #27
0
static void
dma_sparse_view_set_scroll_adjustments (GtkTextView *text_view,
                                      GtkAdjustment *hadj,
                                      GtkAdjustment *vadj)
{
	DmaSparseView *view = DMA_SPARSE_VIEW (text_view);

	if (vadj)
		g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
	
	if (view->priv->vadjustment && (view->priv->vadjustment != vadj))
    {
		g_signal_handlers_disconnect_by_func (view->priv->vadjustment,
									dma_sparse_view_value_changed,
					    			view);
     	g_object_unref (view->priv->vadjustment);
	}
	
	if (view->priv->vadjustment != vadj)
	{
		
		GTK_TEXT_VIEW_CLASS (parent_class)->set_scroll_adjustments  (GTK_TEXT_VIEW (view), hadj, NULL);
		
		if (vadj != NULL)
		{
			g_object_ref_sink (vadj);
      
			g_signal_connect (vadj, "value_changed",
                        G_CALLBACK (dma_sparse_view_value_changed),
						view);
			
			gtk_adjustment_set_upper (vadj, dma_sparse_buffer_get_upper (view->priv->buffer));
			gtk_adjustment_set_lower (vadj, dma_sparse_buffer_get_lower (view->priv->buffer));
			gtk_adjustment_set_value (vadj, 0);
		}
		view->priv->vadjustment = vadj;
		dma_sparse_view_update_adjustement (view);
	}
}
static void
apply_value (GtkAdjustment *adj,
             GVariant      *value,
             const gchar   *property)
{
  GValue val = { 0 };
  gdouble v = 0.0;

  g_assert (GTK_IS_ADJUSTMENT (adj));
  g_assert (value != NULL);
  g_assert (property != NULL);

  if (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE))
    v = g_variant_get_double (value);

  else if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT16))
    v = g_variant_get_int16 (value);
  else if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT16))
    v = g_variant_get_uint16 (value);

  else if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32))
    v = g_variant_get_int32 (value);
  else if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT32))
    v = g_variant_get_uint32 (value);

  else if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT64))
    v = g_variant_get_int64 (value);
  else if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64))
    v = g_variant_get_uint64 (value);

  else
    g_warning ("Unknown variant type: %s\n", (gchar *)g_variant_get_type (value));

  g_value_init (&val, G_TYPE_DOUBLE);
  g_value_set_double (&val, v);
  g_object_set_property (G_OBJECT (adj), property, &val);
  g_value_unset (&val);
}
Exemple #29
0
static GdkRegion*
cursor_calculate_region(HosOrnament *self)
{
  g_return_if_fail(HOS_IS_CURSOR(self));
  HosCursor *cursor = HOS_CURSOR(self);

  GtkAdjustment *adjustment = cursor->adjustment;
  HosCanvas *canvas = HOS_CANVAS_ITEM(self)->canvas;

  if (GTK_IS_ADJUSTMENT(adjustment))
    {

      /* recalculate the update region */
      GdkRectangle rect;
      gdouble pos = gtk_adjustment_get_value(adjustment);
      if (cursor->orientation == HOS_VERTICAL)
	{
	  canvas_world2view(canvas, &pos, NULL);
	  rect.x = pos - (CLICK_RADIUS / 2);
	  rect.width = CLICK_RADIUS;
	  rect.y = 0;
	  rect.height = G_MAXINT;
	}
      else /* HOS_HORIZONTAL */
	{
	  canvas_world2view(canvas, NULL, &pos);
	  rect.y = pos - (CLICK_RADIUS / 2);
	  rect.height = CLICK_RADIUS;
	  rect.x = 0;
	  rect.width = G_MAXINT;
	}

      return(gdk_region_rectangle(&rect));
    }
  else
    return gdk_region_new();
}
Exemple #30
0
void
gimp_handle_bar_set_adjustment (GimpHandleBar  *bar,
                                gint            handle_no,
                                GtkAdjustment  *adjustment)
{
  g_return_if_fail (GIMP_IS_HANDLE_BAR (bar));
  g_return_if_fail (handle_no >= 0 && handle_no <= 2);
  g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));

  if (adjustment == bar->slider_adj[handle_no])
    return;

  if (bar->slider_adj[handle_no])
    {
      g_signal_handlers_disconnect_by_func (bar->slider_adj[handle_no],
                                            gimp_handle_bar_adjustment_changed,
                                            bar);
      g_object_unref (bar->slider_adj[handle_no]);
      bar->slider_adj[handle_no] = NULL;
    }

  bar->slider_adj[handle_no] = adjustment;

  if (bar->slider_adj[handle_no])
    {
      g_object_ref (bar->slider_adj[handle_no]);

      g_signal_connect (bar->slider_adj[handle_no], "value-changed",
                        G_CALLBACK (gimp_handle_bar_adjustment_changed),
                        bar);
      g_signal_connect (bar->slider_adj[handle_no], "changed",
                        G_CALLBACK (gimp_handle_bar_adjustment_changed),
                        bar);
    }

  gimp_handle_bar_adjustment_changed (bar->slider_adj[handle_no], bar);
}