Yearly Archives: 2007

Easy Makefiles

October 8, 2007 » Geek

Here’s a handy g++ option that will let you make up accurate makefiles in a jiffy, -MM.

g++ -MM *.cpp

Run that on your source directory and you’ll get a makefile style list of includes. If it doesn’t work, make sure you add in your compile time defines (like -D_x86 -D_LINUX). This won’t actually check that you need the files you have included, it just makes a list of the ones you have included.

I like to add a sed line to make breaks between source files, like so.

g++ -MM *.cpp | sed 's/^\([a-zA-Z]\)/\n\1/'

It’s very literal though, so if you do "../StaticDevice.h" type includes, watch out for double entries.

$ g++ -MM -D_x86 -D_LINUX devices/*.cpp | sed 's/^\([a-zA-Z]\)/\n\1/'

BaseDevice.o: devices/BaseDevice.cpp devices/BaseDevice.h devices/Enums.h

BaseStream.o: devices/BaseStream.cpp devices/BaseStream.h

CameraTest.o: devices/CameraTest.cpp devices/../camera.h \
  devices/../devices/Nikon/NikonDevice.h \
  devices/../devices/Nikon/../StaticDevice.h \
  devices/../devices/StaticDevice.h \
  devices/../devices/Panasonic/PanasonicDevice.h \
  devices/../devices/Panasonic/../StaticDevice.h \
  devices/../devices/BaseDevice.h devices/../devices/Enums.h \
  devices/../devices/Prosilica/ProsilicaStaticDevice.h \
  devices/../devices/Prosilica/ProsilicaDevice.h \
  devices/../devices/Prosilica/../BaseDevice.h \
  devices/../devices/Prosilica/ProsilicaDeviceConfigurator.h \
  devices/../devices/Prosilica/../inc-pc/PvApi.h \
  devices/../devices/Prosilica/../Enums.h \
  devices/../devices/Prosilica/../StaticDevice.h
$

Karamba Theme

October 4, 2007 » Geek

I’ve been playing with Karamba (SuperKaramba?) and took a monitor script (Unix Monitor) and hacked it up and added some scripts and images of my own. I like it, and it shows some info you don’t usually find on Karamba monitors, like a wireless interface link quality meter. You can check it out on kde-look.org at this link or download it direct at this link.

Tags: ,

Command Line Package Installation in OpenSuSE

October 1, 2007 » Geek

One of the things I love the most about Debian is apt. It’s a great and speedy package manager. Being able to apt-get install from the command line and not have to wait for a heavy UI to come up is a major plus for me. Thats why I was frustrated with OpenSuSE, which we use at work.

First thing first, I think that the OpenSuSE package system is a pig. Yast is a pig. Zypper is a pig. I did, however, find the fastest route to installing via the command line, which I’ll share here.

Unless you happen to know the exact name of the package you want to install, you’ll need to look it up. The fastest way I’ve found is using Webpin, a nice online package searcher. Be careful that you are reading from the right repo though. For example, a search on “magick++” returns many packages, including “libMagick++-devel (6.3.5.10)” which, to my Debian eye, looks like the perfect package. It is from an odd repo though, “Results from http://download.opensuse.org/repositories/home:/dipe/openSUSE_10.2” and the one I really want, and have access to mind you, is “ImageMagick-Magick++-devel (6.3.0.0)” which is in the main repo “Results from http://download.opensuse.org/distribution/10.2/repo/oss/suse”. It’s already too complicated, but we soldier on.

With my new, exact, package name in hand, I open up a root command line. The syntax for a zypper install is zypper install [package name] so I do zypper install ImageMagick-Magick++-devel and let it rip. After a ridiculous amount of parsing, it figures out the dependencies and asks me to continue, which I do. You have to babysit it for key managing, I havent figured out how to force “yes” on it. And that is how you use zypper to install on OpenSuSE.

root:~$ zypper install ImageMagick-Magick++-devel

Restoring system sources...

Parsing metadata for 20070918-142944...

Parsing metadata for 20070927-100843...

Parsing metadata for 20070927-100709...

Parsing metadata for 20070918-055437...

Parsing metadata for SUSE-Linux-10.2-Updates...

Parsing RPM database...

Summary:

   [S3:0][package]libxml2-devel-2.6.26-27.pm.1.i586

   [S4:1][package]liblcms-devel-1.15-30.i586

   [S4:1][package]libwmf-gnome-0.2.8.4-24.i586

   [S4:1][package]libwmf-devel-0.2.8.4-24.i586

   [S4:1][package]readline-devel-5.1-55.i586

   [S5:0][package]ImageMagick-Magick++-devel-6.3.0.0-27.6.i586

   [S5:0][package]ImageMagick-devel-6.3.0.0-27.6.i586

Continue? [y/n] y

Downloading: [S4:1][package]liblcms-devel-1.15-30.i586, 141.5 K(490.1 K unpacked)

Installing: [S4:1][package]liblcms-devel-1.15-30.i586

Downloading: [S4:1][package]libwmf-gnome-0.2.8.4-24.i586, 7.7 K(9.6 K unpacked)

Installing: [S4:1][package]libwmf-gnome-0.2.8.4-24.i586

Downloading: [S4:1][package]readline-devel-5.1-55.i586, 137.2 K(376.7 K unpacked)

Installing: [S4:1][package]readline-devel-5.1-55.i586

Downloading: [S4:1][package]libwmf-devel-0.2.8.4-24.i586, 414.1 K(2.7 M unpacked)

Installing: [S4:1][package]libwmf-devel-0.2.8.4-24.i586

Downloading: [S3:0][package]libxml2-devel-2.6.26-27.pm.1.i586, 2.5 M(11.6 M unpacked)

Installing: [S3:0][package]libxml2-devel-2.6.26-27.pm.1.i586

Downloading: [S5:0][package]ImageMagick-devel-6.3.0.0-27.6.i586, 1.5 M(5.6 M unpacked)

Installing: [S5:0][package]ImageMagick-devel-6.3.0.0-27.6.i586

Downloading: [S5:0][package]ImageMagick-Magick++-devel-6.3.0.0-27.6.i586, 193.2 K(939.8 K unpacked)

Installing: [S5:0][package]ImageMagick-Magick++-devel-6.3.0.0-27.6.i586

root:~$ 

Ever Notice…

September 18, 2007 » Geek

The similarities between GTA & GGG?

Tags:

GTK Tooltips On Notebook Tab Labels

August 22, 2007 » Geek

Here’s a non-obvious (or to me at least) trick to get tooltips onto a Gtk::Notebook tab. It took some searching, but essentially, you just add the Gtk::Label to a Gtk::EventBox and add that to the tab instead. Then you attach the tool tip to the Gtk::EventBox instead of the Gtk::Label.

Here’s an example. I couldn’t get my example to compile, the linker was going crazy, but I’m 99% sure that it’s fine. I’m probably just not seeing one glaring error. Let me know if you find it. The important stuff is all there, even if it won’t build.

main.cpp

#include 
#include "nbtt.h"

using namespace std;

int main (int argc, char *argv[]) {

  Gtk::Main kit (argc, argv);
  Nbtt notebookWindow;
  Gtk::Main::run(notebookWindow);
	
  return 0;
}

nbtt.cpp

#include 
#include "nbtt.h"

using namespace std;

Nbtt::Nbtt() {

  set_title("Notebook Tabs With Labels!");
  set_border_width(10);
  set_default_size(400, 200);

  lblTabOne.set_text("Tab 1");
  lblTabTwo.set_text("Tab 2");
  lblTabThree.set_text("Tab 3");

  ebTabOne.add(lblTabOne);
  ebTabTwo.add(lblTabTwo);
  ebTabThree.add(lblTabThree);
	
  toolTips.set_tip(ebTabOne,"Tab to page one.");
  toolTips.set_tip(ebTabTwo,"Tab to page two.");
  toolTips.set_tip(ebTabThree,"Tab to page three.");

  exNotebook.append_page(pageOne, ebTabOne);
  exNotebook.append_page(pageTwo, "Second");

  show_all();
}

nbtt.h

#ifndef NBTT_H
#define NBTT_H

#include 
#include 
#include 
#include 
#include 

using namespace std;

class Nbtt;

class Nbtt : public Gtk::Window {

  public:
    Nbtt();
	
  private:
    Gtk::Notebook exNotebook;
		
    Gtk::EventBox ebTabOne;
    Gtk::EventBox ebTabTwo;
    Gtk::EventBox ebTabThree;

    Gtk::Label lblTabOne;
    Gtk::Label lblTabTwo;
    Gtk::Label lblTabThree;

    Gtk::Tooltips toolTips;

    Gtk::Label pageOne;
    Gtk::Label pageTwo;
    Gtk::Label pageThree;
	
};

#endif // NBTT_H

I found this trick in the [email protected] history. The thread starts here if you want to read the exchange.

Tags: , , ,