Skip to content

Commit

Permalink
Merge pull request #2 from mtxr/master
Browse files Browse the repository at this point in the history
Showing apps if query is empty, styles and dimensions
  • Loading branch information
yamnikov-oleg authored Jun 26, 2018
2 parents 2d010cd + 2fe1e48 commit bb6e1a0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 6 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,33 @@ websearch:
# on your system. You can specify absolute path to an image file as well,
# e.g. `/home/me/.projektor/google.png`
icon: web-browser
ui:
# These values must be quoted so they would be parsed as strings. This is required for future support of sizes proportional to screen size.
width: "600"
height: "300"
```
Projektor styles should be placed at `~/.projektor/styles.css`.

Here is the default style:

```css
GtkEntry {
background-image: none;
border: none;
box-shadow: none;
font-size: 12pt;
}
GtkTreeView {
background-color: transparent;
font-size: 8pt;
}
GtkTreeView:selected {
background-color: rgba(0,0,0,0.1);
}
GtkTreeView.cell {
padding: 6px 3px;
}
```


4 changes: 0 additions & 4 deletions app_entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ func (ei *EntriesIterator) Entry() *LaunchEntry {
}

func SearchAppEntries(query string) LaunchEntriesList {
if query == "" {
return nil
}

loQuery := strings.ToLower(query)
results := LaunchEntriesList{}

Expand Down
9 changes: 9 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ type ProjektorConfig struct {
Engine string
Icon string
}
UI struct {
Position string
Width string
Height string
}
}

var (
Expand Down Expand Up @@ -58,6 +63,10 @@ func DefaultConfig() *ProjektorConfig {
c.WebSearch.Engine = "https://google.com/search?q=%s"
c.WebSearch.Icon = "web-browser"

c.UI.Position = "center"
c.UI.Width = "400"
c.UI.Height = "480"

return c
}

Expand Down
18 changes: 18 additions & 0 deletions css.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package main

import (
"io/ioutil"
"os"
"path"
)

const CSS_CODE = `
GtkEntry {
background-image: none;
Expand All @@ -18,3 +24,15 @@ const CSS_CODE = `
padding: 6px 3px;
}
`

var (
StylesFilePath = path.Join(AppDir, "styles.css")
)

func AppStyle() string {
if _, err := os.Stat(StylesFilePath); !os.IsNotExist(err) {
cssBytes, _ := ioutil.ReadFile(StylesFilePath)
return string(cssBytes)
}
return CSS_CODE
}
7 changes: 5 additions & 2 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"unsafe"

Expand Down Expand Up @@ -342,10 +343,12 @@ func SetupUi(dry bool) {
logf("Window\n")
Ui.Window.SetPosition(gtk.WIN_POS_CENTER)
Ui.Window.SetGravity(gdk.GRAVITY_SOUTH)
w, _ := strconv.Atoi(Config.UI.Width)
h, _ := strconv.Atoi(Config.UI.Height)
Ui.Window.SetSizeRequest(w, h)
Ui.Window.SetDecorated(false)
Ui.Window.SetSkipTaskbarHint(true)
Ui.Window.SetBorderWidth(6)
Ui.Window.SetSizeRequest(400, 480)
Ui.Window.Connect("key-press-event", func(ctx *glib.CallbackContext) bool {
arg := ctx.Args(0)
e := *(**gdk.EventKey)(unsafe.Pointer(&arg))
Expand Down Expand Up @@ -414,7 +417,7 @@ func SetupUi(dry bool) {
provider := gtk.NewCssProvider()
screen := gdk.GetDefaultDisplay().GetDefaultScreen()
gtk.StyleContextAddProviderForScreen(screen, provider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
err := provider.LoadFromData(CSS_CODE)
err := provider.LoadFromData(AppStyle())
if err != nil {
errduring("CSS loading", err, "")
}
Expand Down

0 comments on commit bb6e1a0

Please sign in to comment.