diff --git a/v2/internal/frontend/desktop/linux/window.go b/v2/internal/frontend/desktop/linux/window.go index 40d553750..63bb7f29c 100644 --- a/v2/internal/frontend/desktop/linux/window.go +++ b/v2/internal/frontend/desktop/linux/window.go @@ -113,30 +113,11 @@ func NewWindow(appoptions *options.App, debug bool) *Window { result.SetKeepAbove(appoptions.AlwaysOnTop) result.SetResizable(!appoptions.DisableResize) result.SetSize(appoptions.Width, appoptions.Height) - result.Center() result.SetDecorated(!appoptions.Frameless) result.SetTitle(appoptions.Title) result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight) result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight) - //if appoptions.Linux != nil && appoptions.Linux.Icon != nil { - // xpmData := png2XPM(appoptions.Linux.Icon) - // xpm := C.CString(xpmData) - // defer C.free(unsafe.Pointer(xpm)) - // appIcon := C.gdk_pixbuf_new_from_xpm_data( - // C.gtk_window_set_icon(result.asGTKWindow(), appIcon) - //} - - //windowStartState := C.int(int(a.appoptions.WindowStartState)) - - //if a.appoptions.RGBA != nil { - // result.SetRGBA(a.appoptions.RGBA.R, a.appoptions.RGBA.G, a.appoptions.RGBA.B, a.appoptions.RGBA.A) - //} - - //if a.appoptions.Menu != nil { - // result.SetApplicationMenu(a.appoptions.Menu) - //} - return result } @@ -162,17 +143,6 @@ func (w *Window) UnFullscreen() { } func (w *Window) Destroy() { - /* - for (gulong connection: { - impl_->deleteEventConnection, - impl_->focusInEventConnection, - impl_->focusOutEventConnection, - impl_->configureEventConnection - }) { - g_signal_handler_disconnect(impl_->gtkWindow, connection); - } - gtk_widget_destroy(GTK_WIDGET(impl_->gtkWindow)); - */ //TODO: Proper shutdown C.g_object_unref(C.gpointer(w.gtkWindow)) @@ -261,16 +231,15 @@ func (w *Window) UpdateApplicationMenu() { func (w *Window) Run() { C.gtk_widget_show_all(w.asGTKWidget()) - //switch w.appoptions.WindowStartState { - //case options.Fullscreen: - // w.Fullscreen() - //case options.Minimised: - // w.Minimise() - //case options.Maximised: - // w.Maximise() - //} - - //println("Fullscreen: ", w.IsFullScreen()) + w.Center() + switch w.appoptions.WindowStartState { + case options.Fullscreen: + w.Fullscreen() + case options.Minimised: + w.Minimise() + case options.Maximised: + w.Maximise() + } C.gtk_main() } diff --git a/v2/pkg/commands/build/desktop_linux.go b/v2/pkg/commands/build/desktop_linux.go index 4d84577bf..7c285f399 100644 --- a/v2/pkg/commands/build/desktop_linux.go +++ b/v2/pkg/commands/build/desktop_linux.go @@ -3,237 +3,6 @@ package build -import ( - "image/png" - "os" - "path/filepath" - "strings" - - "github.com/xyproto/xpm" -) - -// compileIcon will compile the icon found at /icon.png into the application -func (d *DesktopBuilder) compileIcon(assetDir string, iconFile string) error { - - // Load icon into a databuffer - targetFilename := "icon" - targetFile := filepath.Join(assetDir, targetFilename+".h") - - d.addFileToDelete(targetFile) - - // Create a new XPM encoder - enc := xpm.NewEncoder(targetFilename) - - // Open the PNG file - f, err := os.Open(iconFile) - if err != nil { - return err - } - m, err := png.Decode(f) - if err != nil { - return err - } - err = f.Close() - if err != nil { - return err - } - - var buf strings.Builder - - // Generate and output the XPM data - err = enc.Encode(&buf, m) - if err != nil { - return err - } - - // Massage the output so we can extern reference it - output := buf.String() - output = strings.Replace(output, "static char", "const char", 1) - - // save icon.c - err = os.WriteFile(targetFile, []byte(output), 0755) - - return err -} - -// We will compile all tray icons found at /assets/trayicons/*.png into the application -func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) error { - // - // var err error - // - // // Get all the tray icon filenames - // trayIconDirectory := filepath.Join(options.ProjectData.BuildDir, "tray") - // - // // If the directory doesn't exist, create it - // if !fs.DirExists(trayIconDirectory) { - // err = fs.MkDirs(trayIconDirectory) - // if err != nil { - // return err - // } - // } - // - // var trayIconFilenames []string - // trayIconFilenames, err = filepath.Glob(trayIconDirectory + "/*.png") - // if err != nil { - // log.Fatal(err) - // return err - // } - // - // // Setup target - // targetFilename := "trayicons" - // targetFile := filepath.Join(assetDir, targetFilename+".h") - // d.addFileToDelete(targetFile) - // - // var dataBytes []byte - // - // // Use a strings builder - // var cdata strings.Builder - // - // // Write header - // header := `// trayicons.h - //// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL. - //// This file was auto-generated. DO NOT MODIFY. - // - //` - // cdata.WriteString(header) - // - // var variableList slicer.StringSlicer - // - // // Loop over icons - // for count, filename := range trayIconFilenames { - // - // // Load the tray icon - // dataBytes, err = ioutil.ReadFile(filename) - // if err != nil { - // return err - // } - // - // iconname := strings.TrimSuffix(filepath.Base(filename), ".png") - // trayIconName := fmt.Sprintf("trayIcon%dName", count) - // variableList.Add(trayIconName) - // cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", trayIconName, d.convertToHexLiteral([]byte(iconname)))) - // - // trayIconLength := fmt.Sprintf("trayIcon%dLength", count) - // variableList.Add(trayIconLength) - // lengthAsString := strconv.Itoa(len(dataBytes)) - // cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", trayIconLength, d.convertToHexLiteral([]byte(lengthAsString)))) - // - // trayIconData := fmt.Sprintf("trayIcon%dData", count) - // variableList.Add(trayIconData) - // cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { ", trayIconData)) - // - // // Convert each byte to hex - // for _, b := range dataBytes { - // cdata.WriteString(fmt.Sprintf("0x%x, ", b)) - // } - // - // cdata.WriteString("0x00 };\n") - // } - // - // // Write out main trayIcons data - // cdata.WriteString("const unsigned char *trayIcons[] = { ") - // cdata.WriteString(variableList.Join(", ")) - // if len(trayIconFilenames) > 0 { - // cdata.WriteString(", ") - // } - // cdata.WriteString("0x00 };\n") - // - // err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600) - // if err != nil { - // return err - // } - return nil -} - -// We will compile all dialog icons found at /icons/dialog/*.png into the application -func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) error { - - // var err error - // - // // Get all the dialog icon filenames - // dialogIconDirectory := filepath.Join(options.ProjectData.BuildDir, "dialog") - // var dialogIconFilenames []string - // - // // If the directory does not exist, create it - // if !fs.DirExists(dialogIconDirectory) { - // err = fs.MkDirs(dialogIconDirectory) - // if err != nil { - // return err - // } - // } - // - // dialogIconFilenames, err = filepath.Glob(dialogIconDirectory + "/*.png") - // if err != nil { - // log.Fatal(err) - // return err - // } - // - // // Setup target - // targetFilename := "userdialogicons" - // targetFile := filepath.Join(assetDir, targetFilename+".h") - // d.addFileToDelete(targetFile) - // - // var dataBytes []byte - // - // // Use a strings builder - // var cdata strings.Builder - // - // // Write header - // header := `// userdialogicons.h - //// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL. - //// This file was auto-generated. DO NOT MODIFY. - // - //` - // cdata.WriteString(header) - // - // var variableList slicer.StringSlicer - // - // // Loop over icons - // for count, filename := range dialogIconFilenames { - // - // // Load the tray icon - // dataBytes, err = ioutil.ReadFile(filename) - // if err != nil { - // return err - // } - // - // iconname := strings.TrimSuffix(filepath.Base(filename), ".png") - // dialogIconName := fmt.Sprintf("userDialogIcon%dName", count) - // variableList.Add(dialogIconName) - // cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", dialogIconName, d.convertToHexLiteral([]byte(iconname)))) - // - // dialogIconLength := fmt.Sprintf("userDialogIcon%dLength", count) - // variableList.Add(dialogIconLength) - // lengthAsString := strconv.Itoa(len(dataBytes)) - // cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", dialogIconLength, d.convertToHexLiteral([]byte(lengthAsString)))) - // - // dialogIconData := fmt.Sprintf("userDialogIcon%dData", count) - // variableList.Add(dialogIconData) - // cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { ", dialogIconData)) - // - // // Convert each byte to hex - // for _, b := range dataBytes { - // cdata.WriteString(fmt.Sprintf("0x%x, ", b)) - // } - // - // cdata.WriteString("0x00 };\n") - // } - // - // // Write out main dialogIcons data - // cdata.WriteString("const unsigned char *userDialogIcons[] = { ") - // cdata.WriteString(variableList.Join(", ")) - // if len(dialogIconFilenames) > 0 { - // cdata.WriteString(", ") - // } - // cdata.WriteString("0x00 };\n") - // - // err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600) - // if err != nil { - // return err - // } - return nil -} - // PostCompilation is called after the compilation step, if successful func (d *DesktopBuilder) PostCompilation(options *Options) error { return nil diff --git a/v2/pkg/options/linux/linux.go b/v2/pkg/options/linux/linux.go index 1d5b669ef..4feb29bca 100644 --- a/v2/pkg/options/linux/linux.go +++ b/v2/pkg/options/linux/linux.go @@ -2,6 +2,4 @@ package linux // Options specific to Linux builds type Options struct { - // Linux needs the icon embedded - Icon []byte }