Advertisement
kevinf28

audacious_delete-files_global-hotkey

Aug 19th, 2014
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.27 KB | None | 0 0
  1. diff --git a/src/delete-files/delete-files.cc b/src/delete-files/delete-files.cc
  2. index dd16f4e..a5c09fd 100644
  3. --- a/src/delete-files/delete-files.cc
  4. +++ b/src/delete-files/delete-files.cc
  5. @@ -28,6 +28,7 @@
  6.  
  7.  #include <libaudcore/audstrings.h>
  8.  #include <libaudcore/i18n.h>
  9. +#include <libaudcore/hook.h>
  10.  #include <libaudcore/interface.h>
  11.  #include <libaudcore/playlist.h>
  12.  #include <libaudcore/plugin.h>
  13. @@ -92,6 +93,10 @@ static void confirm_delete (void)
  14.      }
  15.  }
  16.  
  17. +static void delete_file_hook (void *hook_data, void *user_data) {
  18. +    confirm_delete();
  19. +}
  20. +
  21.  static void start_delete (void)
  22.  {
  23.      if (dialog)
  24. @@ -134,12 +139,14 @@ static bool_t delete_files_init (void)
  25.  
  26.      for (int i = 0; i < ARRAY_LEN (menus); i ++)
  27.          aud_plugin_menu_add (menus[i], start_delete, _("Delete Selected Files"), "edit-delete");
  28. -
  29. +    hook_associate("delete file", (HookFunction) delete_file_hook, NULL);
  30.      return TRUE;
  31.  }
  32.  
  33.  static void delete_files_cleanup (void)
  34.  {
  35. +    hook_dissociate("delete file", (HookFunction) delete_file_hook);
  36. +
  37.      if (dialog)
  38.          gtk_widget_destroy (dialog);
  39.  
  40. diff --git a/src/hotkey/gui.cc b/src/hotkey/gui.cc
  41. index b10b5cf..b12f240 100644
  42. --- a/src/hotkey/gui.cc
  43. +++ b/src/hotkey/gui.cc
  44. @@ -83,7 +83,8 @@ static const char * event_desc[EVENT_MAX] = {
  45.      [EVENT_TOGGLE_REPEAT] = N_("Toggle repeat"),
  46.      [EVENT_TOGGLE_SHUFFLE] = N_("Toggle shuffle"),
  47.      [EVENT_TOGGLE_STOP] = N_("Toggle stop after current"),
  48. -    [EVENT_RAISE] = N_("Raise player window(s)")
  49. +    [EVENT_RAISE] = N_("Raise player window(s)"),
  50. +    [EVENT_DELETE] = N_("Delete current file")
  51.  };
  52.  
  53.  
  54. diff --git a/src/hotkey/plugin.cc b/src/hotkey/plugin.cc
  55. index 1f4bedd..a754b8e 100644
  56. --- a/src/hotkey/plugin.cc
  57. +++ b/src/hotkey/plugin.cc
  58. @@ -287,6 +287,12 @@ gboolean handle_keyevent (EVENT event)
  59.          return TRUE;
  60.      }
  61.  
  62. +    if (event == EVENT_DELETE)
  63. +    {
  64. +        hook_call("delete file", NULL);
  65. +        return TRUE;
  66. +    }
  67. +
  68.      return FALSE;
  69.  }
  70.  
  71. diff --git a/src/hotkey/plugin.h b/src/hotkey/plugin.h
  72. index 7215d6b..d66d175 100644
  73. --- a/src/hotkey/plugin.h
  74. +++ b/src/hotkey/plugin.h
  75. @@ -27,7 +27,7 @@ typedef enum {
  76.      EVENT_TOGGLE_STOP,
  77.  
  78.      EVENT_RAISE,
  79. -
  80. +    EVENT_DELETE,
  81.      EVENT_MAX
  82.  } EVENT;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement