Archive

Archive for the ‘Open Source Software’ Category

Blast from the Past: Open formats are… the best formats?

December 2nd, 2016 No comments

This post was originally published on January 17, 2016. The original can be found here.


Over the past few years there has been a big push to replace proprietary formats with open formats. For example Open Document Format and Office Open XML have largely replaced the legacy binary formats, we’re now seeing HTML5 + JavaScript supplant Silverlight and Java applets, and even the once venerable Flash is on its deathbed.

This of course all makes sense. We’re now in an era where the computing platforms, be it Microsoft Windows, Apple OS X, Android, iOS, Linux, etc., simply don’t command the individual market shares (or at least mind shares) that they once used to. Things are… more diversified now. And while they may not matter to the user the underlying differences in technologies certainly matter to the developer. This is one of the many reasons you see lots of movement to open formats where the same format can be implemented, relatively easily, on all of the aforementioned platforms.

So then the question must be asked: does this trend mean that open formats are the best formats? That is obviously quite a simple question to a deep (and perhaps subjective) subject so perhaps it’s better to look at it from a user adoption perspective. Does being an open format, given all of its advantages, translate to market adoption? There the answer is not as clear.

Open by example

Let’s take a look a few instances where a clear format winner exists and see if it is an open format or a closed/proprietary format.

Documents

When it comes to documents the Open Document Format and Open Office XML have largely taken over. This has been driven largely by Microsoft making Office Open XML the default file format in all versions of Microsoft Office since 2007. Additionally many governments and organizations around the world have standardized on the use of Open Document Format. That said older Microsoft Office binary formats (i.e. .doc, .xls, etc.) are still widely in use.

Verdict: open formats have largely won out.

Audio

For the purposes of the “audio” category let’s consider simply the audio codec that most people use to consume their music. In that regard MP3 is still the absolute dominant format. While it is somewhat encumbered by patents you will hardly find a single device out there that doesn’t support it. This is true even when there are better lossy compression formats (including the proprietary AAC or open Ogg Vorbis) as well as lossless formats like FLAC.

Verdict: the closed/proprietary MP3 format is the de facto standard.

Video

Similarly for the “video” category I’ll only be focusing on the codecs. While there are plenty of open video formats (Theora, WebM, etc.) they are not nearly as well supported as the proprietary formats like MPEG-2, H.264, etc. Additionally the open formats (in general) don’t have quite as good quality vs size ratios as the proprietary ones which is often while you’ll see websites using them in order to save on bandwidth.

Verdict: closed/proprietary formats have largely won out.

File Compression

Compression is something that most people consider more as an algorithm than a format which is why I’ll be focusing on the compressed file container formats for this category. In that regard the ZIP file format is by far the most common. It has native support in every modern operating system and offers decent compression. Other open formats, such as 7-Zip, offer better performance and even some proprietary formats, like RAR, have seen widespread use but for the most part ZIP is the go-to format. What muddies the waters here a bit is that the base ZIP format is open but some of the features added later on were not. However the majority of uses are based on the open standards.

Verdict: the open zip format is the most widely used standard.

Native Applications vs Web Apps

While applications may not, strictly speaking, be a format it does seem to be the case that every year there are stories about how Web Apps will soon replace Native Applications. So far however the results are a little mixed with e-mail being a perfect example of this paradox. For personal desktop e-mail web apps, mostly Gmail and the like, have largely replaced native applications like Microsoft Outlook and Thunderbird. On mobile however the majority of users still access their e-mail via native “apps”. And even then in enterprises the majority of e-mail usage is still done via native applications. I’m honestly not sure which will eventually win out, if either, but for now let’s call it a tie.

Verdict: tie.

The answer to the question is…

Well just on the five quick examples above we’ve got wins for 2 open formats, 2 closed/proprietary formats and one tie. So clearly based on market adoption we’re at a stand still.

Personally I’d prefer if open formats would take over because then I wouldn’t have to worry about my device supporting the format in question or not. Who knows, maybe by next year we’ll see one of the two pull ahead.

This post originally appeared on my website here.

 




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Alternative software: Vocal Podcast Client

November 1st, 2016 No comments

In my never-ending quest to seek out the hidden gems amongst the Linux alternative software pile I decided to take a look into what was offered in terms of podcast clients or podcatchers if you prefer. It wasn’t long into my Googling that I stumbled across a beautiful piece of software that I had never even heard of before: the Vocal podcast client.

What a nice, clean interface

What a nice, clean interface

Originally designed for elementaryOS this application presents a very clean, attractive interface for managing both your audio and video podcasts. It comes with a few different options like the basics – ability to stream versus download the podcasts or quickly skip forward/backward – but it was how it walked the user through setting it up the first time that actually impressed me the most. Here’s a look at that process.

When you first open the application you are presented with the following screen:

Two pretty standard options and one very intriguing one

Two pretty standard options and one very intriguing one

As you can see in the screenshot there are two pretty standard options – Add a new Feed or Import Subscriptions from another application – but it was the third option that really intrigued me. So what exactly is the Vocal Starter Pack? It’s a curated list of high-quality podcasts that give a good spread of different podcast types and topics, a perfect place for a new user to start getting into podcasts. Seriously this is a really awesome idea!

The Starter Pack imports just like any other export you may have brought over

The Starter Pack imports just like any other export you may have brought over

So once you’ve select your podcasts or imported them you can begin the fun part – the actual listening or watching of your episodes. Selecting an audio episode will display the embedded show notes and other information about it. This is a neat touch and lets you quickly see what other episodes are in the feed that you may want to listen to as well.

Podcast feed and related info

Podcast feed and related info

Or if video podcasts are more your thing Vocal has you covered there as well.

That's an unfortunate screenshot

That’s an unfortunate screenshot

Overall for as simple as this application is I’m very impressed with Vocal. Sure it only does the basics but it does it really well! If the feature set of the upcoming version 2 is anything to go by Vocal has a good future ahead of it (What? Built in iTunes store podcast browser? Heck yeah!).




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Alternative software: Midori Browser

October 30th, 2016 No comments

