Skip to content

Commit 536d889

Browse files
committed
Support --desktop_file_hint via $DESKTOP_FILE_HINT
1 parent cba5adf commit 536d889

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

bridge.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import "C"
1414
import (
1515
"fmt"
1616
"gopkg.in/qml.v0/tref"
17+
"os"
1718
"reflect"
1819
"runtime"
1920
"sync"
@@ -25,9 +26,18 @@ var hookWaiting C.int
2526

2627
// guiLoop runs the main GUI thread event loop in C++ land.
2728
func guiLoop() {
29+
// This is not an option in Init to avoid forcing people to patch
30+
// and recompile an application just so it runs on Ubuntu Touch.
31+
deskfile := os.Getenv("DESKTOP_FILE_HINT")
32+
cdeskfile := (*C.char)(nil)
33+
if deskfile != "" {
34+
os.Setenv("DESKTOP_FILE_HINT", "")
35+
cdeskfile = C.CString("--desktop_file_hint=" + deskfile)
36+
}
37+
2838
runtime.LockOSThread()
2939
guiLoopRef = tref.Ref()
30-
C.newGuiApplication()
40+
C.newGuiApplication(cdeskfile)
3141
C.idleTimerInit(&hookWaiting)
3242
guiLoopReady.Unlock()
3343
C.applicationExec()

cpp/capi.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ void panicf(const char *format, ...)
4343
hookPanic(local_strdup(ba.constData()));
4444
}
4545

46-
void newGuiApplication()
46+
void newGuiApplication(char *deskfile)
4747
{
4848
static char empty[1] = {0};
49-
static char *argv[] = {empty};
49+
static char *argv[] = {empty, empty, empty};
5050
static int argc = 1;
51+
if (deskfile) {
52+
argv[argc] = deskfile;
53+
argc++;
54+
}
5155
new QApplication(argc, argv);
5256

5357
// The event should never die.

cpp/capi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ typedef struct {
105105
int line;
106106
} LogMessage;
107107

108-
void newGuiApplication();
108+
void newGuiApplication(char *deskfile);
109109
void applicationExec();
110110
void applicationFlushAll();
111111

0 commit comments

Comments
 (0)