diff options
author | 2009-12-28 19:51:52 +0100 | |
---|---|---|
committer | 2009-12-28 19:51:52 +0100 | |
commit | 0cdf6df414e5d59cc41d915c6d9f012299656c7e (patch) | |
tree | e22119ce3262be400a3c39fa7e21b1656e3ff280 /plugins/gtkui | |
parent | 50bd3ec6e2a8f0d9c5073aad0f9b0b997fcc4ccb (diff) |
fixed crashbug when deleting tracks with search window opened
now it's possible to delete tracks in search window with Delete key
Diffstat (limited to 'plugins/gtkui')
-rw-r--r-- | plugins/gtkui/callbacks.c | 23 | ||||
-rw-r--r-- | plugins/gtkui/gtkplaylist.c | 26 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 4 | ||||
-rw-r--r-- | plugins/gtkui/search.c | 5 |
4 files changed, 34 insertions, 24 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 31bdb4e8..efa71308 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -64,12 +64,12 @@ playlist_tooltip_handler (GtkWidget *widget, gint x, gint y, gboolean keyboard_m static int main_get_count (void) { - return deadbeef->pl_getcount (); + return deadbeef->pl_getcount (PL_MAIN); } static int search_get_count (void) { - return search_count; + return deadbeef->pl_getcount (PL_SEARCH); } void @@ -514,23 +514,8 @@ void on_remove1_activate (GtkMenuItem *menuitem, gpointer user_data) { - gtkplaylist_t *ps = &main_playlist; - GtkWidget *widget = ps->playlist; - int row = deadbeef->pl_delete_selected (); - if (row >= ps->get_count ()) { - row = ps->get_count ()-1; - } - deadbeef->pl_set_cursor (PL_MAIN, row); - if (row != -1) { - DB_playItem_t *it = deadbeef->pl_get_for_idx (row); - if (it) { - deadbeef->pl_set_selected (it, 1); - } - } - gtkpl_setup_scrollbar (ps); - gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height); - gtkpl_expose (ps, 0, 0, widget->allocation.width, widget->allocation.height); - search_refresh (); + // does nothing here -- required for hotkey hint in the menu + // job is done in keypress handlers } diff --git a/plugins/gtkui/gtkplaylist.c b/plugins/gtkui/gtkplaylist.c index bf551e5a..2f9821dd 100644 --- a/plugins/gtkui/gtkplaylist.c +++ b/plugins/gtkui/gtkplaylist.c @@ -887,6 +887,16 @@ gtkpl_songchanged (gtkplaylist_t *ps, int from, int to) { } void +main_refresh (void) { + if (mainwin && GTK_WIDGET_VISIBLE (mainwin)) { + gtkplaylist_t *ps = &main_playlist; + gtkpl_setup_scrollbar (ps); + gtkpl_draw_playlist (ps, 0, 0, ps->playlist->allocation.width, ps->playlist->allocation.height); + gtkpl_expose (ps, 0, 0, ps->playlist->allocation.width, ps->playlist->allocation.height); + } +} + +void gtkpl_keypress (gtkplaylist_t *ps, int keyval, int state) { GtkWidget *range = ps->scrollbar; int prev = deadbeef->pl_get_cursor (ps->iterator); @@ -935,6 +945,22 @@ gtkpl_keypress (gtkplaylist_t *ps, int keyval, int state) { gtkpl_set_cursor (ps->iterator, 0); } } + else if (keyval == GDK_Delete) { + GtkWidget *widget = ps->playlist; + int row = deadbeef->pl_delete_selected (); + if (row >= ps->get_count ()) { + row = ps->get_count ()-1; + } + deadbeef->pl_set_cursor (ps->iterator, row); + if (row != -1) { + DB_playItem_t *it = deadbeef->pl_get_for_idx (row); + if (it) { + deadbeef->pl_set_selected (it, 1); + } + } + main_refresh (); + search_refresh (); + } if (state & GDK_SHIFT_MASK) { // select all between shift_sel_anchor and deadbeef->pl_get_cursor (ps->iterator) if (prev != deadbeef->pl_get_cursor (ps->iterator)) { diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 85c819e7..d68d558b 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -77,7 +77,7 @@ update_songinfo (gpointer ctx) { float duration = deadbeef->pl_get_item_duration (track); if (deadbeef->get_output ()->state () == OUTPUT_STATE_STOPPED) { - snprintf (sbtext_new, sizeof (sbtext_new), "Stopped | %d tracks | %s total playtime", deadbeef->pl_getcount (), totaltime_str); + snprintf (sbtext_new, sizeof (sbtext_new), "Stopped | %d tracks | %s total playtime", deadbeef->pl_getcount (PL_MAIN), totaltime_str); songpos = 0; } else if (track->decoder) { @@ -111,7 +111,7 @@ update_songinfo (gpointer ctx) { } #endif const char *spaused = deadbeef->get_output ()->state () == OUTPUT_STATE_PAUSED ? "Paused | " : ""; - snprintf (sbtext_new, sizeof (sbtext_new), "%s%s %s| %dHz | %d bit | %s | %d:%02d / %s | %d tracks | %s total playtime", spaused, track->filetype ? track->filetype:"-", sbitrate, samplerate, bitspersample, mode, minpos, secpos, t, deadbeef->pl_getcount (), totaltime_str); + snprintf (sbtext_new, sizeof (sbtext_new), "%s%s %s| %dHz | %d bit | %s | %d:%02d / %s | %d tracks | %s total playtime", spaused, track->filetype ? track->filetype:"-", sbitrate, samplerate, bitspersample, mode, minpos, secpos, t, deadbeef->pl_getcount (PL_MAIN), totaltime_str); } if (strcmp (sbtext_new, sb_text)) { diff --git a/plugins/gtkui/search.c b/plugins/gtkui/search.c index c07d503f..bdb0d13c 100644 --- a/plugins/gtkui/search.c +++ b/plugins/gtkui/search.c @@ -70,7 +70,7 @@ on_searchentry_changed (GtkEditable *editable, // with search_head const gchar *text = gtk_entry_get_text (GTK_ENTRY (editable)); - search_count = deadbeef->pl_process_search (text); + deadbeef->pl_search_process (text); extern gtkplaylist_t search_playlist; gtkplaylist_t *ps = &search_playlist; @@ -93,9 +93,9 @@ void search_refresh (void) { if (searchwin && GTK_WIDGET_VISIBLE (searchwin)) { gtkplaylist_t *ps = &search_playlist; + gtkpl_setup_scrollbar (ps); gtkpl_draw_playlist (ps, 0, 0, ps->playlist->allocation.width, ps->playlist->allocation.height); gtkpl_expose (ps, 0, 0, ps->playlist->allocation.width, ps->playlist->allocation.height); - //on_searchentry_changed (GTK_EDITABLE (lookup_widget (searchwin, "searchentry")), NULL); } } @@ -190,4 +190,3 @@ on_searchlist_configure_event (GtkWidget *widget, return FALSE; } - |