In my previous post I spoke about how the Linux platform has an incredible amount of alternative software and wrote a bit about my experiences using one of those applications: the Konqueror browser. I decided to stay in the same genre of applications and take a look at another alternative web browser Midori.

Midori is an interesting browser whose main goal seems to be to strip away the clutter and really streamline the web browsing experience. It’s no surprise then that Midori has ended up as the default web browser for other lightweight and streamlined distributions such as elementary OS, Bodhi Linux and SliTaz at one time or another. It is also neat from a technical perspective as portions of the browser are written in the Vala programming language.

So what does it look like when you first launch the browser then?

Sigh... Another alternative browser that shows an error on first launch...

Sigh… another alternative browser that shows an error on first launch…

Midori itself is a very nice looking browser but I was disappointed to immediately see an error just like the first time I tried Konqueror. To its credit however I’m almost certain that this error is a result of me running it on Linux Mint 18 – and thus missing the Ubuntu related file it was looking for. So really… this is more of a bug on Linux Mint’s end than a problem with Midori.

Poking around in the application preferences shows a commitment to that streamlined design even in the settings menus. Beyond that there wasn’t too much to note there.

Browsing The Linux Experiment

Browsing The Linux Experiment

So how does Midori handle as a web browser then? First off let me say that it does remarkably better than Konqueror did. Pages seemed to render fine and I only had minor issues overall.

The first issue I hit was that some embedded media and plugins didn’t seem to work. For example I couldn’t get an embedded PDF to display at all. Perhaps this is something that can be fixed by finding a Midori specific plugin?

Another oddity I could see was that sometimes the right fonts wouldn’t be used or the website text would be rendered slightly larger than it would be in Firefox or Chrome for example. For the slightly larger font issue it’s kind of strange to describe… it’s as if Midori shows the text as bolded while the other browsers don’t.

I figured that as a lightweight, streamlined browser it might be a decent idea to quickly see memory usage differences between it and Firefox (just to give a baseline). At first the results showed a clear memory usage advantage to Midori when only viewing one website:

Browser Memory Usage
Firefox 144MB
Midori 46MB

However after opening 4 additional tabs and waiting for them to all finish loading the story reversed quite substantially:

Browser Memory Usage
Firefox 183MB
Midori 507MB

I have no idea why there would be such a difference between the two or why Midori’s memory usage would skyrocket like that but I guess the bottom line is that you may want to reconsider your choice if you’re planning on using Midori on a system with low RAM.

Finally if I had to give one last piece of criticism it would be that even as a stripped down, streamlined browser Midori still doesn’t feel quite as fast as something like Chrome.

Other than those mostly minor issues though Midori did really well. Even YouTube’s HTML5 playback controls worked as expected! I might even recommend people try out Midori if they’re looking for an alternative web browser to use in their day-to-day computing.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Alternative software: Konqueror Browser

October 27th, 2016 4 comments

The Linux platform has an absolute wealth of what I would call alternative software. Many of these applications were built simply to fill in a gap or provide a missing function but since then a real culture of alternative software has emerged as well. What do I mean by this? Well there are many developers who have decided that instead of putting their time and resources into building up a pre-existing application they would rather try building something similar, but different, from scratch themselves. This is both a strength and a weakness for the Linux platform overall because while it means there is always constant innovation many of the applications lack a sense of development and usability maturity about them.

Just visit one of the many, many websites that do nothing but feature these alternatives.

Just visit one of the many, many websites that do nothing but feature these alternatives.

 

One such alternative in the world of file and web browsers is Konqueror. This classic KDE application has been around since 1996 and wears many different hats from file browser and web browser to image and document viewer, etc.

As a bit of background – I only really played around with Konqueror briefly a few years ago, so when I installed it on my Linux Mint 18 Cinnamon computer I was interested in seeing how it performed. Unfortunately when I launched the application the first thing that greeted me was a half-broken interface…

Not the best start...

Not the best start…

I’m not sure if the missing images were as a result of me not running it on KDE but this wasn’t the best first impression all the same.

Next I decided to take a look through the various settings and menus to see what options were available. Most of it was pretty standard fare but I was intruiged by what appeared to be the option to change the web browser engine from KHTML to… well I’m not really sure to be honest as there was only the one option.

Configuring Konqueror

Configuring Konqueror

Being a web browser I figured what better way to run it through its paces than load up a few web sites and see how things go. For the most part Konqueror proved to be an adequate, if not slow, web browser but I also ran into a number of rendering problems along the way. For example while watching videos on YouTube none of the playback controls were visible. Another time I visited a website and there was a weird white square over top of one of the menus.

On the left is Google Chrome rendering it correctly. On the right is Konqueror overlaying a weird square for some reason.

On the left is Google Chrome rendering it correctly. On the right is Konqueror overlaying a weird square for some reason.

When I tried loading up a popular news website Konqueror gave up and completely stop responding. None of these are reasons to recommend anyone actually use this browser over something like Firefox or Chrome.

So if Konqueror isn’t a great web browser how does it compare as a file browser? The short answer is even worse. I tried browsing to my home directory and instead just got what appears to be a low-level file system/type error…

Oh yeah, I'm sure the average user knows exactly what an inode is...

Oh yeah, I’m sure the average user knows exactly what an inode is…

If it isn’t obvious by now I think it’s safe to state the obvious: I would not recommend using Konqueror as an alternative to either one of the mainstream web browsers (i.e. Firefox, Chrome, etc.) or standard file browsers.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Trying out KeePassX

October 23rd, 2016 No comments

KeePassX is an independent implementation of the popular password manager that supports the KeePass (kdb) and KeePass2 (kdbx) database formats. Like the official KeePass application, KeePassX is open source but the main difference is that KeePass requires Microsoft’s .NET framework or the Mono runtime to be installed whereas KeePassX does not.

