summaryrefslogtreecommitdiffstats
path: root/macos.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-10-31 16:53:05 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-10-31 16:53:05 -0700
commit072b4f743c19566ad55bb4b30e0844082cccfbd1 (patch)
tree17a746fc7991f5caa041e29c61a6109ae51a5c6a /macos.c
parent2d4fee79853f1d81585beb62d36b68f1602fce5d (diff)
parentee5c31d2921c0b8970303a1230586391dd06df4a (diff)
downloadsubsurface-072b4f743c19566ad55bb4b30e0844082cccfbd1.tar.gz
Merge branch 'dc-device-selector'
Bring the device selector (when downloading from a dive computer) into master.
Diffstat (limited to 'macos.c')
-rw-r--r--macos.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/macos.c b/macos.c
index 6727c1053..56b5b3bdf 100644
--- a/macos.c
+++ b/macos.c
@@ -72,9 +72,57 @@ void subsurface_close_conf(void)
/* Nothing */
}
-const char *subsurface_USB_name()
+Int subsurface_fill_device_list(GtkListStore *store)
{
- return "/dev/tty.SLAB_USBtoUART";
+ int i = 0;
+ int index = -1;
+ GtkTreeIter iter;
+ GDir *dev;
+ const char *name;
+ char *buffer;
+ gsize length;
+
+ dev = g_dir_open("/dev", 0, NULL);
+ while (dev && (name = g_dir_read_name(dev)) != NULL) {
+ if (strstr(name, "usbserial")) {
+ int len = strlen(name) + 6;
+ char *devicename = malloc(len);
+ snprintf(devicename, len, "/dev/%s", name);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, devicename, -1);
+ if (is_default_dive_computer_device(devicename))
+ index = i;
+ i++;
+ }
+ }
+ if (dev)
+ g_dir_close(dev);
+ dev = g_dir_open("/Volumes", 0, NULL);
+ while (dev && (name = g_dir_read_name(dev)) != NULL) {
+ if (strstr(name, "UEMISSDA")) {
+ int len = strlen(name) + 10;
+ char *devicename = malloc(len);
+ snprintf(devicename, len, "/Volumes/%s", name);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, devicename, -1);
+ if (is_default_dive_computer_device(devicename))
+ index = i;
+ i++;
+ }
+ }
+ if (dev)
+ g_dir_close(dev);
+ if (i == 0) {
+ /* if we can't find anything, use the default */
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, "/dev/tty.SLAB_USBtoUART", -1);
+ if (is_default_dive_computer_device("/dev/tty.SLAB_USBtoUART"))
+ index = i;
+ }
+ return index;
}
const char *subsurface_icon_name()