aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-25 23:49:56 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-25 23:49:56 +0200
commit771925076fe7695e198b4c4279707ca4b028cebf (patch)
treeca10422e8fd7c4f22ed6c52e4457110540554b4d /src
parentc00d3d13b07ed6fa60ac975c2e633e2e5a3cbee3 (diff)
downloadayatana-indicator-session-771925076fe7695e198b4c4279707ca4b028cebf.tar.gz
ayatana-indicator-session-771925076fe7695e198b4c4279707ca4b028cebf.tar.bz2
ayatana-indicator-session-771925076fe7695e198b4c4279707ca4b028cebf.zip
Add 'Report a bug...' item to the session menu.
Diffstat (limited to 'src')
-rw-r--r--src/actions.c8
-rw-r--r--src/actions.h2
-rw-r--r--src/backend-dbus/actions.c33
-rw-r--r--src/service.c10
-rw-r--r--src/utils.c18
-rw-r--r--src/utils.h1
6 files changed, 72 insertions, 0 deletions
diff --git a/src/actions.c b/src/actions.c
index 5c5c624..4f5df12 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -298,6 +298,14 @@ indicator_session_actions_distro_help (IndicatorSessionActions * self)
}
void
+indicator_session_actions_bug (IndicatorSessionActions * self)
+{
+ g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
+
+ INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->bug (self);
+}
+
+void
indicator_session_actions_about (IndicatorSessionActions * self)
{
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
diff --git a/src/actions.h b/src/actions.h
index be13dc7..a37ae73 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -77,6 +77,7 @@ struct _IndicatorSessionActionsClass
void (*power_off) (IndicatorSessionActions * self);
void (*desktop_help) (IndicatorSessionActions * self);
void (*distro_help) (IndicatorSessionActions * self);
+ void (*bug) (IndicatorSessionActions * self);
void (*about) (IndicatorSessionActions * self);
void (*settings) (IndicatorSessionActions * self);
void (*online_accounts) (IndicatorSessionActions * self);
@@ -122,6 +123,7 @@ void indicator_session_actions_power_off (IndicatorSession
void indicator_session_actions_desktop_help (IndicatorSessionActions * self);
void indicator_session_actions_distro_help (IndicatorSessionActions * self);
+void indicator_session_actions_bug (IndicatorSessionActions * self);
void indicator_session_actions_about (IndicatorSessionActions * self);
void indicator_session_actions_settings (IndicatorSessionActions * self);
void indicator_session_actions_online_accounts (IndicatorSessionActions * self);
diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c
index db7d3d5..d8c5f62 100644
--- a/src/backend-dbus/actions.c
+++ b/src/backend-dbus/actions.c
@@ -35,6 +35,11 @@
#include "../utils.h"
+/* some prototypes... */
+static char * find_browser ();
+static void run_outside_app (const char * cmd);
+static gboolean zenity_warning (const char * icon_name, const char * title, const char * text);
+
enum
{
END_SESSION_TYPE_LOGOUT = 0,
@@ -772,6 +777,33 @@ zenity_question (IndicatorSessionActionsDbus * self,
return confirmed;
}
+static void
+my_bug (IndicatorSessionActions * self G_GNUC_UNUSED)
+{
+ const char * bts_url = get_distro_bts_url();
+ static char * browser = NULL;
+
+#ifdef HAS_URLDISPATCHER
+ if (g_getenv ("MIR_SOCKET") != NULL)
+ url_dispatch_send(bts_url, NULL, NULL);
+ else
+#endif
+ {
+
+ if (browser == NULL)
+ browser = find_browser();
+
+ if (browser != NULL)
+ run_outside_app(g_strdup_printf("%s '%s'", browser, bts_url));
+
+ else
+ zenity_warning ("dialog-warning",
+ _("Warning"),
+ _("The operating system's bug tracker needs to be accessed with\na web browser.\n\nThe Ayatana Session Indicator could not find any web\nbrowser on your computer."));
+
+ }
+}
+
static gboolean
zenity_warning (const char * icon_name,
const char * title,
@@ -1296,6 +1328,7 @@ indicator_session_actions_dbus_class_init (IndicatorSessionActionsDbusClass * kl
actions_class->online_accounts = my_online_accounts;
actions_class->desktop_help = my_desktop_help;
actions_class->distro_help = my_distro_help;
+ actions_class->bug = my_bug;
actions_class->about = my_about;
actions_class->switch_to_screensaver = my_switch_to_screensaver;
actions_class->switch_to_greeter = my_switch_to_greeter;
diff --git a/src/service.c b/src/service.c
index 4fee574..30ba3bb 100644
--- a/src/service.c
+++ b/src/service.c
@@ -348,6 +348,7 @@ create_admin_section (void)
g_menu_append (menu, distro_help_label, "indicator.distro_help");
g_free (desktop_help_label);
g_free (distro_help_label);
+ g_menu_append (menu, _("Report a Bug…"), "indicator.bug");
return G_MENU_MODEL (menu);
}
@@ -829,6 +830,14 @@ on_distro_help_activated (GSimpleAction * a G_GNUC_UNUSED,
}
static void
+on_bug_activated (GSimpleAction * a G_GNUC_UNUSED,
+ GVariant * param G_GNUC_UNUSED,
+ gpointer gself)
+{
+ indicator_session_actions_bug (get_backend_actions(gself));
+}
+
+static void
on_settings_activated (GSimpleAction * a G_GNUC_UNUSED,
GVariant * param G_GNUC_UNUSED,
gpointer gself)
@@ -921,6 +930,7 @@ init_gactions (IndicatorSessionService * self)
{ "about", on_about_activated },
{ "desktop_help", on_desktop_help_activated },
{ "distro_help", on_distro_help_activated },
+ { "bug", on_bug_activated },
{ "hibernate", on_hibernate_activated },
{ "logout", on_logout_activated },
{ "online-accounts", on_online_accounts_activated },
diff --git a/src/utils.c b/src/utils.c
index c291f7c..e950d3b 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -155,6 +155,24 @@ get_distro_url (void)
}
const char*
+get_distro_bts_url (void)
+{
+ static char * distro_bts_url = NULL;
+
+ if (distro_bts_url == NULL)
+ {
+ GHashTable * os_release = get_os_release();
+ gpointer value = g_hash_table_lookup(os_release, "BUG_REPORT_URL");
+ if (value == NULL)
+ value = "https://github.com/AyatanaIndicators/ayatana-indicator-session/issues"; /* fallback value */
+ distro_bts_url = g_strdup(value);
+ g_hash_table_destroy(os_release);
+ }
+
+ return distro_bts_url;
+}
+
+const char*
get_desktop_name (void)
{
static char * desktop_name = NULL;
diff --git a/src/utils.h b/src/utils.h
index d39637c..2d3c932 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -36,6 +36,7 @@ gboolean is_xfce();
const char* get_distro_name();
const char* get_distro_url();
+const char* get_distro_bts_url();
const char* get_desktop_name();
GHashTable* get_os_release();