The feature list from their website shows that KeePassX offers:

  • Extensive management
    • title for each entry for its better identification
    • possibility to determine different expiration dates
    • insertion of attachments
    • user-defined symbols for groups and entries
    • fast entry dublication
    • sorting entries in groups
  • Search function
    • search either in specific groups or in complete database
  • Autofill (experimental)
  • Database security
    • access to the KeePassX database is granted either with a password, a key-file (e.g. a CD or a memory-stick) or even both.
  • Automatic generation of secure passwords
    • extremly customizable password generator for fast and easy creation of secure passwords
  • Precaution features
    • quality indicator for chosen passwords
    • hiding all passwords behind asterisks
  • Encryption
    • either the Advanced Encryption Standard (AES) or the Twofish algorithm are used
    • encryption of the database in 256 bit sized increments
  • Import and export of entries
    • import from PwManager (*.pwm) and KWallet (*.xml) files
    • export as textfile (*.txt)
  • Operating system independent
    • KeePassX is cross platform, so are the databases, as well
  • Free software
    • KeePassX is free software, published under the terms of the General Public License, so you are not only free to use it free of charge, but also to redistribute it, to examine and/or modify it’s source code and to publish your modifications as long as you provide the same freedoms for your modified version.

I’ve been a long time user of KeePass and figured I would check out KeePassX to see if there were any advantages to making the switch. Opening up my existing KeePass2 database was a breeze and even the ‘experimental’ autofill seemed to work just fine. I should also point out that, at least on Linux, KeePassX seems to be much quicker and definitely feels more native compared to the WinForms+Mono official version (I imagine the opposite is true while running on Windows).

The password generation tool for KeePassX is also very similar to the one in the official KeePass however they’ve opted for some defaults which could actually reduce the randomness, and thus security, of a password: exclude look-alike characters, ensure that the password contains characters from every group, etc.

The Password Generator in the official KeePass application

The Password Generator in the official KeePass application

These defaults do make it a bit easier to read or transcribe the passwords should you ever need to and given a long enough password the impact on security should be minimal.

The Password Generator in KeePassX

The Password Generator in KeePassX

So what are my feelings on KeePassX overall? In my limited use it seems like an excellent alternative to the official KeePass application and one that may almost be preferred on non-Windows platforms. I think I’ll be making the switch to KeePassX for my Linux-based installs.

Update: after some slow progress a few developers decided to fork the KeePassX project over at KeePassX Reboot. We’ll have to see how things with this fork play out but I wanted to mention it here in case you decided that the fork was the better version for you.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

How To Set Up An OpenVPN Client On Linux

September 28th, 2016 No comments

Getting a VPN set up right on your Linux machine has a number of advantages, especially today when online privacy is a must and files are being shared remotely more extensively than ever. First off, securing your connection with a virtual private network will keep your online traffic encrypted and safe from hackers and other people with malicious intents. But originally, VPNs weren’t used for that reason at all; rather, they were exactly what the name suggests: virtual private networks. By connecting to a VPN, your computer and, for example, your colleague’s remote computer (that’s not physically connected to it via a LAN cable), can “see” each other as if they were part of a local area network and share files via the Internet. VPNs can also be utilized for remotely accessing a computer to offer assistance, or for whatever other reason you’d need to.

OpenVPN is regarded as one of the most secure and most efficient tunneling protocols for VPNs, and fortunately enough it’s quite simple to set up an OpenVPN client on a Linux computer if you know your way around the terminal.

Installing and Configuring The Client

First of all, you have to install the OpenVPN package, which you can easily do via the terminal command sudo apt-get install openvpn. Enter your sudo password (the password of your account) and press Enter. A few dependencies ask for permission to be installed, so just accept all of them for the installation to finish.

Then you’ll have to grab a few certificates off the server that the client side needs in order for OpenVPN to work. Locate the following files on your server PC and put them on a flash drive, so that you can copy them to your client PC:

  • /etc/openvpn/easy-rsa/keys/hostname.crt

  • /etc/openvpn/easy-rsa/keys/hostname.key

  • /etc/openvpn/ca.crt

  • /etc/openvpn/ta.key

Copy all of the files to the /etc/openvpn directory of your client PC (note that instead of “hostname”, in the first two files, it will be the hostname of your client). To further configure the client you have to use the command sudo cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf /etc/openvpn, which copies a sample configuration file to the right directory.

Editing The Configuration File

Use a text editor such as gpedit to open the client.conf file and locate the following text:

dev tap
remote vpn.example.com 1181
cert hostname.crt
key hostname.key
tls-auth ta.key 1

You need to make a few changes here. Instead of “vpn.example.com”, put your server’s address. “1181” should be the port of your OpenVPN server, and “hostname” should, once again, be the actual name of the certificates that you copied to etc/openvpn/easy-rsa/keys a moment ago.

Now that you’ve set all of this up, you need to restart OpenVPN with the following command: sudo /etc/init.d/openvpn restart. Your remote local area network should be accessible now, which you can check by pinging the server’s VPN IP address.

Setting Up A Graphic UI Tool for OpenVPN

Unless you feel like using the terminal to navigate to every file and folder on your virtual network, it’s a good idea to set up some kind of a GUI. The Gadmin OpenVPN client does a fantastic job at this, and it’s real simple to set up, either via the Ubuntu Software Center, Synaptic or PackageKit. No matter what you choose, once it’s installed simply run the command sudo gadmin-openvpn-client and a neat graphic user interface will appear on the screen.

Now all you have to do is input some information about the server, and you’re set. Fill in the Connection name (what you’d like the connection to your VPN to be called), the Server address (the IP address of your OpenVPN server), the Server port, and the location of the certificates (the ca.crt and ta.key files mentioned earlier). Once you’re done with that, click the Add button, select the connection that you’ve just created and click Activate. Your VPN network will now be accessible.

That’s it, you’re done! You now have your own OpenVPN server that you can use to share data. Note that there are plenty other GUI tools for VPNs to be found in the Software store, so if you don’t like Gadmin, you can always use something else and still have access to OpenVPN, just through a different interface.

Summary

As you can see, it’s pretty simple to set up an OpenVPN client and connect to an existing VPN server. Setting up an OpenVPN server on Linux is a bit more of a challenge, though it’s perfectly possible. For a better and smoother experience, though, you might want to think about subscribing to a dedicated VPN provider, such as ExpressVPN. It’s not free, but it’ll give you greater security and stability, and save you the hassle of maintaining an OpenVPN server by yourself. If you’re interested, you should check out some ExpressVPN reviews before you make your choice.

