]> Pileus Git - aweather/commitdiff
Win32 fixes and improvements
authorAndy Spencer <andy753421@gmail.com>
Sun, 2 May 2010 00:50:18 +0000 (00:50 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 2 May 2010 02:29:13 +0000 (02:29 +0000)
- Add NSIS installer
- Add icon (and associated resource files)
- Add G_MODULE_EXPORT to symbols
- Set default window size
- Build path fixes

16 files changed:
.gitignore
Makefile.am
autogen.sh
aweather.nsi [new file with mode: 0644]
configure.ac
data/.gitignore
data/Makefile.am
gen-win32.sh
m4/01gnolib.m4 [new file with mode: 0644]
src/.gitignore
src/Makefile.am
src/aweather-gui.c
src/plugins/Makefile.am
src/plugins/radar.c
src/resource.h [new file with mode: 0644]
src/resource.rc.in [new file with mode: 0644]

index 7ca04826e22f95d7c403718d0e1dabba68208e84..6b62ecbb0c2ae3fc5df523eb4ad5841128317518 100644 (file)
@@ -1,6 +1,9 @@
 *.bz2
 *.gz
+*.exe
 *~
+gtk/
+build/
 /arg-nonnull.h
 /c++defs.h
 /warn-on-use.h
index f472e79c51e3fd918c9a1933918a223242581c09..253146cba4fd1fadd2507d2292c1e3b9879c8efb 100644 (file)
@@ -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
index bd6daa8b8f384426cfea98d6f0f41de1b4033ee1..90d7005e6c4d3dafebbed8a5e6970089c05949d7 100755 (executable)
@@ -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 (file)
index 0000000..aa27d56
--- /dev/null
@@ -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
index d938eb9c232f73e1d95f6edb050ec3376d34a52f..c7971744a4f7258be802523531ee8c59b5c15adf 100644 (file)
@@ -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
index 2154952b9c86b9c6fc4cd88de0bc5b311dbcf75b..0b451448966b0464d85a2a2562b67abd89ffdd07 100644 (file)
@@ -1,3 +1,4 @@
 *.png
+*.ico
 aweather
 main.ui
index 4df280f8e865450f8e198febd14061d847e549a9..29dadf21616785a734a12ef96f27901b9842dfd3 100644 (file)
@@ -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
index 82ac5d41809bee8e2e38664ee2521225ff2d65e8..2c798e3c057fb13aa488a586140335d13de82f31 100755 (executable)
@@ -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 (file)
index 0000000..394b73a
--- /dev/null
@@ -0,0 +1,4 @@
+AC_DEFUN([gl_EARLY], [])
+AC_DEFUN([gl_INIT], [])
+syscmd([mkdir -p lib/])
+syscmd([touch lib/Makefile.am])
index 49f0566d2b1482bc6641745931acafd898b57382..4bbd0ba7c08000d0c954582d1df66dc32331fd9d 100644 (file)
@@ -4,6 +4,7 @@
 *.o
 *.so
 *.prof
+*.rc
 .deps
 .libs
 gmon.*
index 47856d062c6ed60305ceabbcb4568227f2fa00cb..535b1d052f7b3c887197800a2154cb93dbd32014 100644 (file)
@@ -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
 
index 90b1d76e7b79661d430a8f44d6a5d5e63ca66a5a..f93a2ea8c6f0ee9d864c24e312681f3ab4c08985 100644 (file)
@@ -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 */
index be1352430be8d7aa5b700f0fe896ebf3acf73560..7540ecaae6a6767a1016b54f4aca5f0053e381c2 100644 (file)
@@ -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:
index 75fc3783de71e9399ec75d570ae9f40ab7ef8f80..00289c5c4e157cd8ea04c5cb18680829f134571b 100644 (file)
@@ -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 (file)
index 0000000..0f8435a
--- /dev/null
@@ -0,0 +1 @@
+#define AWEATHER_ICON 104\r
diff --git a/src/resource.rc.in b/src/resource.rc.in
new file mode 100644 (file)
index 0000000..cf5da02
--- /dev/null
@@ -0,0 +1,33 @@
+#include <winver.h>\r
+#include "resource.h"\r
+\r
+VS_VERSION_INFO VERSIONINFO\r
+  FILEVERSION    1,0,0,1\r
+  PRODUCTVERSION 1,0,0,1\r
+  FILEFLAGSMASK  0\r
+  FILEFLAGS      0\r
+  FILEOS         VOS__WINDOWS32\r
+  FILETYPE       VFT_APP\r
+  FILESUBTYPE    VFT2_UNKNOWN\r
+  BEGIN\r
+    BLOCK "StringFileInfo"\r
+    BEGIN\r
+      BLOCK "040904B0"\r
+      BEGIN\r
+        VALUE "CompanyName",      "Andy Spencer"\r
+        VALUE "FileDescription",  "AWeather"\r
+        VALUE "FileVersion",      "@VERSION@"\r
+        VALUE "InternalName",     "@PACKAGE@"\r
+        VALUE "LegalCopyright",   "Copyright (C) 2008-2010 Andy Spencer"\r
+        VALUE "OriginalFilename", "@ORIGINAL_FILENAME@"\r
+        VALUE "ProductName",      "AWeather"\r
+        VALUE "ProductVersion",   "@VERSION@"\r
+      END\r
+    END\r
+    BLOCK "VarFileInfo"\r
+    BEGIN\r
+      VALUE "Translation", 0x409, 1200\r
+    END\r
+  END\r
+\r
+AWEATHER_ICON ICON "../data/aweather.ico"\r