skip menu and go to main content

body start

gramophone

  노틸러스에서 여러 파일 던져넣기 1 ]

03.01.07-20:57:55

306271

Submitted by Jang, Dong-Su

 

View692

 

//
// drag and drop supports
//

// drag and drop target type
#define DND_TARGET_TYPE_TEXT_URI_LIST "text/uri-list"
#define DND_TARGET_TYPE_PLAYLIST_IDICES "liteamp-playlist-indices"

// drag and drop target id
typedef enum {
    DND_TARGET_ID_TEXT_URI_LIST, // from nautilus
    DND_TARGET_ID_PLAYLIST_INDICES, // from other playlists(local D&D)
} DndTargetId;

// drag and drop targets
// playlist receives text/uri-list only from nautilus
static const GtkTargetEntry dnd_targets[] = {
    { DND_TARGET_TYPE_TEXT_URI_LIST, 0, DND_TARGET_ID_TEXT_URI_LIST },
    //{ DND_TARGET_TYPE_PLAYLIST_INDICES, 0, DND_TARGET_ID_LITEAMP_PLAYLIST_INDICES },
};

// supported mime types
static const gchar* dnd_mime_types[] = {
    "x-directory/normal",
    "audio/x-mp3",
    "application/x-ogg",
    NULL
};

// check mime type for dropped URI
#define IS_DND_MIME_TYPE_DIR(i) ((i) == 0)
#define IS_DND_MIME_TYPE_SUPPORTED_FILE(i) ((i) >= 1 || (i) <= 2)


....


/**
 * drag data dropped
 */
static void drag_data_received_cb(GtkWidget* widget,
        GdkDragContext* context, gint x, gint y,
        GtkSelectionData* selection_data,
        guint info, guint time, Playlist* pl)
{
    GtkTargetList* target_list;
    GdkAtom target;

    GList* uri_list;
    GList* i;

    GnomeVFSURI* uri;
    gchar* uri_str;
    gchar* mime_type;
    gchar* temp_str;

    // check targets
        target_list = gtk_target_list_new(dnd_targets, G_N_ELEMENTS(dnd_targets));
        target = gtk_drag_dest_find_target(widget, context, target_list);
        gtk_target_list_unref(target_list);
        if(target == GDK_NONE) return;

    uri_list = gnome_vfs_uri_list_parse(selection_data->data);

    if(uri_list == NULL) {
        gtk_drag_finish(context, FALSE, FALSE, time);
        return;
    }

    for(i = uri_list; i != NULL; i = g_list_next(i)) {
        uri = i->data;
        if(!uri) continue;
        playlist_add_uri(pl, uri, TRUE); 이거를 적당한 함수로 바꿔줘야 할듯 ...
    }

    gnome_vfs_uri_list_free(uri_list);

    gtk_drag_finish(context, TRUE, FALSE, time);
}

전체코드는 liteamp의 playlist.c에 들어 있습니다. 그럼~ 휘릭=3=3=3

Comments on this artfact

1 Comments

Jang, Dong-Su

//
// drag and drop supports
//

// drag and drop target type
#define DND_TARGET_TYPE_TEXT_URI_LIST "text/uri-list"
#define DND_TARGET_TYPE_PLAYLIST_IDICES "liteamp-playlist-indices"

// drag and drop target id
typedef enum {
    DND_TARGET_ID_TEXT_URI_LIST, // from nautilus
    DND_TARGET_ID_PLAYLIST_INDICES, // from other playlists(local D&D)
} DndTargetId;

// drag and drop targets
// playlist receives text/uri-list only from nautilus
static const GtkTargetEntry dnd_targets[] = {
    { DND_TARGET_TYPE_TEXT_URI_LIST, 0, DND_TARGET_ID_TEXT_URI_LIST },
    //{ DND_TARGET_TYPE_PLAYLIST_INDICES, 0, DND_TARGET_ID_LITEAMP_PLAYLIST_INDICES },
};

// supported mime types
static const gchar* dnd_mime_types[] = {
    "x-directory/normal",
    "audio/x-mp3",
    "application/x-ogg",
    NULL
};

// check mime type for dropped URI
#define IS_DND_MIME_TYPE_DIR(i) ((i) == 0)
#define IS_DND_MIME_TYPE_SUPPORTED_FILE(i) ((i) >= 1 || (i) <= 2)


....


/**
 * drag data dropped
 */
static void drag_data_received_cb(GtkWidget* widget,
        GdkDragContext* context, gint x, gint y,
        GtkSelectionData* selection_data,
        guint info, guint time, Playlist* pl)
{
    GtkTargetList* target_list;
    GdkAtom target;

    GList* uri_list;
    GList* i;

    GnomeVFSURI* uri;
    gchar* uri_str;
    gchar* mime_type;
    gchar* temp_str;

    // check targets
        target_list = gtk_target_list_new(dnd_targets, G_N_ELEMENTS(dnd_targets));
        target = gtk_drag_dest_find_target(widget, context, target_list);
        gtk_target_list_unref(target_list);
        if(target == GDK_NONE) return;

    uri_list = gnome_vfs_uri_list_parse(selection_data->data);

    if(uri_list == NULL) {
        gtk_drag_finish(context, FALSE, FALSE, time);
        return;
    }

    for(i = uri_list; i != NULL; i = g_list_next(i)) {
        uri = i->data;
        if(!uri) continue;
        playlist_add_uri(pl, uri, TRUE); 이거를 적당한 함수로 바꿔줘야 할듯 ...
    }

    gnome_vfs_uri_list_free(uri_list);

    gtk_drag_finish(context, TRUE, FALSE, time);
}

전체코드는 liteamp의 playlist.c에 들어 있습니다. 그럼~ 휘릭=3=3=3

03.01.07-20:57:55