Пример #1
0
//export our_area_button_press_event_callback
func our_area_button_press_event_callback(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer) C.gboolean {
	// clicking doesn't automatically transfer keyboard focus; we must do so manually (thanks tristan in irc.gimp.net/#gtk+)
	C.gtk_widget_grab_focus(widget)
	e := (*C.GdkEventButton)(unsafe.Pointer(event))
	me := MouseEvent{
		// GDK button ID == our button ID with some exceptions taken care of by finishMouseEvent()
		Down: uint(e.button),
	}

	var maxTime C.gint
	var maxDistance C.gint

	if e._type != C.GDK_BUTTON_PRESS {
		// ignore GDK's generated double-clicks and beyond; we handled those ourselves below
		return continueEventChain
	}
	s := (*sysData)(unsafe.Pointer(data))
	// e.time is unsigned and in milliseconds
	// maxTime is also milliseconds; despite being gint, it is only allowed to be positive
	// maxDistance is also only allowed to be positive
	settings := C.gtk_widget_get_settings(widget)
	C.gtkGetDoubleClickSettings(settings, &maxTime, &maxDistance)
	me.Count = s.clickCounter.click(me.Down, int(e.x), int(e.y),
		uintptr(e.time), uintptr(maxTime),
		int(maxDistance), int(maxDistance))

	finishMouseEvent(widget, data, me, me.Down, e.x, e.y, e.state, e.window)
	return continueEventChain
}
Пример #2
0
func (w *Widget) GetSettings() *Settings {
	s := new(Settings)
	s.SetPtr(glib.Pointer(C.gtk_widget_get_settings(w.g())))
	return s
}