// 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 }
// 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); // } // } // } }