OmPlrClipInfo clip_info;
char clip_name[omPlrMaxClipDirLen];
+ app->library.id_display_idx = 0;
+
pthread_mutex_lock(&app->players.lock);
r = OmPlrClipGetFirst((OmPlrHandle)app->players.item[0].handle, clip_name, sizeof(clip_name));
list[0] = list[0] + 1;
};
-static int* get_selected_items_playlist(omnplay_instance_t* app)
+int* omnplay_selected_idxs_playlist(omnplay_instance_t* app)
{
int* list = NULL;
GtkTreeSelection *selection;
static void omnplay_playlist_block(omnplay_instance_t* app, control_buttons_t button)
{
int start, stop, r, i;
- int* list = get_selected_items_playlist(app);
+ int* list = omnplay_selected_idxs_playlist(app);
if(!list)
return;
static int get_first_selected_item_playlist(omnplay_instance_t* app)
{
int idx;
- int* list = get_selected_items_playlist(app);
+ int* list = omnplay_selected_idxs_playlist(app);
if(!list) return -1;
idx = list[1];
free(list);
return NULL;
};
-static void omnplay_playlist_delete_items(omnplay_instance_t* app, int* idxs, int count)
+static void omnplay_playlist_delete_items(omnplay_instance_t* app, int* idxs, int count, int sel)
{
int i, j, idx;
- GtkTreePath* path;
pthread_mutex_lock(&app->playlist.lock);
pthread_mutex_lock(&app->players.lock);
omnplay_playlist_draw(app);
/* select */
- path = gtk_tree_path_new_from_indices(idxs[0], -1);
- gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid)), path);
- gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->playlist_grid), path, NULL, FALSE);
- gtk_tree_path_free(path);
-
+ if(sel)
+ {
+ GtkTreePath* path;
+ path = gtk_tree_path_new_from_indices(idxs[0], -1);
+ gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid)), path);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->playlist_grid), path, NULL, FALSE);
+ gtk_tree_path_free(path);
+ };
pthread_mutex_unlock(&app->players.lock);
pthread_mutex_unlock(&app->playlist.lock);
int i, idx, c;
int *list, *list2;
- list = get_selected_items_playlist(app);
+ list = omnplay_selected_idxs_playlist(app);
if(!list) return;
list2 = (int*)malloc(sizeof(int) * list[0]);
};
if(c)
- omnplay_playlist_delete_items(app, list2, c);
+ omnplay_playlist_delete_items(app, list2, c, 1);
free(list2);
free(list);
omnplay_playlist_draw(app);
/* select */
- path = gtk_tree_path_new_from_indices(idx + count, -1);
+ path = gtk_tree_path_new_from_indices(idx, -1);
gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid)), path);
gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->playlist_grid), path, NULL, FALSE);
gtk_tree_path_free(path);
{
int *list, i;
- list = get_selected_items_playlist(app);
+ list = omnplay_selected_idxs_playlist(app);
if(!list) return;
for(i = 0; i < list[0]; i++)
static void playlist_grid_drag_data_get_cb(GtkWidget *widget, GdkDragContext *context,
GtkSelectionData *selection_data, guint info, guint time, gpointer userdata)
{
- g_warning("playlist_grid_drag_data_get_cb");
+ int *list, i;
+ playlist_item_t* items;
+ omnplay_instance_t* app = (omnplay_instance_t*)userdata;
+
+ list = omnplay_selected_idxs_playlist(app);
+ if(!list) return;
+
+ /* clear delete flag */
+ for(i = 0; i < app->playlist.count; i++)
+ app->playlist.item[i].del = 0;
+
+ items = (playlist_item_t*)malloc(sizeof(playlist_item_t) * list[0]);
+ for(i = 0; i < list[0]; i++)
+ {
+ items[i] = app->playlist.item[list[i + 1]];
+ if(context->action == GDK_ACTION_MOVE)
+ app->playlist.item[list[i + 1]].del = 1;
+ }
+ gtk_selection_data_set(selection_data, selection_data->target, 8,
+ (const guchar *)items, sizeof(playlist_item_t) * list[0]);
+
+ free(items);
+ free(list);
};
static void library_grid_drag_begin_cb(GtkWidget *widget, GdkDragContext *context, gpointer userdata)
GtkTreePath *path = NULL;
omnplay_instance_t* app = (omnplay_instance_t*)userdata;
- g_warning("playlist_grid_drag_data_received");
+ g_warning("playlist_grid_drag_data_received: context->action=%d", context->action);
items = (playlist_item_t*)gtk_selection_data_get_data(selection_data);
c = gtk_selection_data_get_length(selection_data);
gtk_drag_finish(context, TRUE, FALSE, time);
};
+static void playlist_grid_drag_data_delete(GtkWidget *widget, GdkDragContext *context, gpointer userdata)
+{
+ int c, i, *list;
+ omnplay_instance_t* app = (omnplay_instance_t*)userdata;
+
+ g_warning("playlist_grid_drag_data_delete");
+
+ list = (int*)malloc(sizeof(int) * MAX_PLAYLIST_ITEMS);
+
+ for(i = 0, c = 0; i < app->playlist.count; i++)
+ if(app->playlist.item[i].del)
+ if(!idx_in_players_range(app, i))
+ {
+ /* save index */
+ list[c++] = i;
+ g_warning("playlist_grid_drag_data_delete: i=%d, c=%d", i, c);
+ };
+
+ if(c)
+ omnplay_playlist_delete_items(app, list, c, 0);
+
+ free(list);
+};
+
+/*
+ * http://www.mail-archive.com/mahogany-users@lists.sourceforge.net/msg00286.html
+ */
+static gboolean playlist_grid_drag_motion(GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, guint time, gpointer data)
+{
+ gboolean same;
+ GtkWidget *source_widget;
+
+ g_warning("playlist_grid_drag_motion");
+
+ /* Get source widget and check if it is the same as the
+ * destination widget.
+ */
+ source_widget = gtk_drag_get_source_widget(context);
+ same = ((source_widget == widget) ? TRUE : FALSE);
+
+ /* Put additional checks here, perhaps if same is FALSE then
+ * set the default drag to GDK_ACTION_COPY.
+ */
+
+ /* Say we just want to allow GDK_ACTION_MOVE, first we check
+ * if that is in the list of allowed actions on the dc. If
+ * so then we set it to that. Note if the user holds down the
+ * ctrl key then the only flag in dc->actions will be
+ * GDK_ACTION_COPY. The constraint for dc->actions is that
+ * specified from the given actions in gtk_drag_dest_set() and
+ * gtk_drag_source_set().
+ */
+ if(same)
+ {
+ if(context->actions == GDK_ACTION_MOVE)
+ gdk_drag_status(context, GDK_ACTION_COPY, time);
+ else
+ gdk_drag_status(context, GDK_ACTION_MOVE, time);
+ }
+ else
+ gdk_drag_status(context, context->actions, time);
+
+ return(TRUE);
+}
void omnplay_init(omnplay_instance_t* app)
{
gtk_drag_source_set(app->playlist_grid, GDK_BUTTON1_MASK,
drag_targets, 1, (GdkDragAction)(GDK_ACTION_COPY | GDK_ACTION_MOVE));
- gtk_drag_dest_set(app->playlist_grid, GTK_DEST_DEFAULT_ALL,
+ gtk_drag_dest_set(app->playlist_grid, (GtkDestDefaults)(GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP),
drag_targets, 1, (GdkDragAction)(GDK_ACTION_COPY | GDK_ACTION_MOVE));
g_signal_connect (app->library_grid, "drag_data_get", G_CALLBACK(library_grid_drag_data_get_cb), app);
g_signal_connect (app->library_grid, "drag_begin", G_CALLBACK(library_grid_drag_begin_cb), app);
g_signal_connect (app->playlist_grid, "drag_begin", G_CALLBACK(playlist_grid_drag_begin_cb), app);
g_signal_connect (app->playlist_grid, "drag_data_received", G_CALLBACK (playlist_grid_drag_data_received), app);
+ g_signal_connect (app->playlist_grid, "drag_data_delete", G_CALLBACK (playlist_grid_drag_data_delete), app);
+ g_signal_connect (app->playlist_grid, "drag_motion", G_CALLBACK (playlist_grid_drag_motion), app);
};
void omnplay_release(omnplay_instance_t* app)