Modify version string to post-release version 0.18.101
[gmpc.git] / src / gmpc-mpddata-model-sort.gob
blob681863ba07d6b90046be5402af6c84c97138a8ad
1 /* Gnome Music Player Client (GMPC)
2  * Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl>
3  * Project homepage: http://gmpc.wikia.com/
4  
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 requires 2.0.0
22 %ht{
23 #include <gtk/gtk.h>
24 #include <libmpd/libmpd.h>
25 #include <libmpd/libmpd-internal.h>
26 #include "gmpc-mpddata-model.h"
27 #include "gmpc-mpddata-model-private.h"
33 class Gmpc:MpdData:Model:Sort from Gmpc:MpdData:Model
34                 (interface Gtk:Tree:Drag:Source)
35                 (interface Gtk:Tree:Drag:Dest)
37                 public gchar *playlist = {NULL} destroywith g_free;
39         property STRING playlist 
40                 (nick = "playlist",
41                 blurb = "The current playlist name",
42                 default_value = NULL, 
43                 export,
44                 link);
47                 interface Gtk:Tree:Drag:Source
48                 private 
49                 gboolean row_draggable (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path)
50                 {
51                         if(mpd_server_check_version(connection, 0,13,0))
52                         {
53                                 return TRUE;
54                         }
55                         return FALSE;
56                 }
58                 interface Gtk:Tree:Drag:Source
59                         private 
60                 gboolean drag_data_get (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path, Gtk:Selection:Data *selection_data)
61                 {
62                         return FALSE;
63                 }
64                 interface Gtk:Tree:Drag:Source
65                         private 
66                 gboolean drag_data_delete (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path) 
67                 {
68                         return TRUE;
69                 }
71                 interface Gtk:Tree:Drag:Dest
72                 private gboolean drag_data_received 
73                                 (Gtk:Tree:Drag:Dest *drag_dest, 
74                                  Gtk:Tree:Path *dest,
75                                  Gtk:Selection:Data *selection_data) 
76                 {
77                         GtkTreePath *path=NULL;
78                         GtkTreeModel *model=NULL;
79                         gint *ind = NULL, *ind2 = NULL;
80                         if(dest == NULL || !gtk_tree_get_row_drag_data(selection_data, &model, &path))
81                         {
82                                 return FALSE;
83                         }
84                         if(GMPC_MPDDATA_MODEL(model)->num_rows < 2)
85                         {
86                                 gtk_tree_path_free(path);
87                                 return FALSE;
88                         }
89                         ind = gtk_tree_path_get_indices(dest);
90                         ind2 = gtk_tree_path_get_indices(path);
91                         if(ind && ind2 && GMPC_MPDDATA_MODEL_SORT(model)->playlist)
92                         {
93                                 MpdData *data = NULL;
94                                 int original = ind2[0];
95                                 int destination = ind[0];
96                                 /*              if(destination >0 && ind[1] != '\0') destination--; */
97                                 if(destination > original) destination--;
98                                 mpd_database_playlist_move(connection, GMPC_MPDDATA_MODEL_SORT(model)->playlist,original,destination);
99                                 data = mpd_database_get_playlist_content(connection, GMPC_MPDDATA_MODEL_SORT(model)->playlist); 
100                                 gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(model), data);               
101                         }
102                         gtk_tree_path_free(path);
103                         return TRUE;
104                 }
106                 interface Gtk:Tree:Drag:Dest
107                 private gboolean row_drop_possible 
108                                         (Gtk:Tree:Drag:Dest *drag_dest,
109                                          Gtk:Tree:Path          *dest,
110                                          Gtk:Selection:Data *selection_data)
111                 {
112                         return TRUE;
113                 }
117                 public
118                 Gmpc:MpdData:Model:Sort *new (void)
119                 {
120                         return GET_NEW;
121                 }