LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Advice to get started with making 'a SIMPLE dock' (http://www.linuxquestions.org/questions/programming-9/advice-to-get-started-with-making-a-simple-dock-870246/)

akamikeym 03-22-2011 10:29 AM

Advice to get started with making 'a SIMPLE dock'
 
Hi,

This is probably hopelessly ambitious as I'm not a C or C++ programmer (I normally like to stick to scripting languages like BASH or Perl).

Basically I'm looking on good advice to get me started with writing a Application Dock with the functionality of the OSX dock but without the overly flamboyant graphics that have characterised the Linux versions.

At the moment the closest I've found to what I would like is bbdock. However it falls well short of the functionality of what I would like.

What bbdock does is read a file to create an icon for the openbox dock/fluxbox slit/wmaker whatever that launches an application when first clicked, shows an little arrow when the application is running, and brings the application to the fore when clicked once running.

Here's a screenshot of it doing just that.

The drawback to bbdock is that it doesn't really look for running applications, only those launched from bbdock. So for example it wont notice if I've launched an instance of pcmanfm from the openbox menu. And therefore it obviously also doesn't add icons for other applications that are running.

What I would like to be able to do is detect new running applications and add a bbdock icon for them. Also to detect if an application already with a shortcut has been run and update it's status to show it's open. Probably have an up and down arrow to move the icons up and down when there are too many to fit on the screen.

None of the above needs fancy animation. The fade to gray effect used by bbdock is quite nice and could probably be augmented with a fade in and out to grey to represent another action, say fading to grey and back when launching and greyed when iconified.

So, my question is what do I need to get started doing this? Am I best using the pretty outdated bbdock wmaker dockapp style? What functions and libraries am I likely to need to achieve the effects I want? Are there any examples of how to monitor running applications (well windows and figure out what constitutes a new application) that I could look at for inspiration. Is there anyone who's into C++ for linux who would be interested in helping me out to get this small project working?

posixculprit 03-22-2011 11:13 AM

Hello.

This will probably not be a surprise but (IMO) if you plan to develop this utility in C or C++ a good starting point would be to actually learn the basics of one of these two languages. According to some programmers, these two aren't exactly -easy- to program in, even if you have some experience and have a serious interest in them (which I gather you don't). You might be able to put some libraries together with spit and sweat but my guess is it will happen after an intense period of frustration.

You claim you like Perl so why not take a look to see what libraries are available for it to help you write this utility (various libraries have all sorts of language bindings).

MTK358 03-22-2011 11:24 AM

For finding out what applications are installed, how to launch them, how to find their icons, etc. read this: http://portland.freedesktop.org/wiki/. That way it will nicely work with everything in a standard way.

And, of course, you will need to learn C with GTK+ or C++ with Qt.

IMO Qt is easier to work with, and it also has nice APIs for file/directory manipulation and running child processes (which will be necessary for such a project).

akamikeym 03-22-2011 11:37 AM

posixculprit, thanks for the reply.

No they're not easy languages (everything you can do in a line of another language seem to require about 5 in C and C++ is worse, in my experience). I would say I'm probably at a reading level at the moment, in that I can follow what something someone else has written (at least where it's not too opaque) and occasional tweaking, but I'm not much use at actually writing my own stuff.

It's part of the reason that this as a project appeals to me though as it really should be quite a simple program.

Are you suggesting I write the program in perl? Or are you suggesting I try out the libraries I could use in perl before I try to use them in C++?

akamikeym 03-22-2011 11:46 AM

MTK358, the bbdock app is one of those early linux applications that doesn't use anything like GTK or QT. I'm inclined to keep it that way if I can just to keep things super-light and super-simple. I've done a few GTK projects with perl (and I'm a fan of GTK) so I'd move that way if I were to go either way.

The xdg-utils are a much needed set of utilities but they don't really stretch to providing the kind of access to the currently running processes/windows/applications that this project really requires.

P.S. Also thanks for the reply :)

posixculprit 03-22-2011 11:54 AM

There's a lot of C++ hating on LQ so even though off-topic I'll start with this: in my experience a C++ program is, on average, smaller than the equivalent C program.. that is to say, on average, a line of C++ is more expressive than a line of C. Also in my experience, the number of lines is of limited importance (correctness, efficiency, robustness, clarity are all incomparably more important and difficult to obtain / combine).

Whilst kind of being able to read code written by others can work on some level.. kind of being able to program isn't as likely to be successful. The compiler can't kind of understand what you kind of thought you told it you want your program to do. Because of this, although it may seem like an easy task, you might find that your inexperience also impacts your ability to predict how easy a task is.

I was indeed suggesting you consider writing it in Perl. Both GTK+ and Qt (which MTK358 finds better, as he repeatedly tells us ;-) ) have Perl bindings (and I'm guessing other popular frameworks which might help you get the job done are either written in Perl or have Perl bindings too).

akamikeym 03-22-2011 12:30 PM

Like I said I'm aware of the bindings of languages such as Perl as I've used them (certainly the GTK ones not so much the qt). I'm also aware of the importance of getting code right - and that you are less sheltered from poor programming in a language like C(++). (I also wasn't really having a go at either language I understand that the reason that it takes more lines of code (and it does even if those lines are wrapped up in a library) to achieve something is that the code that you write is closer to the machine level operation of the computer and that has a follow on affects on speed, reliability etc.

I also know that Perl (as much as I like it) is not the language to implement this project. The reason I came to ask the question here is so that instead of reading hundreds/thousands of pages on libraries and X11 window management to figure out how to get started I was hoping to get pointed in the right direction and only have to read dozens.

Telling me to use another language than the two I've identified as obvious candidates isn't really answering the question.

posixculprit 03-22-2011 12:46 PM

Understood, my apologies sir.

akamikeym 03-22-2011 12:59 PM

Apologies if I came across as snappy there. I have respect for anyone who's willing to take time to try and help out others. Just trying to make my intentions and query clear. :)


All times are GMT -5. The time now is 07:09 AM.