From 001f6d05dca762de232c68b7ff10fdc999a61514 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 13 Dec 2011 14:34:42 -0800 Subject: [PATCH 1/3] More intuitive label for "not saving" when exiting Right now the options are "Save" and "Cancel". I wrote that code and it always bugged me - "Cancel" could mean that I want to cancel the the whole operation, i.e. that I don't want to quit after all. Showing "Save" and "No" seems much more logical. Signed-off-by: Dirk Hohndel --- gtk-gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk-gui.c b/gtk-gui.c index dce537232..eae080808 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -162,7 +162,7 @@ static void ask_save_changes() dialog = gtk_dialog_new_with_buttons("Save Changes?", GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_NO, GTK_RESPONSE_NO, NULL); content = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); label = gtk_label_new ("You have unsaved changes\nWould you like to save those before exiting the program?"); From 4b77a5def6df965cae63dec8b836e18e1e09cd58 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 13 Dec 2011 20:34:56 -0800 Subject: [PATCH 2/3] Add reasonable default device names for divecomputer import So far we hard coded /dev/ttyUSB0 - which is a good starting point in Linux but not so useful on Windows or MacOS. This was now moved into one of our OS helper functions with (somewhat) reasonable defaults. Signed-off-by: Dirk Hohndel --- display-gtk.h | 2 ++ gtk-gui.c | 2 +- linux.c | 5 +++++ macos.c | 5 +++++ windows.c | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/display-gtk.h b/display-gtk.h index 8ca5a450e..b20495731 100644 --- a/display-gtk.h +++ b/display-gtk.h @@ -32,6 +32,8 @@ extern void subsurface_set_conf(char *name, pref_type_t type, const void *value) extern const void *subsurface_get_conf(char *name, pref_type_t type); extern void subsurface_close_conf(void); +extern const char *subsurface_USB_name(void); + extern visible_cols_t visible_cols; extern const char *divelist_font; diff --git a/gtk-gui.c b/gtk-gui.c index eae080808..c6b79b690 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -913,7 +913,7 @@ static GtkEntry *dive_computer_device(GtkWidget *vbox) entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(frame), entry); - gtk_entry_set_text(GTK_ENTRY(entry), "/dev/ttyUSB0"); + gtk_entry_set_text(GTK_ENTRY(entry), subsurface_USB_name()); return GTK_ENTRY(entry); } diff --git a/linux.c b/linux.c index 2edcf85a1..e26b3acbd 100644 --- a/linux.c +++ b/linux.c @@ -46,3 +46,8 @@ void subsurface_close_conf(void) { /* this is a no-op */ } + +const char *subsurface_USB_name() +{ + return("/dev/ttyUSB0"); +} diff --git a/macos.c b/macos.c index b48f20d87..0b64e19a0 100644 --- a/macos.c +++ b/macos.c @@ -89,3 +89,8 @@ void subsurface_close_conf(void) CFRelease(xmlData); CFRelease(propertyList); } + +const char *subsurface_USB_name() +{ + return("/dev/tty.SLAB_USBtoUART"); +} diff --git a/windows.c b/windows.c index e4c811984..3e40c38ef 100644 --- a/windows.c +++ b/windows.c @@ -78,3 +78,8 @@ void subsurface_close_conf(void) printf("RegFlushKey failed \n"); RegCloseKey(hkey); } + +const char *subsurface_USB_name() +{ + return("COM3"); +} From 6245b700a4a98cc2dba8c5b8c3f4958491605755 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 14 Dec 2011 11:22:12 -0800 Subject: [PATCH 3/3] Improve Makefile for MacOS Some macs appear to need "-framework CoreFoundation" added to the linking step, others (which appear to have the exact same OS and tools installed), don't. But as it doesn't appeart to hurt, I unconditionally add this. Switched to using pkgconfig to find libdivecomputer on the Mac. Tried to clean up the Makefile a bit Signed-off-by: Dirk Hohndel Acked-by: Henrik Brautaset Aronsen --- Makefile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 5f1f46689..f7c883999 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,10 @@ DESKTOPFILE = $(NAME).desktop MANFILES = $(NAME).1 XSLTFILES = xslt/*.xslt -MACOSXINSTALL = /Applications/Subsurface.app -MACOSXFILES = packaging/macosx +UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win") # find libdivecomputer -# First deal with the cross compile environment. +# First deal with the cross compile environment and with Mac. # For the native case, Linus doesn't want to trust pkg-config given # how young libdivecomputer still is - so we check the typical # subdirectories of /usr/local and /usr and then we give up. You can @@ -37,13 +36,14 @@ MACOSXFILES = packaging/macosx # ifeq ($(CC), i686-w64-mingw32-gcc) # ok, we are cross building for Windows - LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer` LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer` RESFILE = packaging/windows/subsurface.res LDFLAGS += -Wl,-subsystem,windows +else ifeq ($(UNAME), darwin) + LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer` + LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer` else - libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a) libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a) libdc-usr := $(wildcard /usr/lib/libdivecomputer.a) @@ -87,9 +87,6 @@ GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0) CFLAGS += $(shell $(XSLCONFIG) --cflags) -UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win") - - ifeq ($(UNAME), linux) LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) @@ -98,6 +95,9 @@ ifeq ($(UNAME), linux) else ifeq ($(UNAME), darwin) OSSUPPORT = macos OSSUPPORT_CFLAGS = $(GTK2CFLAGS) + MACOSXINSTALL = /Applications/Subsurface.app + MACOSXFILES = packaging/macosx + EXTRALIBS = -framework CoreFoundation else OSSUPPORT = windows OSSUPPORT_CFLAGS = $(GTK2CFLAGS) @@ -110,7 +110,7 @@ ifneq ($(strip $(LIBXSLT)),) endif endif -LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) -lpthread +LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) -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 \