diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/callbacks.c | 21 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.c | 61 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.h | 4 | ||||
-rw-r--r-- | plugins/gtkui/fileman.c | 7 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 23 | ||||
-rw-r--r-- | plugins/gtkui/search.c | 2 |
6 files changed, 79 insertions, 39 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 2b4dd6b6..5065adda 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -349,32 +349,11 @@ on_loop_disable_activate (GtkMenuItem *menuitem, } void -on_playlist_realize (GtkWidget *widget, - gpointer user_data) -{ - GtkTargetEntry entry = { - .target = "STRING", - .flags = GTK_TARGET_SAME_WIDGET/* | GTK_TARGET_OTHER_APP*/, - TARGET_SAMEWIDGET - }; - // setup drag-drop source -// gtk_drag_source_set (widget, GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_MOVE); - // setup drag-drop target - gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_drag_dest_add_uri_targets (widget); -// gtk_drag_dest_set_track_motion (widget, TRUE); -} - -void on_searchlist_realize (GtkWidget *widget, gpointer user_data) { } - - - - char last_playlist_save_name[1024] = ""; void diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index 56f856d9..ae0a8f8a 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -103,7 +103,7 @@ ddb_listview_list_setup_hscroll (DdbListview *ps); void ddb_listview_list_set_hscroll (DdbListview *ps, int newscroll); void -ddb_listview_list_set_cursor (DdbListview *pl, int cursor); +ddb_listview_set_cursor (DdbListview *pl, int cursor); ////// header functions //// void @@ -449,6 +449,23 @@ ddb_listview_refresh (DdbListview *listview, uint32_t flags) { } } +void +ddb_listview_list_realize (GtkWidget *widget, + gpointer user_data) +{ + GtkTargetEntry entry = { + .target = "STRING", + .flags = GTK_TARGET_SAME_WIDGET/* | GTK_TARGET_OTHER_APP*/, + TARGET_SAMEWIDGET + }; + // setup drag-drop source +// gtk_drag_source_set (widget, GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_MOVE); + // setup drag-drop target + gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); + gtk_drag_dest_add_uri_targets (widget); +// gtk_drag_dest_set_track_motion (widget, TRUE); +} + gboolean ddb_listview_list_configure_event (GtkWidget *widget, GdkEventConfigure *event, @@ -609,7 +626,7 @@ void ddb_listview_hscroll_value_changed (GtkRange *widget, gpointer user_data) { - DdbListview *pl = DDB_LISTVIEW (widget); + DdbListview *pl = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); int newscroll = gtk_range_get_value (GTK_RANGE (widget)); ddb_listview_list_set_hscroll (pl, newscroll); } @@ -622,7 +639,8 @@ ddb_listview_list_drag_motion (GtkWidget *widget, guint time, gpointer user_data) { - ddb_listview_list_track_dragdrop (DDB_LISTVIEW (widget), y); + DdbListview *pl = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); + ddb_listview_list_track_dragdrop (pl, y); return FALSE; } @@ -738,7 +756,8 @@ ddb_listview_list_drag_leave (GtkWidget *widget, guint time, gpointer user_data) { - ddb_listview_list_track_dragdrop (DDB_LISTVIEW (widget), -1); + DdbListview *pl = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); + ddb_listview_list_track_dragdrop (pl, -1); } // debug function for gdk_draw_drawable @@ -748,6 +767,16 @@ draw_drawable (GdkDrawable *window, GdkGC *gc, GdkDrawable *drawable, int x1, in gdk_draw_drawable (window, gc, drawable, x1, y1, x2, y2, w, h); } +int +ddb_listview_get_vscroll_pos (DdbListview *listview) { + return listview->scrollpos; +} + +int +ddb_listview_get_hscroll_pos (DdbListview *listview) { + return listview->hscrollpos; +} + #define MIN_COLUMN_WIDTH 16 static GdkCursor* cursor_sz; @@ -984,11 +1013,13 @@ ddb_listview_select_single (DdbListview *ps, int sel) { if (idx == sel) { if (!ps->binding->is_selected (it)) { ps->binding->select (it, 1); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } } else if (ps->binding->is_selected (it)) { ps->binding->select (it, 0); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } DdbListviewIter next = PL_NEXT (it); @@ -1097,6 +1128,7 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, do DdbListviewIter it = ps->binding->get_for_idx (y); if (it) { ps->binding->select (it, 1 - ps->binding->is_selected (it)); + ddb_listview_draw_row (ps, y, it); ps->binding->selection_changed (it, y); UNREF (it); } @@ -1112,17 +1144,20 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, do if (idx >= start && idx <= end) { if (!ps->binding->is_selected (it)) { ps->binding->select (it, 1); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } } else { if (ps->binding->is_selected (it)) { ps->binding->select (it, 0); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } } DdbListviewIter next = PL_NEXT (it); UNREF (it); + it = next; } } cursor = ps->binding->cursor (); @@ -1260,11 +1295,13 @@ ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *event) { if (idx >= start && idx <= end) { if (!ps->binding->is_selected (it)) { ps->binding->select (it, 1); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } } else if (ps->binding->is_selected (it)) { ps->binding->select (it, 0); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } DdbListviewIter next = PL_NEXT(it); @@ -1393,11 +1430,13 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { for (it = ps->binding->head (); it; idx++) { if (idx >= start && idx <= end) { ps->binding->select (it, 1); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } else if (ps->binding->is_selected (it)) { ps->binding->select (it, 0); + ddb_listview_draw_row (ps, idx, it); ps->binding->selection_changed (it, idx); } DdbListviewIter next = PL_NEXT(it); @@ -1409,7 +1448,7 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { } else { ps->shift_sel_anchor = cursor; - ddb_listview_list_set_cursor (ps, cursor); + ddb_listview_set_cursor (ps, cursor); } return 1; } @@ -1893,7 +1932,7 @@ struct set_cursor_t { }; static gboolean -ddb_listview_list_set_cursor_cb (gpointer data) { +ddb_listview_set_cursor_cb (gpointer data) { struct set_cursor_t *sc = (struct set_cursor_t *)data; sc->pl->binding->set_cursor (sc->cursor); ddb_listview_select_single (sc->pl, sc->cursor); @@ -1932,13 +1971,13 @@ ddb_listview_list_set_cursor_cb (gpointer data) { } void -ddb_listview_list_set_cursor (DdbListview *pl, int cursor) { +ddb_listview_set_cursor (DdbListview *pl, int cursor) { int prev = pl->binding->cursor (); struct set_cursor_t *data = malloc (sizeof (struct set_cursor_t)); data->prev = prev; data->cursor = cursor; data->pl = pl; - g_idle_add (ddb_listview_list_set_cursor_cb, data); + g_idle_add (ddb_listview_set_cursor_cb, data); } gboolean @@ -1946,7 +1985,7 @@ ddb_listview_list_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - DdbListview *ps = DDB_LISTVIEW (widget); + DdbListview *ps = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); if (event->button == 1) { ddb_listview_list_mouse1_pressed (ps, event->state, event->x, event->y, event->time); } @@ -2065,7 +2104,7 @@ ddb_listview_list_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - DdbListview *ps = DDB_LISTVIEW (widget); + DdbListview *ps = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); if (event->button == 1) { ddb_listview_list_mouse1_released (ps, event->state, event->x, event->y, event->time); } @@ -2077,7 +2116,7 @@ ddb_listview_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { - DdbListview *ps = DDB_LISTVIEW (widget); + DdbListview *ps = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (widget), "owner")); ddb_listview_list_mousemove (ps, event); return FALSE; } diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h index 2fd1189f..7e4b467f 100644 --- a/plugins/gtkui/ddblistview.h +++ b/plugins/gtkui/ddblistview.h @@ -63,8 +63,8 @@ typedef struct { void (*ref) (DdbListviewIter); void (*unref) (DdbListviewIter); - int (*is_selected) (DdbListviewIter); void (*select) (DdbListviewIter, int sel); + int (*is_selected) (DdbListviewIter); // drag-n-drop void (*drag_n_drop) (DdbListviewIter before, uint32_t *indices, int length); @@ -172,6 +172,8 @@ DdbListviewIter ddb_listview_get_iter_from_coord (DdbListview *listview, int x, int y); int ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state); +void +ddb_listview_set_cursor (DdbListview *pl, int cursor); enum { DDB_REFRESH_COLUMNS = 1, diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c index 340db924..ba5c6070 100644 --- a/plugins/gtkui/fileman.c +++ b/plugins/gtkui/fileman.c @@ -5,6 +5,7 @@ #include "gtkui.h" #include "ddblistview.h" #include "progress.h" +#include "support.h" static gboolean progress_show_idle (gpointer data) { @@ -31,7 +32,7 @@ gtkpl_add_file_info_cb (DB_playItem_t *it, void *data) { static gboolean progress_hide_idle (gpointer data) { progress_hide (); - playlist_refresh (); + //playlist_refresh (); return FALSE; } @@ -97,7 +98,9 @@ static void open_files_worker (void *data) { GSList *lst = (GSList *)data; gtkpl_add_files (lst); - gtkpl_set_cursor (PL_MAIN, 0); + extern GtkWidget *mainwin; + DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist")); + ddb_listview_set_cursor (pl, 0); deadbeef->sendmessage (M_PLAYSONG, 0, 0, 0); } diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index da7cef6e..158ab7f2 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -741,6 +741,12 @@ static int main_get_cursor (void) { return deadbeef->pl_get_cursor (PL_MAIN); } + +static void +main_set_cursor (int cursor) { + return deadbeef->pl_set_cursor (PL_MAIN, cursor); +} + static DdbListviewIter main_head (void) { return (DdbListviewIter)deadbeef->pl_get_first (PL_MAIN); } @@ -1170,6 +1176,16 @@ main_delete_selected (void) { } void +main_select (DdbListviewIter it, int sel) { + deadbeef->pl_set_selected ((DB_playItem_t *)it, sel); +} + +int +main_is_selected (DdbListviewIter it) { + return deadbeef->pl_is_selected ((DB_playItem_t *)it); +} + +void on_add_audio_cd_activate (GtkMenuItem *menuitem, gpointer user_data) { @@ -1201,6 +1217,7 @@ DdbListviewBinding main_binding = { .sel_count = main_get_sel_count, .cursor = main_get_cursor, + .set_cursor = main_set_cursor, .head = main_head, .tail = main_tail, @@ -1210,6 +1227,9 @@ DdbListviewBinding main_binding = { .get_for_idx = main_get_for_idx, .get_idx = main_get_idx, + .is_selected = main_is_selected, + .select = main_select, + .drag_n_drop = main_drag_n_drop, .draw_column_data = main_draw_column_data, @@ -1229,9 +1249,6 @@ DdbListviewBinding main_binding = { .col_set_sort = main_col_set_sort, // callbacks -// .edit_column = main_edit_column, -// .add_column = main_add_column, -// .remove_column = main_remove_column, .handle_doubleclick = main_handle_doubleclick, .selection_changed = main_selection_changed, .header_context_menu = main_header_context_menu, diff --git a/plugins/gtkui/search.c b/plugins/gtkui/search.c index c7e8cb3b..026a3c61 100644 --- a/plugins/gtkui/search.c +++ b/plugins/gtkui/search.c @@ -181,7 +181,7 @@ on_searchwin_key_press_event (GtkWidget *widget, } else if (event->keyval != GDK_Delete && event->keyval != GDK_Home && event->keyval != GDK_End){ GtkWidget *pl = lookup_widget (mainwin, "searchlist"); - if (!gtkpl_keypress (DDB_LISTVIEW (pl), event->keyval, event->state)) { + if (!ddb_listview_handle_keypress (DDB_LISTVIEW (pl), event->keyval, event->state)) { return FALSE; } } |