Thomas Milva is an IT Security Analyst, Web entrepreneur and Tech enthusiast. He is the co-editor of http://wefollowtech.com

KWLUG: Personal Information Manager Synchronization (2016-07)

July 9th, 2016 No comments

This is a podcast presentation from the Kitchener Waterloo Linux Users Group on the topic of Personal Information Manager Synchronization published on July 5th 2016. You can find the original Kitchener Waterloo Linux Users Group post here.

Read more…




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

RetroPie – turning your Raspberry Pi into a retro-gaming console!

June 12th, 2016 No comments

Recently I decided to pick up a new Raspberry Pi 3 B from BuyaPi.ca. I wasn’t exactly sure what I was going to do with it but I figured with all of the neat little projects going on for the device I would find something. After doing some searching I stumbled upon a few candidate projects before finally settling on RetroPie as my first shot at playing around with the Raspberry Pi.

RetroPie works great on other Raspberry Pi models as well but performance is much better on the 3

RetroPie works great on other Raspberry Pi models as well but performance is much better on the 3

RetroPie, as their site says, “allows you to turn your Raspberry Pi into a retro-gaming machine.” It does this by linking together multiple Raspberry Pi projects, including Raspbian, EmulationStation, RetroArch and more, into a really nice interface that essentially just works out of the box.

Setup

The setup couldn’t be easier. Simply follow the instructions to download a ready made image for your SD Card, put the RetroPie image on your SD Card, plug in a controller (I used a wired Xbox 360 controller), power it on and follow the setup instructions.

When it gets to the controller configuration settings screen be careful what you select. If you follow the on-screen button pushes by default (i.e. button “A” for “A” and button “B” for “B”, etc.) you will end up with something that matches the name of the button but not the placement you’re expecting. This is because RetroPie/RetroArch uses the SNES Controller layout as its default.

The 'default' SNES controller layout

The ‘default’ SNES controller layout

So if you simply followed the on-screen wizard and pushed the Xbox 360 controller’s “A” button instead of it’s “B” button (which is the location of the “A” button on the SNES) you’ll experience all sorts of weird behaviour in the various emulators. So be sure to actually follow the setup guide for your particular controller (see below for example).

Notice how you actually have to push "B" when it asks for "A" and so on during the initial controller configuration

Notice how you actually have to push “B” when it asks for “A” and so on during the initial controller configuration

The one confusing downside to this work around is that all of the menus in RetroPie itself still ask you to push “A” or “B” but they really mean what you mapped that to, so it’s kind of backwards until you actually get into a game. That said it’s a minor thing and one that I’m sure I could fix, if I cared enough to do so, by setting a custom alternative controller layout for the menu only.

Games

RetroPie supports a crazy number of emulators. No seriously it’s a bit ridiculous. Look at this list (as of the time of writing):

RetroPie automatically detects if you have games for the systems. So if you had a SNES game for example you would get a SNES system to choose from on the main menu.

RetroPie automatically detects if you have games for the systems. So if you had a SNES game you would get a SNES system to choose from on the main menu.

Additionally you get PC emulators like DOSBox and the Apple II and there are a number of custom ports of PC games including DOOM, Duke Nukem 3D, Minecraft Pi Edition, OpenTTD and more!

Now obviously not all of the above emulators work flawlessly. Some are still labeled experimental and some systems even offer multiple emulators so you can customize it to the game you are trying to play – just in case one emulator happens to offer better compatibility than another. That said for the majority of the emulators I tried, especially for the older systems, things work great.

The RetroPie SD Card contains various folders that you simply copy the ROM or various bits of game data to. Once the files are there you just restart EmulationStation and it automatically discovers the new games.

Remote Storage

One thing I had to try was to see if I could use a remote share to play the games on the RetroPie off of my NAS instead. This would save quite a bit of space on the SD Card and as long as the transfer speeds between the Raspberry Pi and the NAS were decent enough should actually work.

I figured using a Windows share from the NAS was the easiest (this would also let you share games from basically any computer on your network). Here are the steps to set it up:

SSH into the Raspberry Pi

The default login for RetroPie is username pi and password raspberry. You can usually find it on the network by simply connecting to the device name retropie.

Add remote mounts to fstab

The most simple way to set up the remote mounts is to use fstab. This will ensure that the system gets the share as soon as it boots up. However you might run into problems booting the RaspberryPi if it can’t find the share on the network… so that is something to keep in mind.

Open up /etc/fstab (I used nano):

sudo nano /etc/fstab

Then add a line that looks like this to the end of the file

//{the location of the share}    /home/pi/RetroPie/roms/{the location to mount it}    cifs    guest,uid=1000,iocharset=utf8    0    0

replacing the pieces in { brackets } with where you actually want things to mount. So for example let’s say the NAS is at IP address 192.168.1.50 and you wanted to mount a share on the NAS called SNES that contains SNES ROMs for RetroPie. First I would recommend creating a new sub-directory in the standard SNES ROMs location so that you can have both ROMs on the SD Card and remote ones:

mkdir /home/pi/RetroPie/roms/snes/NASGames

Then you would add something like this to your fstab file:

//192.168.1.50/SNES    /home/pi/RetroPie/roms/snes/NASGames    cifs    guest,uid=1000,iocharset=utf8    0    0

The next time you boot up your Raspberry Pi it should successfully add that remote share and show you any SNES ROMs that are on the NAS in RetroPie!

After testing a few remote games this way I can say that it does indeed work well (via WiFi no less!). This is especially true for the older systems where game size is only a few KiB or MiBs. When you start to get into larger PC or disc based games were the sizes are in the hundreds of MiB it still works decently well but the first time you access something you might notice a bit of a delay. Thankfully Linux does a decent job of caching the file data after it’s read it once and so subsequent reads are much faster. That said if you had a good wired connection I have no doubt that things would work even more smoothly.

Portable Console? Best Console? A bit of both.

The RetroPie project is really neat, not only for its feature set but also because as a games console it’s one of the smallest and has the potential to have one of the largest games library ever!

My setup is pretty plain but some people have done awesome things with theirs!

My setup is pretty plain but some people have done awesome things with theirs like turning it into a full arcade cabinet!

