summaryrefslogtreecommitdiffstats
path: root/src/Applet/Applet.cpp
blob: 39b0cc41780ef838e29284fe460c79a8e97382f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "CCApplet.h"
#include "DBusManager.h"
#include <iostream>

//@@global applet object
CApplet *applet;
static void
crash_notify_cb(DBusGProxy *proxy, char* progname, gpointer user_data)
{
    DBusError error;
    dbus_error_init (&error);
#ifdef DEBUG
    std::cerr << "Application " << progname << " has crashed!" << std::endl;
#endif
    /* smth happend, show the blinking icon */
    applet->BlinkIcon(true);
    applet->ShowIcon();
}

int main(int argc, char **argv)
{
    Gtk::Main kit(argc, argv);
    applet = new CApplet();
    CDBusManager dm;
    /* connect to the daemon */
    try
    {
        dm.ConnectToDaemon();
    }
    catch(std::string err)
    {
        std::cerr << "Applet: " << err << std::endl;
        return -1;
    }
    /* catch the CC crash notify on the dbus */
    dm.RegisterToMessage("Crash",G_CALLBACK(crash_notify_cb),NULL,NULL);
    /* run the main loop and wait for some events */
    Gtk::Main::run();
    return 0;
}