From 5761f0ec012080b2f12c5e29a93a97b9a7ede4b4 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sun, 2 May 2010 00:50:18 +0000 Subject: [PATCH] Win32 fixes and improvements - Add NSIS installer - Add icon (and associated resource files) - Add G_MODULE_EXPORT to symbols - Set default window size - Build path fixes --- .gitignore | 3 ++ Makefile.am | 14 ++++++ autogen.sh | 2 - aweather.nsi | 95 +++++++++++++++++++++++++++++++++++++++++ configure.ac | 12 ++++++ data/.gitignore | 1 + data/Makefile.am | 8 +++- gen-win32.sh | 15 ++++--- m4/01gnolib.m4 | 4 ++ src/.gitignore | 1 + src/Makefile.am | 18 +++++--- src/aweather-gui.c | 23 +++++----- src/plugins/Makefile.am | 5 +-- src/plugins/radar.c | 5 ++- src/resource.h | 1 + src/resource.rc.in | 33 ++++++++++++++ 16 files changed, 209 insertions(+), 31 deletions(-) create mode 100644 aweather.nsi create mode 100644 m4/01gnolib.m4 create mode 100644 src/resource.h create mode 100644 src/resource.rc.in diff --git a/.gitignore b/.gitignore index 7ca0482..6b62ecb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ *.bz2 *.gz +*.exe *~ +gtk/ +build/ /arg-nonnull.h /c++defs.h /warn-on-use.h diff --git a/Makefile.am b/Makefile.am index f472e79..253146c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,6 +11,20 @@ EXTRA_DIST = m4/gnulib-cache.m4 test: all (cd src && make test) +build: all + export DESTDIR="`pwd`/build"; \ + make -C ../aweather-win32 install; \ + make -C ../libgis-win32 install; \ + make -C ../rsl-win32 install; + +installers: $(PACKAGE)-$(VERSION).exe $(PACKAGE)-$(VERSION)-gtk.exe + +$(PACKAGE)-$(VERSION).exe: build + makensis -DVERSION=$(VERSION) aweather.nsi + +$(PACKAGE)-$(VERSION)-gtk.exe: build + makensis -DVERSION=$(VERSION) -DUSE_GTK aweather.nsi + release: all dist @echo -en "\nRelease $(PACKAGE)-$(VERSION) (y/n): " @read ans && [ "$$ans" != "y" ] && exit 1 || exit 0 diff --git a/autogen.sh b/autogen.sh index bd6daa8..90d7005 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,5 @@ #!/bin/sh -gnulib-tool --no-vc-files --import strptime - libtoolize aclocal -I m4 autoconf diff --git a/aweather.nsi b/aweather.nsi new file mode 100644 index 0000000..aa27d56 --- /dev/null +++ b/aweather.nsi @@ -0,0 +1,95 @@ +!define MULTIUSER_EXECUTIONLEVEL Highest +!define MULTIUSER_MUI +!define MULTIUSER_INSTALLMODE_COMMANDLINE +!define MULTIUSER_INSTALLMODE_INSTDIR AWeather +!include "MultiUser.nsh" +!include "MUI2.nsh" + +Function .onInit + !insertmacro MULTIUSER_INIT +FunctionEnd + +Function un.onInit + !insertmacro MULTIUSER_UNINIT +FunctionEnd + +name "AWeather" +!ifndef VERSION + !define VERSION LATEST +!endif +!ifdef USE_GTK + outFile "aweather-${VERSION}-gtk.exe" +!else + outFile "aweather-${VERSION}.exe" +!endif +installDir AWeather +Icon "data/aweather.ico" + +!define MUI_ABORTWARNING + +!insertmacro MUI_PAGE_LICENSE "COPYING" +!insertmacro MULTIUSER_PAGE_INSTALLMODE +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +!insertmacro MUI_LANGUAGE "English" + +section "AWeather (required)" SecAWeather + SectionIn RO + + setOutPath $INSTDIR + file /r build/* + !ifdef USE_GTK + file /r gtk/* + !endif + + StrCmp $MultiUser.InstallMode "AllUsers" 0 +4 + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AWeather" "DisplayName" "AWeather" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AWeather" "UninstallString" "$INSTDIR\uninstaller.exe" + Goto +3 + WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\AWeather" "DisplayName" "AWeather" + WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\AWeather" "UninstallString" "$INSTDIR\uninstaller.exe" + + FileOpen $0 $INSTDIR\instmode.dat w + FileWrite $0 $MultiUser.InstallMode + FileClose $0 + + writeUninstaller $INSTDIR\uninstaller.exe +sectionEnd +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN +!insertmacro MUI_DESCRIPTION_TEXT ${SecAWeather} "AWeather core files." +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +Section "Desktop Icons" + setOutPath $INSTDIR\bin + CreateShortCut "$DESKTOP\AWeather.exe.lnk" "$INSTDIR\bin\aweather.exe" "" "$INSTDIR\bin\aweather.exe" 0 +SectionEnd + +Section "Start Menu Shortcuts" + setOutPath $INSTDIR\bin + CreateDirectory "$SMPROGRAMS\AWeather" + CreateShortCut "$SMPROGRAMS\AWeather\Uninstall AWeather.lnk" "$INSTDIR\uninstaller.exe" "" "$INSTDIR\uninstaller.exe" 0 + CreateShortCut "$SMPROGRAMS\AWeather\AWeather.lnk" "$INSTDIR\bin\aweather.exe" "" "$INSTDIR\bin\aweather.exe" 0 +SectionEnd + +section "Uninstall" + FileOpen $0 $INSTDIR\instmode.dat r + FileRead $0 $1 + FileClose $0 + + StrCmp $1 "AllUsers" 0 +4 + SetShellVarContext all + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AWeather" + Goto +3 + SetShellVarContext current + DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\AWeather" + + delete $DESKTOP\AWeather.exe.lnk + + rmdir /r $SMPROGRAMS\AWeather + rmdir /r $INSTDIR +sectionEnd diff --git a/configure.ac b/configure.ac index d938eb9..c797174 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,7 @@ AC_CONFIG_MACRO_DIR([m4]) # Check for required programs AC_PROG_CC gl_EARLY +LT_PROG_RC AC_PROG_LIBTOOL PKG_PROG_PKG_CONFIG gl_INIT @@ -21,11 +22,22 @@ AC_CHECK_LIB(rsl, RSL_wsr88d_to_radar, RSL_LIBS="-lrsl") AM_CONDITIONAL(HAVE_RSL, test "$RSL_LIBS" != "") AC_SUBST(RSL_LIBS) +# Test for Windows vs. Unix +case "${host}" in + *mingw32*) WIN32="yes" ;; + *) WIN32="no" ;; +esac +if test "$WIN32" = yes; then + ac_default_prefix="/" +fi +AM_CONDITIONAL([WIN32], test "$WIN32" = "yes") + # Output AC_CONFIG_FILES([ Makefile lib/Makefile src/Makefile + src/resource.rc src/plugins/Makefile data/Makefile data/main.ui diff --git a/data/.gitignore b/data/.gitignore index 2154952..0b45144 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,3 +1,4 @@ *.png +*.ico aweather main.ui diff --git a/data/Makefile.am b/data/Makefile.am index 4df280f..29dadf2 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -4,14 +4,20 @@ dist_gtkbuilder_DATA = main.ui configdir = $(datadir)/aweather/ dist_config_DATA = defaults.ini +if WIN32 +noinst_DATA = aweather.ico +else desktopdir = $(datadir)/applications dist_desktop_DATA = aweather.desktop pixmapdir = $(datadir)/pixmaps dist_pixmap_DATA = aweather.png +endif .svg.png: - rsvg $< $@ + rsvg -w 48 -h 48 $< $@ +.png.ico: + icotool -c $< -o $@ maintainer-clean-local: rm -f Makefile.in diff --git a/gen-win32.sh b/gen-win32.sh index 82ac5d4..2c798e3 100755 --- a/gen-win32.sh +++ b/gen-win32.sh @@ -1,8 +1,9 @@ #!/bin/bash -dir=$(dirname $(readlink -f $0)) -PKG_CONFIG_PATH="../libgis-win32/src/" \ -./autogen.sh \ - "--host=i686-pc-mingw32" \ - "--datadir=Z:$dir/data/" \ - "--libdir=Z:$dir/src/plugins/" \ - CFLAGS="-g -Werror -Wno-unused $CFLAGS" +gnulib-tool --no-vc-files --import strptime + +GIS="/scratch/libgis-win32/src" +export PKG_CONFIG_PATH="$GIS" +export LIBS="-L$GIS" +export CPPFLAGS="-I$GIS" +export CFLAGS="-g -Werror -Wno-unused -O3" +./autogen.sh --host=i686-pc-mingw32 diff --git a/m4/01gnolib.m4 b/m4/01gnolib.m4 new file mode 100644 index 0000000..394b73a --- /dev/null +++ b/m4/01gnolib.m4 @@ -0,0 +1,4 @@ +AC_DEFUN([gl_EARLY], []) +AC_DEFUN([gl_INIT], []) +syscmd([mkdir -p lib/]) +syscmd([touch lib/Makefile.am]) diff --git a/src/.gitignore b/src/.gitignore index 49f0566..4bbd0ba 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -4,6 +4,7 @@ *.o *.so *.prof +*.rc .deps .libs gmon.* diff --git a/src/Makefile.am b/src/Makefile.am index 47856d0..535b1d0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,21 +1,29 @@ SUBDIRS = plugins -AM_CFLAGS = -Wall --std=gnu99 +AM_CFLAGS = -Wall --std=gnu99 $(GIS_CFLAGS) +AM_LDFLAGS = -Wl,--export-dynamic bin_PROGRAMS = aweather wsr88ddec aweather_SOURCES = main.c \ aweather-gui.c aweather-gui.h \ aweather-location.c aweather-location.h aweather_CPPFLAGS = \ - -DPKGDATADIR="\"$(pkgdatadir)\"" \ - -DPLUGINSDIR="\"$(pkglibdir)\"" -aweather_CFLAGS = $(GIS_CFLAGS) $(AM_CFLAGS) + -DPKGDATADIR="\"$(dots)$(pkgdatadir)\"" \ + -DPLUGINSDIR="\"$(dots)$(pkglibdir)\"" aweather_LDADD = $(GIS_LIBS) wsr88ddec = wsr88ddec.c -wsr88ddec_CFLAGS = $(GLIB_CFLAGS) $(AM_CFLAGS) wsr88ddec_LDADD = $(GLIB_LIBS) -lbz2 +if WIN32 +AM_LDFLAGS += -mwindows +aweather_SOURCES += resource.rc +dots = .. +endif + +.rc.o: ../data/aweather.ico + $(RC) -o $@ $< + CLEANFILES = gmon.out valgrind.out MAINTAINERCLEANFILES = Makefile.in diff --git a/src/aweather-gui.c b/src/aweather-gui.c index 90b1d76..f93a2ea 100644 --- a/src/aweather-gui.c +++ b/src/aweather-gui.c @@ -29,7 +29,7 @@ /************* * Callbacks * *************/ -gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *self) +G_MODULE_EXPORT gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *self) { g_debug("AWeatherGui: on_gui_key_press - key=%x, state=%x", event->keyval, event->state); @@ -49,27 +49,27 @@ gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *se return FALSE; } -void on_quit(GtkMenuItem *menu, AWeatherGui *self) +G_MODULE_EXPORT void on_quit(GtkMenuItem *menu, AWeatherGui *self) { gtk_widget_destroy(GTK_WIDGET(self)); } -void on_zoomin(GtkAction *action, AWeatherGui *self) +G_MODULE_EXPORT void on_zoomin(GtkAction *action, AWeatherGui *self) { gis_viewer_zoom(self->viewer, 3./4); } -void on_zoomout(GtkAction *action, AWeatherGui *self) +G_MODULE_EXPORT void on_zoomout(GtkAction *action, AWeatherGui *self) { gis_viewer_zoom(self->viewer, 4./3); } -void on_refresh(GtkAction *action, AWeatherGui *self) +G_MODULE_EXPORT void on_refresh(GtkAction *action, AWeatherGui *self) { gis_viewer_refresh(self->viewer); } -void on_plugin_toggled(GtkCellRendererToggle *cell, gchar *path_str, AWeatherGui *self) +G_MODULE_EXPORT void on_plugin_toggled(GtkCellRendererToggle *cell, gchar *path_str, AWeatherGui *self) { GtkWidget *tview = aweather_gui_get_widget(self, "prefs_plugins_view"); GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tview)); @@ -87,7 +87,7 @@ void on_plugin_toggled(GtkCellRendererToggle *cell, gchar *path_str, AWeatherGui g_free(name); } -void on_time_changed(AWeatherGui *self) +G_MODULE_EXPORT void on_time_changed(AWeatherGui *self) { g_debug("AWeatherGui: on_time_changed"); struct tm tm = {}; @@ -146,14 +146,14 @@ static void update_time_widget(GisViewer *viewer, time_t time, AWeatherGui *self } /* Prefs callbacks */ -void on_offline(GtkToggleAction *action, AWeatherGui *self) +G_MODULE_EXPORT void on_offline(GtkToggleAction *action, AWeatherGui *self) { gboolean value = gtk_toggle_action_get_active(action); g_debug("AWeatherGui: on_offline - offline=%d", value); gis_viewer_set_offline(self->viewer, value); } -void on_initial_site_changed(GtkComboBox *combo, AWeatherGui *self) +G_MODULE_EXPORT void on_initial_site_changed(GtkComboBox *combo, AWeatherGui *self) { gchar *code; GtkTreeIter iter; @@ -165,14 +165,14 @@ void on_initial_site_changed(GtkComboBox *combo, AWeatherGui *self) g_free(code); } -void on_nexrad_url_changed(GtkEntry *entry, AWeatherGui *self) +G_MODULE_EXPORT void on_nexrad_url_changed(GtkEntry *entry, AWeatherGui *self) { const gchar *text = gtk_entry_get_text(entry); g_debug("AWeatherGui: on_nexrad_url_changed - url=%s", text); gis_prefs_set_string(self->prefs, "aweather/nexrad_url", text); } -int on_log_level_changed(GtkSpinButton *spinner, AWeatherGui *self) +G_MODULE_EXPORT int on_log_level_changed(GtkSpinButton *spinner, AWeatherGui *self) { gint value = gtk_spin_button_get_value_as_int(spinner); g_debug("AWeatherGui: on_log_level_changed - %p, level=%d", self, value); @@ -370,6 +370,7 @@ static void aweather_gui_init(AWeatherGui *self) GtkWidget *paned = aweather_gui_get_widget(self, "main_paned"); gtk_widget_destroy(gtk_paned_get_child1(GTK_PANED(paned))); gtk_paned_pack1(GTK_PANED(paned), GTK_WIDGET(self->viewer), TRUE, FALSE); + gtk_widget_set_size_request(GTK_WIDGET(self->viewer), 600, 400); gtk_widget_show_all(GTK_WIDGET(self)); /* Plugins */ diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index be13524..7540eca 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -1,7 +1,6 @@ AM_CFLAGS = -Wall --std=gnu99 $(GIS_CFLAGS) AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib AM_LDFLAGS = -module -avoid-version -no-undefined -LIBS = $(GIS_LIBS) pluginsdir = $(pkglibdir) @@ -14,8 +13,8 @@ radar_la_SOURCES = \ level2.c level2.h \ ../aweather-colormap.c \ ../aweather-location.c -radar_la_LIBADD = $(addprefix $(top_srcdir)/lib/,$(gl_LTLIBOBJS)) -radar_la_LDFLAGS = $(AM_LDFLAGS) $(RSL_LIBS) +radar_la_LIBADD = $(RSL_LIBS) $(GIS_LIBS) \ + $(addprefix $(top_srcdir)/lib/,$(gl_LTLIBOBJS)) endif test: diff --git a/src/plugins/radar.c b/src/plugins/radar.c index 75fc378..00289c5 100644 --- a/src/plugins/radar.c +++ b/src/plugins/radar.c @@ -308,7 +308,8 @@ RadarSite *radar_site_new(city_t *city, GtkWidget *pconfig, site->pconfig = pconfig; /* Add marker */ - g_idle_add(_site_add_marker, site); + g_idle_add_full(G_PRIORITY_LOW, _site_add_marker, site, NULL); + /* Connect signals */ site->location_id = g_signal_connect(viewer, "location-changed", @@ -609,7 +610,7 @@ static void gis_plugin_radar_init(GisPluginRadar *self) self->sites = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)radar_site_free); self->config = gtk_notebook_new(); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(self->config), GTK_POS_LEFT); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(self->config), GTK_POS_TOP); } static void gis_plugin_radar_dispose(GObject *gobject) { diff --git a/src/resource.h b/src/resource.h new file mode 100644 index 0000000..0f8435a --- /dev/null +++ b/src/resource.h @@ -0,0 +1 @@ +#define AWEATHER_ICON 104 diff --git a/src/resource.rc.in b/src/resource.rc.in new file mode 100644 index 0000000..cf5da02 --- /dev/null +++ b/src/resource.rc.in @@ -0,0 +1,33 @@ +#include +#include "resource.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0 + FILEFLAGS 0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "Andy Spencer" + VALUE "FileDescription", "AWeather" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "@PACKAGE@" + VALUE "LegalCopyright", "Copyright (C) 2008-2010 Andy Spencer" + VALUE "OriginalFilename", "@ORIGINAL_FILENAME@" + VALUE "ProductName", "AWeather" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END + +AWEATHER_ICON ICON "../data/aweather.ico" -- 2.43.2