aboutsummaryrefslogtreecommitdiff
path: root/src/idolocationmenuitem.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-06-17 10:41:25 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-06-17 10:41:25 -0500
commit9205983a6f1a75487abeb32e4fe6df3753980277 (patch)
treeceb874d79d9337b6c67e5aeb52d6155e54100950 /src/idolocationmenuitem.c
parent6de8e0386beb02beafc321aaef82176acaae5424 (diff)
downloadayatana-ido-9205983a6f1a75487abeb32e4fe6df3753980277.tar.gz
ayatana-ido-9205983a6f1a75487abeb32e4fe6df3753980277.tar.bz2
ayatana-ido-9205983a6f1a75487abeb32e4fe6df3753980277.zip
when building location and appointment menuitems from a GMenu, grab all the parameters and then pass them to object_new() as a block to avoid them getting set twice -- once with the constructor's default values, and then once afterwards
Diffstat (limited to 'src/idolocationmenuitem.c')
-rw-r--r--src/idolocationmenuitem.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/idolocationmenuitem.c b/src/idolocationmenuitem.c
index 34e5de3..5993938 100644
--- a/src/idolocationmenuitem.c
+++ b/src/idolocationmenuitem.c
@@ -386,29 +386,49 @@ GtkMenuItem *
ido_location_menu_item_new_from_model (GMenuItem * menu_item,
GActionGroup * actions)
{
+ guint i;
+ guint n;
gchar * str;
IdoLocationMenuItem * ido_location;
+ GParameter parameters[4];
- ido_location = IDO_LOCATION_MENU_ITEM (ido_location_menu_item_new ());
+ /* create the ido_location */
+
+ n = 0;
if (g_menu_item_get_attribute (menu_item, "label", "s", &str))
{
- ido_location_menu_item_set_name (ido_location, str);
- g_free (str);
+ GParameter p = { "name", G_VALUE_INIT };
+ g_value_init (&p.value, G_TYPE_STRING);
+ g_value_take_string (&p.value, str);
+ parameters[n++] = p;
}
if (g_menu_item_get_attribute (menu_item, "x-canonical-timezone", "s", &str))
{
- ido_location_menu_item_set_timezone (ido_location, str);
- g_free (str);
+ GParameter p = { "timezone", G_VALUE_INIT };
+ g_value_init (&p.value, G_TYPE_STRING);
+ g_value_take_string (&p.value, str);
+ parameters[n++] = p;
}
if (g_menu_item_get_attribute (menu_item, "x-canonical-time-format", "s", &str))
{
- ido_location_menu_item_set_format (ido_location, str);
- g_free (str);
+ GParameter p = { "format", G_VALUE_INIT };
+ g_value_init (&p.value, G_TYPE_STRING);
+ g_value_take_string (&p.value, str);
+ parameters[n++] = p;
}
+ g_assert (n <= G_N_ELEMENTS (parameters));
+ ido_location = g_object_newv (IDO_LOCATION_MENU_ITEM_TYPE, n, parameters);
+
+ for (i=0; i<n; i++)
+ g_value_unset (&parameters[i].value);
+
+
+ /* give it an ActionHelper */
+
if (g_menu_item_get_attribute (menu_item, "action", "s", &str))
{
GVariant * target;