diff options
author | waker <wakeroid@gmail.com> | 2012-11-23 23:35:07 +0100 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-11-23 23:35:07 +0100 |
commit | 7c29cb0c857496e4a7c9c2980c4277b88d187c6f (patch) | |
tree | 09a21c2ab8add4064e7a100a428ba7ada549e68a | |
parent | 9cfd3e731d9a8a43de1657a8f6fc54d72d0dbd5d (diff) |
gtkui: added sort custom hotkey
-rw-r--r-- | plugins/gtkui/actionhandlers.c | 40 | ||||
-rw-r--r-- | plugins/gtkui/actionhandlers.h | 6 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.c | 32 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 4 |
4 files changed, 49 insertions, 33 deletions
diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c index 0530a811..4c08f070 100644 --- a/plugins/gtkui/actionhandlers.c +++ b/plugins/gtkui/actionhandlers.c @@ -835,4 +835,44 @@ action_preferences_handler (DB_plugin_action_t *act, int ctx) { return 0; } +gboolean +action_sort_custom_handler_cb (void *data) { + GtkWidget *dlg = create_sortbydlg (); + gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK); + + GtkComboBox *combo = GTK_COMBO_BOX (lookup_widget (dlg, "sortorder")); + GtkEntry *entry = GTK_ENTRY (lookup_widget (dlg, "sortfmt")); + + gtk_combo_box_set_active (combo, deadbeef->conf_get_int ("gtkui.sortby_order", 0)); + deadbeef->conf_lock (); + gtk_entry_set_text (entry, deadbeef->conf_get_str_fast ("gtkui.sortby_fmt", "")); + deadbeef->conf_unlock (); + + int r = gtk_dialog_run (GTK_DIALOG (dlg)); + + if (r == GTK_RESPONSE_OK) { + GtkComboBox *combo = GTK_COMBO_BOX (lookup_widget (dlg, "sortorder")); + GtkEntry *entry = GTK_ENTRY (lookup_widget (dlg, "sortfmt")); + int order = gtk_combo_box_get_active (combo); + const char *fmt = gtk_entry_get_text (entry); + + deadbeef->conf_set_int ("gtkui.sortby_order", order); + deadbeef->conf_set_str ("gtkui.sortby_fmt", fmt); + + ddb_playlist_t *plt = deadbeef->plt_get_curr (); + deadbeef->plt_sort (plt, PL_MAIN, -1, fmt, order == 0 ? DDB_SORT_ASCENDING : DDB_SORT_DESCENDING); + deadbeef->plt_unref (plt); + + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + } + gtk_widget_destroy (dlg); + dlg = NULL; + return FALSE; +} + +int +action_sort_custom_handler (DB_plugin_action_t *act, int ctx) { + gdk_threads_add_idle (action_sort_custom_handler_cb, NULL); + return 0; +} diff --git a/plugins/gtkui/actionhandlers.h b/plugins/gtkui/actionhandlers.h index 2c3c89cc..77084c7e 100644 --- a/plugins/gtkui/actionhandlers.h +++ b/plugins/gtkui/actionhandlers.h @@ -168,4 +168,10 @@ action_preferences_handler_cb (void *data); int action_preferences_handler (DB_plugin_action_t *act, int ctx); +gboolean +action_sort_custom_handler_cb (void *data); + +int +action_sort_custom_handler (DB_plugin_action_t *act, int ctx); + #endif diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 777f46bb..f37404bd 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -1039,37 +1039,7 @@ void on_sort_by_custom_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget *dlg = create_sortbydlg (); - gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK); - - GtkComboBox *combo = GTK_COMBO_BOX (lookup_widget (dlg, "sortorder")); - GtkEntry *entry = GTK_ENTRY (lookup_widget (dlg, "sortfmt")); - - gtk_combo_box_set_active (combo, deadbeef->conf_get_int ("gtkui.sortby_order", 0)); - deadbeef->conf_lock (); - gtk_entry_set_text (entry, deadbeef->conf_get_str_fast ("gtkui.sortby_fmt", "")); - deadbeef->conf_unlock (); - - int r = gtk_dialog_run (GTK_DIALOG (dlg)); - - if (r == GTK_RESPONSE_OK) { - GtkComboBox *combo = GTK_COMBO_BOX (lookup_widget (dlg, "sortorder")); - GtkEntry *entry = GTK_ENTRY (lookup_widget (dlg, "sortfmt")); - int order = gtk_combo_box_get_active (combo); - const char *fmt = gtk_entry_get_text (entry); - - deadbeef->conf_set_int ("gtkui.sortby_order", order); - deadbeef->conf_set_str ("gtkui.sortby_fmt", fmt); - - ddb_playlist_t *plt = deadbeef->plt_get_curr (); - deadbeef->plt_sort (plt, PL_MAIN, -1, fmt, order == 0 ? DDB_SORT_ASCENDING : DDB_SORT_DESCENDING); - deadbeef->plt_unref (plt); - - deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); - } - - gtk_widget_destroy (dlg); - dlg = NULL; + action_sort_custom_handler_cb (NULL); } void diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 93f3cbd2..e77bb030 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -1438,10 +1438,10 @@ static DB_plugin_action_t action_preferences = { }; static DB_plugin_action_t action_sort_custom = { - .title = "Edit/[stub] Sort Custom", + .title = "Edit/Sort Custom", .name = "sort_custom", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_sort_custom_handler, .next = &action_preferences }; |