If you like to play classic games then I would seriously recommend giving RetroPie a try.

This post originally appeared on my website here.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

KWLUG: Raspberry Pi Projects (2016-06)

June 11th, 2016 No comments

This is a podcast presentation from the Kitchener Waterloo Linux Users Group on the topic of Raspberry Pi Projects published on June 7th 2016. You can find the original Kitchener Waterloo Linux Users Group post here.

Read more…




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

KWLUG: Sound in Linux, Part 2 (2016-05)

June 11th, 2016 No comments

This is a podcast presentation from the Kitchener Waterloo Linux Users Group on the topic of Sound in Linux, Part 2 published on May 3rd 2016. You can find the original Kitchener Waterloo Linux Users Group post here.

Read more…




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Fix: trying to overwrite ‘/usr/share/accounts/services/google-im.service’ installing kubuntu-desktop

June 5th, 2016 No comments

I have an Ubuntu 16.04 desktop installation with Unity and wanted to try KDE, so I ran sudo apt-get install kubuntu-desktop. apt failed with the following message:

trying to overwrite '/usr/share/accounts/services/google-im.service', which is also in package account-plugin-google [...]

The original issue at Ask Ubuntu has several suggestions but none of them worked – any apt commands returned the same requirement to run apt-get -f install, which in turn gave the original “trying to overwrite” error message. synaptic also wasn’t installed so I couldn’t use it (or install it, as all other apt installation commands failed.)

I was able to get the dpkg database out of its bad state and continue to install kubuntu-desktop by running the following:

dpkg -P account-plugin-google unity-scope-gdrive
apt-get -f install

(Link to original Kubuntu bug for posterity: https://bugs.launchpad.net/kubuntu-ppa/+bug/1451728)

This post was cross-posted to my personal website.

Categories: God Damnit Linux, Jake B, KDE, Kubuntu, Ubuntu Tags:

Extract album art from MP3 files

May 7th, 2016 No comments

Recently I needed to extract the album art from an MP3 file and came across a really easy to use command line utility called eyeD3 to do just that (among other things). Here is how you can extract all of the album art from a file MyFile.mp3 into a directory called Output.

1) Install eyeD3

sudo apt-get install eyeD3

2) Extract all embedded album art from the file

eyeD3 --write-images=Output/ MyFile.mp3

Pretty simple!




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

KWLUG: Docker Tutorial (2016-04)

April 23rd, 2016 No comments

This is a podcast presentation from the Kitchener Waterloo Linux Users Group on the topic of Docker published on April 5th 2016. You can find the original Kitchener Waterloo Linux Users Group post here.

Read more…




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

KWLUG: Mastering Photo DVDs, KDEnlive (2016-03)

March 8th, 2016 No comments

This is a podcast presentation from the Kitchener Waterloo Linux Users Group on the topic of Mastering Photo DVDs, KDEnlive published on March 8th 2016. You can find the original Kitchener Waterloo Linux Users Group post here.

Read more…




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Murdering misbehaving applications with xkill

March 5th, 2016 No comments

Have you ever had a window in Linux freeze on you and no matter how many times you tried to close it, it just wouldn’t go away? Then when you try and find the process in System Monitor (or the like) you can’t seem to identify it for whatever reason?

Thankfully there is a really easy to use command that lets you simply click on the offending window and POOF!… it goes away instantly. So how does it work? Let’s say you have a window that is frozen like this

As long as you can see it you can kill it!

As long as you can see it you can xkill it!

First open up a new terminal window and type the command

xkill

and hit Enter. This will then tell you to simply click on the window you want to kill:

Select the window whose client you wish to kill with button 1….

Next it is as simple as actually clicking on the frozen window and you can say goodbye to your problem. Happy xkill-ing 🙂

This post originally appeared on my website here.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Setting up Syncthing to share files on Linux

February 21st, 2016 No comments

Syncthing is a file sharing application that lets you easily, and securely, share files between computers without having to store them on a third party server. It is most analogous to BitTorrent Sync (BTS) but whereas BTS is somewhat undocumented and closed source, Syncthing is open source and uses an open protocol that can be independently verified.

This is going to be a basic guide to configure Syncthing to sync a folder between multiple computers. I’m also going to configure these to start automatically when the system starts up and run Syncthing in the background so it doesn’t get in your way if you don’t want to see it.

Download and Install

While it may be possible to get Syncthing from your distribution’s repositories I prefer to grab it right from the source. So for example you can grab the appropriate version for your Linux computer (for example the 64 bit syncthing-linux-amd64-v0.12.19.tar.gz download) right from their website.

Extract the contents to a new folder in your home directory (or a directory wherever you want it to live). One important thing to note is that you want whatever user will be running the program, for example your user account, to have write access to that folder so that Syncthing can auto-update itself. For example you could extract the files to ~/syncthing/ to make things easy.

To start Syncthing all you need to do is execute the syncthing binary in that directory. If you want to configure syncthing to start without also starting up the browser you can simply run it using the -no-browser flag or by changing this behaviour in the settings.

If you are on Debian, Ubuntu or derivatives (such as Linux Mint) there is also an official repository you can add. The steps can be found here but I’ve re-listed them below for completeness sake:

# Add the release PGP keys:
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -

# Add the "release" channel to your APT sources:
echo "deb http://apt.syncthing.net/ syncthing release" | sudo tee /etc/apt/sources.list.d/syncthing.list

# Update and install syncthing:
sudo apt-get update
sudo apt-get install syncthing

This will install syncthing to /usr/bin/syncthing. In order to specify a configuration location you can pass the -home flag which would look something like this:

./usr/bin/syncthing -home="/home/{YOUR USER ACCOUNT}/.config/syncthing"

So to set up syncthing to start automatically without the browser using the specified configuration you would simply add this to your list of startup applications:

/usr/bin/syncthing -no-browser -home="/home/{YOUR USER ACCOUNT}/.config/syncthing"

There are plenty of ways to configure Syncthing to startup automatically but the one described above is a pretty universal method. If you would rather integrate it with your system using runit/systemd/upstart just take a look at the etc folder in the tar.gz.

Here is an example of my Linux Mint configuration in the Startup Applications control panel using the command listed above:

