Skip to content

Commit

Permalink
feat(gui): adding the splash screen (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f authored Oct 14, 2023
1 parent 84908cc commit ed8d0e5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
Binary file modified cmd/gtk/assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion cmd/gtk/assets/ui/dialog_about.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Building Decentralized Future Together!
Pactus is a low-cost, high-performance, and scalable decentralized blockchain protocol with a novel PoS consensus.
</property>
<property name="logo">../images/logo.png</property>
<property name="license-type">mit-x11</property>
<child internal-child="vbox">
<object class="GtkBox">
Expand Down
4 changes: 2 additions & 2 deletions cmd/gtk/dialog_about.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
pactusLogo []byte
)

func showAboutDialog() {
func aboutDialog() *gtk.AboutDialog {
builder, err := gtk.BuilderNewFromString(string(uiAboutDialog))
fatalErrorCheck(err)

Expand All @@ -30,5 +30,5 @@ func showAboutDialog() {
dlg.SetLogo(pxLogo)
dlg.SetVersion(version.Version())

dlg.Show()
return dlg
}
32 changes: 29 additions & 3 deletions cmd/gtk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"

"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
"github.com/pactus-project/pactus/cmd"
Expand Down Expand Up @@ -67,7 +68,33 @@ func main() {
// Connect function to application activate event
app.Connect("activate", func() {
log.Println("application activate")
start(workingDir, app)

// Show about dialog as splash screen
splashDlg := aboutDialog()
splashDlg.SetDecorated(false)
splashDlg.SetResizable(false)
splashDlg.SetPosition(gtk.WIN_POS_CENTER)
splashDlg.SetTypeHint(gdk.WINDOW_TYPE_HINT_SPLASHSCREEN)

gtk.WindowSetAutoStartupNotification(false)
splashDlg.ShowAll()
gtk.WindowSetAutoStartupNotification(true)

app.AddWindow(splashDlg)

// This might also force GTK to draw the splash screen
for gtk.EventsPending() {
gtk.MainIteration()
}

// Running the start-up logic in a separate goroutine
glib.TimeoutAdd(uint(100), func() bool {
start(workingDir, app)
splashDlg.Destroy()

// Ensures the function is not called again
return false
})
})

// Connect function to application shutdown event, this is not required.
Expand All @@ -92,7 +119,6 @@ func start(workingDir string, app *gtk.Application) {
}
return getWalletPassword(wallet)
}

node, wallet, err := cmd.StartNode(workingDir, passwordFetcher)
fatalErrorCheck(err)

Expand All @@ -109,7 +135,7 @@ func start(workingDir string, app *gtk.Application) {
win := buildMainWindow(nodeModel, walletModel)

// Show the Window and all of its components.
win.Show()
win.ShowAll()

walletModel.rebuildModel()

Expand Down
5 changes: 3 additions & 2 deletions cmd/gtk/main_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ func (mw *mainWindow) onAboutGtk() {
}

func (mw *mainWindow) onAbout() {
showAboutDialog()
dlg := aboutDialog()
dlg.ShowAll()
}

func (mw *mainWindow) OnTransactionTransfer() {
Expand All @@ -105,7 +106,7 @@ func (mw *mainWindow) onMenuItemActivateWebsite(_ *gtk.MenuItem) {
}

func (mw *mainWindow) onMenuItemActivateExplorer(_ *gtk.MenuItem) {
if err := openURLInBrowser("https://pactusscan.com/"); err != nil {
if err := openURLInBrowser("https://pacscan.org/"); err != nil {
fatalErrorCheck(err)
}
}
Expand Down

0 comments on commit ed8d0e5

Please sign in to comment.