aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-09-08 18:47:17 +0000
committerTarmac <Unknown>2013-09-08 18:47:17 +0000
commitdd9d2e36dfda0eb3b321a1ed94f8d27739265b2a (patch)
treeaa8f278f8a81546120ed6acd37da88dc0eea343d
parentddebe3c47040869cb8fe94729c43f10f2b763550 (diff)
parent05d0c98b1918fa97369e8b99f6848c19d7b97099 (diff)
downloadayatana-indicator-datetime-dd9d2e36dfda0eb3b321a1ed94f8d27739265b2a.tar.gz
ayatana-indicator-datetime-dd9d2e36dfda0eb3b321a1ed94f8d27739265b2a.tar.bz2
ayatana-indicator-datetime-dd9d2e36dfda0eb3b321a1ed94f8d27739265b2a.zip
Minor changes that eliminate unnecessary temporary strings.
Approved by Ted Gould, PS Jenkins bot.
-rw-r--r--src/service.c18
-rw-r--r--src/utils.c5
2 files changed, 6 insertions, 17 deletions
diff --git a/src/service.c b/src/service.c
index c46beeb..5d90235 100644
--- a/src/service.c
+++ b/src/service.c
@@ -499,12 +499,11 @@ create_desktop_header_state (IndicatorDatetimeService * self)
g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (str));
- g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (str));
+ g_variant_builder_add (&b, "{sv}", "label", g_variant_new_take_string (str));
g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (visible));
/* cleanup */
g_date_time_unref (now);
- g_free (str);
g_free (fmt);
return g_variant_builder_end (&b);
}
@@ -528,7 +527,6 @@ create_phone_header_state (IndicatorDatetimeService * self)
now = indicator_datetime_service_get_localtime (self);
fmt = get_terse_time_format_string (now);
label = g_date_time_format (now, fmt);
- g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
/* icon */
if ((has_alarms = service_has_alarms (self)))
@@ -545,14 +543,12 @@ create_phone_header_state (IndicatorDatetimeService * self)
else
a11y = g_strdup (label);
g_variant_builder_add (&b, "{sv}", "accessible-desc",
- g_variant_new_string (a11y));
+ g_variant_new_take_string (a11y));
- /* visible */
g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
+ g_variant_builder_add (&b, "{sv}", "label", g_variant_new_take_string (label));
/* cleanup */
- g_free (a11y);
- g_free (label);
g_date_time_unref (now);
return g_variant_builder_end (&b);
}
@@ -652,10 +648,8 @@ add_localtime_menuitem (GMenu * menu,
static void
add_calendar_menuitem (GMenu * menu)
{
- char * label;
GMenuItem * menu_item;
- label = g_strdup ("[calendar]");
menu_item = g_menu_item_new ("[calendar]", NULL);
g_menu_item_set_action_and_target_value (menu_item, "indicator.calendar", g_variant_new_int64(0));
g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.calendar");
@@ -663,7 +657,6 @@ add_calendar_menuitem (GMenu * menu)
g_menu_append_item (menu, menu_item);
g_object_unref (menu_item);
- g_free (label);
}
static GMenuModel *
@@ -1034,18 +1027,16 @@ create_locations_section (IndicatorDatetimeService * self)
struct TimeLocation * loc = l->data;
if (loc->visible)
{
- char * label;
char * detailed_action;
char * fmt;
GMenuItem * menu_item;
- label = g_strdup (loc->name);
detailed_action = g_strdup_printf ("indicator.set-location::%s %s",
loc->zone,
loc->name);
fmt = generate_full_format_string_at_time (now, loc->local_time);
- menu_item = g_menu_item_new (label, detailed_action);
+ menu_item = g_menu_item_new (loc->name, detailed_action);
g_menu_item_set_attribute (menu_item, "x-canonical-type",
"s", "com.canonical.indicator.location");
g_menu_item_set_attribute (menu_item, "x-canonical-timezone",
@@ -1057,7 +1048,6 @@ create_locations_section (IndicatorDatetimeService * self)
g_object_unref (menu_item);
g_free (fmt);
g_free (detailed_action);
- g_free (label);
}
}
diff --git a/src/utils.c b/src/utils.c
index b99de94..50d896d 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -134,9 +134,9 @@ T_(const char *msg)
LC_MESSAGES directory, so we won't find any translation there.
*/
char *message_locale = g_strdup(setlocale(LC_MESSAGES, NULL));
- char *time_locale = g_strdup(setlocale(LC_TIME, NULL));
+ const char *time_locale = setlocale (LC_TIME, NULL);
char *language = g_strdup(g_getenv("LANGUAGE"));
- char *rv;
+ const char *rv;
if (language)
g_unsetenv("LANGUAGE");
setlocale(LC_MESSAGES, time_locale);
@@ -149,7 +149,6 @@ T_(const char *msg)
if (language)
g_setenv("LANGUAGE", language, TRUE);
g_free(message_locale);
- g_free(time_locale);
g_free(language);
return rv;
}