<commit_before>/*****************************************************************************
 * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
 *****************************************************************************
 * Copyright (C) 2000, 2001 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <jpsaman _at_ videolan _dot_ org>
 *
 * 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.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <sys/types.h>                                              /* off_t */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include <vlc_vout.h>

#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>

#include <gtk/gtk.h>

#include "pda_callbacks.h"
#include "pda_interface.h"
#include "pda_support.h"
#include "pda.h"

#define VLC_MAX_MRL     256

static char *get_file_perms(struct stat st);

/*****************************************************************************
 * Useful function to retrieve p_intf
 ****************************************************************************/
void * __GtkGetIntf( GtkWidget * widget )
{
    void *p_data;

    if( GTK_IS_MENU_ITEM( widget ) )
    {
        /* Look for a GTK_MENU */
        while( widget->parent && !GTK_IS_MENU( widget ) )
        {
            widget = widget->parent;
        }

        /* Maybe this one has the data */
        p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
        if( p_data )
        {
            return p_data;
        }

        /* Otherwise, the parent widget has it */
        widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
    }

    /* We look for the top widget */
    widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );

    p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );

    return p_data;
}

static void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_size)
{
    intf_thread_t *p_intf = GtkGetIntf( widget );
    playlist_t    *p_playlist;
    int           i_id , i_pos=0;
    GtkTreeView   *p_tvplaylist = NULL;

    p_playlist = pl_Hold( p_intf );

    if( p_playlist ==  NULL)
    {   /* Bail out when VLC's playlist object is not found. */
        return;
    }

    /* Add to playlist object. */
    p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(widget), "tvPlaylist");
    if (p_tvplaylist)
    {
        GtkTreeModel *p_play_model;
        GtkTreeIter   p_play_iter;

        p_play_model = gtk_tree_view_get_model(p_tvplaylist);
 
        if (p_play_model)
        {
            int i;

            /* Add a new row to the playlist treeview model */
            gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
            gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
                                    0, name,   /* Add path to it !!! */
                                    1, "no info",
                                    2, playlist_CurrentSize(p_playlist), /* Hidden index. */
                                    -1 );

            /* Add to VLC's playlist */
#if 0
            if (p_intf->p_sys->b_autoplayfile)
            {
                playlist_Add( p_playlist, (const char*)name, (const char**)ppsz_options, i_size,
                              PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END);
            }
            else
#endif
            {
                i_id = playlist_AddExt( p_playlist, (const char*)name,
                              (const char*)name,
                              PLAYLIST_APPEND, PLAYLIST_END,
                              (mtime_t) 0,
                              i_options, (const char **) ppsz_options, VLC_INPUT_OPTION_TRUSTED,
                              true, pl_Unlocked );
            }

            /* Cleanup memory */
            for (i=0; i<i_size; i++)
                free(ppsz_options[i]);
            free(ppsz_options);
        }
    }
    pl_Release( p_intf );
}

void PlaylistRebuildListStore( intf_thread_t *p_intf,
    GtkListStore * p_list, playlist_t * p_playlist )
{
    GtkTreeIter iter;
    int         i_dummy;
    gchar *     ppsz_text[2];
#if 0
    GdkColor    red;
    red.red     = 65535;
    red.blue    = 0;
    red.green   = 0;
#endif
    PL_LOCK;
    for( i_dummy = 0; i_dummy < playlist_CurrentSize(p_playlist) ; i_dummy++ )
    {
        playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_dummy );
        if( p_item )
        {<commit_msg>pda: fix typo introduced by [ebd7cf22ae7d5b3a1bbf1cd8728926e78f831a9c]<commit_after>/*****************************************************************************
 * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
 *****************************************************************************
 * Copyright (C) 2000, 2001 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <jpsaman _at_ videolan _dot_ org>
 *
 * 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.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <sys/types.h>                                              /* off_t */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include <vlc_vout.h>

#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>

#include <gtk/gtk.h>

#include "pda_callbacks.h"
#include "pda_interface.h"
#include "pda_support.h"
#include "pda.h"

#define VLC_MAX_MRL     256

static char *get_file_perms(struct stat st);

/*****************************************************************************
 * Useful function to retrieve p_intf
 ****************************************************************************/
void * __GtkGetIntf( GtkWidget * widget )
{
    void *p_data;

    if( GTK_IS_MENU_ITEM( widget ) )
    {
        /* Look for a GTK_MENU */
        while( widget->parent && !GTK_IS_MENU( widget ) )
        {
            widget = widget->parent;
        }

        /* Maybe this one has the data */
        p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
        if( p_data )
        {
            return p_data;
        }

        /* Otherwise, the parent widget has it */
        widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
    }

    /* We look for the top widget */
    widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );

    p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );

    return p_data;
}

static void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_size)
{
    intf_thread_t *p_intf = GtkGetIntf( widget );
    playlist_t    *p_playlist;
    int           i_id , i_pos=0;
    GtkTreeView   *p_tvplaylist = NULL;

    p_playlist = pl_Hold( p_intf );

    if( p_playlist ==  NULL)
    {   /* Bail out when VLC's playlist object is not found. */
        return;
    }

    /* Add to playlist object. */
    p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(widget), "tvPlaylist");
    if (p_tvplaylist)
    {
        GtkTreeModel *p_play_model;
        GtkTreeIter   p_play_iter;

        p_play_model = gtk_tree_view_get_model(p_tvplaylist);
 
        if (p_play_model)
        {
            int i;

            /* Add a new row to the playlist treeview model */
            gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
            gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
                                    0, name,   /* Add path to it !!! */
                                    1, "no info",
                                    2, playlist_CurrentSize(p_playlist), /* Hidden index. */
                                    -1 );

            /* Add to VLC's playlist */
#if 0
            if (p_intf->p_sys->b_autoplayfile)
            {
                playlist_Add( p_playlist, (const char*)name, (const char**)ppsz_options, i_size,
                              PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END);
            }
            else
#endif
            {
                i_id = playlist_AddExt( p_playlist, (const char*)name,
                              (const char*)name,
                              PLAYLIST_APPEND, PLAYLIST_END,
                              (mtime_t) 0,
                              i_size, (const char **) ppsz_options, VLC_INPUT_OPTION_TRUSTED,
                              true, pl_Unlocked );
            }

            /* Cleanup memory */
            for (i=0; i<i_size; i++)
                free(ppsz_options[i]);
            free(ppsz_options);
        }
    }
    pl_Release( p_intf );
}

void PlaylistRebuildListStore( intf_thread_t *p_intf,
    GtkListStore * p_list, playlist_t * p_playlist )
{
    GtkTreeIter iter;
    int         i_dummy;
    gchar *     ppsz_text[2];
#if 0
    GdkColor    red;
    red.red     = 65535;
    red.blue    = 0;
    red.green   = 0;
#endif
    PL_LOCK;
    for( i_dummy = 0; i_dummy < playlist_CurrentSize(p_playlist) ; i_dummy++ )
    {
        playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_dummy );
        if( p_item )
        {
{'fraction_non_alphanumeric': 0.18528336380255941, 'fraction_numerical': 0.009414990859232175, 'mean_word_length': 2.341783750763592, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4715898', 'n_tokens_mistral': 3496, 'n_tokens_neox': 3288, 'n_words': 855}