diff options
Diffstat (limited to 'src/Applet')
-rw-r--r-- | src/Applet/Applet.cpp | 40 | ||||
-rw-r--r-- | src/Applet/CCApplet.cpp | 45 | ||||
-rw-r--r-- | src/Applet/CCApplet.h | 37 | ||||
-rw-r--r-- | src/Applet/Makefile.am | 6 |
4 files changed, 128 insertions, 0 deletions
diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp new file mode 100644 index 00000000..39b0cc41 --- /dev/null +++ b/src/Applet/Applet.cpp @@ -0,0 +1,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; +} diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp new file mode 100644 index 00000000..a48260cd --- /dev/null +++ b/src/Applet/CCApplet.cpp @@ -0,0 +1,45 @@ +/* + Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com) + Copyright (C) 2009 RedHat inc. + + This program 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 program 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. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "CCApplet.h" + +CApplet::CApplet() +{ + m_nStatusIcon = Gtk::StatusIcon::create(Gtk::Stock::DIALOG_WARNING); + m_nStatusIcon->set_visible(false); +} + +CApplet::~CApplet() +{ +} + +void CApplet::ShowIcon() +{ + m_nStatusIcon->set_visible(true); +} + +void CApplet::HideIcon() +{ + m_nStatusIcon->set_visible(false); +} + +void CApplet::BlinkIcon(bool pBlink) +{ + m_nStatusIcon->set_blinking(pBlink); +} diff --git a/src/Applet/CCApplet.h b/src/Applet/CCApplet.h new file mode 100644 index 00000000..83c3e750 --- /dev/null +++ b/src/Applet/CCApplet.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com) + Copyright (C) 2009 RedHat inc. + + This program 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 program 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. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef CC_APPLET_H_ +#define CC_APPLET_H_ + +#include <gtkmm.h> + +class CApplet +{ + private: + Glib::RefPtr<Gtk::StatusIcon> m_nStatusIcon; + public: + CApplet(); + ~CApplet(); + void ShowIcon(); + void HideIcon(); + void BlinkIcon(bool pBlink); +}; + +#endif /*CC_APPLET_H_*/ diff --git a/src/Applet/Makefile.am b/src/Applet/Makefile.am new file mode 100644 index 00000000..f98b5bc0 --- /dev/null +++ b/src/Applet/Makefile.am @@ -0,0 +1,6 @@ +bin_PROGRAMS = applet +applet_SOURCES = Applet.cpp CCApplet.cpp CCApplet.h +applet_CPPFLAGS = -I../../lib/MiddleWare \ + -I../../lib/DBus \ + -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(DBUS_GLIB_CFLAGS) $(GTKMM_CFLAGS) +applet_LDADD = ../../lib/MiddleWare/libMiddleWare.la ../../lib/DBus/libDBus.la $(DL_LIBS) $(GTKMM_LIBS) |