dialogs.cpp 4.41 KB
Newer Older
Gildas Bazin's avatar
 
Gildas Bazin committed
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 128 129 130 131 132 133 134 135 136 137 138 139
/*****************************************************************************
 * dialogs.cpp: Handles all the different dialog boxes we provide.
 *****************************************************************************
 * Copyright (C) 2003 VideoLAN
 * $Id: dialogs.cpp,v 1.10 2003/07/17 17:30:40 gbazin Exp $
 *
 * Authors: Gildas Bazin <gbazin@netcourrier.com>
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111,
 * USA.
 *****************************************************************************/

//--- VLC -------------------------------------------------------------------
#include <vlc/vlc.h>
#include <vlc/intf.h>

//--- SKIN ------------------------------------------------------------------
#include "../os_api.h"
#include "event.h"
#include "banks.h"
#include "theme.h"
#include "../os_theme.h"
#include "themeloader.h"
#include "window.h"
#include "vlcproc.h"
#include "skin_common.h"
#include "dialogs.h"

/* Callback prototype */
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
                       vlc_value_t old_val, vlc_value_t new_val, void *param );

//---------------------------------------------------------------------------
// Implementation of Dialogs class
//---------------------------------------------------------------------------
Dialogs::Dialogs( intf_thread_t *_p_intf )
{
    /* Errors while loading the dialogs provider are not fatal.
     * Dialogs just won't be available. */

    p_intf = _p_intf;
    p_intf->p_sys->p_dialogs = this;
    b_popup_change = VLC_FALSE;

    /* Allocate descriptor */
    p_provider = (intf_thread_t *)vlc_object_create( p_intf, VLC_OBJECT_INTF );
    if( p_provider == NULL )
    {
        msg_Err( p_intf, "out of memory" );
        return;
    }

    p_module = module_Need( p_provider, "dialogs provider", NULL );
    if( p_module == NULL )
    {
        msg_Err( p_intf, "no suitable dialogs provider found" );
        vlc_object_destroy( p_provider );
        p_provider = NULL;
        return;
    }

    /* Initialize dialogs provider
     * (returns as soon as initialization is done) */
    if( p_provider->pf_run ) p_provider->pf_run( p_provider );
}

Dialogs::~Dialogs()
{
    if( p_provider && p_module )
    {
        module_Unneed( p_provider, p_module );
        vlc_object_destroy( p_provider );
    }
}

void Dialogs::ShowDialog( intf_thread_t *p_intf, int i_dialog_event,
                          int i_arg )
{
}

void Dialogs::ShowOpen( bool b_play )
{
    if( p_provider && p_provider->pf_show_dialog )
        p_provider->pf_show_dialog( p_provider, INTF_DIALOG_FILE, b_play );
}

void Dialogs::ShowOpenSkin()
{
    if( p_provider && p_provider->pf_show_dialog )
        p_provider->pf_show_dialog( p_provider, INTF_DIALOG_FILE, 0 );
}

void Dialogs::ShowMessages()
{
    if( p_provider && p_provider->pf_show_dialog )
        p_provider->pf_show_dialog( p_provider, INTF_DIALOG_MESSAGES, 0 );
}

void Dialogs::ShowPrefs()
{
    if( p_provider && p_provider->pf_show_dialog )
        p_provider->pf_show_dialog( p_provider, INTF_DIALOG_PREFS, 0 );
}

void Dialogs::ShowFileInfo()
{
    if( p_provider && p_provider->pf_show_dialog )
        p_provider->pf_show_dialog( p_provider, INTF_DIALOG_FILEINFO, 0 );
}

void Dialogs::ShowPopup()
{
}

/*****************************************************************************
 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
 *  We don't show the menu directly here because we don't want the
 *  caller to block for a too long time.
 *****************************************************************************/
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
                        vlc_value_t old_val, vlc_value_t new_val, void *param )
{
    Dialogs *p_dialogs = (Dialogs *)param;
    p_dialogs->ShowPopup();

    return VLC_SUCCESS;
}