Command line programs get windowed!

Опубликовано: 04 Май 2026
на канале: Executive Quest
5,069
8

Have you used a command line program or utility and wished there was a decent window for it with boxes and buttons that remember your preferences? Let's write one using Glade 3.0. This template I wrote eases the task of writing GUI front ends.

A method of writing front-ends is described whereby the widget name is the command line option and the content of the widget contains the value that is passed to the command line. Whence a program is demonstrated that automatically adapts itself to new widgets. Thus the task of writing a front-end is reduced to adding new widgets. It is a front-end template--a template for making front-ends.

In this example, we use our front-end template to create a front-end for ffmpeg, the popular command line video conversion back-end used by most video conversion packages.

Download source: http://thenerdshow.com/c/ffresize.zip

This is an intermediate C program featuring file parsing, re-entrant polymorphic functions, dynamic widgets, combo boxes and tree models.

To add a new command line option, such as -cropleft, just use glade to add the widget and give it a name like out-cropleft. It will automatically be picked up and used by the program!

I mainly use ffresize to resize videos, extract and merge back audio tracks, crop and change frame rates, audio and video codecs, bitrate... Since this program is using glade and GTK2, it will require gtk2-devel and glade to compile. I haven't tried compiling it for windows, but it should work with little or no changes. See readme.

This video is licensed under the Creative Commons Attribution 2.5 Generic license. In short: you are free to share and make derivatives of this work under the conditions that you appropriately attribute it. Any of the above conditions can be waived if you get permission from the copyright holder.


This video contains parts or visuals of a free software program. You may use it freely according to its particular license.

The program I wrote is licensed under the same terms as Glade:

For more info about Glade, visit
http://glade.gnome.org/
Glade is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This work is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

License for Scintilla and SciTE
http://www.scintilla.org/SciTE.html

Copyright 1998-2003 by Neil Hodgson [email protected]
All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.

NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE