[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Vala] Signal questions



Greetings,
  I'd like to create a Gtk widget that is pluggable into a
GtkScrolledWindow. For that it has to have a handler for the
gtk_widget_set_scroll_adjustments signal, and there lies my problem.

GtkWidget (according to  gth gtk+-2.0.vapi file, vala 0.1.7 ) does not
define such a signal, instead it has a simple function of that name.
GtkLayout does have such a signal, its part of its class definition. So
I went ahead and copied the signal declaration into my class. 

I then created the attached test program, and here's what the compiler
says to it:

SignalProblem.c: In function
'_scrollable_area_on_set_scroll_adjustments_scrollable_area_set_scroll_adjustments':
SignalProblem.c:15: warning: passing argument 2 of
'scrollable_area_on_set_scroll_adjustments' from incompatible pointer
type

(SignalProblem:2316): Gtk-WARNING **: gtk_scrolled_window_add(): cannot
add non scrollable widget use gtk_scrolled_window_add_with_viewport()
instead

So I had a look
at '_scrollable_area_on_set_scroll_adjustments_scrollable_area_set_scroll_adjustments':

static gboolean
_scrollable_area_on_set_scroll_adjustments_scrollable_area_set_scroll_adjustments 
     (ScrollableArea* sender, 
      GtkAdjustment* a, GtkAdjustment* b, 
      gpointer self) {
  return scrollable_area_on_set_scroll_adjustments (self, sender, a);
}

Something is very wrong here, since one of the adjustments had been
silently dropped ... Could somebody please explain to me how to handle
this? I'm a bit lost, and every hint would be appreciated ...




using GLib;
using Gtk;

public class ScrollableArea : DrawingArea {
  signal void set_scroll_adjustments(Adjustment a, Adjustment b);
  public void initialize() {
    set_scroll_adjustments += on_set_scroll_adjustments;
  }

  public bool on_set_scroll_adjustments(Adjustment hadj, Adjustment vadj) {
    stderr.printf("  ... here should be more ...\n");
    return true;
  }
}

public class Test {
  public static void main (string[] args) {
    
    Gtk.init(ref args);
    Window win = new Window(WindowType.TOPLEVEL);
    win.destroy += Gtk.main_quit;
    win.title="AnalogClockDemo";
    ScrolledWindow scrolled_win = new ScrolledWindow(null, null);
    ScrollableArea display = new ScrollableArea();
    scrolled_win.add(display);
    win.add(scrolled_win);
    win.show_all();
    Gtk.main();
  }
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]