示例#1
0
文件: dialog_unix.go 项目: sjn1978/ui
//export our_openfile_response_callback
func our_openfile_response_callback(dialog *C.GtkDialog, response C.gint, data C.gpointer) {
	f := (*func(string))(unsafe.Pointer(data))
	if response != C.GTK_RESPONSE_ACCEPT {
		(*f)("")
		C.gtk_widget_destroy((*C.GtkWidget)(unsafe.Pointer(dialog)))
		return
	}
	filename := C.gtk_file_chooser_get_filename((*C.GtkFileChooser)(unsafe.Pointer(dialog)))
	if filename == nil {
		panic("chosen filename NULL in OpenFile()")
	}
	realfilename := fromgstr(filename)
	C.g_free(C.gpointer(unsafe.Pointer(filename)))
	C.gtk_widget_destroy((*C.GtkWidget)(unsafe.Pointer(dialog)))
	(*f)(realfilename)
}
示例#2
0
文件: dialog_unix.go 项目: UIKit0/ui
func (d *dialog) cleanup(box *C.GtkWidget) {
	// have to explicitly close the dialog box, otherwise wacky things will happen
	C.gtk_widget_destroy(box)
	if d.parent != dialogWindow {
		C.gtk_window_group_remove_window(d.newgroup, d.pwin)
		C.g_object_unref(C.gpointer(unsafe.Pointer(d.newgroup))) // free the group
		if d.prevgroup != nil {
			C.gtk_window_group_add_window(d.prevgroup, d.pwin)
		} // otherwise it'll go back into the default group on its own
	}
}
示例#3
0
func _msgBox(parent *Window, primarytext string, secondarytext string, msgtype C.GtkMessageType, buttons C.GtkButtonsType) (result C.gint) {
	ret := make(chan C.gint)
	defer close(ret)
	uitask <- func() {
		var pwin *C.GtkWindow = nil

		// to implement parent, we need to put the GtkMessageDialog into a new window group along with parent
		// a GtkWindow can only be part of one group
		// so we use this to save the parent window group (if there is one) and store the new window group
		// after showing the message box, we restore the previous window group, so future parent == nil can work properly
		// thanks to pbor and mclasen in irc.gimp.net/#gtk+
		var prevgroup *C.GtkWindowGroup = nil
		var newgroup *C.GtkWindowGroup

		if parent != nil {
			pwin = togtkwindow(parent.sysData.widget)
			// we can't remove a window from the "default window group"; otherwise this throws up Gtk-CRITICAL warnings
			if C.gtk_window_has_group(pwin) != C.FALSE {
				prevgroup = C.gtk_window_get_group(pwin)
				C.gtk_window_group_remove_window(prevgroup, pwin)
			}
			newgroup = C.gtk_window_group_new()
			C.gtk_window_group_add_window(newgroup, pwin)
		}

		cprimarytext := C.CString(primarytext)
		defer C.free(unsafe.Pointer(cprimarytext))
		csecondarytext := (*C.char)(nil)
		if secondarytext != "" {
			csecondarytext = C.CString(secondarytext)
			defer C.free(unsafe.Pointer(csecondarytext))
		}
		box := C.gtkNewMsgBox(pwin, msgtype, buttons, cprimarytext, csecondarytext)
		response := C.gtk_dialog_run((*C.GtkDialog)(unsafe.Pointer(box)))
		C.gtk_widget_destroy(box)

		if parent != nil {
			C.gtk_window_group_remove_window(newgroup, pwin)
			C.g_object_unref(C.gpointer(unsafe.Pointer(newgroup))) // free the group
			if prevgroup != nil {
				C.gtk_window_group_add_window(prevgroup, pwin)
			} // otherwise it'll go back into the default group on its own
		}

		ret <- response
	}
	return <-ret
}
示例#4
0
文件: widget.go 项目: napsy/go-gtk3
func (self *Widget) Destroy() {
	C.gtk_widget_destroy(self.object)
}
示例#5
0
文件: widget.go 项目: ziutek/gtk
func (w *Widget) Destroy() {
	C.gtk_widget_destroy(w.g())
}
示例#6
0
文件: gtk.go 项目: evmar/smash
func (w *Window) Close() {
	C.gtk_widget_destroy(w.gtkWin)
}
示例#7
0
// Destroy is a wrapper around gtk_widget_destroy().
func (v *Widget) Destroy() {
	C.gtk_widget_destroy(v.native())
}
示例#8
0
func (w *window) Close() {
	C.gtk_widget_destroy(w.widget)
}
示例#9
0
文件: linux_gtk.go 项目: axet/desktop
func gtk_widget_destroy(p GtkWidget) {
	C.gtk_widget_destroy(Arg(p))
}