示例#1
0
func init() {
	gtk.Init(nil)
	go func() {
		runtime.LockOSThread()
		gtk.Main()
	}()
}
示例#2
0
func main() {
	// Initialize GTK without parsing any command line arguments.
	gtk.Init(nil)

	// Create a new toplevel window, set its title, and connect it to the
	// "destroy" signal to exit the GTK main loop when it is destroyed.
	win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if err != nil {
		log.Fatal("Unable to create window:", err)
	}
	win.SetTitle("Simple Example")
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})

	// Create a new label widget to show in the window.
	list, err := gtk.ListBoxNew()
	if err != nil {
		log.Fatal("Unable to create label:", err)
	}
	gtkList = list
	// Add the label to the window.
	win.Add(gtkList)

	// Set the default window size.
	win.SetDefaultSize(640/2, 1136/2)

	// Recursively show all widgets contained in this window.
	win.ShowAll()

	// Begin executing the GTK main loop.  This blocks until
	// gtk.MainQuit() is run.
	go getEntries()
	gtk.Main()
}
示例#3
0
文件: ui.go 项目: tanujmathur/coyim
// NewGTK returns a new client for a GTK ui
func NewGTK(version string) UI {
	coyimVersion = version
	//*.mo files should be in ./i18n/locale_code.utf8/LC_MESSAGES/
	glib.InitI18n("coy", "./i18n")
	gtk.Init(argsWithApplicationName())

	ret := &gtkUI{
		commands: make(chan interface{}, 5),
		toggleConnectAllAutomaticallyRequest: make(chan bool, 100),
		setShowAdvancedSettingsRequest:       make(chan bool, 100),
	}

	var err error
	flags := glib.APPLICATION_FLAGS_NONE
	if *config.MultiFlag {
		flags = glib.APPLICATION_NON_UNIQUE
	}
	ret.app, err = gtk.ApplicationNew("im.coy.CoyIM", flags)
	if err != nil {
		panic(err)
	}

	ret.keySupplier = config.CachingKeySupplier(ret.getMasterPassword)

	ret.accountManager = newAccountManager(ret)

	return ret
}
示例#4
0
func Example() {
	gtk.Init(nil)
	go func() {
		runtime.LockOSThread()
		gtk.Main()
	}()

	ctx := webloop.New()
	view := ctx.NewView()
	defer view.Close()
	view.Open("http://google.com")
	err := view.Wait()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to load URL: %s", err)
		os.Exit(1)
	}
	res, err := view.EvaluateJavaScript("document.title")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to run JavaScript: %s", err)
		os.Exit(1)
	}
	fmt.Printf("JavaScript returned: %q\n", res)
	// output:
	// JavaScript returned: "Google"
}
示例#5
0
文件: main.go 项目: juanfgs/checkers
func main() {
	gtk.Init(nil)
	window := ui.NewMainWindow()
	window.Window.ShowAll()

	gtk.Main()
}
示例#6
0
func main() {
	gtk.Init(nil)
	initIcons()

	win := setupWindow("Go Example Testreport")

	var iter1, iter2 *gtk.TreeIter

	treeView, treeStore := setupTreeView()
	win.Add(treeView)

	// Add some rows to the tree store
	iter1 = addRow(treeStore, imageOK, "Testsuite 1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-1")
	addSubRow(treeStore, iter2, imageOK, "test1-2-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-3")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-3")
	iter1 = addRow(treeStore, imageFAIL, "Testsuite 2")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-2")
	iter2 = addSubRow(treeStore, iter1, imageFAIL, "test2-3")
	addSubRow(treeStore, iter2, imageOK, "test2-3-1")
	addSubRow(treeStore, iter2, imageFAIL, "test2-3-2")

	win.ShowAll()
	gtk.Main()
}
示例#7
0
文件: applet.go 项目: sqp/godock
func main() {
	gtk.Init(nil)
	go func() {
		appdbus.StandAlone(TVPlay.NewApplet)
		gtk.MainQuit()
	}()
	gtk.Main()
}
示例#8
0
// StartGTK ensures that the GTK+ main loop has started. If it has already been
// started by StartGTK, it will not start it again. If another goroutine is
// already running the GTK+ main loop, StartGTK's behavior is undefined.
func (h *StaticRenderer) StartGTK() {
	startGTKOnce.Do(func() {
		gtk.Init(nil)
		go func() {
			runtime.LockOSThread()
			gtk.Main()
		}()
	})
}
示例#9
0
文件: common.go 项目: sqp/godock
// InitGtk provides GTK start and stop callbacks.
//
func InitGtk() (onstart, onstop func()) {
	gtkStart := func() {

		GRRTHREADS()

		// runtime.LockOSThread()
		gtk.Init(nil)
		gtk.Main()
	}
	return gtkStart, gtk.MainQuit
}
示例#10
0
func main() {
	gtk.Init(nil)

	win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	panicIfNotNil(err)
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})
	win.SetDefaultSize(1280, 720)
	win.SetTitle("mauIRC Desktop")

	// Create a new grid widget to arrange child widgets
	grid, err := gtk.GridNew()
	panicIfNotNil(err)
	grid.SetOrientation(gtk.ORIENTATION_VERTICAL)

	loginLabel, err := gtk.LabelNew("Log in to mauIRC")
	panicIfNotNil(err)

	email, err := gtk.EntryNew()
	panicIfNotNil(err)

	password, err := gtk.EntryNew()
	panicIfNotNil(err)
	password.SetVisibility(false)

	btn, err := gtk.ButtonNewWithLabel("Log in")
	panicIfNotNil(err)

	grid.Attach(loginLabel, 0, 2, 1, 1)
	grid.Attach(email, 0, 3, 1, 1)
	grid.Attach(password, 0, 4, 1, 1)
	grid.Attach(btn, 0, 5, 1, 1)

	//grid.Attach(nb, 1, 1, 1, 2)
	//nb.SetHExpand(true)
	//nb.SetVExpand(true)

	/*nbChild, err := gtk.LabelNew("Notebook content")
	if err != nil {
		log.Fatal("Unable to create button:", err)
	}
	nbTab, err := gtk.LabelNew("Tab label")
	if err != nil {
		log.Fatal("Unable to create label:", err)
	}
	nb.AppendPage(nbChild, nbTab)*/

	win.Add(grid)
	win.ShowAll()

	gtk.Main()
}
示例#11
0
func main() {
	gtk.Init(nil)

	win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if err != nil {
		log.Fatal("Unable to create window:", err)
	}
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})

	win.Add(windowWidget())

	// Native GTK is not thread safe, and thus, gotk3's GTK bindings may not
	// be used from other goroutines.  Instead, glib.IdleAdd() must be used
	// to add a function to run in the GTK main loop when it is in an idle
	// state.
	//
	// Two examples of using glib.IdleAdd() are shown below.  The first runs
	// a user created function, LabelSetTextIdle, and passes it two
	// arguments for a label and the text to set it with.  The second calls
	// (*gtk.Label).SetText directly, passing in only the text as an
	// argument.
	//
	// If the function passed to glib.IdleAdd() returns one argument, and
	// that argument is a bool, this return value will be used in the same
	// manner as a native g_idle_add() call.  If this return value is false,
	// the function will be removed from executing in the GTK main loop's
	// idle state.  If the return value is true, the function will continue
	// to execute when the GTK main loop is in this state.
	go func() {
		for {
			time.Sleep(time.Second)
			s := fmt.Sprintf("Set a label %d time(s)!", nSets)
			_, err := glib.IdleAdd(LabelSetTextIdle, topLabel, s)
			if err != nil {
				log.Fatal("IdleAdd() failed:", err)
			}
			nSets++
			s = fmt.Sprintf("Set a label %d time(s)!", nSets)
			_, err = glib.IdleAdd(bottomLabel.SetText, s)
			if err != nil {
				log.Fatal("IdleAdd() failed:", err)
			}
			nSets++
		}
	}()

	win.ShowAll()
	gtk.Main()
}
示例#12
0
文件: build_test.go 项目: sqp/godock
func TestConfig(t *testing.T) {
	gtk.Init(nil)

	build := vdata.TestInit(vdata.New(log.NewLog(log.Logs), nil, nil), vdata.PathTestConf())
	if build == nil {
		return
	}
	build.BuildAll(pageswitch.New())

	assert.Equal(t, countChanged(t, build), 0, "Build unchanged")

	build.KeyWalk(vdata.TestValues)
	assert.Equal(t, countChanged(t, build), 32, "Build full change")
}
示例#13
0
func main() {
	gtk.Init(nil)

	win := setup_window(winTitle)

	box := newStackFull()
	win.Add(box)

	// Recursively show all widgets contained in this window.
	win.ShowAll()

	// Begin executing the GTK main loop.  This blocks until
	// gtk.MainQuit() is run.
	gtk.Main()
}
示例#14
0
文件: signals.go 项目: adrien3d/gobox
func main() {
	gtk.Init(nil)

	win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if err != nil {
		log.Fatal("Unable to create window:", err)
	}
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})

	win.Add(windowWidget())
	win.ShowAll()

	gtk.Main()
}
示例#15
0
func (s *UIReaderSuite) Test_builderForDefinition_useGoFileIfXMLDoesntExists(c *C) {
	gtk.Init(nil)
	removeFile("definitions/Test.xml")
	//writeTestFile("definitions/TestDefinition.xml", testFile)
	ui := "Test"

	builder := builderForDefinition(ui)

	win, getErr := builder.GetObject("conversation")
	if getErr != nil {
		fmt.Errorf("\nFailed to get window \n%s", getErr.Error())
		c.Fail()
	}
	w, h := win.(*gtk.Window).GetSize()
	c.Assert(h, Equals, 500)
	c.Assert(w, Equals, 400)
}
示例#16
0
文件: ui.go 项目: 0x27/coyim
// NewGTK returns a new client for a GTK ui
func NewGTK(version string) UI {
	coyimVersion = version
	//*.mo files should be in ./i18n/locale_code.utf8/LC_MESSAGES/
	glib.InitI18n("coy", "./i18n")
	gtk.Init(argsWithApplicationName())

	ret := &gtkUI{
		commands: make(chan interface{}, 5),
		toggleConnectAllAutomaticallyRequest: make(chan bool, 100),
	}

	ret.applyStyle()
	ret.keySupplier = config.CachingKeySupplier(ret.getMasterPassword)

	ret.accountManager = newAccountManager(ret)

	return ret
}
示例#17
0
func main() {
	gtk.Init(nil)

	win := setupWindow("Go Feature Timeline")

	treeView, listStore := setupTreeView()
	win.Add(treeView)

	// Add some rows to the list store
	addRow(listStore, "r57", "Gofix command added for rewriting code for new APIs")
	addRow(listStore, "r60", "URL parsing moved to new \"url\" package")
	addRow(listStore, "go1.0", "Rune type introduced as alias for int32")
	addRow(listStore, "go1.1", "Race detector added to tools")
	addRow(listStore, "go1.2", "Limit for number of threads added")
	addRow(listStore, "go1.3", "Support for various BSD's, Plan 9 and Solaris")

	win.ShowAll()
	gtk.Main()
}
示例#18
0
func Example() {
	runtime.LockOSThread()
	gtk.Init(nil)

	webView := webkit2.NewWebView()
	defer webView.Destroy()

	webView.Connect("load-failed", func() {
		fmt.Println("Load failed.")
	})
	webView.Connect("load-changed", func(_ *glib.Object, i int) {
		loadEvent := webkit2.LoadEvent(i)
		switch loadEvent {
		case webkit2.LoadFinished:
			fmt.Println("Load finished.")
			fmt.Printf("Title: %q\n", webView.Title())
			fmt.Printf("URI: %s\n", webView.URI())
			webView.RunJavaScript("window.location.hostname", func(val *gojs.Value, err error) {
				if err != nil {
					fmt.Println("JavaScript error.")
				} else {
					fmt.Printf("Hostname (from JavaScript): %q\n", val)
				}
				gtk.MainQuit()
			})
		}
	})

	glib.IdleAdd(func() bool {
		webView.LoadURI("https://www.google.com/")
		return false
	})

	gtk.Main()

	// output:
	// Load finished.
	// Title: "Google"
	// URI: https://www.google.com/
	// Hostname (from JavaScript): "www.google.com"
}
示例#19
0
文件: confgui.go 项目: sqp/godock
func main() {
	gtk.Init(nil)
	win, e := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if e != nil {
		println(e.Error())
		return
	}

	path, isTest := vdata.TestPathDefault()
	var saveCall func(cftype.Builder)
	if isTest {
		saveCall = cfprint.Updated
	} else {
		saveCall = func(build cftype.Builder) { cfprint.Default(build, true) }
	}
	source := vdata.New(log.NewLog(log.Logs), win, saveCall)
	build := vdata.TestInit(source, path)
	source.SetGrouper(build)

	glib.IdleAdd(packWindow(win, source, build))
	gtk.Main()
}
func main() {
	gtk.Init(&os.Args)

	// Declarations
	Window, _ = gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	RootBox, _ = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 6)
	TreeView, _ = gtk.TreeViewNew()
	Entry, _ = gtk.EntryNew()
	ListStore, _ = gtk.ListStoreNew(glib.TYPE_STRING)

	// Window properties
	Window.SetTitle("Products written in Go")
	Window.Connect("destroy", gtk.MainQuit)

	// TreeView properties
	{
		renderer, _ := gtk.CellRendererTextNew()
		column, _ := gtk.TreeViewColumnNewWithAttribute("Value", renderer, "text", 0)
		TreeView.AppendColumn(column)
	}
	TreeView.SetModel(ListStore)

	// TreeView selection properties
	sel, _ := TreeView.GetSelection()
	sel.SetMode(gtk.SELECTION_MULTIPLE)
	sel.Connect("changed", SelectionChanged)

	// Packing
	RootBox.PackStart(TreeView, true, true, 0)
	RootBox.PackStart(Entry, false, false, 0)
	Window.Add(RootBox)

	// Populating list
	// TODO: Add more values to the list
	AppendMultipleToList("Go", "Docker", "CockroachDB")

	Window.ShowAll()
	gtk.Main()
}
示例#21
0
func main() {
	gtk.Init(nil)

	win := setupWindow()
	box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
	win.Add(box)

	tv := setupTextView(box)

	props := []*BoolProperty{
		&BoolProperty{"cursor visible", (*tv).GetCursorVisible, (*tv).SetCursorVisible},
		&BoolProperty{"editable", (*tv).GetEditable, (*tv).SetEditable},
		&BoolProperty{"overwrite", (*tv).GetOverwrite, (*tv).SetOverwrite},
		&BoolProperty{"accepts tab", (*tv).GetAcceptsTab, (*tv).SetAcceptsTab},
	}

	setupPropertyCheckboxes(tv, box, props)

	win.ShowAll()

	gtk.Main()
}
示例#22
0
func main() {
	gtk.Init(nil)

	// gui boilerplate
	win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	da, _ := gtk.DrawingAreaNew()
	win.Add(da)
	win.SetTitle("Arrow keys")
	win.Connect("destroy", gtk.MainQuit)
	win.ShowAll()

	// Data
	unitSize := 20.0
	x := 0.0
	y := 0.0
	keyMap := map[uint]func(){
		KEY_LEFT:  func() { x-- },
		KEY_UP:    func() { y-- },
		KEY_RIGHT: func() { x++ },
		KEY_DOWN:  func() { y++ },
	}

	// Event handlers
	da.Connect("draw", func(da *gtk.DrawingArea, cr *cairo.Context) {
		cr.SetSourceRGB(0, 0, 0)
		cr.Rectangle(x*unitSize, y*unitSize, unitSize, unitSize)
		cr.Fill()
	})
	win.Connect("key-press-event", func(win *gtk.Window, ev *gdk.Event) {
		keyEvent := &gdk.EventKey{ev}
		if move, found := keyMap[keyEvent.KeyVal()]; found {
			move()
			win.QueueDraw()
		}
	})

	gtk.Main()
}
示例#23
0
文件: confcmd.go 项目: sqp/godock
func main() {
	path, isTest := vdata.TestPathDefault()

	// path := cdglobal.ConfigDirDock("") + "/current_theme/cairo-dock.conf"

	// path := cdglobal.AppBuildPathFull(pathGoGmail...)

	gtk.Init(nil)

	source := vdata.New(log.NewLog(log.Logs), nil, nil)
	build := vdata.TestInit(source, path)
	if build == nil {
		return
	}
	build.BuildAll(pageswitch.New())
	if isTest {
		cfprint.Updated(build)
		build.KeyWalk(vdata.TestValues)
		cfprint.Updated(build)
	} else {
		cfprint.Default(build, true)
	}
}
示例#24
0
func main() {
	gtk.Init(nil)

	win := setup_window("Simple Example")
	box := setup_box(gtk.ORIENTATION_VERTICAL)
	win.Add(box)

	tv := setup_tview()
	set_text_in_tview(tv, "Hello there!")
	box.PackStart(tv, true, true, 0)

	btn := setup_btn("Submit", func() {
		text := get_text_from_tview(tv)
		fmt.Println(text)
	})
	box.Add(btn)

	// Recursively show all widgets contained in this window.
	win.ShowAll()

	// Begin executing the GTK main loop.  This blocks until
	// gtk.MainQuit() is run.
	gtk.Main()
}
示例#25
0
func main() {
	gtk.Init(nil)
	initIcons()

	win := setupWindow("Go Example Testreport")

	var iter1, iter2 *gtk.TreeIter

	treeView, treeStore := setupTreeView()
	win.Add(treeView)

	// Add some rows to the tree store
	iter1 = addRow(treeStore, imageOK, "Testsuite 1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-1")
	addSubRow(treeStore, iter2, imageOK, "test1-2-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-3")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-3")
	iter1 = addRow(treeStore, imageFAIL, "Testsuite 2")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-2")
	iter2 = addSubRow(treeStore, iter1, imageFAIL, "test2-3")
	addSubRow(treeStore, iter2, imageOK, "test2-3-1")
	addSubRow(treeStore, iter2, imageFAIL, "test2-3-2")

	selection, err := treeView.GetSelection()
	if err != nil {
		log.Fatal("Could not get tree selection object.")
	}
	selection.SetMode(gtk.SELECTION_SINGLE)
	selection.Connect("changed", treeSelectionChangedCB)

	win.ShowAll()
	gtk.Main()
}
示例#26
0
func InitGTK() {
	gtk.Init(nil)
}
示例#27
0
文件: grid.go 项目: adrien3d/gobox
func main() {
	gtk.Init(nil)

	win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if err != nil {
		log.Fatal("Unable to create window:", err)
	}
	win.SetTitle("Grid Example")
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})

	// Create a new grid widget to arrange child widgets
	grid, err := gtk.GridNew()
	if err != nil {
		log.Fatal("Unable to create grid:", err)
	}

	// gtk.Grid embeds an Orientable struct to simulate the GtkOrientable
	// GInterface.  Set the orientation from the default horizontal to
	// vertical.
	grid.SetOrientation(gtk.ORIENTATION_VERTICAL)

	// Create some widgets to put in the grid.
	lab, err := gtk.LabelNew("Just a label")
	if err != nil {
		log.Fatal("Unable to create label:", err)
	}

	btn, err := gtk.ButtonNewWithLabel("Button with label")
	if err != nil {
		log.Fatal("Unable to create button:", err)
	}

	entry, err := gtk.EntryNew()
	if err != nil {
		log.Fatal("Unable to create entry:", err)
	}

	spnBtn, err := gtk.SpinButtonNewWithRange(0.0, 1.0, 0.001)
	if err != nil {
		log.Fatal("Unable to create spin button:", err)
	}

	nb, err := gtk.NotebookNew()
	if err != nil {
		log.Fatal("Unable to create notebook:", err)
	}

	// Calling (*gtk.Container).Add() with a gtk.Grid will add widgets next
	// to each other, in the order they were added, to the right side of the
	// last added widget when the grid is in a horizontal orientation, and
	// at the bottom of the last added widget if the grid is in a vertial
	// orientation.  Using a grid in this manner works similar to a gtk.Box,
	// but unlike gtk.Box, a gtk.Grid will respect its child widget's expand
	// and margin properties.
	grid.Add(btn)
	grid.Add(lab)
	grid.Add(entry)
	grid.Add(spnBtn)

	// Widgets may also be added by calling (*gtk.Grid).Attach() to specify
	// where to place the widget in the grid, and optionally how many rows
	// and columns to span over.
	//
	// Additional rows and columns are automatically added to the grid as
	// necessary when new widgets are added with (*gtk.Container).Add(), or,
	// as shown in this case, using (*gtk.Grid).Attach().
	//
	// In this case, a notebook is added beside the widgets inserted above.
	// The notebook widget is inserted with a left position of 1, a top
	// position of 1 (starting at the same vertical position as the button),
	// a width of 1 column, and a height of 2 rows (spanning down to the
	// same vertical position as the entry).
	//
	// This example also demonstrates how not every area of the grid must
	// contain a widget.  In particular, the area to the right of the label
	// and the right of spin button have contain no widgets.
	grid.Attach(nb, 1, 1, 1, 2)
	nb.SetHExpand(true)
	nb.SetVExpand(true)

	// Add a child widget and tab label to the notebook so it renders.
	nbChild, err := gtk.LabelNew("Notebook content")
	if err != nil {
		log.Fatal("Unable to create button:", err)
	}
	nbTab, err := gtk.LabelNew("Tab label")
	if err != nil {
		log.Fatal("Unable to create label:", err)
	}
	nb.AppendPage(nbChild, nbTab)

	// Add the grid to the window, and show all widgets.
	win.Add(grid)
	win.ShowAll()

	gtk.Main()
}
示例#28
0
func init() {
	gtk.Init(nil)
}
示例#29
0
文件: gtk3.go 项目: adrien3d/gobox
func main() {
	gtk.Init(nil)

	win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if err != nil {
		log.Fatal("Impossible de créer la fenêtre :", err)
	}
	win.SetTitle("GoBox a0.1")
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})

	grid, err := gtk.GridNew()
	if err != nil {
		log.Fatal("Impossible de créer la grille :", err)
	}

	label1, err := gtk.LabelNew("Adresse IP / Port : ")
	if err != nil {
		log.Fatal("Impossible de créer le label IP :", err)
	}

	label3, err := gtk.LabelNew("Dossier à synchroniser : ")
	if err != nil {
		log.Fatal("Impossible de créer le label Dossier :", err)
	}

	entry1, err := gtk.EntryNew()
	if err != nil {
		log.Fatal("Impossible de créer le champ IP :", err)
	}
	entry2, err := gtk.EntryNew()
	if err != nil {
		log.Fatal("Impossible de créer le champ Port :", err)
	}
	entry3, err := gtk.EntryNew()
	if err != nil {
		log.Fatal("Impossible de créer le champ Dossier :", err)
	}

	btn, err := gtk.ButtonNewWithLabel("Lancer la synchronisation")
	if err != nil {
		log.Fatal("Impossible de créer le bouton synchronisation :", err)
	}

	/*btn2, err := gtk.FileChooserButtonNew("Choix")
	  if err != nil {
	      log.Fatal("Impossible de créer le bouton choix :", err)
	  }*/

	grid.SetOrientation(gtk.ORIENTATION_HORIZONTAL)
	//Attach(child IWidget, left, top, width, height int)
	grid.Add(label1)
	grid.SetOrientation(gtk.ORIENTATION_HORIZONTAL)
	grid.Add(entry1)
	grid.Add(entry2)

	grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
	grid.Add(label3)
	grid.Add(entry3)

	grid.Attach(btn, 1, 2, 1, 2)

	btn.Connect("clicked", func() {
		/*dialog, _ := gtk.DialogNew()

		  filechooser, _ := gtk.FileChooserWidgetNew(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
		  dialog.AddButton("Valider", gtk.RESPONSE_ACCEPT)
		  dialog.AddButton("Annuler", gtk.RESPONSE_CANCEL)
		  dialog.SetTitle("Choisir le dossier a synchroniser")
		  box, _ := dialog.GetContentArea()
		  box.Add(filechooser)
		  box.ShowAll()
		  log.Print("Clic lancer synchro")*/
		filechooserdialog, _ := gtk.FileChooserDialogNewWith1Button(
			"Choisissez un fichier ...",
			//btn.GetTopLevelAsWindow(),
			win,
			gtk.FILE_CHOOSER_ACTION_OPEN,
			"Valider",
			gtk.RESPONSE_ACCEPT)
		/*filter := gtk.NewFileFilter()
		  filter.AddPattern("*.go")
		  filechooserdialog.AddFilter(filter)*/
		filechooserdialog.Response(func() {
			println(filechooserdialog.GetFilename())
			filechooserdialog.Destroy()
		})
		filechooserdialog.Run()
	})
	/*
	   nbChildAll, err := gtk.LabelNew("Tous mes fichiers sont ici")
	   if err != nil {
	       log.Fatal("Unable to create button:", err)
	   }
	   nbTabAll, err := gtk.LabelNew("Tout")
	   if err != nil {
	       log.Fatal("Unable to create label:", err)
	   }

	   nbChildMusic, err := gtk.LabelNew("Toute ma musique est ici")
	   if err != nil {
	       log.Fatal("Unable to create button:", err)
	   }
	   nbTabMusic, err := gtk.LabelNew("Musique")
	   if err != nil {
	       log.Fatal("Unable to create label:", err)
	   }

	   nbChildPhotos, err := gtk.LabelNew("Toutes mes photos sont ici")
	   if err != nil {
	       log.Fatal("Unable to create button:", err)
	   }
	   nbTabPhotos, err := gtk.LabelNew("Photos")
	   if err != nil {
	       log.Fatal("Unable to create label:", err)
	   }

	   nbChildVideos, err := gtk.LabelNew("Toutes mes vidéos sont ici")
	   if err != nil {
	       log.Fatal("Unable to create button:", err)
	   }
	   nbTabVideos, err := gtk.LabelNew("Vidéos")
	   if err != nil {
	       log.Fatal("Unable to create label:", err)
	   }
	   nb.AppendPage(nbChildAll, nbTabAll)
	   nb.AppendPage(nbChildMusic, nbTabMusic)
	   nb.AppendPage(nbChildPhotos, nbTabPhotos)
	   nb.AppendPage(nbChildVideos, nbTabVideos)*/

	win.Add(grid)
	win.SetDefaultSize(200, 250)
	win.ShowAll()

	gtk.Main()
}
示例#30
0
func main() {
	gtk.Init(nil)
	uiSetup()
	gtk.Main()
}