1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
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.
25 #include <libmpd/libmpd.h>
26 #include <libmpd/libmpd-internal.h>
27 #include "gmpc-mpddata-model.h"
28 #include "gmpc-mpddata-model-private.h"
34 class Gmpc:MpdData:Model:Sort from Gmpc:MpdData:Model
35 (interface Gtk:Tree:Drag:Source)
36 (interface Gtk:Tree:Drag:Dest)
38 public gchar *playlist = {NULL} destroywith g_free;
40 property STRING playlist
42 blurb = "The current playlist name",
48 interface Gtk:Tree:Drag:Source
50 gboolean row_draggable (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path)
52 if(mpd_server_check_version(connection, 0,13,0))
59 interface Gtk:Tree:Drag:Source
61 gboolean drag_data_get (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path, Gtk:Selection:Data *selection_data)
65 interface Gtk:Tree:Drag:Source
67 gboolean drag_data_delete (Gtk:Tree:Drag:Source *drag_source, Gtk:Tree:Path *path)
72 interface Gtk:Tree:Drag:Dest
73 private gboolean drag_data_received
74 (Gtk:Tree:Drag:Dest *drag_dest,
76 Gtk:Selection:Data *selection_data)
78 GtkTreePath *path=NULL;
79 GtkTreeModel *model=NULL;
80 gint *ind = NULL, *ind2 = NULL;
82 if(dest == NULL || !gtk_tree_get_row_drag_data(selection_data, &model, &path))
86 if(GMPC_MPDDATA_MODEL(model)->num_rows < 2)
88 gtk_tree_path_free(path);
91 ind = gtk_tree_path_get_indices(dest);
92 ind2 = gtk_tree_path_get_indices(path);
93 if(ind && ind2 && GMPC_MPDDATA_MODEL_SORT(model)->playlist)
96 int original = ind2[0];
97 int destination = ind[0];
98 /* if(destination >0 && ind[1] != '\0') destination--; */
99 if(destination > original) destination--;
100 mpd_database_playlist_move(connection, GMPC_MPDDATA_MODEL_SORT(model)->playlist,original,destination);
101 data = mpd_database_get_playlist_content(connection, GMPC_MPDDATA_MODEL_SORT(model)->playlist);
102 gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(model), data);
104 gtk_tree_path_free(path);
108 interface Gtk:Tree:Drag:Dest
109 private gboolean row_drop_possible
110 (Gtk:Tree:Drag:Dest *drag_dest,
112 Gtk:Selection:Data *selection_data)
120 Gmpc:MpdData:Model:Sort *new (void)