aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-03-24 10:19:00 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-03-24 10:19:00 +0000
commit0638860f575fda1a3531d236a3803bcaff271fbe (patch)
tree4a7d0f45684070c6cecb38d11ec5a94a11734a71
parent1db25fd1b84bcc592b1da794e81592c2942ef84a (diff)
parente5f30358325683fe338137fc0cc71541e73c81be (diff)
downloadayatana-indicator-session-0638860f575fda1a3531d236a3803bcaff271fbe.tar.gz
ayatana-indicator-session-0638860f575fda1a3531d236a3803bcaff271fbe.tar.bz2
ayatana-indicator-session-0638860f575fda1a3531d236a3803bcaff271fbe.zip
Don't show a red icon in indicator-session when there's an online user account error. Fixes: 1206550
-rw-r--r--src/service.c39
-rw-r--r--tests/gtest-dbus-fixture.h55
-rw-r--r--tests/test-service.cc7
3 files changed, 35 insertions, 66 deletions
diff --git a/src/service.c b/src/service.c
index 5136a44..68fbc50 100644
--- a/src/service.c
+++ b/src/service.c
@@ -108,9 +108,6 @@ struct _IndicatorSessionServicePrivate
int rebuild_flags;
GDBusConnection * conn;
GCancellable * cancellable;
-
- /* serialized icon cache */
- GVariant * alert_icon_serialized;
GVariant * default_icon_serialized;
};
@@ -167,8 +164,6 @@ static GVariant *
action_state_for_header (IndicatorSessionService * self)
{
const priv_t * const p = self->priv;
- gboolean need_attn;
- GVariant * serialized_icon;
gboolean show_name;
const gchar * real_name;
const gchar * label;
@@ -176,38 +171,17 @@ action_state_for_header (IndicatorSessionService * self)
GVariantBuilder b;
GVariant * state;
- if (indicator_session_actions_has_online_account_error (p->backend_actions))
- {
- need_attn = TRUE;
- serialized_icon = p->alert_icon_serialized;
- }
- else
- {
- need_attn = FALSE;
- serialized_icon = p->default_icon_serialized;
- }
-
show_name = g_settings_get_boolean (p->indicator_settings,
"show-real-name-on-panel");
real_name = get_current_real_name (self);
label = show_name && real_name ? real_name : "";
- if (*label && need_attn)
- {
- /* Translators: the name of the menu ("System"), then the user's name,
- then a hint that something in this menu requires user attention */
- a11y = g_strdup_printf (_("System, %s (Attention Required)"), real_name);
- }
- else if (*label)
+ if (*label)
{
/* Translators: the name of the menu ("System"), then the user's name */
a11y = g_strdup_printf (_("System, %s"), label);
}
- else if (need_attn)
- {
- a11y = g_strdup (_("System (Attention Required)"));
- }
else
{
a11y = g_strdup (_("System"));
@@ -216,8 +190,7 @@ action_state_for_header (IndicatorSessionService * self)
/* build the state */
g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (a11y));
- if (serialized_icon != NULL)
- g_variant_builder_add (&b, "{sv}", "icon", serialized_icon);
+ g_variant_builder_add (&b, "{sv}", "icon", p->default_icon_serialized);
if (label && *label)
g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
@@ -1113,12 +1086,6 @@ indicator_session_service_init (IndicatorSessionService * self)
&p->backend_users,
&p->backend_guest);
- /* build the serialized icon cache */
-
- icon = g_themed_icon_new_with_default_fallbacks (ICON_ALERT);
- p->alert_icon_serialized = g_icon_serialize (icon);
- g_object_unref (icon);
-
icon = g_themed_icon_new_with_default_fallbacks (ICON_DEFAULT);
p->default_icon_serialized = g_icon_serialize (icon);
g_object_unref (icon);
@@ -1283,8 +1250,6 @@ my_dispose (GObject * o)
g_clear_object (&p->guest_switcher_action);
g_clear_object (&p->conn);
- /* clear the serialized icon cache */
- g_clear_pointer (&p->alert_icon_serialized, g_variant_unref);
g_clear_pointer (&p->default_icon_serialized, g_variant_unref);
G_OBJECT_CLASS (indicator_session_service_parent_class)->dispose (o);
diff --git a/tests/gtest-dbus-fixture.h b/tests/gtest-dbus-fixture.h
index e6cd9c7..dedb727 100644
--- a/tests/gtest-dbus-fixture.h
+++ b/tests/gtest-dbus-fixture.h
@@ -54,13 +54,6 @@ class GTestDBusFixture : public ::testing::Test
g_main_loop_quit (self->loop);
}
- static gboolean
- wait_for_signal__timeout (gpointer name)
- {
- g_error ("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name);
- return G_SOURCE_REMOVE;
- }
-
protected:
virtual void SetUp ()
@@ -103,29 +96,45 @@ class GTestDBusFixture : public ::testing::Test
g_clear_pointer (&loop, g_main_loop_unref);
}
- /* convenience func to loop while waiting for a GObject's signal */
- void wait_for_signal (gpointer o, const gchar * signal)
+ private:
+
+ static gboolean
+ wait_for_signal__timeout(gpointer name)
{
- const int timeout_seconds = 5; // arbitrary
+ g_error("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name);
+ return G_SOURCE_REMOVE;
+ }
+ static gboolean
+ wait_msec__timeout(gpointer loop)
+ {
+ g_main_loop_quit(static_cast<GMainLoop*>(loop));
+ return G_SOURCE_CONTINUE;
+ }
+
+ protected:
+
+ /* convenience func to loop while waiting for a GObject's signal */
+ void wait_for_signal(gpointer o, const gchar * signal, const int timeout_seconds=5)
+ {
// wait for the signal or for timeout, whichever comes first
- guint handler_id = g_signal_connect_swapped (o, signal,
- G_CALLBACK(g_main_loop_quit),
- loop);
- gulong timeout_id = g_timeout_add_seconds (timeout_seconds,
- wait_for_signal__timeout,
- loop);
- g_main_loop_run (loop);
- g_source_remove (timeout_id);
- g_signal_handler_disconnect (o, handler_id);
+ const auto handler_id = g_signal_connect_swapped(o, signal,
+ G_CALLBACK(g_main_loop_quit),
+ loop);
+ const auto timeout_id = g_timeout_add_seconds(timeout_seconds,
+ wait_for_signal__timeout,
+ loop);
+ g_main_loop_run(loop);
+ g_source_remove(timeout_id);
+ g_signal_handler_disconnect(o, handler_id);
}
/* convenience func to loop for N msec */
- void wait_msec (int msec)
+ void wait_msec(int msec=50)
{
- guint id = g_timeout_add (msec, (GSourceFunc)g_main_loop_quit, loop);
- g_main_loop_run (loop);
- g_source_remove (id);
+ const auto id = g_timeout_add(msec, wait_msec__timeout, loop);
+ g_main_loop_run(loop);
+ g_source_remove(id);
}
GMainLoop * loop;
diff --git a/tests/test-service.cc b/tests/test-service.cc
index 20c70f5..ab84459 100644
--- a/tests/test-service.cc
+++ b/tests/test-service.cc
@@ -616,7 +616,7 @@ TEST_F (ServiceTest, OnlineAccountError)
check_last_command_is ("online-accounts");
// check that the header's icon and a11y adjusted to the error state
- check_header ("", "system-devices-panel-alert", "System (Attention Required)");
+ check_header ("", "system-devices-panel", "System");
// cleanup
g_settings_reset (mock_settings, error_key);
@@ -756,12 +756,7 @@ TEST_F (ServiceTest, User)
g_settings_set_boolean (indicator_settings, show_name_key, true);
wait_for_signal (action_group, "action-state-changed");
check_header ("Third Doctor", "system-devices-panel", "System, Third Doctor");
- g_settings_set_boolean (mock_settings, error_key, true);
- wait_for_signal (action_group, "action-state-changed");
- check_header ("Third Doctor", "system-devices-panel-alert", "System, Third Doctor (Attention Required)");
- g_settings_reset (mock_settings, error_key);
g_settings_reset (indicator_settings, show_name_key);
- wait_for_menu_resync ();
// try setting the max user count to 2...
// since troughton has the fewest logins, he should get culled