summaryrefslogtreecommitdiff
path: root/gtkplaylist.h
blob: 25333c7fb075c424b4a9923b127e072e8a7512bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
    DeaDBeeF - ultimate music player for GNU/Linux systems with X11
    Copyright (C) 2009  Alexey Yakovenko

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTKPLAYLIST_H
#define __GTKPLAYLIST_H

#include <gtk/gtk.h>
#include <stdint.h>
#include <assert.h>
#include "playlist.h"

enum {
    TARGET_URILIST,
    TARGET_SAMEWIDGET,
};

#define ps_ncolumns 5
#define ps_colname_max 100

// structure of this kind must be set as user data for playlist, header and scrollbar widgets
// pointer to this structure must be passed too all functions that
// implement playlist functionality (like this pointer)
typedef struct {
    // cached gtk/gdk object pointers
    GtkWidget *playlist;
    GtkWidget *header;
    GtkWidget *scrollbar;
    GdkPixmap *backbuf;
    // parameters
    playItem_t **pcurr; // pointer to current item
    int *count; // pointer to count of items in list
    int iterator; // index into next array of playItem_t struct
    int lastpos[2]; // last mouse position (for playlist widget)
    int multisel; // if it uses multiple selection
    // current state
    int scrollpos;
    int row;
    double clicktime; // for doubleclick detection
    int nvisiblerows;
    int16_t *fmtcache; // cached text formatting
    int header_fitted[ps_ncolumns];
    char colnames_fitted[ps_ncolumns][ps_colname_max]; // cached formatted names of columns
    int colwidths[ps_ncolumns]; // current column widths
} gtkplaylist_t;

#define GTKPS_PROLOGUE \
    gtkplaylist_t *ps = (gtkplaylist_t *)gtk_object_get_data (GTK_OBJECT (widget), "ps"); assert (ps); 

void
gtkps_redraw_ps_row (gtkplaylist_t *ps, int row);

void
gtkps_redraw_ps_row_novis (gtkplaylist_t *ps, int row);

void
gtkps_setup_scrollbar (gtkplaylist_t *ps);

void
gtkps_draw_ps_row_back (gtkplaylist_t *ps, cairo_t *cr, int row, playItem_t *it);

void
gtkps_draw_ps_row (gtkplaylist_t *ps, cairo_t *cr, int row, playItem_t *it);

void
gtkps_draw_playlist (gtkplaylist_t *ps, int x, int y, int w, int h);

void
gtkps_reconf (gtkplaylist_t *ps);

void
gtkps_expose (gtkplaylist_t *ps, int x, int y, int w, int h);

void
gtkps_mouse1_pressed (gtkplaylist_t *ps, int state, int ex, int ey, double time);

void
gtkps_mouse1_released (gtkplaylist_t *ps, int state, int ex, int ey, double time);

void
gtkps_mousemove (gtkplaylist_t *ps, GdkEventMotion *event);

void
gtkps_scroll (gtkplaylist_t *ps, int newscroll);

void
gtkps_handle_scroll_event (gtkplaylist_t *ps, int direction);

void
gtkps_keypress (gtkplaylist_t *ps, int keyval, int state);

void
gtkps_track_dragdrop (gtkplaylist_t *ps, int y);

void
gtkps_handle_drag_drop (gtkplaylist_t *ps, int drop_y, uint32_t *d, int length);

void
gtkps_handle_fm_drag_drop (gtkplaylist_t *ps, int drop_y, void *ptr, int length);

void
gtkps_add_fm_dropped_files (gtkplaylist_t *ps, char *ptr, int length, int drop_y);

void
gtkps_select_single (gtkplaylist_t *ps, int sel);

void
gtkps_header_draw (gtkplaylist_t *ps);

void
gtkps_add_dir (gtkplaylist_t *ps, char *folder);

void
gtkps_add_files (gtkplaylist_t *ps, GSList *lst);

void
gtkps_configure (gtkplaylist_t *ps);

int
gtkps_get_idx_of (gtkplaylist_t *ps, playItem_t *it);

playItem_t *
gtkps_get_for_idx (gtkplaylist_t *ps, int idx);

// this functions take value from passed playlist, that's why it's here
void
gtkps_playsong (gtkplaylist_t *ps);

void
gtkps_songchanged (gtkplaylist_t *ps, int from, int to);

// these functions operate on global playlist level,
// no need to pass gtkplaylist_t ptr to them

void
gtkps_add_fm_dropped_files (gtkplaylist_t *ps, char *ptr, int length, int drop_y);

// these functions should not belong here
void
gtkps_prevsong (void);

void
gtkps_nextsong (void);

void
gtkps_randomsong (void);

void
gtkps_pausesong (void);

void
gtkps_playsongnum (int idx);

#endif // __GTKPLAYLIST_H