Context
I'm new to Vala development (although I have some years of experience with C#) under Linux, and I decided to recreate one of my C# programs, however, I need to use images in the UI.
My problem
How can I embed resource files (such as images) for later use in the UI? How to access them later? And how to put them in a button?
What I'm using
I'm using Linux (Mint) and Anjuta development IDE, with the Glade UI designer integrated. The Vala project targets a GTK+ 3.0 project.
What I've tried
I have tried adding a new specific objective for images, adding them into the project... But I don't seem to succeed.
I have seen the default images provided by Linux, and those work just fine, but I need to add my own.
Thanks in advance!
The normal approach would be to install your images to PREFIX/share/pixmaps/YOUR_APP. For example Gnumeric installs some .png files in /usr/share/pixmaps/gnumeric/.
You can use GResource to embed binary files (like images) into your executable if you really want to. The glib-compile-resources command can be added to your build system (see also this question).
You can also use icons from the users icon theme.
You didn't write what component you want to use to display your images, so I'll assume Gtk.Image here.
Gtk.Image has several constructors for the purpose of loading the image:
from_icon_name loads the image from the current icon theme (which is useful to support user themes).
from_resource loads the image from an embedded GResource.
from_file loads the image from a file.
See the main documentation of Gtk.Image for more methods. Some other widgets have similar methods to load images (for example toolbar buttons).
You should not use from_stock any more (There was a stock system in Gtk+ that is being replaced by freedesktop.org icon schemas).
Related
I have been finding it difficult to display a pdf on flutter windows and other desktop applications. Can someone help me out
This is the same as this question, but for Windows, so the answer is the same at a high level. As with Linux, PlatformView is not yet supported for Windows.
Two options that could work without PlatformView support:
Swap the window between displaying the Flutter view and a PDF view (if you want the PDF to fill the window while displayed).
Place the Flutter view and the PDF view side by side in the window (if you want both Flutter content and PDF content visible at the same time).
Both would require the work to be done in the native code, so you would need to either write a plugin, or implement it directly in your runner, and use a method channel to coordinate between Dart and native code.
I want to show a flash file (.swf) in my executable program on Windows.
Every single modern browser are able to do it by using the official flash plugin DLL by Adobe. But there's no documentation anywhere of HOW you do it!
For years I've searched high and low on the Internet for an answer to HOW DO YOU USE THE OFFICIAL FLASH PLAYER PLUGIN IN YOUR PROGRAMS?
Programming language doesn't matter, I can adapt. I just want instructions on how to do it. Links to hidden resources on the web or your own expertise. Say I make a program that uses OpenGL, I want to send the binary of a swf file to the flash plugin, get data back and then render it using OpenGL. But how? How do browsers do it? How how how???
Try this... if you are using .NET... use the ActiveX dll and create an activeX object, then load the swf file within that container.
Cheers.
I'm developing a HTML5 app with node-webkit.
I want my application to follow the icon theme of the host computer that runs it (primarly Linux hosts).
Frameworks such as GTK+ or QT successfully find the corresponding icon of a standard stock (such as NEW_FILE) based on the user's theme.
GTK icons theme are installed at $HOME/.icons or /usr/share/icons and icons theme share a common directory structure.
But is it any rule or algorithm to get an exact icon?
How can I look up a (NEW_FILE, SAVE_FILE or whatever) stock icon within the users theme?
I'm quite lost with this.
You could look in the source code for GTK+ or QT and see how they determine the right icons?
Here's the deal. I've animated + coded a variety of 'screensavers' in Actionscript3/Flash. They make extensive use of the timeline, AS3 code, the TweenLite library, and embedded fonts. That's the limit of my programming knowledge. I've tried, to no avail, to convert my .SWFs into screensaver files using a variety of software, such as InstantStorm. Somehow it never works, the code never executes properly, it's a disaster.
So, I'm wondering if it's possible to make a screensaver that simply contains an embedded browser, and have it point to my .SWF file, hosted on my web-server. Basically, imagine a full-screen website acting as a screensaver.
If this is possible, what is the EASIEST and FASTEST way for me to whip up a solution for both PCs and Macs? Language, etc. I'm hoping something that has a library I can simply draw from to embed the browser view :)
My startup is developing a product to do exactly this, it's called Screensaver Ninja and you can find it at https://Screensaver.Ninja.
You can set many different web pages with different timers. The configuration tool allows you log in and navigate to the page you want to display:
It uses WebKit, on Mac OS X it uses Safari's and on Windows it uses Chrome's and in both cases it has a separate session from any other browser installed on the computer.
Here's a small Windows-only solution:
https://github.com/cwc/web-page-screensaver/releases
You could modify this open-source one for the Mac so that it's hard-coded to your URL:
http://www.liquidx.net/blog/2010/11/13/webviewscreensaver-for-mac/
Modify hasConfigureSheet() to return NO and change the URL in kScreenSaverDefaultURL. And change the name!
Is there an application that lets you pack it with a bunch of html files and it will render them? Basically, I want an app that all it does is that it has an embedded browser, and I can pack it with my files. Is there such thing?
It would be nice if it was cross-platform or offered additional APIs.
My end goal is I wanna build an app that produces html and then compiles it and gives it to the user.
One solution is to use Opera Widgets, my app can build the html files, and then pack it as a desktop widget. But that requires user to have Opera installed. It would be nice if there was an embedded browser solution.
Try Adobe Air. It is basically a JS-heavy application packed in a platfrom-independent package. Also includes a WebKit-compatible browser.
May be less or more than what you need.