Exemple #1
0
func (ui *Ui) initDeviceView() *gtk.Box {
	vbox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
	ui.deviceBox = vbox

	hbox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
	vbox.PackStart(hbox, false, true, 20)

	img, _ := gtk.ImageNew()
	hbox.PackStart(img, false, true, 0)
	ui.deviceIcon = img

	nameBox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
	hbox.PackStart(nameBox, true, true, 0)

	l, _ := gtk.LabelNew("")
	l.Set("xalign", 0)
	nameBox.PackStart(l, true, true, 0)
	ui.deviceNameLabel = l

	l, _ = gtk.LabelNew("")
	l.Set("xalign", 0)
	nameBox.PackStart(l, true, true, 0)
	ui.deviceStatusLabel = l

	browseBtn, _ := gtk.ButtonNewFromIconName("document-open-symbolic", gtk.ICON_SIZE_BUTTON)
	hbox.PackStart(browseBtn, false, false, 0)
	ui.browseBtn = browseBtn

	browseBtn.Connect("clicked", func() {
		log.Println("Browse device", ui.selectedDevice)
		ui.plugins.Sftp.SendStartBrowsing(ui.selectedDevice)
	})

	pairBtn, _ := gtk.ButtonNew()
	hbox.PackStart(pairBtn, false, false, 5)
	ui.pairBtn = pairBtn

	pairBtn.Connect("clicked", func() {
		log.Println("Pair/unpair device", ui.selectedDevice)

		if ui.selectedDevice.Paired {
			ui.engine.UnpairDevice(ui.selectedDevice)
		} else {
			ui.engine.PairDevice(ui.selectedDevice)
		}
	})

	return vbox
}
Exemple #2
0
func (ui *Ui) init() {
	win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	win.SetTitle("GNOMEConnect")
	win.SetDefaultSize(800, 600)
	win.Connect("destroy", func() {
		gtk.MainQuit()
		ui.Quit <- true
	})
	ui.win = win

	hbox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
	win.Add(hbox)

	scroller := ui.initDevicesList()
	hbox.PackStart(scroller, false, true, 0)

	sep, _ := gtk.SeparatorNew(gtk.ORIENTATION_HORIZONTAL)
	hbox.PackStart(sep, false, true, 0)

	box := ui.initDeviceView()
	hbox.PackEnd(box, true, true, 0)

	titlebar := ui.initTitlebar()
	win.SetTitlebar(titlebar)

	win.ShowAll()
	ui.selectDevice(nil)
}
Exemple #3
0
func setup_box(orient gtk.Orientation) *gtk.Box {
	box, err := gtk.BoxNew(orient, 0)
	if err != nil {
		log.Fatal("Unable to create box:", err)
	}
	return box
}
Exemple #4
0
func setupPropertyCheckboxes(tv *gtk.TextView, outer *gtk.Box, props []*BoolProperty) {
	box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
	for _, prop := range props {
		chk, _ := gtk.CheckButtonNewWithLabel(prop.Name)
		// initialize the checkbox with the property's current value
		chk.SetActive(prop.Get())
		p := prop // w/o this all the checkboxes will toggle the last property in props
		chk.Connect("toggled", func() {
			p.Set(chk.GetActive())
		})
		box.PackStart(chk, true, true, 0)
	}
	outer.PackStart(box, false, false, 0)
}
Exemple #5
0
func (ui *Ui) initTitlebar() *gtk.Box {
	hbox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)

	headerbar, _ := gtk.HeaderBarNew()
	headerbar.SetTitle("Devices")
	headerbar.SetSizeRequest(sidebarWidth, -1)
	hbox.PackStart(headerbar, false, true, 0)

	sep, _ := gtk.SeparatorNew(gtk.ORIENTATION_HORIZONTAL)
	hbox.PackStart(sep, false, true, 0)

	headerbar, _ = gtk.HeaderBarNew()
	headerbar.SetTitle("GNOMEConnect")
	headerbar.SetShowCloseButton(true)
	hbox.PackEnd(headerbar, true, true, 0)

	return hbox
}
Exemple #6
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()
}