aboutsummaryrefslogtreecommitdiff
path: root/src/idoappointmentmenuitem.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/idoappointmentmenuitem.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/idoappointmentmenuitem.c')
-rw-r--r--src/idoappointmentmenuitem.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/idoappointmentmenuitem.c b/src/idoappointmentmenuitem.c
index 929e011..45daeed 100644
--- a/src/idoappointmentmenuitem.c
+++ b/src/idoappointmentmenuitem.c
@@ -366,35 +366,58 @@ GtkMenuItem *
ido_appointment_menu_item_new_from_model (GMenuItem * menu_item,
GActionGroup * actions)
{
+ guint i;
+ guint n;
gint64 i64;
gchar * str;
IdoAppointmentMenuItem * ido_appointment;
+ GParameter parameters[8];
- ido_appointment = IDO_APPOINTMENT_MENU_ITEM (ido_appointment_menu_item_new());
+ /* create the ido_appointment */
+
+ n = 0;
if (g_menu_item_get_attribute (menu_item, "label", "s", &str))
{
- ido_appointment_menu_item_set_summary (ido_appointment, str);
- g_free (str);
+ GParameter p = { "summary", 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-color", "s", &str))
{
- ido_appointment_menu_item_set_color (ido_appointment, str);
- g_free (str);
+ GParameter p = { "color", 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", "x", &i64))
+ if (g_menu_item_get_attribute (menu_item, "x-canonical-time-format", "s", &str))
{
- ido_appointment_menu_item_set_time (ido_appointment, (time_t)i64);
+ GParameter p = { "format", 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))
+ if (g_menu_item_get_attribute (menu_item, "x-canonical-time", "x", &i64))
{
- ido_appointment_menu_item_set_format (ido_appointment, str);
- g_free (str);
+ GParameter p = { "time", G_VALUE_INIT };
+ g_value_init (&p.value, G_TYPE_INT64);
+ g_value_set_int64 (&p.value, i64);
+ parameters[n++] = p;
}
+ g_assert (n <= G_N_ELEMENTS (parameters));
+ ido_appointment = g_object_newv (IDO_APPOINTMENT_MENU_ITEM_TYPE, n, parameters);
+
+ for (i=0; i<n; i++)
+ g_value_unset (&parameters[i].value);
+
+
+ /* add an ActionHelper */
+
if (g_menu_item_get_attribute (menu_item, "action", "s", &str))
{
GVariant * target;