summaryrefslogtreecommitdiffstats
path: root/src/Applet
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-09-04 13:42:17 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-09-04 13:42:17 +0200
commitb5990bc884c0334a0333af195c7c67637e6de27d (patch)
tree8cead5aa8f636216cbbfcd08a25165002d1627d0 /src/Applet
parent39845b1a81a432a5ff1bf1ff1937eae85f4902b1 (diff)
downloadabrt-b5990bc884c0334a0333af195c7c67637e6de27d.tar.gz
abrt-b5990bc884c0334a0333af195c7c67637e6de27d.tar.xz
abrt-b5990bc884c0334a0333af195c7c67637e6de27d.zip
APPLET: added about dialog, removed popup, if icon is not visible, fixed (trac#43)
It was confusing for some users, that the applet didn't have any description If the status icon wasn't visible (embedded in tray) the popup was shown in the wrong place Applet isn't shown if GUI is running (trac#43).
Diffstat (limited to 'src/Applet')
-rw-r--r--src/Applet/Applet.cpp4
-rw-r--r--src/Applet/CCApplet.cpp151
-rw-r--r--src/Applet/CCApplet.h6
-rw-r--r--src/Applet/popup.GtkBuilder50
4 files changed, 173 insertions, 38 deletions
diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp
index 530a8462..41fc3b75 100644
--- a/src/Applet/Applet.cpp
+++ b/src/Applet/Applet.cpp
@@ -48,8 +48,8 @@ crash_notify_cb(const char* progname)
#endif
//applet->AddEvent(uid, std::string(progname));
applet->SetIconTooltip(message, progname);
- applet->CrashNotify(message, progname);
applet->ShowIcon();
+ applet->CrashNotify(message, progname);
}
int main(int argc, char **argv)
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
}
DBus::Connection conn = DBus::Connection::SystemBus();
- applet = new CApplet(conn, CC_DBUS_PATH, CC_DBUS_NAME);
+ applet = new CApplet(conn, session, CC_DBUS_PATH, CC_DBUS_NAME);
applet->ConnectCrashHandler(crash_notify_cb);
if(!conn.has_name(CC_DBUS_NAME))
{
diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp
index 75c2fbe6..89073974 100644
--- a/src/Applet/CCApplet.cpp
+++ b/src/Applet/CCApplet.cpp
@@ -23,6 +23,7 @@
#include <cstdarg>
#include <sstream>
#include <cstdio>
+#include <unistd.h>
@@ -43,33 +44,84 @@ static const char *DBUS_SERVICE_NAME = "org.freedesktop.DBus";
static const char *DBUS_SERVICE_PATH = "/org/freedesktop/DBus";
const gchar *CApplet::menu_xml =
"<?xml version=\"1.0\"?>\
- <interface>\
- <requires lib=\"gtk+\" version=\"2.16\"/>\
- <!-- interface-naming-policy project-wide -->\
- <object class=\"GtkMenu\" id=\"popup_menu\">\
+<interface>\
+ <requires lib=\"gtk+\" version=\"2.16\"/>\
+ <!-- interface-naming-policy project-wide -->\
+ <object class=\"GtkMenu\" id=\"popup_menu\">\
+ <property name=\"visible\">True</property>\
+ <child>\
+ <object class=\"GtkMenuItem\" id=\"miHide\">\
+ <property name=\"visible\">True</property>\
+ <property name=\"label\" translatable=\"yes\">Hide</property>\
+ </object>\
+ </child>\
+ <child>\
+ <object class=\"GtkImageMenuItem\" id=\"miQuit\">\
+ <property name=\"label\">gtk-quit</property>\
+ <property name=\"visible\">True</property>\
+ <property name=\"use_underline\">True</property>\
+ <property name=\"use_stock\">True</property>\
+ <property name=\"always_show_image\">True</property>\
+ </object>\
+ </child>\
+ <child>\
+ <object class=\"GtkSeparatorMenuItem\" id=\"miSep1\">\
+ <property name=\"visible\">True</property>\
+ </object>\
+ </child>\
+ <child>\
+ <object class=\"GtkImageMenuItem\" id=\"miAbout\">\
+ <property name=\"label\">gtk-about</property>\
+ <property name=\"visible\">True</property>\
+ <property name=\"use_underline\">True</property>\
+ <property name=\"use_stock\">True</property>\
+ <property name=\"always_show_image\">True</property>\
+ </object>\
+ </child>\
+ </object>\
+ <object class=\"GtkAboutDialog\" id=\"aboutdialog\">\
+ <property name=\"border_width\">5</property>\
+ <property name=\"type_hint\">normal</property>\
+ <property name=\"has_separator\">False</property>\
+ <property name=\"program_name\">Automatic Bug Reporting Tool</property>\
+ <property name=\"copyright\" translatable=\"yes\">Copyright &#xA9; 2009 Red Hat, Inc</property>\
+ <property name=\"website\">https://fedorahosted.org/abrt/</property>\
+ <property name=\"website_label\" translatable=\"yes\">Website</property>\
+ <property name=\"license\" translatable=\"yes\">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, see &lt;http://www.gnu.org/licenses/&gt;.</property>\
+ <property name=\"authors\">Jiri Moskovcak &lt;jmoskovc@redhat.com&gt;</property>\
+ <child internal-child=\"vbox\">\
+ <object class=\"GtkVBox\" id=\"dialog-vbox1\">\
+ <property name=\"visible\">True</property>\
+ <property name=\"orientation\">vertical</property>\
+ <property name=\"spacing\">2</property>\
+ <child>\
+ <placeholder/>\
+ </child>\
+ <child internal-child=\"action_area\">\
+ <object class=\"GtkHButtonBox\" id=\"dialog-action_area1\">\
<property name=\"visible\">True</property>\
- <child>\
- <object class=\"GtkMenuItem\" id=\"miHide\">\
- <property name=\"visible\">True</property>\
- <property name=\"label\" translatable=\"yes\">Hide</property>\
- </object>\
- </child>\
- <child>\
- <object class=\"GtkImageMenuItem\" id=\"miQuit\">\
- <property name=\"label\">gtk-quit</property>\
- <property name=\"visible\">True</property>\
- <property name=\"use_underline\">True</property>\
- <property name=\"use_stock\">True</property>\
- <property name=\"always_show_image\">True</property>\
- </object>\
- </child>\
+ <property name=\"layout_style\">end</property>\
</object>\
- </interface>";
+ <packing>\
+ <property name=\"expand\">False</property>\
+ <property name=\"pack_type\">end</property>\
+ <property name=\"position\">0</property>\
+ </packing>\
+ </child>\
+ </object>\
+ </child>\
+ </object>\
+</interface>";
-CApplet::CApplet(DBus::Connection &connection, const char *path, const char *name)
-: DBus::ObjectProxy(connection, path, name)
+CApplet::CApplet(DBus::Connection &system, DBus::Connection &session, const char *path, const char *name)
+: DBus::ObjectProxy(system, path, name)
{
- m_pDaemonWatcher = new DaemonWatcher(connection, DBUS_SERVICE_PATH, DBUS_SERVICE_NAME);
+ m_pSessionDBus = &session;
+ m_pDaemonWatcher = new DaemonWatcher(system, DBUS_SERVICE_PATH, DBUS_SERVICE_NAME);
m_pDaemonWatcher->ConnectStateChangeHandler(DaemonStateChange_cb, this);
m_pStatusIcon = gtk_status_icon_new_from_stock(GTK_STOCK_DIALOG_WARNING);
m_bDaemonRunning = true;
@@ -82,7 +134,8 @@ CApplet::CApplet(DBus::Connection &connection, const char *path, const char *nam
g_signal_connect(G_OBJECT(m_pStatusIcon), "popup_menu", GTK_SIGNAL_FUNC(CApplet::OnMenuPopup_cb), this);
SetIconTooltip(_("Pending events: %i"), m_mapEvents.size());
m_pBuilder = gtk_builder_new();
- if(gtk_builder_add_from_string(m_pBuilder, menu_xml, strlen(menu_xml), NULL))
+ //if(gtk_builder_add_from_string(m_pBuilder, menu_xml, strlen(menu_xml), NULL))
+ if(gtk_builder_add_from_file(m_pBuilder, "popup.GtkBuilder", NULL))
{
m_pMenu = gtk_builder_get_object(m_pBuilder, "popup_menu");
//gtk_menu_attach_to_widget(GTK_MENU(m_pMenu), GTK_WIDGET(m_pStatusIcon), NULL);
@@ -96,6 +149,12 @@ CApplet::CApplet(DBus::Connection &connection, const char *path, const char *nam
{
g_signal_connect(m_pmiQuit,"activate",G_CALLBACK(gtk_main_quit),NULL);
}
+ m_pAboutDialog = gtk_builder_get_object(m_pBuilder, "aboutdialog");
+ m_pmiAbout = gtk_builder_get_object(m_pBuilder, "miAbout");
+ {
+ g_signal_connect(m_pmiAbout,"activate",G_CALLBACK(CApplet::onAbout_cb),m_pAboutDialog);
+ }
+
}
else
{
@@ -111,19 +170,26 @@ CApplet::~CApplet()
/* dbus related */
void CApplet::Crash(const std::string& progname, const std::string& uid )
{
- if (m_pCrashHandler)
+ if(m_pSessionDBus->has_name("com.redhat.abrt.gui"))
{
- std::istringstream input_string(uid);
- uid_t num;
- input_string >> num;
-
- if( (num == getuid()) )
- m_pCrashHandler(progname.c_str());
+ return;
}
else
{
- std::cout << _("This is default handler, you should register your own with ConnectCrashHandler") << std::endl;
- std::cout.flush();
+ if (m_pCrashHandler)
+ {
+ std::istringstream input_string(uid);
+ uid_t num;
+ input_string >> num;
+
+ if( (num == getuid()) )
+ m_pCrashHandler(progname.c_str());
+ }
+ else
+ {
+ std::cout << _("This is default handler, you should register your own with ConnectCrashHandler") << std::endl;
+ std::cout.flush();
+ }
}
}
@@ -171,14 +237,18 @@ void CApplet::CrashNotify(const char *format, ...)
va_list args;
char *buf;
int n;
+ GError *err = NULL;
va_start(args, format);
buf = NULL;
n = vasprintf(&buf, format, args);
va_end(args);
- notify_notification_update(m_pNotification, _("Warning"), buf, NULL);
- notify_notification_show(m_pNotification, NULL);
+ notify_notification_update(m_pNotification, _("Warning"), buf, NULL);
+ if(gtk_status_icon_is_embedded (m_pStatusIcon))
+ notify_notification_show(m_pNotification, &err);
+ if(err != NULL)
+ g_print(err->message);
}
void CApplet::OnAppletActivate_CB(GtkStatusIcon *status_icon,gpointer user_data)
@@ -217,11 +287,22 @@ void CApplet::OnMenuPopup_cb(GtkStatusIcon *status_icon,
void CApplet::ShowIcon()
{
gtk_status_icon_set_visible(m_pStatusIcon, true);
+ //Active wait for icon to be REALLY visible in status area
+ //while(!gtk_status_icon_is_embedded (m_pStatusIcon));
}
+
void CApplet::onHide_cb(GtkMenuItem *menuitem, gpointer applet)
{
((CApplet*)applet)->HideIcon();
}
+
+void CApplet::onAbout_cb(GtkMenuItem *menuitem, gpointer dialog)
+{
+ if(dialog)
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_hide(GTK_WIDGET(dialog));
+}
+
void CApplet::HideIcon()
{
gtk_status_icon_set_visible(m_pStatusIcon, false);
diff --git a/src/Applet/CCApplet.h b/src/Applet/CCApplet.h
index e1b56e0e..74c8cc52 100644
--- a/src/Applet/CCApplet.h
+++ b/src/Applet/CCApplet.h
@@ -39,13 +39,16 @@ class CApplet
GtkBuilder *m_pBuilder;
GObject *m_pmiHide;
GObject *m_pmiQuit;
+ GObject *m_pmiAbout;
+ GObject *m_pAboutDialog;
NotifyNotification *m_pNotification;
std::map<int, std::string > m_mapEvents;
DaemonWatcher *m_pDaemonWatcher;
bool m_bDaemonRunning;
+ DBus::Connection *m_pSessionDBus;
public:
- CApplet(DBus::Connection &connection, const char *path, const char *name);
+ CApplet(DBus::Connection &system, DBus::Connection &session, const char *path, const char *name);
~CApplet();
void ShowIcon();
void HideIcon();
@@ -72,6 +75,7 @@ class CApplet
guint activate_time,
gpointer user_data);
static void onHide_cb(GtkMenuItem *menuitem, gpointer applet);
+ static void onAbout_cb(GtkMenuItem *menuitem, gpointer applet);
private:
/* dbus stuff */
void Crash(const std::string& progname, const std::string& uid);
diff --git a/src/Applet/popup.GtkBuilder b/src/Applet/popup.GtkBuilder
index 38240cfb..baa5cf22 100644
--- a/src/Applet/popup.GtkBuilder
+++ b/src/Applet/popup.GtkBuilder
@@ -19,5 +19,55 @@
<property name="always_show_image">True</property>
</object>
</child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="miSep1">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="miAbout">
+ <property name="label">gtk-about</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <property name="always_show_image">True</property>
+ </object>
+ </child>
+ </object>
+ <object class="GtkAboutDialog" id="aboutdialog">
+ <property name="border_width">5</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <property name="program_name">Automatic Bug Reporting Tool</property>
+ <property name="copyright" translatable="yes">Copyright &#xA9; 2009 Red Hat, Inc</property>
+ <property name="website">https://fedorahosted.org/abrt/</property>
+ <property name="website_label" translatable="yes">Website</property>
+ <property name="license" translatable="yes">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, see &lt;http://www.gnu.org/licenses/&gt;.</property>
+ <property name="authors">Jiri Moskovcak &lt;jmoskovc@redhat.com&gt;</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</interface>