get rid of the leftbox
This commit is contained in:
BIN
bin/nwg-drawer
BIN
bin/nwg-drawer
Binary file not shown.
27
main.go
27
main.go
@@ -26,7 +26,6 @@ var (
|
||||
configDirectory string
|
||||
pinnedFile string
|
||||
pinned []string
|
||||
leftBox *gtk.Box
|
||||
rightBox *gtk.Box
|
||||
src glib.SourceHandle
|
||||
imgSizeScaled int
|
||||
@@ -293,27 +292,6 @@ func main() {
|
||||
alignmentBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||
outerBox.PackStart(alignmentBox, true, true, 0)
|
||||
|
||||
leftBox, _ = gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||
alignmentBox.PackStart(leftBox, false, false, 10)
|
||||
|
||||
leftColumn, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
leftBox.PackStart(leftColumn, false, false, 0)
|
||||
|
||||
pinnedListBox = setUpPinnedListBox()
|
||||
leftColumn.PackStart(pinnedListBox, false, false, 10)
|
||||
|
||||
categoriesListBox = setUpCategoriesListBox()
|
||||
leftColumn.PackStart(categoriesListBox, false, false, 10)
|
||||
|
||||
userDirsListBox = setUpUserDirsList()
|
||||
leftColumn.PackStart(userDirsListBox, false, true, 10)
|
||||
|
||||
buttonsWrapper, _ = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
|
||||
buttonBox = setUpButtonBox()
|
||||
buttonsWrapper.PackStart(buttonBox, false, false, 10)
|
||||
leftColumn.PackEnd(buttonsWrapper, false, true, 0)
|
||||
|
||||
rightBox, _ = gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||
alignmentBox.PackStart(rightBox, true, true, 10)
|
||||
|
||||
@@ -351,14 +329,9 @@ func main() {
|
||||
resultWindow.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
|
||||
resultWindow.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
resultWrapper.PackStart(resultWindow, true, true, 0)
|
||||
|
||||
/*pinnedFlowBoxWrapper, _ = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
resultWindow.Add(pinnedFlowBoxWrapper)
|
||||
pinnedFlowBox = setUpPinnedFlowBox()*/
|
||||
|
||||
appFlowBoxWrapper, _ = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
resultWindow.Add(appFlowBoxWrapper)
|
||||
appFlowBox = setUpAppsFlowBox(nil, "")
|
||||
|
||||
4
tools.go
4
tools.go
@@ -525,10 +525,6 @@ func pinItem(itemID string) {
|
||||
pinned = append(pinned, itemID)
|
||||
savePinned()
|
||||
println(itemID, "pinned")
|
||||
|
||||
row := setUpPinnedListBoxRow(itemID)
|
||||
pinnedListBox.Add(row)
|
||||
pinnedListBox.ShowAll()
|
||||
}
|
||||
|
||||
func unpinItem(itemID string) {
|
||||
|
||||
347
uicomponents.go
347
uicomponents.go
@@ -10,78 +10,6 @@ import (
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
)
|
||||
|
||||
func setUpPinnedListBox() *gtk.ListBox {
|
||||
listBox, _ := gtk.ListBoxNew()
|
||||
|
||||
if len(pinned) > 0 {
|
||||
for _, desktopID := range pinned {
|
||||
row := setUpPinnedListBoxRow(desktopID)
|
||||
listBox.Add(row)
|
||||
}
|
||||
}
|
||||
|
||||
listBox.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
|
||||
return listBox
|
||||
}
|
||||
|
||||
func setUpPinnedListBoxRow(desktopID string) *gtk.ListBoxRow {
|
||||
entry := id2entry[desktopID]
|
||||
|
||||
row, _ := gtk.ListBoxRowNew()
|
||||
row.SetSelectable(false)
|
||||
row.SetCanFocus(false)
|
||||
vBox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
|
||||
// We need gtk.EventBox to detect mouse event
|
||||
eventBox, _ := gtk.EventBoxNew()
|
||||
hBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 6)
|
||||
eventBox.Add(hBox)
|
||||
vBox.PackStart(eventBox, false, false, *itemPadding)
|
||||
|
||||
pixbuf, _ := createPixbuf(entry.Icon, *iconSizeLarge)
|
||||
img, err := gtk.ImageNewFromPixbuf(pixbuf)
|
||||
if err != nil {
|
||||
println(err, entry.Icon)
|
||||
}
|
||||
hBox.PackStart(img, false, false, 0)
|
||||
lbl, _ := gtk.LabelNew("")
|
||||
name := ""
|
||||
if entry.NameLoc != "" {
|
||||
name = entry.NameLoc
|
||||
} else {
|
||||
name = entry.Name
|
||||
}
|
||||
if len(name) > 35 {
|
||||
name = fmt.Sprintf("%s...", name[:32])
|
||||
}
|
||||
lbl.SetText(name)
|
||||
hBox.PackStart(lbl, false, false, 0)
|
||||
row.Add(vBox)
|
||||
|
||||
row.Connect("activate", func() {
|
||||
launch(entry.Exec, entry.Terminal)
|
||||
})
|
||||
|
||||
eventBox.Connect("button-release-event", func(row *gtk.ListBoxRow, e *gdk.Event) bool {
|
||||
btnEvent := gdk.EventButtonNewFromEvent(e)
|
||||
if btnEvent.Button() == 1 {
|
||||
launch(entry.Exec, entry.Terminal)
|
||||
return true
|
||||
} else if btnEvent.Button() == 3 {
|
||||
unpinItem(entry.DesktopID)
|
||||
row.Destroy()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
return row
|
||||
}
|
||||
|
||||
func setUpPinnedFlowBox() *gtk.FlowBox {
|
||||
if pinnedFlowBox != nil {
|
||||
pinnedFlowBox.Destroy()
|
||||
@@ -136,7 +64,6 @@ func setUpPinnedFlowBox() *gtk.FlowBox {
|
||||
|
||||
flowBox.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
|
||||
pinnedFlowBoxWrapper.PackStart(flowBox, true, true, 0)
|
||||
@@ -145,43 +72,6 @@ func setUpPinnedFlowBox() *gtk.FlowBox {
|
||||
return flowBox
|
||||
}
|
||||
|
||||
func setUpCategoriesListBox() *gtk.ListBox {
|
||||
listBox, _ := gtk.ListBoxNew()
|
||||
for _, cat := range categories {
|
||||
if isSupposedToShowUp(cat.Name) {
|
||||
row, _ := gtk.ListBoxRowNew()
|
||||
row.SetCanFocus(false)
|
||||
row.SetSelectable(false)
|
||||
vBox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
eventBox, _ := gtk.EventBoxNew()
|
||||
hBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 6)
|
||||
eventBox.Add(hBox)
|
||||
vBox.PackStart(eventBox, false, false, *itemPadding)
|
||||
|
||||
connectCategoryListBox(cat.Name, eventBox, row)
|
||||
|
||||
pixbuf, _ := createPixbuf(cat.Icon, *iconSizeLarge)
|
||||
img, _ := gtk.ImageNewFromPixbuf(pixbuf)
|
||||
hBox.PackStart(img, false, false, 0)
|
||||
|
||||
lbl, _ := gtk.LabelNew(cat.DisplayName)
|
||||
hBox.PackStart(lbl, false, false, 0)
|
||||
|
||||
pixbuf, _ = createPixbuf("pan-end-symbolic", *iconSizeSmall)
|
||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||
hBox.PackEnd(img, false, false, 0)
|
||||
|
||||
row.Add(vBox)
|
||||
listBox.Add(row)
|
||||
}
|
||||
}
|
||||
listBox.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
return listBox
|
||||
}
|
||||
|
||||
func setUpCategoriesButtonBox() *gtk.EventBox {
|
||||
lists := map[string][]string{
|
||||
"utility": listUtility,
|
||||
@@ -267,59 +157,6 @@ func notEmpty(listCategory []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func connectCategoryListBox(catName string, eventBox *gtk.EventBox, row *gtk.ListBoxRow) {
|
||||
var listCategory []string
|
||||
|
||||
switch catName {
|
||||
case "utility":
|
||||
listCategory = listUtility
|
||||
case "development":
|
||||
listCategory = listDevelopment
|
||||
case "game":
|
||||
listCategory = listGame
|
||||
case "graphics":
|
||||
listCategory = listGraphics
|
||||
case "internet-and-network":
|
||||
listCategory = listInternetAndNetwork
|
||||
case "office":
|
||||
listCategory = listOffice
|
||||
case "audio-video":
|
||||
listCategory = listAudioVideo
|
||||
case "system-tools":
|
||||
listCategory = listSystemTools
|
||||
default:
|
||||
listCategory = listOther
|
||||
}
|
||||
|
||||
eventBox.Connect("button-release-event", func(eb *gtk.EventBox, e *gdk.Event) bool {
|
||||
btnEvent := gdk.EventButtonNewFromEvent(e)
|
||||
if btnEvent.Button() == 1 {
|
||||
searchEntry.SetText("")
|
||||
clearSearchResult()
|
||||
row.SetSelectable(true)
|
||||
row.SetCanFocus(false)
|
||||
categoriesListBox.SelectRow(row)
|
||||
listBox := setUpCategoryListBox(listCategory)
|
||||
if resultWindow != nil {
|
||||
resultWindow.Destroy()
|
||||
}
|
||||
resultWindow, _ = gtk.ScrolledWindowNew(nil, nil)
|
||||
resultWindow.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
|
||||
resultWindow.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
})
|
||||
resultWrapper.PackStart(resultWindow, true, true, 0)
|
||||
resultWindow.Add(listBox)
|
||||
|
||||
userDirsListBox.Hide()
|
||||
resultWindow.ShowAll()
|
||||
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
func setUpBackButton() *gtk.Box {
|
||||
vBox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
hBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 10)
|
||||
@@ -398,7 +235,6 @@ func setUpCategorySearchResult(searchPhrase string) *gtk.ListBox {
|
||||
resultWindow.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
|
||||
resultWindow.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
resultWrapper.PackStart(resultWindow, true, true, 0)
|
||||
|
||||
@@ -529,7 +365,6 @@ func setUpFileSearchResult() *gtk.ListBox {
|
||||
fileSearchResultWindow.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
|
||||
fileSearchResultWindow.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
resultWrapper.PackStart(fileSearchResultWindow, true, true, 0)
|
||||
|
||||
@@ -557,7 +392,6 @@ func setUpSearchEntry() *gtk.SearchEntry {
|
||||
searchEntry, _ := gtk.SearchEntryNew()
|
||||
searchEntry.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
searchEntry.Connect("search-changed", func() {
|
||||
phrase, _ = searchEntry.GetText()
|
||||
@@ -614,9 +448,9 @@ func searchUserDir(dir string) {
|
||||
fileSearchResults = make(map[string]string)
|
||||
filepath.WalkDir(userDirsMap[dir], walk)
|
||||
if len(fileSearchResults) > 0 {
|
||||
row := setUpUserDirsListRow(fmt.Sprintf("folder-%s", dir), "", dir, userDirsMap)
|
||||
/*row := setUpUserDirsListRow(fmt.Sprintf("folder-%s", dir), "", dir, userDirsMap)
|
||||
fileSearchResultListBox.Add(row)
|
||||
fileSearchResultListBox.ShowAll()
|
||||
fileSearchResultListBox.ShowAll()*/
|
||||
|
||||
for _, path := range fileSearchResults {
|
||||
row := setUpUserFileSearchResultRow(path, path)
|
||||
@@ -626,73 +460,6 @@ func searchUserDir(dir string) {
|
||||
}
|
||||
}
|
||||
|
||||
func setUpUserDirsList() *gtk.ListBox {
|
||||
listBox, _ := gtk.ListBoxNew()
|
||||
userDirsMap = mapXdgUserDirs()
|
||||
|
||||
row := setUpUserDirsListRow("folder-home", "Home", "home", userDirsMap)
|
||||
listBox.Add(row)
|
||||
row = setUpUserDirsListRow("folder-documents", "", "documents", userDirsMap)
|
||||
listBox.Add(row)
|
||||
row = setUpUserDirsListRow("folder-downloads", "", "downloads", userDirsMap)
|
||||
listBox.Add(row)
|
||||
row = setUpUserDirsListRow("folder-music", "", "music", userDirsMap)
|
||||
listBox.Add(row)
|
||||
row = setUpUserDirsListRow("folder-pictures", "", "pictures", userDirsMap)
|
||||
listBox.Add(row)
|
||||
row = setUpUserDirsListRow("folder-videos", "", "videos", userDirsMap)
|
||||
listBox.Add(row)
|
||||
|
||||
listBox.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
restoreButtonBox()
|
||||
})
|
||||
|
||||
return listBox
|
||||
}
|
||||
|
||||
func setUpUserDirsListRow(iconName, displayName, entryName string, userDirsMap map[string]string) *gtk.ListBoxRow {
|
||||
if displayName == "" {
|
||||
parts := strings.Split(userDirsMap[entryName], "/")
|
||||
displayName = parts[(len(parts) - 1)]
|
||||
}
|
||||
row, _ := gtk.ListBoxRowNew()
|
||||
//row.SetCanFocus(false)
|
||||
row.SetSelectable(false)
|
||||
vBox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||
eventBox, _ := gtk.EventBoxNew()
|
||||
hBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 6)
|
||||
eventBox.Add(hBox)
|
||||
vBox.PackStart(eventBox, false, false, *itemPadding)
|
||||
|
||||
//img, _ := gtk.ImageNewFromIconName(iconName, gtk.ICON_SIZE_DND)
|
||||
pixbuf, _ := createPixbuf(iconName, *iconSizeLarge)
|
||||
img, _ := gtk.ImageNewFromPixbuf(pixbuf)
|
||||
hBox.PackStart(img, false, false, 0)
|
||||
|
||||
if len(displayName) > 45 {
|
||||
displayName = fmt.Sprintf("%s...", displayName[:42])
|
||||
}
|
||||
lbl, _ := gtk.LabelNew(displayName)
|
||||
hBox.PackStart(lbl, false, false, 0)
|
||||
row.Add(vBox)
|
||||
|
||||
row.Connect("activate", func() {
|
||||
launch(fmt.Sprintf("%s %s", *fileManager, userDirsMap[entryName]), false)
|
||||
})
|
||||
|
||||
eventBox.Connect("button-release-event", func(row *gtk.ListBoxRow, e *gdk.Event) bool {
|
||||
btnEvent := gdk.EventButtonNewFromEvent(e)
|
||||
if btnEvent.Button() == 1 {
|
||||
launch(fmt.Sprintf("%s %s", *fileManager, userDirsMap[entryName]), false)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
return row
|
||||
}
|
||||
|
||||
func setUpUserFileSearchResultRow(fileName, filePath string) *gtk.ListBoxRow {
|
||||
row, _ := gtk.ListBoxRowNew()
|
||||
//row.SetCanFocus(false)
|
||||
@@ -726,116 +493,6 @@ func setUpUserFileSearchResultRow(fileName, filePath string) *gtk.ListBoxRow {
|
||||
return row
|
||||
}
|
||||
|
||||
func setUpButtonBox() *gtk.EventBox {
|
||||
eventBox, _ := gtk.EventBoxNew()
|
||||
wrapperHbox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||
wrapperHbox.PackStart(box, true, true, 0)
|
||||
eventBox.Add(wrapperHbox)
|
||||
|
||||
btn, _ := gtk.ButtonNew()
|
||||
pixbuf, _ := createPixbuf("system-lock-screen", *iconSizeLarge)
|
||||
img, _ := gtk.ImageNewFromPixbuf(pixbuf)
|
||||
btn.SetImage(img)
|
||||
btn.SetCanFocus(false)
|
||||
box.PackStart(btn, true, true, 0)
|
||||
btn.Connect("clicked", func() {
|
||||
launch(*cmdLock, false)
|
||||
//confirmationBox = setUpConfirmationBox("system-lock-screen", *cmdLock)
|
||||
buttonBox.Hide()
|
||||
})
|
||||
|
||||
btn, _ = gtk.ButtonNew()
|
||||
pixbuf, _ = createPixbuf("system-log-out", *iconSizeLarge)
|
||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||
btn.SetImage(img)
|
||||
btn.SetCanFocus(false)
|
||||
box.PackStart(btn, true, true, 0)
|
||||
btn.Connect("clicked", func() {
|
||||
confirmationBox = setUpConfirmationBox("system-log-out", *cmdLogout)
|
||||
buttonBox.Hide()
|
||||
})
|
||||
|
||||
btn, _ = gtk.ButtonNew()
|
||||
pixbuf, _ = createPixbuf("system-reboot", *iconSizeLarge)
|
||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||
btn.SetImage(img)
|
||||
btn.SetCanFocus(false)
|
||||
box.PackStart(btn, true, true, 0)
|
||||
btn.Connect("clicked", func() {
|
||||
confirmationBox = setUpConfirmationBox("system-reboot", *cmdRestart)
|
||||
buttonBox.Hide()
|
||||
})
|
||||
|
||||
btn, _ = gtk.ButtonNew()
|
||||
pixbuf, _ = createPixbuf("system-shutdown", *iconSizeLarge)
|
||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||
btn.SetImage(img)
|
||||
btn.SetCanFocus(false)
|
||||
box.PackStart(btn, true, true, 0)
|
||||
btn.Connect("clicked", func() {
|
||||
confirmationBox = setUpConfirmationBox("system-shutdown", *cmdShutdown)
|
||||
buttonBox.Hide()
|
||||
})
|
||||
|
||||
eventBox.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
})
|
||||
|
||||
return eventBox
|
||||
}
|
||||
|
||||
func setUpConfirmationBox(icon string, command string) *gtk.Box {
|
||||
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||
|
||||
btn, _ := gtk.ButtonNew()
|
||||
pixbuf, _ := createPixbuf(icon, *iconSizeLarge)
|
||||
img, _ := gtk.ImageNewFromPixbuf(pixbuf)
|
||||
btn.SetImage(img)
|
||||
btn.SetCanFocus(false)
|
||||
box.PackEnd(btn, true, true, 6)
|
||||
btn.Connect("clicked", func() {
|
||||
defer restoreButtonBox()
|
||||
launch(command, false)
|
||||
|
||||
})
|
||||
btn.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
})
|
||||
|
||||
btn, _ = gtk.ButtonNew()
|
||||
pixbuf, _ = createPixbuf("dialog-cancel", *iconSizeLarge)
|
||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||
btn.SetImage(img)
|
||||
btn.SetCanFocus(false)
|
||||
box.PackEnd(btn, true, true, 6)
|
||||
btn.Connect("clicked", func() {
|
||||
restoreButtonBox()
|
||||
})
|
||||
btn.Connect("enter-notify-event", func() {
|
||||
cancelClose()
|
||||
})
|
||||
|
||||
buttonsWrapper.PackEnd(box, false, false, 10)
|
||||
|
||||
box.ShowAll()
|
||||
w := buttonBox.GetAllocatedWidth()
|
||||
h := buttonBox.GetAllocatedHeight()
|
||||
box.SetSizeRequest(w, h)
|
||||
box.SetHExpand(false)
|
||||
|
||||
return box
|
||||
}
|
||||
|
||||
func restoreButtonBox() {
|
||||
if confirmationBox != nil {
|
||||
confirmationBox.Destroy()
|
||||
}
|
||||
if !buttonBox.IsVisible() {
|
||||
buttonBox.Show()
|
||||
}
|
||||
}
|
||||
|
||||
func clearSearchResult() {
|
||||
if resultWindow != nil {
|
||||
resultWindow.Destroy()
|
||||
|
||||
Reference in New Issue
Block a user