It's easy enough to get Syncthing started

It’s easy enough to get Syncthing started

Configure Syncthing

Once Syncthing is running you should be able to browse to it’s interface by going to http://localhost:8080. From this point forward I’m going to assume you want to sync between two computers which I will refer to as Computer 1 and Computer 2.

First let’s start by letting Computer 1 know about Computer 2 and vice versa.

  1. On Computer 1 click Actions > Show ID. Copy the long device identification text (it will look like a series of XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-…).
  2. On Computer 2 click Add Device and enter the copied Device ID and give it a Device Name.
  3. Back on Computer 1 you may notice a New Device notification which will allow you to easily add Computer 2 there as well. If you do not see this notification simply follow the steps above but in reverse, copying Computer 2’s device ID to Computer 1.
Once both computers know about each other they can begin syncing!

Once both computers know about each other they can begin syncing!

In order to share a folder you need to start by adding it to the Syncthing on one of the two computers. To make it simple I will do this on Computer 1. Click Add Folder and you will see a popup asking for a bunch of information. The important ones are:

  • Folder ID: This is the name or label of the shared folder. It must be the same on all computers taking part in the share.
  • Folder Path: This is where you want it to store the files on the local computer. For example on Computer 1 I might wan this to be ~/Sync/MyShare but on Computer 2 it could be /syncthing/shares/stuff.
  • Share With Devices: These are the computers you want to share this folder with.

So for example let’s say I want to share a folder called “CoolThings” and I wanted it to live in ~/Sync/CoolThings on Computer 1. Filling in this information would look like this:

syncthing_folder_setup

Finally to share it with Computer 2 I would check Computer 2 under the Share With Devices section.

Once done you should see a new notification on Computer 2 asking if you want to add the newly shared folder there as well.

Syncthing alerts you to newly shared folders

Syncthing alerts you to newly shared folders

Once done the folder should be shared and anything you put into the folder on either computer will be automatically synchronized on the other.

If you would like to add a third or fourth computer just follow the steps above again. Pretty easy no?

This post originally appeared on my website here.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

CoreGTK 3.10.2 Released!

February 19th, 2016 No comments

The next version of CoreGTK, version 3.10.2, has been tagged for release today.

Highlights for this release:

  • This is a bug fix release.
  • Corrected issue with compiling CoreGTK on OS X.

CoreGTK is an Objective-C language binding for the GTK+ widget toolkit. Like other “core” Objective-C libraries, CoreGTK is designed to be a thin wrapper. CoreGTK is free software, licensed under the GNU LGPL.

You can find more information about the project here and the release itself here.

This post originally appeared on my personal website here.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Turn your computer into your own Chromecast

February 7th, 2016 No comments

Google Chromecasts are neat little devices that let you ‘cast’ (send) media from your phone or tablet to play on your TV. If however, you already have a computer hooked up to your TV you don’t need to go out and buy a new device simply to have the same functionality. Instead you can install the excellent Leapcast program and accomplish the same functionality.

Leapcast works on all major operating systems – Windows, Mac and Linux – but for the purposes of this post I’m going to be focusing on how to set it up on a Debian based Linux distribution.

Step 1) Install Google Chrome browser

The Google Chrome browser is required for Leapcast to work correctly so the first thing you’ll need to do is head over to the download page and install it.

Step 2) Install miscellaneous required applications and libraries

Leapcast also requires a few extra tools and libraries to be installed.

sudo apt-get install virtualenvwrapper python-pip python-twisted-web python2.7-dev

Step 3) Download Leapcast

Head over to the GitHub page and download the zip of the latest Leapcast code. Alternatively you can also install git and use it to grab the latest code that way:

git clone https://github.com/dz0ny/leapcast.git

Step 4) Install Leapcast

In the leapcast directory run the following command. Note you may need to be root in order to do this without error.

sudo python setup.py develop

Step 5) Run Leapcast

Now that Leapcast is install you should be able to run it. Simply open a terminal and type

leapcast

There are some other neat options you can pass it as well. For example if you want your computer to show up as, say, TheLinuxExperiment when someone goes to cast to it simply pass the –name parameter.

leapcast --name TheLinuxExperiment

Happy casting!




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Open formats are… the best formats?

January 17th, 2016 2 comments

Over the past few years there has been a big push to replace proprietary formats with open formats. For example Open Document Format and Office Open XML have largely replaced the legacy binary formats, we’re now seeing HTML5 + JavaScript supplant Silverlight and Java applets, and even the once venerable Flash is on its deathbed.

This of course all makes sense. We’re now in an era where the computing platforms, be it Microsoft Windows, Apple OS X, Android, iOS, Linux, etc., simply don’t command the individual market shares (or at least mind shares) that they once used to. Things are… more diversified now. And while they may not matter to the user the underlying differences in technologies certainly matter to the developer. This is one of the many reasons you see lots of movement to open formats where the same format can be implemented, relatively easily, on all of the aforementioned platforms.

So then the question must be asked: does this trend mean that open formats are the best formats? That is obviously quite a simple question to a deep (and perhaps subjective) subject so perhaps it’s better to look at it from a user adoption perspective. Does being an open format, given all of its advantages, translate to market adoption? There the answer is not as clear.

Open by example

Let’s take a look a few instances where a clear format winner exists and see if it is an open format or a closed/proprietary format.

Documents

When it comes to documents the Open Document Format and Open Office XML have largely taken over. This has been driven largely by Microsoft making Office Open XML the default file format in all versions of Microsoft Office since 2007. Additionally many governments and organizations around the world have standardized on the use of Open Document Format. That said older Microsoft Office binary formats (i.e. .doc, .xls, etc.) are still widely in use.

Verdict: open formats have largely won out.

Audio

For the purposes of the “audio” category let’s consider simply the audio codec that most people use to consume their music. In that regard MP3 is still the absolute dominant format. While it is somewhat encumbered by patents you will hardly find a single device out there that doesn’t support it. This is true even when there are better lossy compression formats (including the proprietary AAC or open Ogg Vorbis) as well as lossless formats like FLAC.

Verdict: the closed/proprietary MP3 format is the de facto standard.

