Exemple #1
0
// NewWindow creates a new config window with its widget, ready to use.
//
func NewWindow(data datatype.Source, log cdtype.Logger) (*GuiConfigure, error) {
	win, e := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if e != nil {
		return nil, e
	}
	win.SetDefaultSize(WindowWidth, WindowHeight)
	win.SetTitle(WindowTitle)
	win.SetWMClass(WindowClass, WindowTitle)

	win.SetIconFromFile(data.AppIcon())

	widget := NewWidget(data, log)
	widget.SetWindow(win)

	win.Add(widget)
	win.ShowAll()

	return widget, nil
}
Exemple #2
0
// Widget creates a desktop class informations widget.
//
func Widget(source datatype.Source, selected datatype.DesktopClasser, origins string) gtk.IWidget {
	apps := strings.Split(origins, ";")
	if len(apps) == 0 {
		return nil
	}

	// Remove the path from the first item.
	dir := filepath.Dir(apps[0])
	apps[0] = filepath.Base(apps[0])

	// Try force select the first one (can be inactive if "do not bind appli").
	if selected.String() == "" {
		selected = source.DesktopClasser(strings.TrimSuffix(apps[0], ".desktop"))
	}

	command := selected.Command()
	desktopFile := desktopFileText(apps, dir, selected.String())

	wName := boxLabel(selected.Name())
	wIcon := boxLabel(selected.Icon())
	wCommand := boxButton(command, func() { println("need to launch", command) })
	wDesktopFiles := boxLabel(desktopFile)

	grid := newgtk.Grid()
	grid.Attach(boxLabel("Name"), 0, 0, 1, 1)
	grid.Attach(boxLabel("Icon"), 0, 1, 1, 1)
	grid.Attach(boxLabel("Command"), 0, 2, 1, 1)
	grid.Attach(boxLabel("Desktop file"), 0, 3, 1, 1)
	grid.Attach(wName, 1, 0, 1, 1)
	grid.Attach(wIcon, 1, 1, 1, 1)
	grid.Attach(wCommand, 1, 2, 1, 1)
	grid.Attach(wDesktopFiles, 1, 3, 1, 1)

	frame := newgtk.Frame("")
	label := newgtk.Label(common.Bold("Launcher origin"))
	label.SetUseMarkup(true)
	frame.SetLabelWidget(label)
	frame.Add(grid)
	frame.ShowAll()
	return frame
}