Finding file icon given a MIME type using GTK - gtk

Is there a way to find out which icon to use for a given MIME type, using GTK/pygtk?
I know about gio.File(filename).query_info("standard::icon").get_icon(), but I need to find the icon without having to read the file.

Try gio.content_type_get_icon(). E.g.:
>>> gio.content_type_get_icon ('text/python')
<gio.ThemedIcon at 0xb7d0f734: text-python, gnome-mime-text-python, text-x-generic>

Related

How to get the extension file of Input Stream

I have a code
var test = Base64.getDecoder.decode(base64);
ByteArrayInputStream(test);
var input_stream = new ByteArrayInputStream(test);
Logger.debug(test.getClass.getSimpleName)
How do I get the file extension of the variable input_stream?
I believe you are asking how to determine the image file format from its bytes.
This has already been answered here: Java get image extension/type using BufferedImage from URL
I would not use the term "file extension" to refer to the file format -- while many systems (including Windows) conventionally use the file name extension to indicate the file format, you cannot always rely on this convention, and these are two separate concepts. I found the above question by Googling "java how to detect image type"
Good luck!

go to file in eclipse by using location datatype

When clicking on a location type in the output window of eclipse, you can go to that file (location).
I would like to be able to trigger this with a method in rascal.
So to be clear, I have the location of a java method, I would like to trigger eclipse to focus on this file through rascal.
Take a look at the util::Editors module. It contains an edit function that opens any file you pass it, with the relevant editor, with optional highlights.
Note, that if you have a logical location like java+method://... you will have to lookup the actual physical location of the method in the m3 model using IO:resolveLocation, and use that. For example:
rascal>import IO;
ok
rascal>resolveLocation(|java+method:///io/usethesource/impulse/language/LanguageRegistry/IMPFileEditorMapping/setTheDefaultEditor(org.eclipse.ui.IEditorDescriptor)|)
loc: |project://impulse/src/io/usethesource/impulse/language/LanguageRegistry.java|(15638,134,<433,8>,<436,9>)
rascal>openEditor(resolveLocation(|java+method:///io/usethesource/impulse/language/LanguageRegistry/IMPFileEditorMapping/setTheDefaultEditor(org.eclipse.ui.IEditorDescriptor)|))
You are looking for openEditor in util::ValueUI.
First import util::ValueUI;, then try
openEditor(|project://rascal/src/org/rascalmpl/library/Map.rsc|);
and an editor for the Map module will open.

Regarding external-document in FOP

I am creating pdf file through the XML, XSL and FOP. I want PDF file contents to display external file contents such as word document.
I know for displaying image in PDF we use but what tag we should to display file contents other than pdf file type.
There's a FOP extension that claims to be able to do this:
jeremias-maerki.ch/development/fop/index.html
Also see xmlgraphics.apache.org/fop/1.0/extensions.html#external-document
When I used in this way
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
content-type="pdf" src="C:\temp\reports\p2.pdf"/>
I am getting exception as
org.apache.fop.apps.FOPException: Error(Unknown location): No element mapping definition found for fox:external-document
Let me know the reason.
THanks in advance.
I'd say you're probably using an old Apache FOP version which doesn't have the fox:external-document extension, yet. Please upgrade to FOP 1.0 (or at least 0.95).
Change the namespace from:
http://xml.apache.org/fop/extensions
to
http://xmlgraphics.apache.org/fop/extensions

How to add an extra plist property using CMake?

I'm trying to add the item
<key>UIStatusBarHidden</key><true/>
to my plist that's auto-generated by CMake. For certain keys, it appears there are pre-defined ways to add an item; for example:
set(MACOSX_BUNDLE_ICON_FILE ${ICON})
But I can't find a way to add an arbitrary property.
I tried using the MACOSX_BUNDLE_INFO_PLIST target property as follows: I'd like the resulting plist to be identical to the old one, except with the new property I want, so I just copied the auto-generated plist and set that as my template. But the plist uses some Xcode variables, which also look like ${foo}, and CMake grumbles about this:
Syntax error in cmake code when
parsing string
<string>com.bedaire.${PRODUCT_NAME:identifier}</string>
syntax error, unexpected cal_SYMBOL,
expecting } (47)
Policy CMP0010 is not set: Bad
variable reference syntax is an error.
Run "cmake --help-policy CMP0010"
for policy details. Use the
cmake_policy command to set the
policy and suppress this warning. This
warning is for project developers.
Use -Wno-dev to suppress it.
In any case, I'm not even sure that this is the right thing to do. I can't find a good example or any good documentation about this. Ideally, I'd just let CMake generate everything as before, and just add a single extra line. What can I do?
Have you looked into copying the relevant *.plist.in file in /opt/local/share/cmake-2.8/Modules (such as MacOSXBundleInfo.plist.in), editing it to put <key>UIStatusBarHidden</key><true/> (or #VAR_TO_REPLACE_BY_CMAKE#), and adding the directory of the edited version in the CMAKE_MODULE_PATH?
If you have CMake installed as an app bundle, then the location of that file is /Applications/CMake.app/Contents/share/cmake-N.N/Modules
You can add your values using # and pass #ONLY to configure_file.
Unfortunately there is no simple way to add custom line to generated file.

RedDot LiveServer dynament error

How do I go about debugging what a return code of -26504 means? It's the result of a 'content' dynament of type 'import'.
Sounds like the import dynament had some issues with the content it was trying to import. I would examine this file for any possible syntax issues (if the type is XSL or XML, it will need to be valid.)
I recommend checking your rde.log for a little more information. You can probably just search for the name of the content item you're trying to import.