static void omnplay_playlist_item_swap(omnplay_instance_t* app, int dir)
{
- int sel, a, b;
+ int sel, a, b, e = 1;
GtkTreePath* path;
playlist_item_t item;
app->playlist.item[b] = item;
/* rewite type */
- app->playlist.item[a].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE;
- app->playlist.item[b].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE;
+ if(app->playlist.item[a].type != app->playlist.item[b].type)
+ {
+ e = 0;
+ app->playlist.item[a].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE;
+ app->playlist.item[b].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE;
+ };
/* redraw main items */
omnplay_playlist_draw_item(app, a);
omnplay_playlist_draw_item(app, b);
/* fix block types */
- if(a)
+ if(a && !e)
{
app->playlist.item[a - 1].type = (playlist_item_type_t)(app->playlist.item[a - 1].type |
OMNPLAY_PLAYLIST_BLOCK_END);
omnplay_playlist_draw_item(app, a - 1);
};
- if(b + 1 < app->playlist.count)
+ if(b + 1 < app->playlist.count && !e)
{
app->playlist.item[b + 1].type = (playlist_item_type_t)(app->playlist.item[b + 1].type |
OMNPLAY_PLAYLIST_BLOCK_BEGIN);
pthread_mutex_unlock(&app->playlist.lock);
};
+static void omnplay_library_add(omnplay_instance_t* app, int after)
+{
+ int idx, c, i;
+ playlist_item_t* items;
+ playlist_item_type_t t;
+
+ /* find insert position */
+ idx = get_first_selected_item_playlist(app);
+ if(idx < 0)
+ idx = 0;
+ else
+ idx += (after)?1:0;
+
+ if(!omnplay_playlist_insert_check(app, idx, &t))
+ return;
+
+ items = omnplay_library_get_selected(app, &c);
+
+ /* clear item */
+ if(items)
+ {
+ for(i = 0; i < c; i++)
+ {
+ items[i].type = t;
+ items[i].error = 0;
+ };
+ omnplay_playlist_insert_items(app, idx, items, c);
+ };
+};
+
+
static gboolean omnplay_button_click(omnplay_instance_t* app, control_buttons_t button)
{
switch(button)
omnplay_ctl(app, button);
break;
case BUTTON_LIBRARY_ADD:
+ omnplay_library_add(app, 0);
break;
case BUTTON_LIBRARY_REFRESH:
omnplay_library_refresh(app);
return TRUE;
};
break;
+ case GDK_S:
+ case GDK_s:
+ if(event->state & GDK_CONTROL_MASK)
+ {
+ omnplay_playlist_save(app);
+ return TRUE;
+ };
+ break;
+ case GDK_O:
+ case GDK_o:
+ if(event->state & GDK_CONTROL_MASK)
+ {
+ omnplay_playlist_load(app);
+ return TRUE;
+ };
+ break;
case GDK_KEY_space:
omnplay_ctl(app, BUTTON_PLAYER_PLAY);
return TRUE;
/* destroy library lock */
pthread_mutex_destroy(&app->library.lock);
};
+
+void omnplay_playlist_normalize(omnplay_instance_t* app)
+{
+ int i;
+
+ /* normalize playlist */
+ for(i = 0; i < app->playlist.count; i++)
+ if(omnplay_library_normalize_item(app, &app->playlist.item[i]))
+ omnplay_playlist_draw_item(app, i);
+};