summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-11-18 20:04:40 +0100
committerGravatar waker <wakeroid@gmail.com>2012-11-18 20:04:40 +0100
commitc0af023f30195806d07b735a027875eecf0c568d (patch)
tree1fb5262f23d3a3e4c0ac0e689bd2b4ef8d69f60d /plugins
parent10c19706ba4a538231cc81771fd815e55cde428f (diff)
gtkui: fixed dialog hanging issues, hotkeys WIP
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/actionhandlers.c90
-rw-r--r--plugins/gtkui/actionhandlers.h6
-rw-r--r--plugins/gtkui/gtkui.c12
-rw-r--r--plugins/gtkui/plcommon.c33
4 files changed, 93 insertions, 48 deletions
diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c
index 7de3a93f..a7337a1a 100644
--- a/plugins/gtkui/actionhandlers.c
+++ b/plugins/gtkui/actionhandlers.c
@@ -154,7 +154,7 @@ action_open_files_handler_cb (void *userdata) {
int
action_open_files_handler (struct DB_plugin_action_s *action, int ctx) {
- g_idle_add (action_open_files_handler_cb, NULL);
+ gdk_threads_add_idle (action_open_files_handler_cb, NULL);
return 0;
}
@@ -193,7 +193,7 @@ action_add_files_handler_cb (void *user_data) {
int
action_add_files_handler (struct DB_plugin_action_s *action, int ctx) {
- g_idle_add (action_add_files_handler_cb, NULL);
+ gdk_threads_add_idle (action_add_files_handler_cb, NULL);
return 0;
}
@@ -252,7 +252,7 @@ action_add_folders_handler_cb (void *user_data) {
int
action_add_folders_handler (struct DB_plugin_action_s *action, int ctx) {
- g_idle_add (action_add_folders_handler_cb, NULL);
+ gdk_threads_add_idle (action_add_folders_handler_cb, NULL);
return 0;
}
@@ -325,7 +325,7 @@ action_new_playlist_handler_cb (void *user_data) {
int
action_new_playlist_handler (struct DB_plugin_action_s *action, int ctx) {
- g_idle_add (action_new_playlist_handler_cb, NULL);
+ gdk_threads_add_idle (action_new_playlist_handler_cb, NULL);
return 0;
}
@@ -414,7 +414,7 @@ action_add_location_handler_cb (void *user_data) {
int
action_add_location_handler (DB_plugin_action_t *act, int ctx) {
- g_idle_add (action_add_location_handler_cb, NULL);
+ gdk_threads_add_idle (action_add_location_handler_cb, NULL);
return 0;
}
@@ -430,7 +430,7 @@ action_show_help_handler_cb (void *user_data) {
int
action_show_help_handler (DB_plugin_action_t *act, int ctx) {
- g_idle_add (action_show_help_handler_cb, NULL);
+ gdk_threads_add_idle (action_show_help_handler_cb, NULL);
return 0;
}
@@ -481,3 +481,81 @@ action_remove_from_playlist_handler (DB_plugin_action_t *act, int ctx) {
}
return 0;
}
+
+gboolean
+action_delete_from_disk_handler_cb (void *data) {
+ int ctx = (intptr_t)data;
+ if (deadbeef->conf_get_int ("gtkui.delete_files_ask", 1)) {
+ GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("Delete files from disk"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), _("Files will be lost. Proceed?\n(This dialog can be turned off in GTKUI plugin settings)"));
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Warning"));
+
+ int response = gtk_dialog_run (GTK_DIALOG (dlg));
+ gtk_widget_destroy (dlg);
+ if (response != GTK_RESPONSE_YES) {
+ return FALSE;
+ }
+ }
+
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (!plt) {
+ return FALSE;
+ }
+ deadbeef->pl_lock ();
+
+ if (ctx == DDB_ACTION_CTX_SELECTION) {
+ DB_playItem_t *it = deadbeef->plt_get_first (plt, PL_MAIN);
+ while (it) {
+ const char *uri = deadbeef->pl_find_meta (it, ":URI");
+ if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (uri)) {
+ unlink (uri);
+ deadbeef->plt_remove_item (plt, it);
+ }
+ DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
+ deadbeef->pl_item_unref (it);
+ it = next;
+ }
+
+ deadbeef->pl_save_all ();
+ }
+ else if (ctx == DDB_ACTION_CTX_PLAYLIST) {
+ DB_playItem_t *it = deadbeef->plt_get_first (plt, PL_MAIN);
+ while (it) {
+ const char *uri = deadbeef->pl_find_meta (it, ":URI");
+ if (deadbeef->is_local_file (uri)) {
+ unlink (uri);
+ deadbeef->plt_remove_item (plt, it);
+ }
+ DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
+ deadbeef->pl_item_unref (it);
+ it = next;
+ }
+
+ deadbeef->pl_save_all ();
+ }
+ else if (ctx == DDB_ACTION_CTX_NOWPLAYING) {
+ DB_playItem_t *it = deadbeef->streamer_get_playing_track ();
+ if (it) {
+ const char *uri = deadbeef->pl_find_meta (it, ":URI");
+ if (deadbeef->is_local_file (uri)) {
+ int idx = deadbeef->plt_get_item_idx (plt, it, PL_MAIN);
+ if (idx != -1) {
+ unlink (uri);
+ deadbeef->plt_remove_item (plt, it);
+ }
+ }
+ deadbeef->pl_item_unref (it);
+ }
+ }
+ deadbeef->pl_unlock ();
+ deadbeef->plt_unref (plt);
+
+ deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
+ return FALSE;
+}
+
+int
+action_delete_from_disk_handler (DB_plugin_action_t *act, int ctx) {
+ gdk_threads_add_idle (action_delete_from_disk_handler_cb, (void *)(intptr_t)ctx);
+ return 0;
+}
diff --git a/plugins/gtkui/actionhandlers.h b/plugins/gtkui/actionhandlers.h
index 0ad928e1..03af45d2 100644
--- a/plugins/gtkui/actionhandlers.h
+++ b/plugins/gtkui/actionhandlers.h
@@ -102,4 +102,10 @@ action_show_help_handler (DB_plugin_action_t *act, int ctx);
int
action_remove_from_playlist_handler (DB_plugin_action_t *act, int ctx);
+gboolean
+action_delete_from_disk_handler_cb (void *data);
+
+int
+action_delete_from_disk_handler (DB_plugin_action_t *act, int ctx);
+
#endif
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index fc80f268..35657d0e 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -1006,7 +1006,6 @@ gtkui_thread (void *ctx) {
XInitThreads (); // gtkglext/xcb doesn't work without this
// let's start some gtk
g_thread_init (NULL);
-// add_pixmap_directory (PREFIX "/share/deadbeef/pixmaps");
add_pixmap_directory (deadbeef->get_pixmap_dir ());
gdk_threads_init ();
gdk_threads_enter ();
@@ -1043,13 +1042,6 @@ gtkui_thread (void *ctx) {
}
#endif
- // let's start some gtk
- g_thread_init (NULL);
-// add_pixmap_directory (PREFIX "/share/deadbeef/pixmaps");
- add_pixmap_directory (deadbeef->get_pixmap_dir ());
- gdk_threads_init ();
- gdk_threads_enter ();
-
gtk_init (&argc, (char ***)&argv);
// register widget types
@@ -1468,10 +1460,10 @@ static DB_plugin_action_t action_quit = {
};
static DB_plugin_action_t action_delete_from_disk = {
- .title = "[stub] Delete From Disk",
+ .title = "Delete From Disk",
.name = "delete_from_disk",
.flags = DB_ACTION_SINGLE_TRACK | DB_ACTION_MULTIPLE_TRACKS,
- .callback = action_quit_handler,
+ .callback = action_delete_from_disk_handler,
.next = &action_quit
};
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index e2399333..77127bea 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -337,38 +337,7 @@ void
on_remove_from_disk_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- GtkWidget *widget = GTK_WIDGET (menuitem);
-
- if (deadbeef->conf_get_int ("gtkui.delete_files_ask", 1)) {
- GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("Delete files from disk"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), _("Files will be lost. Proceed?\n(This dialog can be turned off in GTKUI plugin settings)"));
- gtk_window_set_title (GTK_WINDOW (dlg), _("Warning"));
-
- int response = gtk_dialog_run (GTK_DIALOG (dlg));
- gtk_widget_destroy (dlg);
- if (response != GTK_RESPONSE_YES) {
- return;
- }
- }
-
- deadbeef->pl_lock ();
-
- DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
- while (it) {
- const char *uri = deadbeef->pl_find_meta (it, ":URI");
- if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (uri)) {
- unlink (uri);
- }
- DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
- deadbeef->pl_item_unref (it);
- it = next;
- }
-
- int cursor = deadbeef->pl_delete_selected ();
- deadbeef->pl_save_all ();
- deadbeef->pl_unlock ();
-
- deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
+ action_delete_from_disk_handler_cb ((void *)(intptr_t)DDB_ACTION_CTX_SELECTION);
}
void