Exemple #1
0
// addBoxItem adds an item to the list.
//
func (widget *List) addBoxItem(icon datatype.Iconer, indent int, bold bool) *gtk.ListBoxRow {
	row := newgtk.ListBoxRow()
	box := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0)
	row.Add(box)

	name, img := icon.DefaultNameIcon()

	box.Set("margin-start", 15*indent)
	if bold {
		name = common.Bold(name)
	}
	if img != "" {
		if pix, e := common.ImageNewFromFile(img, iconSize); !widget.log.Err(e, "Load icon") {
			box.PackStart(pix, false, false, 0)
		}
	}
	lbl := newgtk.Label(name)
	lbl.SetUseMarkup(true)
	box.PackStart(lbl, false, false, 0)

	widget.list.Add(row)
	widget.index[row] = icon

	return row
}
Exemple #2
0
// AddButton adds a button to the entry.
//
func (o *ButtonsEntry) AddButton(tooltip, img string, call interface{}) *gtk.Button {
	btn := newgtk.Button()
	btn.SetTooltipText(tooltip)
	btn.Connect("clicked", call)
	o.box.PackEnd(btn, false, false, 0)

	if img != "" {

		// 		if (*gtkStock == '/')
		// 			int size = cairo_dock_search_icon_size (GTK_ICON_SIZE_MENU);

		image, e := common.ImageNewFromFile(img, 12) // TODO: icon size
		if e == nil {
			btn.SetImage(image)
		}
		o.img = append(o.img, image)
	} else {
		o.img = append(o.img, nil)
	}

	o.list = append(o.list, btn)
	return btn
}
Exemple #3
0
// Frame adds a simple or expanded frame widget.
//
func Frame(key *cftype.Key) {
	if len(key.AuthorizedValues) == 0 {
		key.SetFrame(nil)
		key.SetFrameBox(nil)
		return
	}

	value, img := "", ""
	if key.AuthorizedValues[0] == "" {
		key.Log().Info("WidgetFrame, need value case 1")
		// value = g_key_file_get_string(pKeyFile, cGroupName, cKeyName, NULL) // utile ?
	} else {
		value = key.AuthorizedValues[0]
		if len(key.AuthorizedValues) > 1 {
			img = key.AuthorizedValues[1]
		}
	}

	// Create the frame label with the optional icon.
	label := newgtk.Label("")
	// key.SetLabel(label)
	label.SetMarkup(" " + common.Bold(key.Translate(value)) + " ")

	var labelContainer gtk.IWidget
	if img == "" {
		labelContainer = label
	} else {
		box := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, cftype.MarginIcon/2)
		if icon, e := common.ImageNewFromFile(img, iconSizeFrame); !key.Log().Err(e, "Frame icon") { // TODO: fix size : int(gtk.ICON_SIZE_MENU)
			box.Add(icon)
		}
		box.Add(label)
		labelContainer = box
	}

	// Create the box that will contain next widgets (inside the frame).
	box := newgtk.Box(gtk.ORIENTATION_VERTICAL, cftype.MarginGUI)
	key.SetFrameBox(box)

	frame := newgtk.Frame("")
	key.SetFrame(frame)
	frame.SetBorderWidth(cftype.MarginGUI)
	frame.SetShadowType(gtk.SHADOW_OUT)
	frame.Add(box)

	// Set label and create the expander around the frame if needed.
	switch key.Type {
	case cftype.KeyFrame:
		frame.SetLabelWidget(labelContainer)
		key.BoxPage().PackStart(frame, false, false, 0)

	case cftype.KeyExpander:
		expand := newgtk.Expander("")
		expand.SetExpanded(false)
		expand.SetLabelWidget(labelContainer)

		expand.Add(frame)
		key.BoxPage().PackStart(expand, false, false, 0)
	}

	// SAME AS IN builder.go

	// 	if (pControlWidgets != NULL)
	// 	{
	// 		cd_debug ("ctrl\n");
	// 		CDControlWidget *cw = pControlWidgets->data;
	// 		if (cw->pControlContainer == key.Box)
	// 		{
	// 			cd_debug ("ctrl (NbControlled:%d, iFirstSensitiveWidget:%d, iNbSensitiveWidgets:%d)", cw->NbControlled, cw->iFirstSensitiveWidget, cw->iNbSensitiveWidgets);
	// 			cw->NbControlled --;
	// 			if (cw->iFirstSensitiveWidget > 0)
	// 				cw->iFirstSensitiveWidget --;
	// 			cw->iNonSensitiveWidget --;

	// 			GtkWidget *w = pExternFrame;
	// 			if (cw->iFirstSensitiveWidget == 0 && cw->iNbSensitiveWidgets > 0 && cw->iNonSensitiveWidget != 0)
	// 			{
	// 				cd_debug (" => sensitive\n");
	// 				cw->iNbSensitiveWidgets --;
	// 				if (GTK_IS_EXPANDER (w))
	// 					gtk_expander_set_expanded (GTK_EXPANDER (w), TRUE);
	// 			}
	// 			else
	// 			{
	// 				cd_debug (" => unsensitive\n");
	// 				if (!GTK_IS_EXPANDER (w))
	// 					gtk_widget_set_sensitive (w, FALSE);
	// 			}
	// 			if (cw->iFirstSensitiveWidget == 0 && cw->NbControlled == 0)
	// 			{
	// 				pControlWidgets = g_list_delete_link (pControlWidgets, pControlWidgets);
	// 				g_free (cw);
	// 			}
	// 		}
	// 	}
}