Video

Similarly for the “video” category I’ll only be focusing on the codecs. While there are plenty of open video formats (Theora, WebM, etc.) they are not nearly as well supported as the proprietary formats like MPEG-2, H.264, etc. Additionally the open formats (in general) don’t have quite as good quality vs size ratios as the proprietary ones which is often while you’ll see websites using them in order to save on bandwidth.

Verdict: closed/proprietary formats have largely won out.

File Compression

Compression is something that most people consider more as an algorithm than a format which is why I’ll be focusing on the compressed file container formats for this category. In that regard the ZIP file format is by far the most common. It has native support in every modern operating system and offers decent compression. Other open formats, such as 7-Zip, offer better performance and even some proprietary formats, like RAR, have seen widespread use but for the most part ZIP is the go-to format. What muddies the waters here a bit is that the base ZIP format is open but some of the features added later on were not. However the majority of uses are based on the open standards.

Verdict: the open zip format is the most widely used standard.

Native Applications vs Web Apps

While applications may not, strictly speaking, be a format it does seem to be the case that every year there are stories about how Web Apps will soon replace Native Applications. So far however the results are a little mixed with e-mail being a perfect example of this paradox. For personal desktop e-mail web apps, mostly Gmail and the like, have largely replaced native applications like Microsoft Outlook and Thunderbird. On mobile however the majority of users still access their e-mail via native “apps”. And even then in enterprises the majority of e-mail usage is still done via native applications. I’m honestly not sure which will eventually win out, if either, but for now let’s call it a tie.

Verdict: tie.

The answer to the question is…

Well just on the five quick examples above we’ve got wins for 2 open formats, 2 closed/proprietary formats and one tie. So clearly based on market adoption we’re at a stand still.

Personally I’d prefer if open formats would take over because then I wouldn’t have to worry about my device supporting the format in question or not. Who knows, maybe by next year we’ll see one of the two pull ahead.

This post originally appeared on my website here.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Let’s write a very simple text editor in CoreGTK

December 5th, 2015 No comments

In this post I’ll quickly show how you can write a very simple text editor using CoreGTK. This example is purposely very basic, has no real error handling and few features but it does show how to use CoreGTK in various ways.

To start with I quickly threw something together in GLADE (which if you aren’t aware is an excellent drag and drop GUI editor for GTK+).

coregtk_glade

Very basic shell in GLADE

Next I created a SimpleTextEditor class that will house the majority of my logic and stubbed out my callbacks and methods.

@interface SimpleTextEditor : NSObject
{
    CGTKTextView *txtView;
    CGTKWidget *window;
}

-(void)show;

// Callbacks
-(void)winMain_Destroy;
-(void)btnNew_Clicked;
-(void)btnOpen_Clicked;
-(void)btnSave_Clicked;

// Helper methods to deal with the text view
-(NSString *)getText;
-(void)setText:(NSString *)text;

@end

Now the fun part begins: filling in the implementation of the methods. First create the init and dealloc methods:

-(id)init
{
    self = [super init];
    
    if(self)
    {
        CGTKBuilder *builder = [[CGTKBuilder alloc] init];
        if(![builder addFromFileWithFilename:@"gui.glade" andErr:NULL])
        {
            NSLog(@"Error loading GUI file");
            return nil;
        }
        
        NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:
            [CGTKCallbackData withObject:self andSEL:@selector(winMain_Destroy)], @"winMain_Destroy",
            [CGTKCallbackData withObject:self andSEL:@selector(btnNew_Clicked)], @"btnNew_Clicked",
            [CGTKCallbackData withObject:self andSEL:@selector(btnOpen_Clicked)], @"btnOpen_Clicked",
            [CGTKCallbackData withObject:self andSEL:@selector(btnSave_Clicked)], @"btnSave_Clicked",
            nil];
        
        [CGTKBaseBuilder connectSignalsToObjectsWithBuilder:builder andSignalDictionary:dic];
        
        // Get a reference to the window
        window = [CGTKBaseBuilder getWidgetFromBuilder:builder withName:@"winMain"];
        
        // Get a reference to the text view
        txtView = [[CGTKTextView alloc] initWithGObject:[[CGTKBaseBuilder getWidgetFromBuilder:builder withName:@"txtView"] WIDGET]];
        
        [builder release];
    }
    
    return self;
}
-(void)dealloc
{
    [txtView release];
    [window release];
    [super dealloc];
}

OK let’s break down what we’ve done so far.

CGTKBuilder *builder = [[CGTKBuilder alloc] init];
if(![builder addFromFileWithFilename:@"gui.glade" andErr:NULL])
{
    NSLog(@"Error loading GUI file");
    return nil;
}

First thing is to parse the GLADE file which is what this code does. Next we need to connect the signals we defined for the different events in GLADE to the callback methods we defined in our code:

NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:
    [CGTKCallbackData withObject:self andSEL:@selector(winMain_Destroy)], @"winMain_Destroy",
    [CGTKCallbackData withObject:self andSEL:@selector(btnNew_Clicked)], @"btnNew_Clicked",
    [CGTKCallbackData withObject:self andSEL:@selector(btnOpen_Clicked)], @"btnOpen_Clicked",
    [CGTKCallbackData withObject:self andSEL:@selector(btnSave_Clicked)], @"btnSave_Clicked",
    nil];

[CGTKBaseBuilder connectSignalsToObjectsWithBuilder:builder andSignalDictionary:dic]

Finally extract and store references to the window and the text view for later:

// Get a reference to the window
window = [CGTKBaseBuilder getWidgetFromBuilder:builder withName:@"winMain"];

// Get a reference to the text view
txtView = [[CGTKTextView alloc] initWithGObject:[[CGTKBaseBuilder getWidgetFromBuilder:builder withName:@"txtView"] WIDGET]];

Before we can test anything out we need to fill in a few more basic methods to show the window on command and to exit the GTK+ loop when we close the window:

-(void)show
{
    [window showAll];
}

-(void)winMain_Destroy
{
    [CGTK mainQuit];
}

Now we can actually use our SimpleTextEditor so let’s write a main method to create it:

