From 7f0c866f486eab549e25853bedd2e96b1b211773 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 29 Oct 2011 09:14:15 -0700 Subject: Get icons working correctly under Windows With this we are able to include both a separate .ico file that the program can load at runtime and a .res file (that is created from the .rc file, both in the packaging/windows directory) that is linked into the executable and makes the Windows Explorer show the correct icon for subsurface. Signed-off-by: Dirk Hohndel --- Makefile | 3 ++- gtk-gui.c | 6 +++++- packaging/windows/subsurface.ico | Bin 0 -> 16958 bytes packaging/windows/subsurface.rc | 25 +++++++++++++++++++++++++ packaging/windows/subsurface.res | Bin 0 -> 18056 bytes 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 packaging/windows/subsurface.ico create mode 100644 packaging/windows/subsurface.rc create mode 100644 packaging/windows/subsurface.res diff --git a/Makefile b/Makefile index cc353f7d2..5b5adb044 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,7 @@ ifeq ($(CC), i686-w64-mingw32-gcc) LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer` LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer` + RESFILE = packaging/windows/subsurface.res else libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a) @@ -76,7 +77,7 @@ LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread OBJS = main.o dive.o profile.o info.o equipment.o divelist.o \ parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \ - gtk-gui.o + gtk-gui.o $(RESFILE) $(NAME): $(OBJS) $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS) diff --git a/gtk-gui.c b/gtk-gui.c index ea3f646e7..b1bc82a73 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -552,7 +552,11 @@ static void about_dialog(GtkWidget *w, gpointer data) GdkPixbuf *logo = NULL; if (need_icon) { +#ifndef WIN32 GtkWidget *image = gtk_image_new_from_file("subsurface.svg"); +#else + GtkWidget *image = gtk_image_new_from_file("subsurface.ico"); +#endif if (image) { logo = gtk_image_get_pixbuf(GTK_IMAGE(image)); @@ -823,7 +827,7 @@ void init_ui(int argc, char **argv) #ifndef WIN32 gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.svg", NULL); #else - gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.bmp", NULL); + gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.ico", NULL); #endif g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(on_delete), NULL); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL); diff --git a/packaging/windows/subsurface.ico b/packaging/windows/subsurface.ico new file mode 100644 index 000000000..fe7d1090b Binary files /dev/null and b/packaging/windows/subsurface.ico differ diff --git a/packaging/windows/subsurface.rc b/packaging/windows/subsurface.rc new file mode 100644 index 000000000..af79f6de9 --- /dev/null +++ b/packaging/windows/subsurface.rc @@ -0,0 +1,25 @@ +1 VERSIONINFO +FILEVERSION 1,1,0,0 +PRODUCTVERSION 1,1,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "subsurface team" + VALUE "FileDescription", "subsurface dive log" + VALUE "FileVersion", "1.1" + VALUE "InternalName", "subsurface" + VALUE "LegalCopyright", "Linus Torvalds, Dirk Hohndel and others" + VALUE "OriginalFilename", "subsurface.exe" + VALUE "ProductName", "subsurface" + VALUE "ProductVersion", "1.1" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END +ID ICON "subsurface.ico" \ No newline at end of file diff --git a/packaging/windows/subsurface.res b/packaging/windows/subsurface.res new file mode 100644 index 000000000..616cf5ea9 Binary files /dev/null and b/packaging/windows/subsurface.res differ -- cgit v1.2.3-70-g09d2 From 667f07d281399414ff683536a848dda71e04d561 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 29 Oct 2011 10:02:40 -0700 Subject: Add first cut of the mingw cross build spec file + nsi file These need more work but I'd rather have them here under version control. The spec file appears to successfully build the Windows binaries, given the right tar file to start with. Those binaries are then packed into an rpm file (extermely useless to Windows users). Once the rpm is unpacked one can then use the NSIS compiler and the .nsi file to create a Windows installer. This all is still extremely fragile, but it worked at least once... Signed-off-by: Dirk Hohndel --- packaging/windows/mingw-subsurface.spec | 112 ++++++++++++++++++++++++++++++++ packaging/windows/subsurface.nsi | 89 +++++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 packaging/windows/mingw-subsurface.spec create mode 100644 packaging/windows/subsurface.nsi diff --git a/packaging/windows/mingw-subsurface.spec b/packaging/windows/mingw-subsurface.spec new file mode 100644 index 000000000..e1335de1f --- /dev/null +++ b/packaging/windows/mingw-subsurface.spec @@ -0,0 +1,112 @@ +%define __strip %{_mingw32_strip} +%define __objdump %{_mingw32_objdump} +%define _use_internal_dependency_generator 0 +%define __find_requires %{_mingw32_findrequires} +%define __find_provides %{_mingw32_findprovides} +%define __os_install_post %{_mingw32_debug_install_post} \ + %{_mingw32_install_post} + + +Name: mingw32-subsurface +Summary: Simple Dive Log Program +Version: 1.1 +Release: 5 +License: GPLv2 +URL: http://subsurface.hohndel.org +Source0: subsurface-1.1.tar.gz +BuildArch: noarch +BuildRequires: mingw32-cross-pkg-config mingw32-cross-gcc +BuildRequires: mingw32-gtk2-devel mingw32-glib2-devel mingw32-libxml2-devel +BuildRequires: mingw32-libdivecomputer0-devel mingw32-gconf2-devel +BuildRequires: mingw32-pthreads-devel +BuildRequires: mingw32-gtk2 mingw32-glib2 mingw32-libxml2 +BuildRequires: mingw32-libdivecomputer0 mingw32-gconf2 +BuildRequires: mingw32-pthreads mingw32-zlib + +Group: Productivity/Other + +%description +subsurface is a simple dive log program written in C + +%{_mingw32_debug_package} + +%prep +%setup -q -n subsurface-1.1 + +%build +make CC=%{_mingw32_target}-gcc PKGCONFIG=%{_mingw32_target}-pkg-config XML2CONFIG=%{_mingw32_bindir}/xml2-config NAME=subsurface.exe + +%clean +#rm -rf %{buildroot} + +%install +mkdir -p $RPM_BUILD_ROOT/%{_mingw32_bindir} +mkdir -p $RPM_BUILD_ROOT/%{_mingw32_datadir} +install -m 755 subsurface.exe $RPM_BUILD_ROOT/%{_mingw32_bindir}/subsurface.exe +install -m 644 subsurface.svg $RPM_BUILD_ROOT/%{_mingw32_datadir}/subsurface.svg +# this seems like a really ugly hack +install -m 755 %{_mingw32_bindir}/libdivecomputer-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libdivecomputer-0.dll +install -m 755 %{_mingw32_bindir}/libcairo-2.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libcairo-2.dll +install -m 755 %{_mingw32_bindir}/libgconf-2-4.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgconf-2-4.dll +install -m 755 %{_mingw32_bindir}/libgdk-win32-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgdk-win32-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libglib-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libglib-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libgtk-win32-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgtk-win32-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libpango-1.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libpango-1.0-0.dll +install -m 755 %{_mingw32_bindir}/libpangocairo-1.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libpangocairo-1.0-0.dll +install -m 755 %{_mingw32_bindir}/pthreadGC2.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/pthreadGC2.dll +install -m 755 %{_mingw32_bindir}/libxml2-2.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libxml2-2.dll +install -m 755 %{_mingw32_bindir}/libfontconfig-1.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libfontconfig-1.dll +install -m 755 %{_mingw32_bindir}/libfreetype-6.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libfreetype-6.dll +install -m 755 %{_mingw32_bindir}/libpixman-1-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libpixman-1-0.dll +install -m 755 %{_mingw32_bindir}/libpng15-15.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libpng15-15.dll +install -m 755 %{_mingw32_bindir}/zlib1.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/zlib1.dll +install -m 755 %{_mingw32_bindir}/libintl-8.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libintl-8.dll +install -m 755 %{_mingw32_bindir}/libgmodule-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgmodule-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libgdk_pixbuf-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgdk_pixbuf-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libgobject-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgobject-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libgio-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgio-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libjasper-1.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libjasper-1.dll +install -m 755 %{_mingw32_bindir}/libgthread-2.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libgthread-2.0-0.dll +install -m 755 %{_mingw32_bindir}/libffi-5.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libffi-5.dll +install -m 755 %{_mingw32_bindir}/libjpeg-8.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libjpeg-8.dll +install -m 755 %{_mingw32_bindir}/libtiff-3.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libtiff-3.dll +install -m 755 %{_mingw32_bindir}/libpangoft2-1.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libpangoft2-1.0-0.dll +install -m 755 %{_mingw32_bindir}/libpangowin32-1.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libpangowin32-1.0-0.dll +install -m 755 %{_mingw32_bindir}/libatk-1.0-0.dll $RPM_BUILD_ROOT/%{_mingw32_bindir}/libatk-1.0-0.dll + +%files +%defattr(-,root,root) +%{_mingw32_bindir}/subsurface.exe +%{_mingw32_bindir}/libdivecomputer-0.dll +%{_mingw32_bindir}/libcairo-2.dll +%{_mingw32_bindir}/libgconf-2-4.dll +%{_mingw32_bindir}/libgdk-win32-2.0-0.dll +%{_mingw32_bindir}/libglib-2.0-0.dll +%{_mingw32_bindir}/libgtk-win32-2.0-0.dll +%{_mingw32_bindir}/libpango-1.0-0.dll +%{_mingw32_bindir}/libpangocairo-1.0-0.dll +%{_mingw32_bindir}/pthreadGC2.dll +%{_mingw32_bindir}/libxml2-2.dll +%{_mingw32_bindir}/libfontconfig-1.dll +%{_mingw32_bindir}/libfreetype-6.dll +%{_mingw32_bindir}/libpixman-1-0.dll +%{_mingw32_bindir}/libpng15-15.dll +%{_mingw32_bindir}/zlib1.dll +%{_mingw32_bindir}/libintl-8.dll +%{_mingw32_bindir}/libgmodule-2.0-0.dll +%{_mingw32_bindir}/libgdk_pixbuf-2.0-0.dll +%{_mingw32_bindir}/libgobject-2.0-0.dll +%{_mingw32_bindir}/libgio-2.0-0.dll +%{_mingw32_bindir}/libjasper-1.dll +%{_mingw32_bindir}/libgthread-2.0-0.dll +%{_mingw32_bindir}/libffi-5.dll +%{_mingw32_bindir}/libjpeg-8.dll +%{_mingw32_bindir}/libtiff-3.dll +%{_mingw32_bindir}/libpangoft2-1.0-0.dll +%{_mingw32_bindir}/libpangowin32-1.0-0.dll +%{_mingw32_bindir}/libatk-1.0-0.dll + +%{_mingw32_datadir}/subsurface.svg + + +%changelog diff --git a/packaging/windows/subsurface.nsi b/packaging/windows/subsurface.nsi new file mode 100644 index 000000000..c4fd48f27 --- /dev/null +++ b/packaging/windows/subsurface.nsi @@ -0,0 +1,89 @@ + +# define the name of the installer +outfile "subsurface-installer.exe" +Name subsurface + +VIProductVersion "1.1.0.0" +VIAddVersionKey ProductName subsurface +VIAddVersionKey ProductVersion "1.1" +VIAddVersionKey FileVersion "1.1" + +Icon ..\share\subsurface.ico + + +RequestExecutionLevel admin + +Function .onInit + MessageBox MB_YESNO "This will install subsurface. Do you wish to continue?" IDYES gogogo + Abort + gogogo: +FunctionEnd + +# define the directory to install to, the desktop in this case as specified +# by the predefined $DESKTOP variable +installDir "$DESKTOP\subsurface" + +# default section +Section + +# define the output path for this file +setOutPath $INSTDIR + +SetShellVarContext all + +# create directory in the Start menu +CreateDirectory "$SMPROGRAMS\subsurface" + +# create Start menu shortcut +createShortCut "$SMPROGRAMS\subsurface\subsurface.lnk" "$INSTDIR\subsurface.exe" + +#create uninstaller and corresponding shortcut in Start menu +writeUninstaller "$INSTDIR\subsurface-uninstall.exe" +createShortCut "$SMPROGRAMS\subsurface\uninstall-subsurface.lnk" "$INSTDIR\subsurface-uninstall.exe" + +# define what to install and place it in the output path +file subsurface.exe +file libatk-1.0-0.dll +file libcairo-2.dll +file libdivecomputer-0.dll +file libffi-5.dll +file libfontconfig-1.dll +file libfreetype-6.dll +file libgdk_pixbuf-2.0-0.dll +file libgdk-win32-2.0-0.dll +file libgio-2.0-0.dll +file libglib-2.0-0.dll +file libgmodule-2.0-0.dll +file libgobject-2.0-0.dll +file libgthread-2.0-0.dll +file libgtk-win32-2.0-0.dll +file libintl-8.dll +file libjasper-1.dll +file libjpeg-8.dll +file libpango-1.0-0.dll +file libpangocairo-1.0-0.dll +file libpangoft2-1.0-0.dll +file libpangowin32-1.0-0.dll +file libpixman-1-0.dll +file libpng15-15.dll +file libtiff-3.dll +file libxml2-2.dll +file pthreadGC2.dll +file zlib1.dll +file /oname=subsurface.ico ..\\share\\subsurface.ico +file /oname=subsurface.bmp ..\\share\\subsurface.bmp +file /oname=subsurface.svg ..\\share\\subsurface.svg + + +sectionEnd + +section "uninstall" + SetShellVarContext all + delete "$INSTDIR\subsurface-uninstall.exe" + delete "$INSTDIR\*.*" + RMDir "$INSTDIR" + delete "$SMPROGRAMS\subsurface\uninstall-subsurface.lnk" + delete "$SMPROGRAMS\subsurface\subsurface.lnk" + RMDir "$SMPROGRAMS\subsurface" +sectionEnd + -- cgit v1.2.3-70-g09d2 From ae8bf9f6f417d8d8eed10796f234367a015e837d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 29 Oct 2011 10:27:49 -0700 Subject: Get rid of the terminal window that is displayed under Windows Thanks to Michael Wiedmann I now know the magic incantation to get MinGW to create a Windows executable that doesn't open two windows, a text console and the actual gtk window. Signed-off-by: Dirk Hohndel --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5b5adb044..0d736e1b7 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ ifeq ($(CC), i686-w64-mingw32-gcc) LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer` LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer` RESFILE = packaging/windows/subsurface.res + LDFLAGS += -Wl,-subsystem,windows else libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a) -- cgit v1.2.3-70-g09d2 From 28d4075746c6120b56231dc58564a2353cc88a6a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 29 Oct 2011 12:04:52 -0700 Subject: Fix Windows install destination I used Desktop for trying things out and forgot to switch back to the more traditional "Program Files" Signed-off-by: Dirk Hohndel --- packaging/windows/subsurface.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/windows/subsurface.nsi b/packaging/windows/subsurface.nsi index c4fd48f27..8595c419b 100644 --- a/packaging/windows/subsurface.nsi +++ b/packaging/windows/subsurface.nsi @@ -21,7 +21,7 @@ FunctionEnd # define the directory to install to, the desktop in this case as specified # by the predefined $DESKTOP variable -installDir "$DESKTOP\subsurface" +installDir "$PROGRAMFILES\subsurface" # default section Section -- cgit v1.2.3-70-g09d2