From 8f2d9f2e63cb6cc5f9d4a72985c42fe8ca4adb6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Tue, 23 Aug 2011 19:39:30 +0100 Subject: Makefile.am: fix typo to include .gschema.xml.in to the dist --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 8ae7e6d..8b57590 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,7 +35,7 @@ dist_noinst_SCRIPTS = \ autogen.sh dist_noinst_DATA = \ - data/org.ubuntu.indicator-power.gschema.xml + data/org.ubuntu.indicator-power.gschema.xml \ $(gsettings_in_file) CLEANFILES = \ -- cgit v1.2.3 From bc4d8d425ada55b3bf707b9d65893cd53cdd81a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Wed, 24 Aug 2011 11:55:44 +0100 Subject: Fix a memory leak Fixes https://bugs.launchpad.net/ubuntu/+source/indicator-power/+bug/779185 --- src/indicator-power.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/indicator-power.c b/src/indicator-power.c index 7f9e479..3be04be 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -496,7 +496,7 @@ build_menu (IndicatorPower *self) gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item); /* preferences */ - item = gtk_image_menu_item_new_with_mnemonic (_("Power Settings...")); + item = gtk_image_menu_item_new_with_label (_("Power Settings...")); image = gtk_image_new_from_icon_name (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); g_signal_connect (G_OBJECT (item), "activate", @@ -661,6 +661,7 @@ get_devices_cb (GObject *source_object, return; } priv->devices = g_variant_get_child_value (devices_container, 0); + g_variant_unref (devices_container); priv->device = get_primary_device (priv->devices); if (priv->device == NULL) -- cgit v1.2.3 From 1c9c7772c2d4f2cf3108d833b9a1fe2113fd33a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Thu, 25 Aug 2011 18:46:15 +0100 Subject: Use consistent location for gsettings schema Use the same location as indicator-datetime --- Makefile.am | 4 ++-- data/com.canonical.indicator.power.gschema.xml.in | 9 +++++++++ data/org.ubuntu.indicator-power.gschema.xml.in | 9 --------- src/indicator-power.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 data/com.canonical.indicator.power.gschema.xml.in delete mode 100644 data/org.ubuntu.indicator-power.gschema.xml.in diff --git a/Makefile.am b/Makefile.am index 8b57590..0d4d34b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} SUBDIRS = po -gsettings_in_file = data/org.ubuntu.indicator-power.gschema.xml.in +gsettings_in_file = data/com.canonical.indicator.power.gschema.xml.in gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml) @INTLTOOL_XML_NOMERGE_RULE@ @@ -35,7 +35,7 @@ dist_noinst_SCRIPTS = \ autogen.sh dist_noinst_DATA = \ - data/org.ubuntu.indicator-power.gschema.xml \ + data/com.canonical.indicator.power.gschema.xml \ $(gsettings_in_file) CLEANFILES = \ diff --git a/data/com.canonical.indicator.power.gschema.xml.in b/data/com.canonical.indicator.power.gschema.xml.in new file mode 100644 index 0000000..bf4368f --- /dev/null +++ b/data/com.canonical.indicator.power.gschema.xml.in @@ -0,0 +1,9 @@ + + + + false + <_summary>Show time in Menu Bar + <_description>Whether show the time in the menu bar. + + + diff --git a/data/org.ubuntu.indicator-power.gschema.xml.in b/data/org.ubuntu.indicator-power.gschema.xml.in deleted file mode 100644 index ff6c807..0000000 --- a/data/org.ubuntu.indicator-power.gschema.xml.in +++ /dev/null @@ -1,9 +0,0 @@ - - - - false - <_summary>Show time in Menu Bar - <_description>Whether show the time in the menu bar. - - - diff --git a/src/indicator-power.c b/src/indicator-power.c index 3be04be..cf30051 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -769,7 +769,7 @@ indicator_power_init (IndicatorPower *self) self); /* GSettings */ - priv->settings = g_settings_new ("org.ubuntu.indicator-power"); + priv->settings = g_settings_new ("com.canonical.indicator.power"); } static void -- cgit v1.2.3 From 2fb46855d00f3e0215bf1160d29672728ebccd94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Wed, 7 Sep 2011 17:21:15 +0100 Subject: indicator-power.c: Add padding between the icon and the text in the menu items --- src/indicator-power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indicator-power.c b/src/indicator-power.c index cf30051..800ac5a 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -409,7 +409,7 @@ menu_add_device (GtkMenu *menu, item = gtk_image_menu_item_new (); grid = gtk_grid_new (); - gtk_grid_set_row_spacing (GTK_GRID (grid), 6); + gtk_grid_set_column_spacing (GTK_GRID (grid), 6); gtk_grid_attach (GTK_GRID (grid), icon, 0, 0, 1, 1); details_label = gtk_label_new (details); gtk_grid_attach_next_to (GTK_GRID (grid), details_label, icon, GTK_POS_RIGHT, 1, 1); -- cgit v1.2.3 From 14adfe549aed71619ad4ff784e9fb39ecfb05d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Thu, 8 Sep 2011 14:43:46 +0100 Subject: Handle the case with broken batteries The remining time is not reported with is more than 100h. This generally means that our battery is broken (never reach a fully charged status) --- src/indicator-power.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/indicator-power.c b/src/indicator-power.c index 800ac5a..3908f14 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -533,6 +533,7 @@ get_primary_device (GVariant *devices) for (i = 0; i < n_devices; i++) { + time = 0; device = g_variant_get_child_value (devices, i); g_variant_get (device, "(susdut)", @@ -561,6 +562,10 @@ get_primary_device (GVariant *devices) else if (state == UP_DEVICE_STATE_CHARGING) { charging = TRUE; + if (time == 0) /* Battery broken */ + { + primary_device_charging = device; + } if (time > max_charging_time) { max_charging_time = time; -- cgit v1.2.3 From 87369425cab6787f01ec965ba9392524155b825f Mon Sep 17 00:00:00 2001 From: Gabor Kelemen Date: Sun, 11 Sep 2011 11:32:53 +0200 Subject: Use correct dgettext and g_dngettext calls. LP: #846895 --- src/indicator-power.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/indicator-power.c b/src/indicator-power.c index 3908f14..a8ce859 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -183,7 +183,7 @@ get_timestring (guint64 time_secs, if (minutes < 60) { *short_timestring = g_strdup_printf ("0:%.2i", minutes); - *detailed_timestring = g_strdup_printf (ngettext ("%i minute", + *detailed_timestring = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%i minute", "%i minutes", minutes), minutes); return; @@ -196,7 +196,7 @@ get_timestring (guint64 time_secs, if (minutes == 0) { - *detailed_timestring = g_strdup_printf (ngettext ( + *detailed_timestring = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%i hour", "%i hours", hours), hours); @@ -206,8 +206,8 @@ get_timestring (guint64 time_secs, /* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes" * Swap order with "%2$s %2$i %1$s %1$i if needed */ *detailed_timestring = g_strdup_printf (_("%i %s %i %s"), - hours, ngettext ("hour", "hours", hours), - minutes, ngettext ("minute", "minutes", minutes)); + hours, g_dngettext (GETTEXT_PACKAGE, "hour", "hours", hours), + minutes, g_dngettext (GETTEXT_PACKAGE, "minute", "minutes", minutes)); } } @@ -219,47 +219,47 @@ device_kind_to_localised_string (UpDeviceKind kind) switch (kind) { case UP_DEVICE_KIND_LINE_POWER: /* TRANSLATORS: system power cord */ - text = gettext ("AC adapter"); + text = _("AC adapter"); break; case UP_DEVICE_KIND_BATTERY: /* TRANSLATORS: laptop primary battery */ - text = gettext ("Battery"); + text = _("Battery"); break; case UP_DEVICE_KIND_UPS: /* TRANSLATORS: battery-backed AC power source */ - text = gettext ("UPS"); + text = _("UPS"); break; case UP_DEVICE_KIND_MONITOR: /* TRANSLATORS: a monitor is a device to measure voltage and current */ - text = gettext ("Monitor"); + text = _("Monitor"); break; case UP_DEVICE_KIND_MOUSE: /* TRANSLATORS: wireless mice with internal batteries */ - text = gettext ("Mouse"); + text = _("Mouse"); break; case UP_DEVICE_KIND_KEYBOARD: /* TRANSLATORS: wireless keyboard with internal battery */ - text = gettext ("Keyboard"); + text = _("Keyboard"); break; case UP_DEVICE_KIND_PDA: /* TRANSLATORS: portable device */ - text = gettext ("PDA"); + text = _("PDA"); break; case UP_DEVICE_KIND_PHONE: /* TRANSLATORS: cell phone (mobile...) */ - text = gettext ("Cell phone"); + text = _("Cell phone"); break; case UP_DEVICE_KIND_MEDIA_PLAYER: /* TRANSLATORS: media player, mp3 etc */ - text = gettext ("Media player"); + text = _("Media player"); break; case UP_DEVICE_KIND_TABLET: /* TRANSLATORS: tablet device */ - text = gettext ("Tablet"); + text = _("Tablet"); break; case UP_DEVICE_KIND_COMPUTER: /* TRANSLATORS: tablet device */ - text = gettext ("Computer"); + text = _("Computer"); break; default: g_warning ("enum unrecognised: %i", kind); -- cgit v1.2.3 From 49ac0f5b5d346cb2851526bc36b7faa63561c7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Mon, 12 Sep 2011 13:59:15 +0100 Subject: Use the same icon for all charge levels if we are in the charging status From the designers (see bug comments): "I think the shading inside the battery when charging is obscuring the lightning bolt, and also giving the icon a visual style that is obviously different from the text and discourages "reading" it together with the text. So, I suggest leaving the brackets in place, but removing the shading from the icon. Fixes https://bugs.launchpad.net/indicator-power/+bug/824629 --- src/indicator-power.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/indicator-power.c b/src/indicator-power.c index a8ce859..28a8f17 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -359,6 +359,41 @@ set_accessible_desc (IndicatorPower *self, priv->accessible_desc = g_strdup (desc); } +static GIcon* +get_device_icon (UpDeviceKind kind, + UpDeviceState state, + gchar *device_icon) +{ + GIcon *gicon; + + if (kind == UP_DEVICE_KIND_BATTERY && + state == UP_DEVICE_STATE_CHARGING) + { + GString *filename; + gchar **iconnames; + const gchar *kind_str; + + kind_str = up_device_kind_to_string (kind); + filename = g_string_new (NULL); + g_string_append_printf (filename, "battery-caution-charging-symbolic;"); + g_string_append_printf (filename, "gpm-%s-000-charging;", kind_str); + g_string_append_printf (filename, "battery-caution-charging;"); + + iconnames = g_strsplit (filename->str, ";", -1); + gicon = g_themed_icon_new_from_names (iconnames, -1); + + g_strfreev (iconnames); + g_string_free (filename, TRUE); + } + else + { + gicon = g_icon_new_for_string (device_icon, NULL); + } + + return gicon; +} + + static void menu_add_device (GtkMenu *menu, GVariant *device) @@ -397,7 +432,7 @@ menu_add_device (GtkMenu *menu, g_debug ("%s: got data from object %s", G_STRFUNC, object_path); /* Process the data */ - device_gicons = g_icon_new_for_string (device_icon, NULL); + device_gicons = get_device_icon (kind, state, device_icon); icon = gtk_image_new_from_gicon (device_gicons, GTK_ICON_SIZE_SMALL_TOOLBAR); @@ -623,7 +658,7 @@ put_primary_device (IndicatorPower *self, g_debug ("%s: got data from object %s", G_STRFUNC, object_path); /* set icon */ - device_gicons = g_icon_new_for_string (device_icon, NULL); + device_gicons = get_device_icon (kind, state, device_icon); gtk_image_set_from_gicon (priv->status_image, device_gicons, GTK_ICON_SIZE_LARGE_TOOLBAR); -- cgit v1.2.3 From 0c0a7b00f9e808a2038569d125c20c51d4a18802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Mon, 12 Sep 2011 14:13:18 +0100 Subject: Fix a gap in the indicators region when the power indicator is not show This fixes https://bugs.launchpad.net/indicator-power/+bug/842188 --- src/indicator-power.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/indicator-power.c b/src/indicator-power.c index 28a8f17..db10f2c 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -839,6 +839,7 @@ get_label (IndicatorObject *io) { /* Create the label if it doesn't exist already */ priv->label = GTK_LABEL (gtk_label_new ("")); + gtk_widget_set_visible (GTK_WIDGET (priv->label), FALSE); } return priv->label; -- cgit v1.2.3 From 8c55038dea892597dc8dff22ff9537980e66e58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Mon, 12 Sep 2011 14:15:57 +0100 Subject: 0.8 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8cdded6..6e25c95 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([indicator-power], - [0.7], + [0.8], [http://bugs.launchpad.net/indicator-power], [indicator-power], [http://launchpad.net/indicator-power]) -- cgit v1.2.3 From 8be5a9d3030f0d52c16997f569d373b34658b471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Wed, 14 Sep 2011 15:58:22 +0100 Subject: Do not show (charged) in menu title when fully charged Fixes https://bugs.launchpad.net/ubuntu/+source/indicator-power/+bug/850011 --- src/indicator-power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indicator-power.c b/src/indicator-power.c index db10f2c..13f5ff7 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -324,7 +324,7 @@ build_device_time_details (const gchar *device_name, { *details = g_strdup_printf (_("%s (charged)"), device_name); *accesible_name = g_strdup (*details); - *short_details = g_strdup (_("(charged)")); + *short_details = g_strdup (""); } else if (percentage > 0) { -- cgit v1.2.3 From 50bee91a9241f69c12e39ad8e5bf160060a923c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Wed, 21 Sep 2011 13:55:02 +0200 Subject: Do not activate g-s-d, but just watch dbus for g-s-d to appear Fixes https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/854717 --- src/indicator-power.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/indicator-power.c b/src/indicator-power.c index 13f5ff7..275e871 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -79,6 +79,7 @@ struct _IndicatorPowerPrivate GCancellable *proxy_cancel; GDBusProxy *proxy; + guint watcher_id; GVariant *devices; GVariant *device; @@ -782,6 +783,28 @@ service_proxy_cb (GObject *object, user_data); } +static void +gsd_appeared_callback (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data) +{ + IndicatorPower *self = INDICATOR_POWER (user_data); + IndicatorPowerPrivate *priv = self->priv; + + priv->proxy_cancel = g_cancellable_new (); + + g_dbus_proxy_new (connection, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + name, + POWER_DBUS_PATH, + POWER_DBUS_INTERFACE, + priv->proxy_cancel, + service_proxy_cb, + self); +} + static void indicator_power_init (IndicatorPower *self) { @@ -796,17 +819,14 @@ indicator_power_init (IndicatorPower *self) priv->menu = NULL; priv->accessible_desc = NULL; - priv->proxy_cancel = g_cancellable_new(); - - g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - DBUS_SERVICE, - POWER_DBUS_PATH, - POWER_DBUS_INTERFACE, - priv->proxy_cancel, - service_proxy_cb, - self); + + priv->watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION, + DBUS_SERVICE, + G_BUS_NAME_WATCHER_FLAGS_NONE, + gsd_appeared_callback, + NULL, + self, + NULL); /* GSettings */ priv->settings = g_settings_new ("com.canonical.indicator.power"); -- cgit v1.2.3 From a93ea524812af4e44481280e0baba8eafde6bc83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 23 Sep 2011 17:35:01 +0200 Subject: 0.9 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6e25c95..4176d1f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([indicator-power], - [0.8], + [0.9], [http://bugs.launchpad.net/indicator-power], [indicator-power], [http://launchpad.net/indicator-power]) -- cgit v1.2.3