1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl>
3 * Project homepage: http://gmpc.wikia.com/
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.
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
41 blurb = "The current playlist name",
47 interface Gtk:Tree:Drag:Source
49 gboolean row_draggable (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path)
51 if(mpd_server_check_version(connection, 0,13,0))
58 interface Gtk:Tree:Drag:Source
60 gboolean drag_data_get (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path, Gtk:Selection:Data *selection_data)
64 interface Gtk:Tree:Drag:Source
66 gboolean drag_data_delete (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path)
71 interface Gtk:Tree:Drag:Dest
72 private gboolean drag_data_received
73 (Gtk:Tree:Drag:Dest *drag_dest,
75 Gtk:Selection:Data *selection_data)
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))
84 if(GMPC_MPDDATA_MODEL(model)->num_rows < 2)
86 gtk_tree_path_free(path);
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)
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);
102 gtk_tree_path_free(path);
106 interface Gtk:Tree:Drag:Dest
107 private gboolean row_drop_possible
108 (Gtk:Tree:Drag:Dest *drag_dest,
110 Gtk:Selection:Data *selection_data)
118 Gmpc:MpdData:Model:Sort *new (void)