Пример #1
0
// New creates an applet preview widget.
//
func New(log cdtype.Logger) *Preview {
	builder := buildhelp.New()
	builder.AddFromString(string(appletpreviewXML()))
	// builder.AddFromFile("appletpreview.xml")

	widget := &Preview{
		Box:          *builder.GetBox("widget"),
		title:        builder.GetLabel("title"),
		author:       builder.GetLabel("author"),
		size:         builder.GetLabel("size"),
		stateText:    builder.GetLabel("stateText"),
		stateIcon:    builder.GetImage("stateIcon"),
		description:  builder.GetLabel("description"),
		previewFrame: builder.GetFrame("previewFrame"),
		previewImage: builder.GetImage("previewImage"),
		log:          log,
	}

	if len(builder.Errors) > 0 {
		for _, e := range builder.Errors {
			log.Err(e, "build appletpreview")
		}
		return nil
	}

	widget.Connect("destroy", widget.RemoveTmpFile)

	return widget
}
Пример #2
0
// NewList creates a new applets list widget.
//
func NewList(control ControlDownload, log cdtype.Logger) *List {
	builder := buildhelp.New()

	builder.AddFromString(string(appletlistXML()))
	// builder.AddFromFile("appletlist.xml")

	widget := &List{
		ScrolledWindow: *builder.GetScrolledWindow("widget"),
		model:          builder.GetListStore("model"),
		tree:           builder.GetTreeView("tree"),
		columnCategory: builder.GetTreeViewColumn("columnCategory"),
		control:        control,
		log:            log,
		rows:           make(map[string]*Row),
	}

	columnName := builder.GetTreeViewColumn("columnName")

	if len(builder.Errors) > 0 {
		for _, e := range builder.Errors {
			log.Err(e, "build appletlist")
		}
		return nil
	}

	control.SetControlInstall(widget)

	// Double click launch add action.
	widget.tree.Connect("button-press-event", func(tree *gtk.TreeView, ev *gdk.Event) {
		btn := &gdk.EventButton{Event: ev}
		if btn.Button() == 1 && btn.Type() == gdk.EVENT_2BUTTON_PRESS {
			control.Save()
		}
	})

	// Action: Treeview Select line.
	if sel, e := widget.tree.GetSelection(); !log.Err(e, "appletlist TreeView.GetSelection") {
		sel.Connect("changed", widget.onSelectionChanged) // Changed is connected to TreeSelection
	}

	// Sort applets by name.
	columnName.Emit("clicked")

	return widget
}
Пример #3
0
// New creates a handbook widget (applet info).
//
func New(log cdtype.Logger) *Handbook {
	builder := buildhelp.New()

	builder.AddFromString(string(handbookXML()))
	// builder.AddFromFile("handbook.xml")

	widget := &Handbook{
		Frame:        *builder.GetFrame("handbook"),
		title:        builder.GetLabel("title"),
		author:       builder.GetLabel("author"),
		description:  builder.GetLabel("description"),
		previewFrame: builder.GetFrame("previewFrame"),
		previewImage: builder.GetImage("previewImage"),
	}

	if len(builder.Errors) > 0 {
		for _, e := range builder.Errors {
			log.Err(e, "build handbook")
		}
		return nil
	}

	return widget
}