int main(int argc, char *argv[])
{    
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    /* 
     * This is called in all GTK applications. Arguments are parsed
     * from the command line and are returned to the application. 
     */
    [CGTK autoInitWithArgc:argc andArgv:argv];
    
    // Create and display editor
    SimpleTextEditor *editor = [[SimpleTextEditor alloc] init];
    
    // Check for error
    if(editor == nil)
    {
        return 1;
    }
    
    // Show the window    
    [editor show];
    
    // Start GTK+ loop
    [CGTK main];

    // Release allocated memory
    [editor release];
    [pool release];

    // Return success
    return 0;
}

Compile and run this and you’ll be presented with a cool Simple Text Editor window!

Our very... err... simple text editor

Our very… err… simple text editor

So far so good. Let’s keep filling in our stubbed in methods starting with our helper methods that will allow us to manipulate the underlying text buffer:

-(NSString *)getText
{
    gchar *gText = NULL;
    GtkTextBuffer *buf = NULL;
    GtkTextIter start, end;
    NSString *nsText = nil;
    
    // Grab reference to text buffer
    buf = [txtView getBuffer];
    
    // Determine the bounds of the buffer
    gtk_text_buffer_get_bounds (buf, &start, &end);
    
    // Get the gchar text from the buffer
    gText = gtk_text_buffer_get_text(buf, &start, &end, FALSE);
    
    // Convert it to an NSString
    nsText = [NSString stringWithUTF8String:gText];
    
    // Free the allocated gchar string
    g_free(gText);

    // Return the text
    return nsText;
}

-(void)setText:(NSString *)text
{
    // Get reference to text buffer
    GtkTextBuffer *buf = [txtView getBuffer];
    
    // Set contents of text buffer
    gtk_text_buffer_set_text(buf, [text UTF8String], -1);
}

At this point we have everything we need to implement our New button click callback method:

-(void)btnNew_Clicked
{
    [self setText:@""];
}

Like I said this is a pretty basic example so in a real world application I would hope you would prompt the user before blowing away all of their text!

All that’s left to do at this point is to implement the Open and Save callback methods. For these I’m going to create a new class, MultiDialog, to show how you can still really dig into the GTK+ C code when you need to.

@interface MultiDialog : NSObject
{
}

+(NSString *)presentOpenDialog;
+(NSString *)presentSaveDialog;

@end

And here is the implementation:

@implementation MultiDialog

+(NSString *)presentOpenDialog
{
    // Variables
    CGTKFileChooserDialog *dialog = nil;
    gchar *gText = NULL;
    gint result;
    NSString *filename = nil;

    // Create the dialog itself
    dialog = [[CGTKFileChooserDialog alloc] initWithTitle:@"Open File" andParent:nil andAction:GTK_FILE_CHOOSER_ACTION_OPEN];
    
    // Add cancel and open buttons
    gtk_dialog_add_button ([dialog DIALOG],
                   "_Cancel",
                   GTK_RESPONSE_CANCEL);
    gtk_dialog_add_button ([dialog DIALOG],
                   "_Open",
                   GTK_RESPONSE_ACCEPT);
    
    // Run the dialog
    result = gtk_dialog_run (GTK_DIALOG ([dialog WIDGET]));

    // If the user clicked Open
    if(result == GTK_RESPONSE_ACCEPT)
    {
        // Extract the filename and convert it to an NSString
        gText = gtk_file_chooser_get_filename ([dialog FILECHOOSERDIALOG]);
        filename = [NSString stringWithUTF8String:gText];
    }

    // Cleanup
    g_free(gText);
    gtk_widget_destroy ([dialog WIDGET]);
    [dialog release];
    
    return filename;
}

+(NSString *)presentSaveDialog
{
    // Variables
    CGTKFileChooserDialog *dialog = nil;
    gchar *gText = NULL;
    gint result;
    NSString *filename = nil;

    // Create the dialog itself
    dialog = [[CGTKFileChooserDialog alloc] initWithTitle:@"Save File" andParent:nil andAction:GTK_FILE_CHOOSER_ACTION_SAVE];
    
    // Add cancel and save buttons
    gtk_dialog_add_button ([dialog DIALOG],
                   "_Cancel",
                   GTK_RESPONSE_CANCEL);
    gtk_dialog_add_button ([dialog DIALOG],
                   "_Save",
                   GTK_RESPONSE_ACCEPT);

    // Set settings
    gtk_file_chooser_set_do_overwrite_confirmation ([dialog FILECHOOSERDIALOG], TRUE);
    gtk_file_chooser_set_current_name([dialog FILECHOOSERDIALOG], "Untitled document");
    
    // Run the dialog
    result = gtk_dialog_run (GTK_DIALOG ([dialog WIDGET]));

    // If the user clicked Save
    if(result == GTK_RESPONSE_ACCEPT)
    {
        // Extract the filename and convert it to an NSString
        gText = gtk_file_chooser_get_filename ([dialog FILECHOOSERDIALOG]);
        filename = [NSString stringWithUTF8String:gText];
    }

    // Cleanup
    g_free(gText);
    gtk_widget_destroy ([dialog WIDGET]);
    [dialog release];
    
    return filename;
}

@end

There is quite a bit of code there but hopefully the comments make it pretty easy to follow. Now that we have our MultiDialog class we can use it in our SimpleTextEditor methods:

-(void)btnOpen_Clicked
{
    NSString *text = [NSString stringWithContentsOfFile:[MultiDialog presentOpenDialog]];    
    [self setText:text];
}

-(void)btnSave_Clicked
{
    NSString *filename = [MultiDialog presentSaveDialog];
    NSString *text = [self getText];
        
    NSError *error;
    BOOL succeed = [text writeToFile:filename atomically:YES encoding:NSUTF8StringEncoding error:&error];

    if(!succeed)
    {
        NSLog(@"%@:%s Error saving: %@", [self class], _cmd, [error localizedDescription]);
    }
}

And there you have it a very simple text editor that lets you open text file and save them. You can find the full source for this application under the examples directory of the CoreGTK github repository.

 

This post originally appeared on my website here.




I am currently running a variety of distributions, primarily Linux Mint 18.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Categories: Open Source Software, Tyler B Tags: