Use te device mounted flag to decide what to do
authorMikko Rasa <tdb@tdb.fi>
Sat, 29 Aug 2015 16:01:20 +0000 (19:01 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 29 Aug 2015 16:01:20 +0000 (19:01 +0300)
main.c

diff --git a/main.c b/main.c
index ae08cbb7cda87de794b03d673e40a6de691e721e..26dbca32f208a84be2832d8f7c61a0191cc4e886 100644 (file)
--- a/main.c
+++ b/main.c
@@ -621,7 +621,7 @@ void row_activated(GtkTreeView *list, GtkTreePath *path, GtkTreeViewColumn *colu
 {
        GtkTreeModel *model;
        GtkTreeIter iter;
-       int umount = *(int *)user_data;
+       int umount;
        char buf[1024];
        int pos = 0;
        int status = 0;
@@ -637,6 +637,7 @@ void row_activated(GtkTreeView *list, GtkTreePath *path, GtkTreeViewColumn *colu
                return;
 
        gtk_tree_model_get(model, &iter, 1, &device, -1);
+       umount = !!device->mounted;
 
        pipe(pipe_fd);
 
@@ -749,6 +750,7 @@ void row_activated(GtkTreeView *list, GtkTreePath *path, GtkTreeViewColumn *colu
        }
 
        (void)column;
+       (void)user_data;
 }
 
 /**
@@ -850,7 +852,7 @@ int main(int argc, char **argv)
 
        list = gtk_tree_view_new();
        gtk_container_add(GTK_CONTAINER(viewport), list);
-       g_signal_connect(list, "row-activated", G_CALLBACK(&row_activated), &umount);
+       g_signal_connect(list, "row-activated", G_CALLBACK(&row_activated), NULL);
 
        store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
        gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(store));