コード例 #1
0
ファイル: video_epg.c プロジェクト: mstorsjo/vlc
static char * GetDefaultArtUri( void )
{
    char *psz_uri = NULL;
    char *psz_path = config_GetSysPath(VLC_SYSDATA_DIR, "icons/hicolor/"
                                       "128x128/"PACKAGE_NAME".png");
    if( psz_path != NULL )
    {
        psz_uri = vlc_path2uri( psz_path, NULL );
        free( psz_path );
    }
    return psz_uri;
}
コード例 #2
0
ファイル: win32_factory.cpp プロジェクト: videolan/vlc
bool Win32Factory::init()
{
    LPCTSTR vlc_name = TEXT("VLC Media Player");
    LPCTSTR vlc_icon = TEXT("VLC_ICON");
    LPCTSTR vlc_class = TEXT("SkinWindowClass");

    // Get instance handle
    m_hInst = GetModuleHandle( NULL );
    if( m_hInst == NULL )
    {
        msg_Err( getIntf(), "Cannot get module handle" );
    }

    // Create window class
    WNDCLASS skinWindowClass;
    skinWindowClass.style = CS_DBLCLKS;
    skinWindowClass.lpfnWndProc = (WNDPROC)Win32Factory::Win32Proc;
    skinWindowClass.lpszClassName = vlc_class;
    skinWindowClass.lpszMenuName = NULL;
    skinWindowClass.cbClsExtra = 0;
    skinWindowClass.cbWndExtra = 0;
    skinWindowClass.hbrBackground = NULL;
    skinWindowClass.hCursor = LoadCursor( NULL, IDC_ARROW );
    skinWindowClass.hIcon = LoadIcon( m_hInst, vlc_icon );
    skinWindowClass.hInstance = m_hInst;

    // Register class and check it
    if( !RegisterClass( &skinWindowClass ) )
    {
        WNDCLASS wndclass;

        // Check why it failed. If it's because the class already exists
        // then fine, otherwise return with an error.
        if( !GetClassInfo( m_hInst, vlc_class, &wndclass ) )
        {
            msg_Err( getIntf(), "cannot register window class" );
            return false;
        }
    }

    // Create Window
    m_hParentWindow = CreateWindowEx( WS_EX_TOOLWINDOW, vlc_class,
        vlc_name, WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX,
        -200, -200, 0, 0, 0, 0, m_hInst, 0 );
    if( m_hParentWindow == NULL )
    {
        msg_Err( getIntf(), "cannot create parent window" );
        return false;
    }

    // Store with it a pointer to the interface thread
    SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() );

    // We do it this way otherwise CreateWindowEx will fail
    // if WS_EX_LAYERED is not supported
    SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
                      GetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE ) |
                      WS_EX_LAYERED );

    ShowWindow( m_hParentWindow, SW_SHOW );

    // Initialize the systray icon
    m_trayIcon.cbSize = sizeof( NOTIFYICONDATA );
    m_trayIcon.hWnd = m_hParentWindow;
    m_trayIcon.uID = 42;
    m_trayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE;
    m_trayIcon.uCallbackMessage = MY_WM_TRAYACTION;
    m_trayIcon.hIcon = LoadIcon( m_hInst, vlc_icon );
    wcscpy( m_trayIcon.szTip, vlc_name );

    // Show the systray icon if needed
    if( var_InheritBool( getIntf(), "skins2-systray" ) )
    {
        addInTray();
    }

    // Show the task in the task bar if needed
    if( var_InheritBool( getIntf(), "skins2-taskbar" ) )
    {
        addInTaskBar();
    }

    // Initialize the OLE library (for drag & drop)
    OleInitialize( NULL );

    // Initialize the resource path
    char *datadir = config_GetUserDir( VLC_USERDATA_DIR );
    m_resourcePath.push_back( (std::string)datadir + "\\skins" );
    free( datadir );
    datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
    m_resourcePath.push_back( (std::string)datadir + "\\skins" );
    m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
    m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
    m_resourcePath.push_back( (std::string)datadir + "\\share\\skins2" );
    free( datadir );

    // Enumerate all monitors available
    EnumDisplayMonitors( NULL, NULL, MonitorEnumProc, (LPARAM)&m_monitorList );
    int num = 0;
    for( std::list<HMONITOR>::iterator it = m_monitorList.begin();
         it != m_monitorList.end(); ++it, num++ )
    {
        MONITORINFO mi;
        mi.cbSize = sizeof( MONITORINFO );
        if( GetMonitorInfo( *it, &mi ) )
        {
            msg_Dbg( getIntf(), "monitor #%i, %ldx%ld at +%ld+%ld", num,
                        mi.rcMonitor.right - mi.rcMonitor.left,
                        mi.rcMonitor.bottom - mi.rcMonitor.top,
                        mi.rcMonitor.left,
                        mi.rcMonitor.top );
        }
    }

    // All went well
    return true;
}
コード例 #3
0
ファイル: notify.c プロジェクト: mstorsjo/vlc
/*****************************************************************************
 * ItemChange: Playlist item change callback
 *****************************************************************************/
