예제 #1
0
// @pymethod |PyICustomDestinationList|AppendCategory|Adds a custom category to the jump list
PyObject *PyICustomDestinationList::AppendCategory(PyObject *self, PyObject *args)
{
	ICustomDestinationList *pICDL = GetI(self);
	if ( pICDL == NULL )
		return NULL;
	
	TmpWCHAR Category;
	PyObject *obCategory, *obItems;
	IObjectArray *Items;
	// @pyparm str|Category||Display name of the category, can also be a dll and resource id for localization
	// @pyparm <o PyIObjectArray>|Items||Collection of IShellItem and/or IShellLink interfaces
	if ( !PyArg_ParseTuple(args, "OO:AppendCategory", &obCategory, &obItems))
		return NULL;
	if (!PyWinObject_AsWCHAR(obCategory, &Category, FALSE))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obItems, IID_IObjectArray, (void **)&Items, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICDL->AppendCategory(Category, Items);
	Items->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList );
	Py_INCREF(Py_None);
	return Py_None;
}
// Removes that existing custom Jump List for this application.
void DeleteJumpList()
{
    ICustomDestinationList *pcdl;
    HRESULT hr = CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pcdl));
    if (SUCCEEDED(hr))
    {
        hr = pcdl->DeleteList(NULL);
        pcdl->Release();
    }
}
void JumpListsManager::deleteList(const wchar_t *appId)
{
	if (!appId)
		appId = m_appId;
	ICustomDestinationList *list;
	CoInitialize(0);
	HRESULT res = CoCreateInstance(CLSID_DestinationList, 0, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, (void**)&list);
	if (FAILED(res))
		return;
	res = list->DeleteList(appId);
	list->Release();
	m_actionInfoMap.clear();
}
예제 #4
0
bool wxTaskBarJumpListImpl::BeginUpdate()
{
    if ( m_destinationList == NULL )
        return false;

    unsigned int max_count = 0;
    HRESULT hr = m_destinationList->BeginList(&max_count,
        wxIID_IObjectArray, reinterpret_cast<void**>(&(m_objectArray)));
    if ( !m_appID.empty() )
        m_destinationList->SetAppID(m_appID.wc_str());

    return SUCCEEDED(hr);
}
예제 #5
0
void wxTaskBarJumpListImpl::Update()
{
    if ( !BeginUpdate() )
        return;

    AddTasksToDestinationList();
    AddCustomCategoriesToDestionationList();
    if ( m_recent_visible )
        m_destinationList->AppendKnownCategory(KDC_RECENT);
    if ( m_frequent_visible )
        m_destinationList->AppendKnownCategory(KDC_FREQUENT);
    CommitUpdate();
}
예제 #6
0
// @pymethod |PyICustomDestinationList|AbortList|Discards all changes
PyObject *PyICustomDestinationList::AbortList(PyObject *self, PyObject *args)
{
	ICustomDestinationList *pICDL = GetI(self);
	if ( pICDL == NULL )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICDL->AbortList( );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList );
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #7
0
void wxTaskBarJumpListImpl::AddCustomCategoriesToDestionationList()
{
    for ( wxTaskBarJumpListCategories::iterator it = m_customCategories.begin();
          it != m_customCategories.end();
          ++it )
    {
        IObjectCollection* collection = CreateObjectCollection();
        if ( !collection )
            continue;

        const wxTaskBarJumpListItems& tasks = (*it)->GetItems();
        for ( wxTaskBarJumpListItems::const_iterator iter = tasks.begin();
              iter != tasks.end();
              ++iter )
        {
            wxASSERT_MSG(
                (*iter)->GetType() == wxTASKBAR_JUMP_LIST_DESTIONATION,
                "Invalid category item." );
            AddShellLink(collection, *(*iter));
        }
        m_destinationList->AppendCategory((*it)->GetTitle().wc_str(),
                                          collection);
        collection->Release();
    }
}
// Builds a new custom Jump List for this application.
void CreateJumpList()
{
    // Create the custom Jump List object.
    ICustomDestinationList *pcdl;
    HRESULT hr = CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pcdl));
    if (SUCCEEDED(hr))
    {
        // Custom Jump Lists follow a push model - applications are responsible for providing an updated
        // list anytime the contents should be changed.  Lists are generated in a list-building
        // transaction that starts by calling BeginList.  Until the list is committed, Windows will
        // display the previous version of the list, if available.
        //
        // The cMinSlots out parameter indicates the minimum number of items that the Jump List UI is
        // guaranteed to display.  Applications can provide more items when building a custom Jump List,
        // but the extra items may not be displayed.  The number is dependant upon a number of factors,
        // such as screen resolution and the "Number of recent items to display in Jump Lists" user setting.
        // See the MSDN documentation on BeginList for more information.
        //
        // The IObjectArray returned from BeginList contains a list of items the user has chosen to remove
        // from their Jump List.  Applications must respect the user's removal of an item and not re-add any
        // item in the removed list during this list-building transaction.  Applications should also clear any
        // persited usage-tracking data for any item in the removed list.  If the user begins using a
        // previously removed item in the future, it may be re-added to the list.
        UINT cMinSlots;
        IObjectArray *poaRemoved;
        hr = pcdl->BeginList(&cMinSlots, IID_PPV_ARGS(&poaRemoved));
        if (SUCCEEDED(hr))
        {
            // Add content to the Jump List.
            hr = _AddCategoryToList(pcdl, poaRemoved);
            if (SUCCEEDED(hr))
            {
                hr = _AddTasksToList(pcdl);
                if (SUCCEEDED(hr))
                {
                    // Commit the list-building transaction.
                    hr = pcdl->CommitList();
                }
            }
            poaRemoved->Release();
        }
        pcdl->Release();
    }
}
예제 #9
0
// @pymethod <o PyIObjectArray>|PyICustomDestinationList|GetRemovedDestinations|Returns all the items removed from the jump list
PyObject *PyICustomDestinationList::GetRemovedDestinations(PyObject *self, PyObject *args)
{
	ICustomDestinationList *pICDL = GetI(self);
	if ( pICDL == NULL )
		return NULL;
	// @pyparm <o PyIID>|riid|IID_IObjectArray|The interface to return
	REFIID riid = IID_IObjectArray;
	void *pv;
	if ( !PyArg_ParseTuple(args, "|O&:GetRemovedDestinations", PyWinObject_AsIID, &riid))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICDL->GetRemovedDestinations( riid, &pv );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList );
	return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE);
}
예제 #10
0
// @pymethod |PyICustomDestinationList|AppendKnownCategory|Adds one of the predefined categories to the custom list
PyObject *PyICustomDestinationList::AppendKnownCategory(PyObject *self, PyObject *args)
{
	ICustomDestinationList *pICDL = GetI(self);
	if ( pICDL == NULL )
		return NULL;
	KNOWNDESTCATEGORY category;
	// @pyparm int|Category||shellcon.KDC_RECENT or KDC_FREQUENT
	if ( !PyArg_ParseTuple(args, "i:AppendKnownCategory", &category) )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICDL->AppendKnownCategory( category );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList );
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #11
0
// @pymethod |PyICustomDestinationList|SetAppID|Specifies the taskbar identifier for the jump list
// @comm Only needed if the calling app doesn't use the system-assigned default
PyObject *PyICustomDestinationList::SetAppID(PyObject *self, PyObject *args)
{
	ICustomDestinationList *pICDL = GetI(self);
	if ( pICDL == NULL )
		return NULL;
	TmpWCHAR AppID;
	PyObject *obAppID;
	// @pyparm str|AppID||The taskbar identifier of the application
	if ( !PyArg_ParseTuple(args, "O:SetAppID", &obAppID) )
		return NULL;
	if (!PyWinObject_AsWCHAR(obAppID, &AppID ))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICDL->SetAppID(AppID );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList );
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #12
0
// @pymethod |PyICustomDestinationList|AddUserTasks|Sets the entries shown in the Tasks category
PyObject *PyICustomDestinationList::AddUserTasks(PyObject *self, PyObject *args)
{
	ICustomDestinationList *pICDL = GetI(self);
	if ( pICDL == NULL )
		return NULL;
	PyObject *obItems;
	IObjectArray *Items;
	// @pyparm <o PyIObjectArray>|Items||Collection of <o PyIShellItem> and/or <o PyIShellLink> interfaces
	if ( !PyArg_ParseTuple(args, "O:AddUserTasks", &obItems))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obItems, IID_IObjectArray, (void **)&Items, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICDL->AddUserTasks(Items);
	Items->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList );
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #13
0
void wxTaskBarJumpListImpl::AddTasksToDestinationList()
{
    if ( !m_tasks.get() )
        return;

    IObjectCollection* collection = CreateObjectCollection();
    if ( !collection )
        return;

    const wxTaskBarJumpListItems& tasks = m_tasks->GetItems();
    for ( wxTaskBarJumpListItems::const_iterator it = tasks.begin();
          it != tasks.end();
          ++it )
    {
        wxASSERT_MSG( ((*it)->GetType() == wxTASKBAR_JUMP_LIST_TASK ||
                       (*it)->GetType() == wxTASKBAR_JUMP_LIST_SEPARATOR),
                      "Invalid task Item." );
        AddShellLink(collection, *(*it));
    }
    m_destinationList->AddUserTasks(collection);
    collection->Release();
}
예제 #14
0
bool wxTaskBarJumpListImpl::CommitUpdate()
{
    m_objectArray->Release();
    return SUCCEEDED(m_destinationList->CommitList());
}