Re: manipulating scrollbars with gtkbutton
- From: drouin stna dgac fr
- To: gtk-app-devel-list gnome org
- Subject: Re: manipulating scrollbars with gtkbutton
- Date: Thu, 28 Mar 2002 16:45:20 +0100
What i need to do is a little more complicated... My buttons need to behave
the same way the arrows on scrollbars do (keep scrolling while pressed).
For now i have coded timer tricks, but i am not really happy with that.
#define SCROLL_INITIAL_DELAY 250  /* must hold button this long before ...
*/
#define SCROLL_LATER_DELAY   100  /* ... it starts repeating at this rate 
*/
static gint scroll_down_timeout(gpointer user_data) {
  struct ihm_Window* window = (struct ihm_Window*)user_data;
  GtkAdjustment* adj =  GTK_TEXT(window->text[0])->vadj;
  
  if (adj->value - adj->step_increment >= adj->lower)
   gtk_adjustment_set_value(adj, adj->value - adj->step_increment);
 else
   gtk_adjustment_set_value(adj,adj->lower);
 
 return adj->value != adj->lower;
}
static gint scroll_down_initial_timeout(gpointer user_data) {
  struct ihm_Window* window = (struct ihm_Window*)user_data;
  window->scrolling_timer_id = gtk_timeout_add(SCROLL_LATER_DELAY,
scroll_down_timeout, window);
  return FALSE;
}
void 
on_scroll_down_pressed(GtkButton *button, gpointer user_data) {
  struct ihm_Window* window = (struct ihm_Window*)user_data;
  window->scrolling_timer_id = gtk_timeout_add(SCROLL_INITIAL_DELAY,
scroll_down_initial_timeout, window);
}
void on_scroll_down_released(GtkButton *button, gpointer user_data) {
  struct ihm_Window* window = (struct ihm_Window*)user_data;
  gtk_timeout_remove(window->scrolling_timer_id);
}
I need to command a gtkscrollbar with two gtkbuttons (scroll up and
down).
I cannot figure out a simple way of doing it. any clue ?
Just call gtk_adjustment_set_value() on the scrollbar adjustments.
Havoc
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]