summaryrefslogtreecommitdiff
path: root/plugins/gtkui
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/gtkui')
-rw-r--r--plugins/gtkui/ddblistview.c59
-rw-r--r--plugins/gtkui/ddblistview.h5
-rw-r--r--plugins/gtkui/ddbtabstrip.c12
-rw-r--r--plugins/gtkui/fileman.c4
-rw-r--r--plugins/gtkui/gtkui.c21
-rw-r--r--plugins/gtkui/gtkui.h3
-rw-r--r--plugins/gtkui/mainplaylist.c5
-rw-r--r--plugins/gtkui/plcommon.c2
-rw-r--r--plugins/gtkui/search.c9
-rw-r--r--plugins/gtkui/search.h3
-rw-r--r--plugins/gtkui/trkproperties.c3
11 files changed, 79 insertions, 47 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index 18ccf4a4..c50dd9df 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -85,6 +85,9 @@ static void ddb_listview_init(DdbListview *listview);
//static void ddb_listview_paint(GtkWidget *widget);
static void ddb_listview_destroy(GtkObject *object);
+static void
+ddb_listview_build_groups (DdbListview *listview);
+
// fwd decls
void
ddb_listview_free_groups (DdbListview *listview);
@@ -473,11 +476,6 @@ ddb_listview_destroy(GtkObject *object)
void
ddb_listview_refresh (DdbListview *listview, uint32_t flags) {
if (flags & DDB_REFRESH_LIST) {
- int height = listview->fullheight;
- ddb_listview_build_groups (listview);
- if (height != listview->fullheight) {
- flags |= DDB_REFRESH_VSCROLL;
- }
gtk_widget_queue_draw (listview->list);
}
if (flags & DDB_REFRESH_VSCROLL) {
@@ -527,20 +525,33 @@ ddb_listview_list_configure_event (GtkWidget *widget,
return FALSE;
}
+static void
+ddb_listview_groupcheck (DdbListview *listview) {
+ time_t tm = listview->binding->modification_time ();
+ if (tm != listview->groups_build_time) {
+ ddb_listview_build_groups (listview);
+ }
+}
+
// returns Y coordinate of an item by its index
int
ddb_listview_get_row_pos (DdbListview *listview, int row_idx) {
int y = 0;
int idx = 0;
+ deadbeef->pl_lock ();
+ ddb_listview_groupcheck (listview);
DdbListviewGroup *grp = listview->groups;
while (grp) {
if (idx + grp->num_items > row_idx) {
- return y + listview->grouptitle_height + (row_idx - idx) * listview->rowheight;
+ int i = y + listview->grouptitle_height + (row_idx - idx) * listview->rowheight;
+ deadbeef->pl_unlock ();
+ return i;
}
y += grp->height;
idx += grp->num_items;
grp = grp->next;
}
+ deadbeef->pl_unlock ();
return y;
}
@@ -552,6 +563,8 @@ ddb_listview_list_pickpoint_y (DdbListview *listview, int y, DdbListviewGroup **
int idx = 0;
int grp_y = 0;
int gidx = 0;
+ deadbeef->pl_lock ();
+ ddb_listview_groupcheck (listview);
DdbListviewGroup *grp = listview->groups;
while (grp) {
int h = grp->height;
@@ -570,6 +583,7 @@ ddb_listview_list_pickpoint_y (DdbListview *listview, int y, DdbListviewGroup **
*group_idx = (y - listview->grouptitle_height) / listview->rowheight;
*global_idx = idx + *group_idx;
}
+ deadbeef->pl_unlock ();
return 0;
}
grp_y += grp->height;
@@ -577,6 +591,7 @@ ddb_listview_list_pickpoint_y (DdbListview *listview, int y, DdbListviewGroup **
grp = grp->next;
gidx++;
}
+ deadbeef->pl_unlock ();
return -1;
}
@@ -589,6 +604,7 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) {
int idx = 0;
int abs_idx = 0;
deadbeef->pl_lock ();
+ ddb_listview_groupcheck (listview);
// find 1st group
DdbListviewGroup *grp = listview->groups;
printf ("starting to render listview, groups=%p, num_items=%d\n", grp, grp?grp->num_items : 0);
@@ -1128,6 +1144,8 @@ ddb_listview_list_setup_hscroll (DdbListview *ps) {
// returns -1 if row not found
int
ddb_listview_list_get_drawinfo (DdbListview *listview, int row, DdbListviewGroup **pgrp, int *even, int *cursor, int *group_y, int *x, int *y, int *w, int *h) {
+ deadbeef->pl_lock ();
+ ddb_listview_groupcheck (listview);
DdbListviewGroup *grp = listview->groups;
int idx = 0;
int idx2 = 0;
@@ -1145,6 +1163,7 @@ ddb_listview_list_get_drawinfo (DdbListview *listview, int row, DdbListviewGroup
*y += listview->grouptitle_height + (row - idx) * listview->rowheight;
*w = listview->totalwidth;
*h = listview->rowheight;
+ deadbeef->pl_unlock ();
return 0;
}
*y += grpheight;
@@ -1152,6 +1171,7 @@ ddb_listview_list_get_drawinfo (DdbListview *listview, int row, DdbListviewGroup
idx2 += grp->num_items + 1;
grp = grp->next;
}
+ deadbeef->pl_unlock ();
return -1;
}
@@ -1290,11 +1310,11 @@ ddb_listview_header_expose (DdbListview *ps, int x, int y, int w, int h) {
void
ddb_listview_select_single (DdbListview *ps, int sel) {
int nchanged = 0;
- deadbeef->plt_lock ();
+ deadbeef->pl_lock ();
DB_playItem_t *sel_it = ps->binding->get_for_idx (sel);
if (!sel_it) {
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
return;
}
@@ -1325,7 +1345,7 @@ ddb_listview_select_single (DdbListview *ps, int sel) {
}
UNREF (it);
UNREF (sel_it);
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
if (nchanged >= NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW, 1) {
ddb_listview_refresh (ps, DDB_REFRESH_LIST);
@@ -1337,6 +1357,8 @@ ddb_listview_select_single (DdbListview *ps, int sel) {
void
ddb_listview_click_selection (DdbListview *ps, int ex, int ey, DdbListviewGroup *grp, int grp_index, int sel, int dnd) {
+ deadbeef->pl_lock ();
+ ddb_listview_groupcheck (ps);
if (sel == -1 && (!grp || grp_index >= grp->num_items)) {
// clicked empty space, deselect everything
DdbListviewIter it;
@@ -1398,6 +1420,7 @@ ddb_listview_click_selection (DdbListview *ps, int ex, int ey, DdbListviewGroup
}
UNREF (it);
}
+ deadbeef->pl_unlock ();
}
// {{{ expected behaviour for mouse1 without modifiers:
@@ -1421,8 +1444,11 @@ ddb_listview_click_selection (DdbListview *ps, int ex, int ey, DdbListviewGroup
void
ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, GdkEventType type) {
// cursor must be set here, but selection must be handled in keyrelease
+ deadbeef->pl_lock ();
+ ddb_listview_groupcheck (ps);
int cnt = ps->binding->count ();
if (cnt == 0) {
+ deadbeef->pl_unlock ();
return;
}
// remember mouse coords for doubleclick detection
@@ -1433,6 +1459,7 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, Gd
int grp_index;
int sel;
if (ddb_listview_list_pickpoint_y (ps, ey + ps->scrollpos, &grp, &grp_index, &sel) == -1) {
+ deadbeef->pl_unlock ();
return;
}
@@ -1450,6 +1477,7 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, Gd
if (it) {
ps->binding->unref (it);
}
+ deadbeef->pl_unlock ();
return;
}
}
@@ -1486,6 +1514,7 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, Gd
int cursor = sel;//ps->binding->cursor ();
if (cursor == -1) {
// find group
+ ddb_listview_groupcheck (ps);
DdbListviewGroup *g = ps->groups;
int idx = 0;
while (g) {
@@ -1531,6 +1560,7 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, Gd
ddb_listview_draw_row (ps, prev, it);
UNREF (it);
}
+ deadbeef->pl_unlock ();
}
void
@@ -1650,6 +1680,7 @@ ddb_listview_list_scroll_cb (gpointer data) {
void
ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *ev, int ex, int ey) {
+ deadbeef->pl_lock ();
if (ps->dragwait) {
GtkWidget *widget = ps->list;
if (gtk_drag_check_threshold (widget, ps->lastpos[0], ex, ps->lastpos[1], ey)) {
@@ -1712,6 +1743,7 @@ ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *ev, int ex, int ey
int idx = 0;
if (y == -1) {
// find group
+ ddb_listview_groupcheck (ps);
DdbListviewGroup *g = ps->groups;
while (g) {
if (g == grp) {
@@ -1809,6 +1841,7 @@ ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *ev, int ex, int ey
// debug only
// ddb_listview_list_dbg_draw_areasel (widget, event->x, event->y);
}
+ deadbeef->pl_unlock ();
}
void
@@ -2847,6 +2880,8 @@ ddb_listview_free_groups (DdbListview *listview) {
void
ddb_listview_build_groups (DdbListview *listview) {
deadbeef->pl_lock ();
+ int old_height = listview->fullheight;
+ listview->groups_build_time = listview->binding->modification_time ();
ddb_listview_free_groups (listview);
listview->fullheight = 0;
@@ -2881,6 +2916,9 @@ ddb_listview_build_groups (DdbListview *listview) {
listview->fullheight = grp->height;
listview->fullheight += listview->grouptitle_height;
deadbeef->pl_unlock ();
+ if (old_height != listview->fullheight) {
+ ddb_listview_refresh (listview, DDB_REFRESH_VSCROLL);
+ }
return;
}
if (!grp || strcmp (str, curr)) {
@@ -2922,6 +2960,9 @@ ddb_listview_build_groups (DdbListview *listview) {
printf ("groupsize: %d!\n", listview->groups->num_items);
}
deadbeef->pl_unlock ();
+ if (old_height != listview->fullheight) {
+ ddb_listview_refresh (listview, DDB_REFRESH_VSCROLL);
+ }
}
void
diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h
index d0a7ceb9..5ba1e0ed 100644
--- a/plugins/gtkui/ddblistview.h
+++ b/plugins/gtkui/ddblistview.h
@@ -85,6 +85,7 @@ typedef struct {
void (*col_free_user_data) (void *user_data);
void (*vscroll_changed) (int pos);
void (*cursor_changed) (int pos);
+ time_t (*modification_time) (void);
} DdbListviewBinding;
struct _DdbListviewColumn;
@@ -139,6 +140,7 @@ struct _DdbListview {
struct _DdbListviewColumn *columns;
struct _DdbListviewGroup *groups;
+ time_t groups_build_time;
int fullheight;
int block_redraw_on_scroll;
int grouptitle_height;
@@ -193,8 +195,7 @@ int
ddb_listview_column_get_info (DdbListview *listview, int col, const char **title, int *width, int *align_right, int *minheight, void **user_data);
int
ddb_listview_column_set_info (DdbListview *listview, int col, const char *title, int width, int align_right, int minheight, void *user_data);
-void
-ddb_listview_build_groups (DdbListview *listview);
+
void
ddb_listview_show_header (DdbListview *listview, int show);
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c
index 60b806c8..a1f2aa10 100644
--- a/plugins/gtkui/ddbtabstrip.c
+++ b/plugins/gtkui/ddbtabstrip.c
@@ -47,10 +47,10 @@ plt_get_title_wrapper (int plt, char *buffer, int len) {
strcpy (buffer, "");
return;
}
- deadbeef->plt_lock ();
+ deadbeef->pl_lock ();
void *p = deadbeef->plt_get_handle (plt);
deadbeef->plt_get_title (p, buffer, len);
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
char *end;
if (!g_utf8_validate (buffer, -1, (const gchar **)&end)) {
*end = 0;
@@ -469,7 +469,7 @@ set_tab_text_color (int idx) {
if (idx == -1) {
return;
}
- deadbeef->plt_lock ();
+ deadbeef->pl_lock ();
void *plt = deadbeef->plt_get_handle (idx);
const char *clr = deadbeef->plt_find_meta (plt, "gui.color");
int fallback = 1;
@@ -487,7 +487,7 @@ set_tab_text_color (int idx) {
float fg[3] = {(float)color.red/0xffff, (float)color.green/0xffff, (float)color.blue/0xffff};
draw_set_fg_color (fg);
}
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
}
void
@@ -668,10 +668,10 @@ on_rename_playlist1_activate (GtkMenuItem *menuitem,
int res = gtk_dialog_run (GTK_DIALOG (dlg));
if (res == GTK_RESPONSE_OK) {
const char *text = gtk_entry_get_text (GTK_ENTRY (e));
- deadbeef->plt_lock ();
+ deadbeef->pl_lock ();
void *p = deadbeef->plt_get_handle (tab_clicked);
deadbeef->plt_set_title (p, text);
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
}
gtk_widget_destroy (dlg);
}
diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c
index d33764c0..3b5db560 100644
--- a/plugins/gtkui/fileman.c
+++ b/plugins/gtkui/fileman.c
@@ -22,7 +22,7 @@ gtkpl_adddir_cb (gpointer data, gpointer userdata) {
void
gtkpl_add_dirs (GSList *lst) {
- deadbeef->plt_lock ();
+ deadbeef->pl_lock ();
deadbeef->pl_add_files_begin (deadbeef->plt_get_curr ());
if (g_slist_length (lst) == 1
&& deadbeef->conf_get_int ("gtkui.name_playlist_from_folder", 0)) {
@@ -42,7 +42,7 @@ gtkpl_add_dirs (GSList *lst) {
}
}
}
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
g_slist_foreach(lst, gtkpl_adddir_cb, NULL);
g_slist_free (lst);
deadbeef->pl_add_files_end ();
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index a43bf409..0a268a52 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -492,10 +492,6 @@ playlistchanged_cb (gpointer none) {
void
gtkui_playlist_changed (void) {
- DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
- ddb_listview_build_groups (pl);
- search_rebuild_groups ();
-
g_idle_add (playlistchanged_cb, NULL);
}
@@ -535,10 +531,6 @@ playlistswitch_cb (gpointer none) {
static int
gtkui_on_playlistswitch (DB_event_t *ev, uintptr_t data) {
- printf ("gtkui_on_playlistchanged\n");
- DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
- ddb_listview_build_groups (pl);
- search_rebuild_groups ();
g_idle_add (playlistswitch_cb, NULL);
return 0;
}
@@ -628,6 +620,15 @@ gtkui_hide_status_icon () {
}
}
+time_t
+gtkui_get_curr_playlist_modtime (void) {
+ deadbeef->pl_lock ();
+ void *plt = deadbeef->plt_get_handle (deadbeef->plt_get_curr ());
+ time_t res = plt ? deadbeef->plt_get_modification_time (plt) : 0;
+ deadbeef->pl_unlock ();
+ return res;
+}
+
static int
gtkui_on_configchanged (DB_event_t *ev, uintptr_t data) {
// order and looping
@@ -938,7 +939,7 @@ gtkui_add_new_playlist (void) {
else {
snprintf (name, sizeof (name), _("New Playlist (%d)"), idx);
}
- deadbeef->plt_lock ();
+ deadbeef->pl_lock ();
for (i = 0; i < cnt; i++) {
char t[100];
void *plt = deadbeef->plt_get_handle (i);
@@ -947,7 +948,7 @@ gtkui_add_new_playlist (void) {
break;
}
}
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
if (i == cnt) {
return deadbeef->plt_add (cnt, name);
}
diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h
index 4074ddb2..e940bcfa 100644
--- a/plugins/gtkui/gtkui.h
+++ b/plugins/gtkui/gtkui.h
@@ -166,4 +166,7 @@ gtkui_playlist_set_curr (int playlist);
void
gtkui_setup_gui_refresh ();
+time_t
+gtkui_get_curr_playlist_modtime (void);
+
#endif
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index 340cbfb3..0c736150 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -108,7 +108,7 @@ int main_get_idx (DdbListviewIter it) {
void
main_drag_n_drop (DdbListviewIter before, int from_playlist, uint32_t *indices, int length, int copy) {
- deadbeef->plt_lock ();
+ deadbeef->pl_lock ();
int curr = deadbeef->plt_get_curr ();
if (copy) {
deadbeef->pl_copy_items (PL_MAIN, from_playlist, (DB_playItem_t *)before, indices, length);
@@ -116,7 +116,7 @@ main_drag_n_drop (DdbListviewIter before, int from_playlist, uint32_t *indices,
else {
deadbeef->pl_move_items (PL_MAIN, from_playlist, (DB_playItem_t *)before, indices, length);
}
- deadbeef->plt_unlock ();
+ deadbeef->pl_unlock ();
}
void main_external_drag_n_drop (DdbListviewIter before, char *mem, int length) {
@@ -284,6 +284,7 @@ DdbListviewBinding main_binding = {
.list_context_menu = list_context_menu,
.delete_selected = main_delete_selected,
.vscroll_changed = main_vscroll_changed,
+ .modification_time = gtkui_get_curr_playlist_modtime,
};
void
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index 8fbd8dc7..ad758007 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -328,7 +328,6 @@ on_remove_from_disk_activate (GtkMenuItem *menuitem,
}
deadbeef->pl_lock ();
- deadbeef->plt_lock ();
DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
while (it) {
@@ -341,7 +340,6 @@ on_remove_from_disk_activate (GtkMenuItem *menuitem,
}
int cursor = deadbeef->pl_delete_selected ();
- deadbeef->plt_unlock ();
deadbeef->pl_unlock ();
main_refresh ();
diff --git a/plugins/gtkui/search.c b/plugins/gtkui/search.c
index cde5ceea..9baf18f3 100644
--- a/plugins/gtkui/search.c
+++ b/plugins/gtkui/search.c
@@ -92,14 +92,6 @@ search_refresh (void) {
}
}
-void
-search_rebuild_groups (void) {
- if (searchwin) {
- GtkWidget *pl = lookup_widget (searchwin, "searchlist");
- ddb_listview_build_groups (DDB_LISTVIEW (pl));
- }
-}
-
///////// searchwin header handlers
gboolean
@@ -377,6 +369,7 @@ DdbListviewBinding search_binding = {
.header_context_menu = header_context_menu,
.list_context_menu = list_context_menu,
.delete_selected = search_delete_selected,
+ .modification_time = gtkui_get_curr_playlist_modtime,
};
void
diff --git a/plugins/gtkui/search.h b/plugins/gtkui/search.h
index ddfe2844..98216d5c 100644
--- a/plugins/gtkui/search.h
+++ b/plugins/gtkui/search.h
@@ -36,7 +36,4 @@ search_get_idx (DdbListviewIter it);
void
search_playlist_init (GtkWidget *widget);
-void
-search_rebuild_groups (void);
-
#endif // __SEARCH_H
diff --git a/plugins/gtkui/trkproperties.c b/plugins/gtkui/trkproperties.c
index cc419d59..5b58890c 100644
--- a/plugins/gtkui/trkproperties.c
+++ b/plugins/gtkui/trkproperties.c
@@ -339,7 +339,6 @@ trkproperties_fill_metadata (void) {
void
show_track_properties_dlg (void) {
- deadbeef->plt_lock ();
deadbeef->pl_lock ();
if (tracks) {
@@ -371,13 +370,11 @@ show_track_properties_dlg (void) {
}
else {
deadbeef->pl_unlock ();
- deadbeef->plt_unlock ();
return;
}
}
deadbeef->pl_unlock ();
- deadbeef->plt_unlock ();
GtkTreeView *tree;
GtkTreeView *proptree;