static int ItemChange( vlc_object_t *p_this, const char *psz_var,
                       vlc_value_t oldval, vlc_value_t newval, void *param )
{
    VLC_UNUSED(psz_var); VLC_UNUSED(oldval); VLC_UNUSED(newval);
    char           psz_tmp[MAX_LENGTH];
    char           psz_notify[MAX_LENGTH];
    char           *psz_title;
    char           *psz_artist;
    char           *psz_album;
    char           *psz_arturl;
    input_thread_t *p_input = newval.p_address;
    intf_thread_t  *p_intf  = param;
    intf_sys_t     *p_sys   = p_intf->p_sys;

    if( !p_input )
        return VLC_SUCCESS;

    /* Playing something ... */
    input_item_t *p_input_item = input_GetItem( p_input );

    /* Checking for click on directories */
    if(p_input_item->i_type == ITEM_TYPE_DIRECTORY || p_input_item->i_type == ITEM_TYPE_PLAYLIST
        || p_input_item->i_type == ITEM_TYPE_NODE || p_input_item->i_type== ITEM_TYPE_UNKNOWN
        || p_input_item->i_type == ITEM_TYPE_CARD){
        return VLC_SUCCESS;
    }

    psz_title = input_item_GetTitleFbName( p_input_item );
    /* We need at least a title */
    if( EMPTY_STR( psz_title ) )
    {
        free( psz_title );
        return VLC_SUCCESS;
    }

    psz_artist = input_item_GetArtist( p_input_item );
    psz_album = input_item_GetAlbum( p_input_item );

    if( !EMPTY_STR( psz_artist ) )
    {
        if( !EMPTY_STR( psz_album ) )
            snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>\n%s\n[%s]",
                      psz_title, psz_artist, psz_album );
        else
            snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>\n%s",
                      psz_title, psz_artist );
    }
    else
        snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>", psz_title );

    free( psz_title );
    free( psz_artist );
    free( psz_album );

    GdkPixbuf *pix = NULL;
    psz_arturl = input_item_GetArtURL( p_input_item );

    if( psz_arturl )
    {
        char *psz = vlc_uri2path( psz_arturl );
        free( psz_arturl );
        psz_arturl = psz;
    }

    if( psz_arturl )
    { /* scale the art to show it in notify popup */
        GError *p_error = NULL;
        pix = gdk_pixbuf_new_from_file_at_scale( psz_arturl,
                                                 72, 72, TRUE, &p_error );
    }
    else /* else we show state-of-the art logo */
    {
        /* First try to get an icon from the current theme. */
        GtkIconTheme* p_theme = gtk_icon_theme_get_default();
        pix = gtk_icon_theme_load_icon( p_theme, "vlc", 72, 0, NULL);

        if( !pix )
        {
        /* Load icon from share/ */
            GError *p_error = NULL;
            char *psz_pixbuf = config_GetSysPath(VLC_SYSDATA_DIR,
                                     "icons/hicolor/48x48/"PACKAGE_NAME".png");
            if (psz_pixbuf != NULL)
            {
                pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
                free( psz_pixbuf );
            }
        }
    }

    free( psz_arturl );

    /* we need to replace '&' with '&amp;' because '&' is a keyword of
     * notification-daemon parser */
    const int i_len = strlen( psz_tmp );
    int i_notify = 0;
    for( int i = 0; i < i_len && i_notify < ( MAX_LENGTH - 5 ); i++ )
    { /* we use MAX_LENGTH - 5 because if the last char of psz_tmp is '&'
       * we will need 5 more characters: 'amp;\0' .
       * however that's unlikely to happen because the last char is '\0' */
        if( psz_tmp[i] != '&' )
        {
            psz_notify[i_notify] = psz_tmp[i];
        }
        else
        {
            strcpy( &psz_notify[i_notify], "&amp;" );
            i_notify += 4;
        }
        i_notify++;
    }
    psz_notify[i_notify] = '\0';

    vlc_mutex_lock( &p_sys->lock );

    Notify( p_this, psz_notify, pix, p_intf );

    vlc_mutex_unlock( &p_sys->lock );

    return VLC_SUCCESS;
}