示例#1
0
文件: confapplets.go 项目: sqp/godock
// NewMenuDownload creates the menu to control the selected applet.
//
func NewMenuDownload(log cdtype.Logger) *MenuDownload {
	widget := &MenuDownload{
		Box:       *newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0),
		installed: newgtk.Switch(),
		active:    newgtk.Switch(),
		log:       log,
	}

	// Actions
	var e error
	widget.handlerInstalled, e = widget.installed.Connect("notify::active", widget.toggledInstalled)
	log.Err(e, "Connect installed button callback")
	widget.handlerActive, e = widget.active.Connect("notify::active", widget.toggledActive)
	log.Err(e, "Connect active button callback")

	widget.PackStart(newgtk.Label("Installed"), false, false, 4)
	widget.PackStart(widget.installed, false, false, 0)
	widget.PackStart(newgtk.Box(gtk.ORIENTATION_VERTICAL, 0), false, false, 8)
	widget.PackStart(newgtk.Label("Active"), false, false, 4)
	widget.PackStart(widget.active, false, false, 0)
	return widget
}
示例#2
0
文件: widgets.go 项目: sqp/godock
// CheckButton adds a check button widget.
//
func CheckButton(key *cftype.Key) {
	if key.NbElements > 1 { // TODO: remove temp test
		key.Log().Info("CheckButton multi", key.NbElements, key.Type.String())
	}

	values := key.Value().ListBool()

	var activers []widgetActiver

	for k := 0; k < key.NbElements; k++ {
		var value bool
		if k < len(values) {
			value = values[k]
		}
		w := newgtk.Switch()
		w.SetActive(value)
		key.PackSubWidget(w)
		activers = append(activers, w)

		if key.IsType(cftype.KeyBoolCtrl) {
			// 		_allocate_new_buffer;
			// 		data[0] = pKeyBox;
			// 		data[1] = (pFrameVBox != NULL ? pFrameVBox : pGroupBox);
			// 		if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[0] != NULL)
			// 			NbControlled = g_ascii_strtod (pAuthorizedValuesList[0], NULL);
			// 		else
			// 			NbControlled = 1;
			// 		data[2] = GINT_TO_POINTER (NbControlled);
			// 		if (NbControlled < 0)  // a negative value means that the behavior is inverted.
			// 		{
			// 			bValue = !bValue;
			// 			NbControlled = -NbControlled;
			// 		}
			// 		g_signal_connect (G_OBJECT (pOneWidget), "toggled", G_CALLBACK(_cairo_dock_toggle_control_button), data);

			// 		g_object_set_data (G_OBJECT (pKeyBox), "nb-ctrl-widgets", GINT_TO_POINTER (NbControlled));
			// 		g_object_set_data (G_OBJECT (pKeyBox), "one-widget", pOneWidget);

			// 		if (! bValue)  // les widgets suivants seront inactifs.
			// 		{
			// 			CDControlWidget *cw = g_new0 (CDControlWidget, 1);
			// 			pControlWidgets = g_list_prepend (pControlWidgets, cw);
			// 			cw->iNbSensitiveWidgets = 0;
			// 			cw->NbControlled = NbControlled;
			// 			cw->iFirstSensitiveWidget = 1;
			// 			cw->pControlContainer = (pFrameVBox != NULL ? pFrameVBox : pGroupBox);
			// 		}  // sinon le widget suivant est sensitif, donc rien a faire.
		}
	}
	if key.NbElements == 1 {
		key.PackKeyWidget(key,
			func() interface{} { return activers[0].GetActive() },
			func(uncast interface{}) { activers[0].SetActive(uncast.(bool)) },
		)
	} else {
		key.PackKeyWidget(key,
			func() interface{} { return listActiverGet(activers) },
			func(uncast interface{}) { listActiverSet(activers, uncast.([]bool)) },
		)
	}
}