1 /*
2  *  Copyright (C) 2005 Marc Pavot <marc.pavot@gmail.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2, or (at your option)
7  *  any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef __ARIO_TREE_H
21 #define __ARIO_TREE_H
22 
23 #include <gtk/gtk.h>
24 #include "servers/ario-server.h"
25 #include "sources/ario-source.h"
26 #include "shell/ario-shell-coverdownloader.h"
27 
28 G_BEGIN_DECLS
29 
30 #define TYPE_ARIO_TREE         (ario_tree_get_type ())
31 #define ARIO_TREE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_ARIO_TREE, ArioTree))
32 #define ARIO_TREE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), TYPE_ARIO_TREE, ArioTreeClass))
33 #define IS_ARIO_TREE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_ARIO_TREE))
34 #define IS_ARIO_TREE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_ARIO_TREE))
35 #define ARIO_TREE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_ARIO_TREE, ArioTreeClass))
36 
37 typedef struct ArioTreePrivate ArioTreePrivate;
38 
39 /**
40  * ArioTree is used by ArioBrowser to list one kind of tag on
41  * music server. Criteria are associated to ArioTree to filter
42  * items in the list.
43  */
44 typedef struct
45 {
46         GtkScrolledWindow parent;
47 
48         ArioTreePrivate *priv;
49 
50         GtkWidget *tree;
51         GtkListStore *model;
52         GtkTreeSelection *selection;
53 
54         ArioServerTag tag;
55         gboolean is_first;
56 
57         /* List of ArioServerCriteria */
58         GSList *criterias;
59 } ArioTree;
60 
61 typedef struct
62 {
63         GString *string;
64         ArioTree *tree;
65 } ArioTreeStringData;
66 
67 typedef struct
68 {
69         GtkScrolledWindowClass parent;
70 
71         /* Virtual methods */
72         void            (*build_tree)           (ArioTree *tree,
73                                                  GtkTreeView *treeview);
74         void            (*fill_tree)            (ArioTree *tree);
75 
76         GdkPixbuf*      (*get_dnd_pixbuf)       (ArioTree *tree);
77 
78         void            (*get_drag_source)      (const GtkTargetEntry** targets,
79                                                  int* n_targets);
80         void            (*append_drag_data)     (ArioTree *tree,
81                                                  GtkTreeModel *model,
82                                                  GtkTreeIter *iter,
83                                                  ArioTreeStringData *data);
84         void            (*add_to_playlist)      (ArioTree *tree,
85                                                  const PlaylistAction action);
86         /* Signals */
87         void            (*selection_changed)    (ArioTree *tree);
88 
89         void            (*menu_popup)           (ArioTree *tree);
90 } ArioTreeClass;
91 
92 GType                   ario_tree_get_type              (void) G_GNUC_CONST;
93 
94 GtkWidget*              ario_tree_new                   (ArioServerTag tag,
95                                                          gboolean is_first);
96 void                    ario_tree_fill                  (ArioTree *tree);
97 
98 void                    ario_tree_clear_criterias       (ArioTree *tree);
99 
100 void                    ario_tree_add_criteria          (ArioTree *tree,
101                                                          ArioServerCriteria *criteria);
102 GSList*                 ario_tree_get_criterias         (ArioTree *tree);
103 
104 void                    ario_tree_cmd_add               (ArioTree *tree,
105                                                          const PlaylistAction action);
106 void                    ario_tree_goto_playling_song    (ArioTree *tree,
107                                                          const ArioServerSong *song);
108 void                    ario_tree_add_tags              (ArioTree *tree,
109                                                          ArioServerCriteria *criteria,
110                                                          GSList *tags);
111 void                    ario_tree_get_cover             (ArioTree *tree,
112                                                          const ArioShellCoverdownloaderOperation operation);
113 G_END_DECLS
114 
115 #endif /* __ARIO_TREE_H */
116