mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 20:10:08 +01:00
Add wx.FileType.GetIconInfo
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@75694 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -142,6 +142,33 @@ def run():
|
||||
c.find('GetAllCommands.verbs').out = True
|
||||
c.find('GetAllCommands.commands').out = True
|
||||
|
||||
c.addCppMethod('PyObject*', 'GetIconInfo', '()',
|
||||
doc="""\
|
||||
Returns a tuple containing the Icon for this file type, the file where the
|
||||
icon is found, and the index of the image in that file, if applicable.
|
||||
""",
|
||||
body="""\
|
||||
wxIconLocation loc;
|
||||
if (self->GetIcon(&loc)) {
|
||||
wxString iconFile = loc.GetFileName();
|
||||
int iconIndex = -1;
|
||||
#ifdef __WXMSW__
|
||||
iconIndex = loc.GetIndex();
|
||||
#endif
|
||||
// Make a tuple and put the values in it
|
||||
wxPyThreadBlocker blocker;
|
||||
PyObject* tuple = PyTuple_New(3);
|
||||
PyTuple_SetItem(tuple, 0,
|
||||
wxPyConstructObject(new wxIcon(loc), wxT("wxIcon"), true));
|
||||
PyTuple_SetItem(tuple, 1, wx2PyString(iconFile));
|
||||
PyTuple_SetItem(tuple, 2, wxPyInt_FromLong(iconIndex));
|
||||
return tuple;
|
||||
}
|
||||
else
|
||||
RETURN_NONE();
|
||||
""")
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
c = module.find('wxFileTypeInfo')
|
||||
|
||||
@@ -40,6 +40,16 @@ class mimetype_Tests(wtc.WidgetTestCase):
|
||||
self.assertEqual(fti.GetExtensions(), ['ext1', 'ext2', 'ext3'])
|
||||
self.assertEqual(fti.GetExtensionsCount(), 3)
|
||||
|
||||
def test_mimetype5(self):
|
||||
ft = wx.TheMimeTypesManager.GetFileTypeFromMimeType('image/png')
|
||||
if ft:
|
||||
info = ft.GetIconInfo()
|
||||
if info is not None:
|
||||
self.assertTrue(isinstance(info, tuple))
|
||||
self.assertTrue(len(info) == 3)
|
||||
self.assertTrue(isinstance(info[0], wx.Icon))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user