From 9e9bb82025e24619dcb4e4ed7976dfd851fdc8f0 Mon Sep 17 00:00:00 2001 From: Belac Darkstorm Date: Fri, 14 Apr 2017 01:56:36 -0500 Subject: [PATCH] Moved "Show windows apps" to settings Added "Hide Portable from app names" --- appimg/download.go | 2 +- {gxui => gxui (legacy)}/main.go | 0 {gxui => gxui (legacy)}/setup.go | 0 {gxui => gxui (legacy)}/strList.go | 0 {gxui => gxui (legacy)}/ui.go | 0 main.go | 17 +++++++++------ settings.go | 35 ++++++++++++++++++++++++++---- setup.go | 3 +++ ui.go | 35 +++++++++++------------------- 9 files changed, 58 insertions(+), 34 deletions(-) rename {gxui => gxui (legacy)}/main.go (100%) rename {gxui => gxui (legacy)}/setup.go (100%) rename {gxui => gxui (legacy)}/strList.go (100%) rename {gxui => gxui (legacy)}/ui.go (100%) diff --git a/appimg/download.go b/appimg/download.go index efcd20c..1d87c33 100644 --- a/appimg/download.go +++ b/appimg/download.go @@ -52,7 +52,7 @@ func downloadApp(parent *gtk.Window, ap appimg) { } else if _, err = os.Open("PortableApps/" + name); err == nil { foldName = "PortableApps/" + name } else { - os.Mkdir("PortableApps/"+name, 0777) + os.Mkdir("PortableApps/"+name+"Portable", 0777) foldName = "PortableApps/" + name } fil, err := os.Create(foldName + "/" + ap.name) diff --git a/gxui/main.go b/gxui (legacy)/main.go similarity index 100% rename from gxui/main.go rename to gxui (legacy)/main.go diff --git a/gxui/setup.go b/gxui (legacy)/setup.go similarity index 100% rename from gxui/setup.go rename to gxui (legacy)/setup.go diff --git a/gxui/strList.go b/gxui (legacy)/strList.go similarity index 100% rename from gxui/strList.go rename to gxui (legacy)/strList.go diff --git a/gxui/ui.go b/gxui (legacy)/ui.go similarity index 100% rename from gxui/ui.go rename to gxui (legacy)/ui.go diff --git a/main.go b/main.go index d9eaea2..e24a3e3 100644 --- a/main.go +++ b/main.go @@ -14,13 +14,14 @@ const ( ) var ( - master map[string][]app - linmaster map[string][]app - cats []string - lin []string - wine bool - comEnbld bool - wineAvail bool + master map[string][]app + linmaster map[string][]app + cats []string + lin []string + wine bool + comEnbld bool + wineAvail bool + portableHide bool ) func main() { @@ -61,6 +62,7 @@ func savePrefs() { } enc := gob.NewEncoder(fil) enc.Encode(wine) + enc.Encode(portableHide) } func loadPrefs() { @@ -70,6 +72,7 @@ func loadPrefs() { } dec := gob.NewDecoder(fil) dec.Decode(&wine) + dec.Decode(&portableHide) } func contains(arr []string, str string) bool { diff --git a/settings.go b/settings.go index ffa2be4..d248a2f 100644 --- a/settings.go +++ b/settings.go @@ -7,10 +7,16 @@ import ( "github.com/gotk3/gotk3/gtk" ) -func settingsUI() { +func settingsUI(parent *gtk.Window, onExit func()) { win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL) + win.SetTransientFor(parent) + parent.SetSensitive(false) win.SetDefaultSize(600, 300) - win.SetPosition(gtk.WIN_POS_CENTER) + win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT) + win.Connect("destroy", func() { + parent.SetSensitive(true) + onExit() + }) comTagTbl, _ := gtk.TextTagTableNew() comBuf, _ := gtk.TextBufferNew(comTagTbl) ntbk, _ := gtk.NotebookNew() @@ -21,7 +27,6 @@ func settingsUI() { gnrl.SetMarginBottom(10) dlWine, _ := gtk.ButtonNewWithLabel("Download Wine") wineLbl, _ := gtk.LabelNew("PortableApps/LinuxPACom/Wine present") - gnrl.Add(wineLbl) dlWine.Connect("clicked", func() { cb := make(chan bool) downloadWine(win, cb) @@ -37,7 +42,29 @@ func settingsUI() { dlWine.SetSensitive(false) dlWine.SetTooltipText("common.sh needed") } + pthdCheck, _ := gtk.CheckButtonNewWithLabel("Hide \"Portable\" from app name") + pthdCheck.Connect("toggled", func() { + portableHide = pthdCheck.GetActive() + master = make(map[string][]app) + linmaster = make(map[string][]app) + cats = make([]string, 0) + lin = make([]string, 0) + setup() + }) + wineCheck, _ := gtk.CheckButtonNewWithLabel("Show Windows apps (Wine)") + if !wineAvail { + wineCheck.SetSensitive(false) + wineCheck.SetTooltipText("Download wine to run windows apps") + } + wineCheck.SetActive(wine) + wineCheck.Connect("toggled", func() { + wine = wineCheck.GetActive() + }) + pthdCheck.SetActive(portableHide) + gnrl.Add(wineLbl) gnrl.Add(dlWine) + gnrl.Add(pthdCheck) + gnrl.Add(wineCheck) ntbk.AppendPage(gnrl, getLabel("General")) com, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5) com.SetMarginStart(10) @@ -51,7 +78,6 @@ func settingsUI() { hScroll, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0) comScrl, _ := gtk.ScrolledWindowNew(hScroll, vScroll) comScrl.Add(comEdit) - com.Add(comScrl) svBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5) sv, _ := gtk.ButtonNewWithLabel("Save") sv.Connect("clicked", func() { @@ -65,6 +91,7 @@ func settingsUI() { }) svBox.Add(sv) svBox.Add(cnl) + com.Add(comScrl) com.Add(svBox) ntbk.AppendPage(com, getLabel("common.sh")) win.Add(ntbk) diff --git a/setup.go b/setup.go index ff4efbc..f4114de 100644 --- a/setup.go +++ b/setup.go @@ -82,6 +82,9 @@ func processApp(fold string) (out app) { if out.cat == "" { out.cat = "Other" } + if portableHide { + out.name = strings.TrimSuffix(out.name, "Portable") + } out.icon = getIcon(fold) folder, _ := os.Open(fold) fis, _ := folder.Readdirnames(-1) diff --git a/ui.go b/ui.go index 61dc453..1b8882c 100644 --- a/ui.go +++ b/ui.go @@ -14,9 +14,6 @@ func ui(win *gtk.Window) { header.SetTitle("LinuxPA") header.SetSubtitle("PortableApps.com type launcher") settings, _ := gtk.ButtonNewFromIconName("applications-system", gtk.ICON_SIZE_SMALL_TOOLBAR) - settings.Connect("clicked", func() { - settingsUI() - }) settings.SetTooltipText("Settings") dnl, _ := gtk.ButtonNewFromIconName("emblem-downloads", gtk.ICON_SIZE_SMALL_TOOLBAR) dnl.SetTooltipText("Download Apps") @@ -57,24 +54,6 @@ func ui(win *gtk.Window) { botBox.SetMarginEnd(10) botBox.SetMarginTop(10) botBox.SetMarginBottom(10) - wineCheck, _ := gtk.CheckButtonNewWithLabel("Show Windows apps (Wine)") - if !wineAvail { - wineCheck.SetSensitive(false) - wineCheck.SetTooltipText("Download wine to run windows apps") - } - wineCheck.SetActive(wine) - wineCheck.Connect("toggled", func() { - wine = wineCheck.GetActive() - store.Clear() - for i := range ls { - catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1)) - } - ls = getCatRows() - for _, v := range ls { - catList.Add(v) - } - catList.ShowAll() - }) edit, _ := gtk.ButtonNewWithLabel("Edit App..") edit.Connect("clicked", func() { selec, _ := appsList.GetSelection() @@ -111,7 +90,6 @@ func ui(win *gtk.Window) { } } }) - botBox.Add(wineCheck) botBox.PackEnd(edit, false, false, 0) topLvl.Add(lrBox) topLvl.PackEnd(botBox, false, true, 0) @@ -179,6 +157,19 @@ func ui(win *gtk.Window) { catList.ShowAll() }) }) + settings.Connect("clicked", func() { + settingsUI(win, func() { + store.Clear() + for i := range ls { + catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1)) + } + ls = getCatRows() + for i, v := range ls { + catList.Insert(v, i) + } + catList.ShowAll() + }) + }) } func getCatRows() (out []*gtk.Label) {