summaryrefslogtreecommitdiff
path: root/plugins/gtkui/trkproperties.c
blob: 9f196671e307a38bc87999ad16e51a2cb8826585 (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
/*
    DeaDBeeF - ultimate music player for GNU/Linux systems with X11
    Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net>

    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 2
    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, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <string.h>
#include "trkproperties.h"
#include "interface.h"
#include "support.h"
#include "../../deadbeef.h"
#include "gtkui.h"

GtkWidget *trackproperties;

gboolean
on_trackproperties_delete_event        (GtkWidget       *widget,
                                        GdkEvent        *event,
                                        gpointer         user_data)
{
    trackproperties = NULL;
    return FALSE;
}

gboolean
on_trackproperties_key_press_event     (GtkWidget       *widget,
                                        GdkEventKey     *event,
                                        gpointer         user_data)
{
    if (event->keyval == GDK_Escape) {
        trackproperties = NULL;
        gtk_widget_destroy (widget);
    }
    return FALSE;
}

void
show_track_properties_dlg (DB_playItem_t *it) {
    if (!trackproperties) {
        trackproperties = create_trackproperties ();
        gtk_window_set_transient_for (GTK_WINDOW (trackproperties), GTK_WINDOW (mainwin));
    }
    GtkWidget *widget = trackproperties;
    GtkWidget *w;
    const char *meta;
    // fill in metadata
    // location
    w = lookup_widget (widget, "location");
    gtk_entry_set_text (GTK_ENTRY (w), it->fname);
    // title
    w = lookup_widget (widget, "title");
    meta = deadbeef->pl_find_meta (it, "title");
    if (!meta) {
        meta = "";
    }
    gtk_entry_set_text (GTK_ENTRY (w), meta);
    // artist
    w = lookup_widget (widget, "artist");
    meta = deadbeef->pl_find_meta (it, "artist");
    if (!meta) {
        meta = "";
    }
    gtk_entry_set_text (GTK_ENTRY (w), meta);
    // band
    w = lookup_widget (widget, "band");
    meta = deadbeef->pl_find_meta (it, "band");
    if (!meta) {
        meta = "";
    }
    gtk_entry_set_text (GTK_ENTRY (w), meta);
    // album
    w = lookup_widget (widget, "album");
    meta = deadbeef->pl_find_meta (it, "album");
    if (!meta) {
        meta = "";
    }
    gtk_entry_set_text (GTK_ENTRY (w), meta);
    // genre
    w = lookup_widget (widget, "genre");
    meta = deadbeef->pl_find_meta (it, "genre");
    if (!meta) {
        meta = "";
    }
    gtk_entry_set_text (GTK_ENTRY (w), meta);
    // year
    w = lookup_widget (widget, "year");
    meta = deadbeef->pl_find_meta (it, "year");
    if (!meta) {
        meta = "";
    }
    gtk_entry_set_text (GTK_ENTRY (w), meta);
    // track
    w = lookup_widget (widget, "track");
    meta = deadbeef->pl_find_meta (it, "track");
    if (!meta) {
        meta = "";
    }
    gtk_entry_set_text (GTK_ENTRY (w), meta);
    // comment
    w = lookup_widget (widget, "comment");
    meta = deadbeef->pl_find_meta (it, "comment");
    if (!meta) {
        meta = "";
    }
    GtkTextBuffer *buffer = gtk_text_buffer_new (NULL);
    gtk_text_buffer_set_text (buffer, meta, strlen (meta));
    gtk_text_view_set_buffer (GTK_TEXT_VIEW (w), buffer);
    g_object_unref (buffer);

    gtk_widget_show (widget);
    gtk_window_present (GTK_WINDOW (widget));
}