diff --git a/plugins/cocoaui/Undo/DdbUndoBuffer.h b/plugins/cocoaui/Undo/DdbUndoBuffer.h index 9392b66ee5..9493597db3 100644 --- a/plugins/cocoaui/Undo/DdbUndoBuffer.h +++ b/plugins/cocoaui/Undo/DdbUndoBuffer.h @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN @interface DdbUndoBuffer : NSObject -- (instancetype)initWithUndoBuffer:(undobuffer_t *)buffer; +- (instancetype)initWithUndoBuffer:(ddb_undobuffer_t *)buffer; - (void)apply; @end diff --git a/plugins/cocoaui/Undo/DdbUndoBuffer.m b/plugins/cocoaui/Undo/DdbUndoBuffer.m index efe9a76364..2b09032da8 100644 --- a/plugins/cocoaui/Undo/DdbUndoBuffer.m +++ b/plugins/cocoaui/Undo/DdbUndoBuffer.m @@ -29,24 +29,24 @@ @interface DdbUndoBuffer() -@property (nonatomic) undobuffer_t *buffer; +@property (nonatomic) ddb_undobuffer_t *buffer; @end @implementation DdbUndoBuffer - (void)dealloc { - undobuffer_free (_buffer); + ddb_undobuffer_free (_buffer); } -- (instancetype)initWithUndoBuffer:(undobuffer_t *)buffer { +- (instancetype)initWithUndoBuffer:(ddb_undobuffer_t *)buffer { self = [super init]; _buffer = buffer; return self; } - (void)apply { - undobuffer_execute(self.buffer, undomanager_get_buffer(undomanager_shared())); + ddb_undobuffer_execute(self.buffer, ddb_undomanager_get_buffer(ddb_undomanager_shared())); deadbeef->sendmessage(DB_EV_PLAYLISTCHANGED, 0, 0, 0); } diff --git a/plugins/cocoaui/Undo/NSUndoManager+DdbUndoBuffer.m b/plugins/cocoaui/Undo/NSUndoManager+DdbUndoBuffer.m index cae7b9c8ae..e71c57142c 100644 --- a/plugins/cocoaui/Undo/NSUndoManager+DdbUndoBuffer.m +++ b/plugins/cocoaui/Undo/NSUndoManager+DdbUndoBuffer.m @@ -41,7 +41,7 @@ - (void)registerUndoBuffer:(DdbUndoBuffer *)undoBuffer { [target apply]; [DdbUndoBufferRetainer.shared releaseBuffer:target]; - undobuffer_t *undobuffer = undomanager_consume_buffer(undomanager_shared()); + ddb_undobuffer_t *undobuffer = ddb_undomanager_consume_buffer(ddb_undomanager_shared()); DdbUndoBuffer *wrappedBuffer = [[DdbUndoBuffer alloc] initWithUndoBuffer:undobuffer]; [self registerUndoBuffer:wrappedBuffer]; }]; diff --git a/plugins/cocoaui/main.m b/plugins/cocoaui/main.m index d278cd9aa5..df8089ac78 100644 --- a/plugins/cocoaui/main.m +++ b/plugins/cocoaui/main.m @@ -53,7 +53,7 @@ int cocoaui_command (int command, ...) { // register undo va_list args; va_start(args, command); - undobuffer_t *undobuffer = va_arg(args, undobuffer_t *); + ddb_undobuffer_t *undobuffer = va_arg(args, ddb_undobuffer_t *); const char *name = va_arg(args, const char *); va_end(args); diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c index edda03c07b..2bf59a3078 100644 --- a/plugins/gtkui/fileman.c +++ b/plugins/gtkui/fileman.c @@ -91,7 +91,7 @@ gtkui_add_dirs (GSList *lst) { gtkui_dispatch_on_main(^{ ddb_playItem_t *tail = deadbeef->plt_get_tail_item(plt_curr, PL_MAIN); - deadbeef->undo_set_action_name ("Add Folders"); + deadbeef->undo_set_action_name (_("Add Folders")); deadbeef->plt_move_all_items (plt_curr, plt, tail); if (tail != NULL) { deadbeef->pl_item_unref (tail); @@ -122,7 +122,7 @@ gtkui_add_files (struct _GSList *lst) { gtkpl_add_files (plt, lst); gtkui_dispatch_on_main (^{ ddb_playItem_t *tail = deadbeef->plt_get_tail_item (plt_curr, PL_MAIN); - deadbeef->undo_set_action_name ("Add Files"); + deadbeef->undo_set_action_name (_("Add Files")); deadbeef->plt_move_all_items (plt_curr, plt, tail); if (tail != NULL) { deadbeef->pl_item_unref (tail); @@ -194,13 +194,13 @@ gtkui_add_location (const char *path, const char *custom_title) { } ddb_playItem_t *tail = deadbeef->plt_get_tail_item (plt_curr, PL_MAIN); - deadbeef->undo_set_action_name ("Add Files"); deadbeef->plt_move_all_items (plt_curr, plt, tail); if (tail != NULL) { deadbeef->pl_item_unref (tail); } deadbeef->plt_save_config (plt_curr); + deadbeef->undo_set_action_name(_("Add Location")); deadbeef->plt_add_files_end (plt, 0); free (path_copy); @@ -254,28 +254,18 @@ strcopy_special (char *dest, const char *src, int len) { *dest = 0; } -static gboolean -set_dnd_cursor_idle (gpointer data) { - if (!data) { +static void +set_dnd_cursor (ddb_playItem_t *first) { + if (first == NULL) { deadbeef->pl_set_cursor (PL_MAIN, -1); - deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0); - return FALSE; + return; } - int cursor = deadbeef->pl_get_idx_of (DB_PLAYITEM (data)); + int cursor = deadbeef->pl_get_idx_of (first); deadbeef->pl_set_cursor (PL_MAIN, cursor); - deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0); - return FALSE; } -void -gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) { - ddb_playlist_t *plt = deadbeef->plt_get_curr (); - if (deadbeef->plt_add_files_begin (plt, 0) < 0) { - free (ptr); - deadbeef->plt_unref (plt); - return; - } - +static ddb_playItem_t * +gtkpl_add_fm_dropped_files (ddb_playlist_t *plt, DB_playItem_t *drop_before, const char *ptr, int length) { DdbListviewIter first = NULL; DdbListviewIter after = NULL; if (drop_before) { @@ -293,8 +283,6 @@ gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) { if (pe - p < 4096 && pe - p > 7) { char fname[(int)(pe - p)+1]; strcopy_special (fname, (const char *)p, (int)(pe-p)); - //strncpy (fname, p, pe - p); - //fname[pe - p] = 0; int abort = 0; DdbListviewIter inserted = deadbeef->plt_insert_dir2 (0, plt, after, fname, &abort, NULL, NULL); if (!inserted && !abort) { @@ -323,12 +311,11 @@ gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) { if (after) { deadbeef->pl_item_unref (after); } - free (ptr); - deadbeef->plt_add_files_end (plt, 0); - deadbeef->plt_save_config (plt); - deadbeef->plt_unref (plt); - g_idle_add (set_dnd_cursor_idle, first); + if (first != NULL) { + deadbeef->pl_item_ref (first); + } + return first; } struct fmdrop_data { @@ -339,11 +326,7 @@ struct fmdrop_data { void gtkui_receive_fm_drop (DB_playItem_t *before, char *mem, int length) { - struct fmdrop_data *data = malloc (sizeof (struct fmdrop_data)); - if (!data) { - fprintf (stderr, "gtkui_receive_fm_drop: malloc failed\n"); - return; - } + struct fmdrop_data *data = calloc (1, sizeof (struct fmdrop_data)); data->mem = mem; data->length = length; if (before) { @@ -351,12 +334,47 @@ gtkui_receive_fm_drop (DB_playItem_t *before, char *mem, int length) { } data->drop_before = before; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - gtkpl_add_fm_dropped_files (data->drop_before, data->mem, data->length); + ddb_playlist_t *plt = deadbeef->plt_alloc ("receive-drag-drop"); + ddb_playlist_t *plt_curr = deadbeef->plt_get_curr (); + + if (deadbeef->plt_add_files_begin (plt, 0) < 0) { if (data->drop_before) { deadbeef->pl_item_unref (data->drop_before); } + free (mem); free (data); + deadbeef->plt_unref (plt); + deadbeef->plt_unref (plt_curr); + return; + } + + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + ddb_playItem_t *first = gtkpl_add_fm_dropped_files (plt, data->drop_before, data->mem, data->length); + + gtkui_dispatch_on_main(^{ + ddb_playItem_t *tail = deadbeef->plt_get_tail_item(plt_curr, PL_MAIN); + deadbeef->undo_set_action_name(_("Drag & Drop")); + deadbeef->plt_move_all_items (plt_curr, plt, tail); + if (tail != NULL) { + deadbeef->pl_item_unref (tail); + } + + deadbeef->plt_save_config (plt_curr); + deadbeef->plt_add_files_end (plt, 0); + set_dnd_cursor (first); + + if (first != NULL) { + deadbeef->pl_item_unref (first); + } + if (data->drop_before) { + deadbeef->pl_item_unref (data->drop_before); + } + free (mem); + free (data); + deadbeef->plt_unref (plt); + deadbeef->plt_unref (plt_curr); + }); }); } diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index e9b9cfb6e2..6994dec176 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -2314,10 +2314,10 @@ int _gtkui_command (int command, ...) { if (command == 110) { // init with undomanager va_list args; va_start (args, command); - undomanager_t *undomanager = va_arg (args, undomanager_t *); + ddb_undomanager_t *undomanager = va_arg (args, ddb_undomanager_t *); va_end (args); - undomanager_shared_init (undomanager); + ddb_undomanager_shared_init (undomanager); return 0; } @@ -2326,7 +2326,7 @@ int _gtkui_command (int command, ...) { // register undo buffer va_list args; va_start (args, command); - undobuffer_t *undobuffer = va_arg (args, undobuffer_t *); + ddb_undobuffer_t *undobuffer = va_arg (args, ddb_undobuffer_t *); const char *name = va_arg (args, const char *); va_end (args); diff --git a/plugins/gtkui/undo.c b/plugins/gtkui/undo.c index 435ce87317..69cff79fa9 100644 --- a/plugins/gtkui/undo.c +++ b/plugins/gtkui/undo.c @@ -35,7 +35,7 @@ typedef struct undo_item_s undo_item_t; struct undo_item_s { char *action_name; - undobuffer_t *undobuffer; + ddb_undobuffer_t *undobuffer; undo_item_t *prev; undo_item_t *next; }; @@ -60,7 +60,7 @@ static undo_state_t _state; static void _free_item (undo_item_t *item) { - undobuffer_free(item->undobuffer); + ddb_undobuffer_free(item->undobuffer); free (item->action_name); free (item); } @@ -106,7 +106,7 @@ _pop_last (undo_item_t **head, undo_item_t **tail) { } void -gtkui_undo_append_buffer (undobuffer_t *undobuffer, const char *action_name) { +gtkui_undo_append_buffer (ddb_undobuffer_t *undobuffer, const char *action_name) { if (_state.type == none) { // discard all redo operations _free_item_list (_state.redo_head); @@ -147,15 +147,15 @@ _perform_undo_redo (undo_type_t type) { return; } - undomanager_t *undomanager = undomanager_shared (); - undobuffer_t *new_buffer = undomanager_get_buffer (undomanager); + ddb_undomanager_t *undomanager = ddb_undomanager_shared (); + ddb_undobuffer_t *new_buffer = ddb_undomanager_get_buffer (undomanager); // pop last undo item and execute in undo mode _pop_last (head, tail); _state.type = type; - undobuffer_execute(item->undobuffer, new_buffer); - undomanager_set_action_name(undomanager, item->action_name); + ddb_undobuffer_execute(item->undobuffer, new_buffer); + ddb_undomanager_set_action_name(undomanager, item->action_name); deadbeef->undo_process(); _free_item (item); _state.type = none; diff --git a/plugins/gtkui/undo.h b/plugins/gtkui/undo.h index 6741ab373d..0e66234272 100644 --- a/plugins/gtkui/undo.h +++ b/plugins/gtkui/undo.h @@ -30,7 +30,7 @@ void gtkui_undo_deinit (void); void -gtkui_undo_append_buffer (undobuffer_t *undobuffer, const char *action_name); +gtkui_undo_append_buffer (ddb_undobuffer_t *undobuffer, const char *action_name); void gtkui_perform_undo (void); diff --git a/shared/undo/undobuffer.c b/shared/undo/undobuffer.c index 80402467ed..685487b9db 100644 --- a/shared/undo/undobuffer.c +++ b/shared/undo/undobuffer.c @@ -25,23 +25,23 @@ #include #include "undobuffer.h" -struct _undobuffer_s { - undo_operation_t *operations; +struct _ddb_undobuffer_s { + ddb_undo_operation_t *operations; int enabled; int grouping; }; -undobuffer_t * -undobuffer_alloc(void) { - undobuffer_t *undobuffer = calloc (1, sizeof (undobuffer_t)); +ddb_undobuffer_t * +ddb_undobuffer_alloc(void) { + ddb_undobuffer_t *undobuffer = calloc (1, sizeof (ddb_undobuffer_t)); undobuffer->enabled = 1; return undobuffer; } static void -_undobuffer_free_operations(undobuffer_t *undobuffer, undo_operation_t **operations) { - for (undo_operation_t *op = *operations; op;) { - undo_operation_t *next = op->next; +_undobuffer_free_operations(ddb_undobuffer_t *undobuffer, ddb_undo_operation_t **operations) { + for (ddb_undo_operation_t *op = *operations; op;) { + ddb_undo_operation_t *next = op->next; if (op->deinit) { op->deinit (op); @@ -55,35 +55,35 @@ _undobuffer_free_operations(undobuffer_t *undobuffer, undo_operation_t **operati } void -undobuffer_free (undobuffer_t *undobuffer) { +ddb_undobuffer_free (ddb_undobuffer_t *undobuffer) { _undobuffer_free_operations(undobuffer, &undobuffer->operations); free (undobuffer); } void -undobuffer_set_enabled (undobuffer_t *undobuffer, int enabled) { +ddb_undobuffer_set_enabled (ddb_undobuffer_t *undobuffer, int enabled) { undobuffer->enabled = enabled; } int -undobuffer_is_enabled (undobuffer_t *undobuffer) { +ddb_undobuffer_is_enabled (ddb_undobuffer_t *undobuffer) { return undobuffer->enabled; } static void -_undobuffer_append_operation(undobuffer_t *undobuffer, undo_operation_t *op, undo_operation_t **operations) { +_undobuffer_append_operation(ddb_undobuffer_t *undobuffer, ddb_undo_operation_t *op, ddb_undo_operation_t **operations) { op->next = *operations; *operations = op; } void -undobuffer_append_operation (undobuffer_t *undobuffer, undo_operation_t *op) { +ddb_undobuffer_append_operation (ddb_undobuffer_t *undobuffer, ddb_undo_operation_t *op) { _undobuffer_append_operation(undobuffer, op, &undobuffer->operations); } void -undobuffer_execute (undobuffer_t *undobuffer, undobuffer_t *current_undobuffer) { - for (undo_operation_t *op = undobuffer->operations; op != NULL; op = op->next) { +ddb_undobuffer_execute (ddb_undobuffer_t *undobuffer, ddb_undobuffer_t *current_undobuffer) { + for (ddb_undo_operation_t *op = undobuffer->operations; op != NULL; op = op->next) { if (op->perform != NULL) { op->perform(current_undobuffer, op); } @@ -91,26 +91,26 @@ undobuffer_execute (undobuffer_t *undobuffer, undobuffer_t *current_undobuffer) } int -undobuffer_has_operations(undobuffer_t *undobuffer) { +ddb_undobuffer_has_operations(ddb_undobuffer_t *undobuffer) { return undobuffer->operations != NULL; } void -undobuffer_group_begin (undobuffer_t *undobuffer) { +ddb_undobuffer_group_begin (ddb_undobuffer_t *undobuffer) { undobuffer->grouping = 1; } void -undobuffer_group_end (undobuffer_t *undobuffer) { +ddb_undobuffer_group_end (ddb_undobuffer_t *undobuffer) { undobuffer->grouping = 0; } int -undobuffer_is_grouping (undobuffer_t *undobuffer) { +ddb_undobuffer_is_grouping (ddb_undobuffer_t *undobuffer) { return undobuffer->grouping; } -undo_operation_t * -undobuffer_get_current_operation (undobuffer_t *undobuffer) { +ddb_undo_operation_t * +ddb_undobuffer_get_current_operation (ddb_undobuffer_t *undobuffer) { return undobuffer->grouping ? undobuffer->operations : NULL; } diff --git a/shared/undo/undobuffer.h b/shared/undo/undobuffer.h index dd1cb6b480..d6b3117361 100644 --- a/shared/undo/undobuffer.h +++ b/shared/undo/undobuffer.h @@ -23,56 +23,56 @@ -#ifndef undobuffer_h -#define undobuffer_h +#ifndef ddb_undobuffer_h +#define ddb_undobuffer_h -struct _undobuffer_s; +struct _ddb_undobuffer_s; -typedef struct _undobuffer_s undobuffer_t; +typedef struct _ddb_undobuffer_s ddb_undobuffer_t; -struct undo_operation_s; -typedef void (*undo_operation_perform_fn)(undobuffer_t *undobuffer, struct undo_operation_s *op); -typedef void (*undo_operation_deinit_fn)(struct undo_operation_s *op); +struct ddb_undo_operation_s; +typedef void (*ddb_undo_operation_perform_fn)(ddb_undobuffer_t *undobuffer, struct ddb_undo_operation_s *op); +typedef void (*ddb_undo_operation_deinit_fn)(struct ddb_undo_operation_s *op); -typedef struct undo_operation_s { - struct undo_operation_s *next; - undo_operation_perform_fn perform; - undo_operation_deinit_fn deinit; -} undo_operation_t; +typedef struct ddb_undo_operation_s { + struct ddb_undo_operation_s *next; + ddb_undo_operation_perform_fn perform; + ddb_undo_operation_deinit_fn deinit; +} ddb_undo_operation_t; -undobuffer_t * -undobuffer_alloc(void); +ddb_undobuffer_t * +ddb_undobuffer_alloc(void); void -undobuffer_free (undobuffer_t *undobuffer); +ddb_undobuffer_free (ddb_undobuffer_t *undobuffer); void -undobuffer_set_enabled (undobuffer_t *undobuffer, int enabled); +ddb_undobuffer_set_enabled (ddb_undobuffer_t *undobuffer, int enabled); int -undobuffer_is_enabled (undobuffer_t *undobuffer); +ddb_undobuffer_is_enabled (ddb_undobuffer_t *undobuffer); void -undobuffer_group_begin (undobuffer_t *undobuffer); +ddb_undobuffer_group_begin (ddb_undobuffer_t *undobuffer); void -undobuffer_group_end (undobuffer_t *undobuffer); +ddb_undobuffer_group_end (ddb_undobuffer_t *undobuffer); int -undobuffer_is_grouping (undobuffer_t *undobuffer); +ddb_undobuffer_is_grouping (ddb_undobuffer_t *undobuffer); -undo_operation_t * -undobuffer_get_current_operation (undobuffer_t *undobuffer); +ddb_undo_operation_t * +ddb_undobuffer_get_current_operation (ddb_undobuffer_t *undobuffer); void -undobuffer_append_operation (undobuffer_t *undobuffer, undo_operation_t *op); +ddb_undobuffer_append_operation (ddb_undobuffer_t *undobuffer, ddb_undo_operation_t *op); /// @param undobuffer the buffer to execute /// @param current_undobuffer the current buffer to register the resulting undo operations void -undobuffer_execute (undobuffer_t *undobuffer, undobuffer_t *current_undobuffer); +ddb_undobuffer_execute (ddb_undobuffer_t *undobuffer, ddb_undobuffer_t *current_undobuffer); int -undobuffer_has_operations(undobuffer_t *undobuffer); +ddb_undobuffer_has_operations(ddb_undobuffer_t *undobuffer); -#endif /* undobuffer_h */ +#endif /* ddb_undobuffer_h */ diff --git a/shared/undo/undomanager.c b/shared/undo/undomanager.c index 1cab4a7f05..16a5410583 100644 --- a/shared/undo/undomanager.c +++ b/shared/undo/undomanager.c @@ -25,70 +25,70 @@ #include #include "undomanager.h" -struct undomanager_s { - undobuffer_t *buffer; +struct ddb_undomanager_s { + ddb_undobuffer_t *buffer; char *action_name; }; -static undomanager_t *_shared; +static ddb_undomanager_t *_shared; -undomanager_t * -undomanager_alloc (void) { - undomanager_t *undomanager = calloc (1, sizeof (undomanager_t)); - undomanager->buffer = undobuffer_alloc(); +ddb_undomanager_t * +ddb_undomanager_alloc (void) { + ddb_undomanager_t *undomanager = calloc (1, sizeof (ddb_undomanager_t)); + undomanager->buffer = ddb_undobuffer_alloc(); return undomanager; } void -undomanager_free (undomanager_t *undomanager) { +ddb_undomanager_free (ddb_undomanager_t *undomanager) { if (undomanager == _shared) { _shared = NULL; } free (undomanager->action_name); if (undomanager->buffer != NULL) { - undobuffer_free(undomanager->buffer); + ddb_undobuffer_free(undomanager->buffer); } free (undomanager); } -undomanager_t * -undomanager_shared (void) { +ddb_undomanager_t * +ddb_undomanager_shared (void) { return _shared; } void -undomanager_shared_init (undomanager_t *undomanager) { +ddb_undomanager_shared_init (ddb_undomanager_t *undomanager) { if (undomanager == NULL) { - _shared = undomanager_alloc (); + _shared = ddb_undomanager_alloc (); } else { _shared = undomanager; } } -undobuffer_t * -undomanager_get_buffer (undomanager_t *undomanager) { +ddb_undobuffer_t * +ddb_undomanager_get_buffer (ddb_undomanager_t *undomanager) { if (undomanager == NULL) { return NULL; } return undomanager->buffer; } -undobuffer_t * -undomanager_consume_buffer (undomanager_t *undomanager) { - undobuffer_t *buffer = undomanager->buffer; - undomanager->buffer = undobuffer_alloc(); +ddb_undobuffer_t * +ddb_undomanager_consume_buffer (ddb_undomanager_t *undomanager) { + ddb_undobuffer_t *buffer = undomanager->buffer; + undomanager->buffer = ddb_undobuffer_alloc(); return buffer; } void -undomanager_set_action_name (undomanager_t *undomanager, const char *name) { +ddb_undomanager_set_action_name (ddb_undomanager_t *undomanager, const char *name) { free (undomanager->action_name); undomanager->action_name = name ? strdup (name) : NULL; } const char * -undomanager_get_action_name (undomanager_t *undomanager) { +ddb_undomanager_get_action_name (ddb_undomanager_t *undomanager) { return undomanager->action_name; } diff --git a/shared/undo/undomanager.h b/shared/undo/undomanager.h index a368a57e5b..5aab46ba55 100644 --- a/shared/undo/undomanager.h +++ b/shared/undo/undomanager.h @@ -21,40 +21,39 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifndef undomanager_h -#define undomanager_h +#ifndef ddb_undomanager_h +#define ddb_undomanager_h #include "undobuffer.h" -struct undomanager_s; +struct ddb_undomanager_s; -typedef struct undomanager_s undomanager_t; +typedef struct ddb_undomanager_s ddb_undomanager_t; -undomanager_t * -undomanager_alloc (void); +ddb_undomanager_t * +ddb_undomanager_alloc (void); void -undomanager_free (undomanager_t *undomanager); +ddb_undomanager_free (ddb_undomanager_t *undomanager); -undobuffer_t * -undomanager_get_buffer (undomanager_t *undomanager); +ddb_undobuffer_t * +ddb_undomanager_get_buffer (ddb_undomanager_t *undomanager); -undobuffer_t * -undomanager_consume_buffer (undomanager_t *undomanager); +ddb_undobuffer_t * +ddb_undomanager_consume_buffer (ddb_undomanager_t *undomanager); void -undomanager_set_action_name (undomanager_t *undomanager, const char *name); +ddb_undomanager_set_action_name (ddb_undomanager_t *undomanager, const char *name); const char * -undomanager_get_action_name (undomanager_t *undomanager); - +ddb_undomanager_get_action_name (ddb_undomanager_t *undomanager); #pragma mark - Shared instance -undomanager_t * -undomanager_shared (void); +ddb_undomanager_t * +ddb_undomanager_shared (void); void -undomanager_shared_init (undomanager_t *undomanager); +ddb_undomanager_shared_init (ddb_undomanager_t *undomanager); -#endif /* undomanager_h */ +#endif /* ddb_undomanager_h */ diff --git a/src/main.c b/src/main.c index d7b8f68b26..61cccde12d 100644 --- a/src/main.c +++ b/src/main.c @@ -1106,7 +1106,7 @@ main_cleanup_and_quit (void) { scriptableDeinitShared (); #endif - undomanager_free(undomanager_shared()); + ddb_undomanager_free(ddb_undomanager_shared()); pl_free (); // may access conf_* conf_free (); @@ -1578,7 +1578,7 @@ main (int argc, char *argv[]) { streamer_playmodes_init (); - undomanager_shared_init (NULL); + ddb_undomanager_shared_init (NULL); pl_load_all (); diff --git a/src/playlist.c b/src/playlist.c index e3a4a61a5b..509fe900eb 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -1644,7 +1644,7 @@ plt_remove_item (playlist_t *playlist, playItem_t *it) { // remove from both lists LOCK; - undo_remove_items(undomanager_get_buffer(undomanager_shared()), playlist, &it, 1); + undo_remove_items(ddb_undomanager_get_buffer(ddb_undomanager_shared()), playlist, &it, 1); for (int iter = PL_MAIN; iter <= PL_SEARCH; iter++) { if (it->prev[iter] || it->next[iter] || playlist->head[iter] == it || playlist->tail[iter] == it) { @@ -1797,7 +1797,7 @@ pl_get_idx_of_iter (playItem_t *it, int iter) { playItem_t * plt_insert_item (playlist_t *playlist, playItem_t *after, playItem_t *it) { LOCK; - undo_insert_items(undomanager_get_buffer(undomanager_shared()), playlist, &it, 1); + undo_insert_items(ddb_undomanager_get_buffer(ddb_undomanager_shared()), playlist, &it, 1); pl_item_ref (it); if (!after) { it->next[PL_MAIN] = playlist->head[PL_MAIN]; @@ -1948,12 +1948,12 @@ plt_delete_selected (playlist_t *playlist) { } UNLOCK; - undobuffer_group_begin (undomanager_get_buffer (undomanager_shared ())); + ddb_undobuffer_group_begin (ddb_undomanager_get_buffer (ddb_undomanager_shared ())); for (i = 0; i < count; i++) { plt_remove_item (playlist, items_to_delete[i]); pl_item_unref (items_to_delete[i]); } - undobuffer_group_end (undomanager_get_buffer (undomanager_shared ())); + ddb_undobuffer_group_end (ddb_undomanager_get_buffer (ddb_undomanager_shared ())); free (items_to_delete); LOCK; @@ -3693,7 +3693,7 @@ plt_move_all_items (playlist_t *to, playlist_t *from, playItem_t *insert_after) LOCK; playItem_t *it = from->head[PL_MAIN]; pl_item_ref(it); - undobuffer_group_begin (undomanager_get_buffer (undomanager_shared ())); + ddb_undobuffer_group_begin (ddb_undomanager_get_buffer (ddb_undomanager_shared ())); while (it != NULL) { playItem_t *next = it->next[PL_MAIN]; if (next != NULL) { @@ -3706,7 +3706,7 @@ plt_move_all_items (playlist_t *to, playlist_t *from, playItem_t *insert_after) pl_item_unref (it); it = next; } - undobuffer_group_end (undomanager_get_buffer (undomanager_shared ())); + ddb_undobuffer_group_end (ddb_undomanager_get_buffer (ddb_undomanager_shared ())); UNLOCK; } diff --git a/src/plugins.c b/src/plugins.c index 0567df85dd..8a9c594cae 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -155,29 +155,29 @@ _plug_get_gui (void) { static void _undo_process(void) { - undomanager_t *undomanager = undomanager_shared(); + ddb_undomanager_t *undomanager = ddb_undomanager_shared(); DB_plugin_t *ui_plugin = _plug_get_gui (); - undobuffer_t *undobuffer = undomanager_consume_buffer (undomanager); + ddb_undobuffer_t *undobuffer = ddb_undomanager_consume_buffer (undomanager); int has_ui_command = ui_plugin != NULL && ui_plugin->command != NULL; int res = -1; - if (undobuffer_has_operations (undobuffer) && has_ui_command) { + if (ddb_undobuffer_has_operations (undobuffer) && has_ui_command) { ui_plugin->command (110, undomanager); - res = ui_plugin->command (111, undobuffer, undomanager_get_action_name (undomanager)); + res = ui_plugin->command (111, undobuffer, ddb_undomanager_get_action_name (undomanager)); } if (res != 0) { - undobuffer_free (undobuffer); + ddb_undobuffer_free (undobuffer); } - undomanager_set_action_name (undomanager, NULL); + ddb_undomanager_set_action_name (undomanager, NULL); } static void _undo_set_action_name (const char *name) { - undomanager_set_action_name (undomanager_shared(), name); + ddb_undomanager_set_action_name (ddb_undomanager_shared(), name); } diff --git a/src/undo/undo_playlist.c b/src/undo/undo_playlist.c index 97c0e54fe7..2ba121a03b 100644 --- a/src/undo/undo_playlist.c +++ b/src/undo/undo_playlist.c @@ -31,7 +31,7 @@ // The list of items is required to be contiguous in the target playlist. // ChangeSelection operations are registered automatically before registering Insert or Remove, only when undobuffer is empty. typedef struct { - undo_operation_t _super; + ddb_undo_operation_t _super; playlist_t *plt; playItem_t **items; playItem_t *insert_position; // insert after this item @@ -43,7 +43,7 @@ typedef struct { } undo_operation_item_list_t; void -undo_change_selection(undobuffer_t *undobuffer, playlist_t *plt); +undo_change_selection(ddb_undobuffer_t *undobuffer, playlist_t *plt); static void _undo_operation_item_list_deinit(undo_operation_item_list_t *op) { @@ -58,7 +58,7 @@ _undo_operation_item_list_deinit(undo_operation_item_list_t *op) { } static undo_operation_item_list_t * -_undo_operation_item_list_new(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count, int copy) { +_undo_operation_item_list_new(ddb_undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count, int copy) { undo_operation_item_list_t *op = calloc (1, sizeof (undo_operation_item_list_t)); op->count = count; plt_ref(plt); @@ -73,34 +73,34 @@ _undo_operation_item_list_new(undobuffer_t *undobuffer, playlist_t *plt, playIte else { op->items = items; } - op->_super.deinit = (undo_operation_deinit_fn)_undo_operation_item_list_deinit; + op->_super.deinit = (ddb_undo_operation_deinit_fn)_undo_operation_item_list_deinit; return op; } static void -_undo_perform_remove_items(undobuffer_t *undobuffer, undo_operation_t *_op) { +_undo_perform_remove_items(ddb_undobuffer_t *undobuffer, ddb_undo_operation_t *_op) { undo_operation_item_list_t *op = (undo_operation_item_list_t *)_op; - undobuffer_group_begin (undobuffer); + ddb_undobuffer_group_begin (undobuffer); for (size_t i = 0; i < op->count; i++) { plt_remove_item(op->plt, op->items[i]); } - undobuffer_group_end (undobuffer); + ddb_undobuffer_group_end (undobuffer); } static void -_undo_perform_insert_items (undobuffer_t *undobuffer, undo_operation_t *_op) { +_undo_perform_insert_items (ddb_undobuffer_t *undobuffer, ddb_undo_operation_t *_op) { undo_operation_item_list_t *op = (undo_operation_item_list_t *)_op; - undobuffer_group_begin (undobuffer); + ddb_undobuffer_group_begin (undobuffer); playItem_t *after = op->insert_position; for (size_t i = 0; i < op->count; i++) { plt_insert_item(op->plt, after, op->items[i]); after = op->items[i]; } - undobuffer_group_end (undobuffer); + ddb_undobuffer_group_end (undobuffer); } static void -_undo_perform_change_selection (undobuffer_t *undobuffer, undo_operation_t *_op) { +_undo_perform_change_selection (ddb_undobuffer_t *undobuffer, ddb_undo_operation_t *_op) { undo_operation_item_list_t *op = (undo_operation_item_list_t *)_op; // Restore selection according to the flag. if (op->flags & UNDO_SELECTION_LIST_UNSELECTED) { @@ -117,12 +117,12 @@ _undo_perform_change_selection (undobuffer_t *undobuffer, undo_operation_t *_op) } static int -_undo_operation_prepare(undobuffer_t *undobuffer, playlist_t *plt) { +_undo_operation_prepare(ddb_undobuffer_t *undobuffer, playlist_t *plt) { if (!plt->undo_enabled) { return 1; } - if (!undobuffer_has_operations(undobuffer)) { + if (!ddb_undobuffer_has_operations(undobuffer)) { undo_change_selection(undobuffer, plt); } @@ -132,15 +132,15 @@ _undo_operation_prepare(undobuffer_t *undobuffer, playlist_t *plt) { // The list of items must be contiguous in playlist. // The list will be batched with the previous operation if possible. void -undo_remove_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count) { +undo_remove_items(ddb_undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count) { if (_undo_operation_prepare (undobuffer, plt) != 0) { return; } // optimization: batching undo_operation_item_list_t *op = NULL; - if (undobuffer_is_grouping (undobuffer)) { - undo_operation_t *baseop = undobuffer_get_current_operation(undobuffer); - if (baseop->perform == (undo_operation_perform_fn)_undo_perform_insert_items) { + if (ddb_undobuffer_is_grouping (undobuffer)) { + ddb_undo_operation_t *baseop = ddb_undobuffer_get_current_operation(undobuffer); + if (baseop->perform == (ddb_undo_operation_perform_fn)_undo_perform_insert_items) { op = (undo_operation_item_list_t *)baseop; } } @@ -153,8 +153,8 @@ undo_remove_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, pl_item_ref (after); op->insert_position = after; } - op->_super.perform = (undo_operation_perform_fn)_undo_perform_insert_items; - undobuffer_append_operation(undobuffer, &op->_super); + op->_super.perform = (ddb_undo_operation_perform_fn)_undo_perform_insert_items; + ddb_undobuffer_append_operation(undobuffer, &op->_super); return; } @@ -167,15 +167,15 @@ undo_remove_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, } void -undo_insert_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count) { +undo_insert_items(ddb_undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count) { if (_undo_operation_prepare (undobuffer, plt) != 0) { return; } // optimization: batching undo_operation_item_list_t *op = NULL; - if (undobuffer_is_grouping (undobuffer)) { - undo_operation_t *baseop = undobuffer_get_current_operation(undobuffer); + if (ddb_undobuffer_is_grouping (undobuffer)) { + ddb_undo_operation_t *baseop = ddb_undobuffer_get_current_operation(undobuffer); if (baseop->perform == _undo_perform_remove_items) { op = (undo_operation_item_list_t *)baseop; } @@ -184,7 +184,7 @@ undo_insert_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, if (op == NULL) { op = _undo_operation_item_list_new(undobuffer, plt, items, count, 1); op->_super.perform = _undo_perform_remove_items; - undobuffer_append_operation(undobuffer, &op->_super); + ddb_undobuffer_append_operation(undobuffer, &op->_super); return; } op->items = realloc (op->items, (op->count + count) * sizeof (playItem_t *)); @@ -196,7 +196,7 @@ undo_insert_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, } void -undo_change_selection(undobuffer_t *undobuffer, playlist_t *plt) { +undo_change_selection(ddb_undobuffer_t *undobuffer, playlist_t *plt) { if (!plt->undo_enabled) { return; } @@ -233,5 +233,5 @@ undo_change_selection(undobuffer_t *undobuffer, playlist_t *plt) { op->flags = flags; op->_super.perform = _undo_perform_change_selection; - undobuffer_append_operation(undobuffer, &op->_super); + ddb_undobuffer_append_operation(undobuffer, &op->_super); } diff --git a/src/undo/undo_playlist.h b/src/undo/undo_playlist.h index 72153992c4..053397319a 100644 --- a/src/undo/undo_playlist.h +++ b/src/undo/undo_playlist.h @@ -28,9 +28,9 @@ #include "../playlist.h" void -undo_remove_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count); +undo_remove_items(ddb_undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count); void -undo_insert_items(undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count); +undo_insert_items(ddb_undobuffer_t *undobuffer, playlist_t *plt, playItem_t **items, size_t count); #endif /* undo_playlist_h */