add doubleclick support for grids
[omnplay] / src / omnplay.cpp
index 34b8d6d..5858d1d 100644 (file)
@@ -482,12 +482,16 @@ static void omnplay_playlist_delete_items(omnplay_instance_t* app, int* idxs, in
         idx = idxs[j] - j;
 
         /* fix block types */
-        if(idx)
-            app->playlist.item[idx - 1].type = (playlist_item_type_t)(app->playlist.item[idx - 1].type |
-                OMNPLAY_PLAYLIST_BLOCK_END);
-        if(idx + 1 < app->playlist.count)
-            app->playlist.item[idx + 1].type = (playlist_item_type_t)(app->playlist.item[idx + 1].type |
-                OMNPLAY_PLAYLIST_BLOCK_BEGIN);
+        if( app->playlist.item[idx].type != OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY &&
+            app->playlist.item[idx].type != OMNPLAY_PLAYLIST_ITEM_LOOP_BODY)
+        {
+            if(idx)
+                app->playlist.item[idx - 1].type = (playlist_item_type_t)(app->playlist.item[idx - 1].type |
+                    OMNPLAY_PLAYLIST_BLOCK_END);
+            if(idx + 1 < app->playlist.count)
+                app->playlist.item[idx + 1].type = (playlist_item_type_t)(app->playlist.item[idx + 1].type |
+                    OMNPLAY_PLAYLIST_BLOCK_BEGIN);
+        };
 
         /* shift playlist items */
         memmove
@@ -1152,6 +1156,28 @@ static gboolean on_library_grid_key(GtkWidget *widget, GdkEventKey *event, gpoin
     return FALSE;
 };
 
+static gboolean on_library_grid_button(GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+    if(event->button==1 && event->type==GDK_2BUTTON_PRESS)
+    {
+        omnplay_library_add((omnplay_instance_t* )data, 0);
+        return TRUE;
+    };
+
+    return FALSE;
+};
+
+static gboolean on_playlist_grid_button(GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+    if(event->button==1 && event->type==GDK_2BUTTON_PRESS)
+    {
+        omnplay_ctl((omnplay_instance_t* )data, BUTTON_PLAYER_CUE);
+        return TRUE;
+    };
+
+    return FALSE;
+};
+
 void omnplay_init(omnplay_instance_t* app)
 {
     int i;
@@ -1173,6 +1199,12 @@ void omnplay_init(omnplay_instance_t* app)
     gtk_signal_connect(GTK_OBJECT(app->library_grid), "key-press-event",
         GTK_SIGNAL_FUNC(on_library_grid_key), app);
 
+    gtk_signal_connect(GTK_OBJECT(app->playlist_grid), "button-press-event",
+        GTK_SIGNAL_FUNC(on_playlist_grid_button), app);
+
+    gtk_signal_connect(GTK_OBJECT(app->library_grid), "button-press-event",
+        GTK_SIGNAL_FUNC(on_library_grid_button), app);
+
     /* create lock */
     pthread_mutex_init(&app->players.lock, &attr);