diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-12-04 14:26:11 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-12-04 14:26:11 +0100 |
commit | 1545345255210e8fbf781c2bbebcdd49fa5a87cd (patch) | |
tree | 0af826edcc3fa90ae163e4b1f089775f9586922e | |
parent | 0ab4079b28220f4051f8d0935a976e550514ad7f (diff) | |
download | ayatana-ido-1545345255210e8fbf781c2bbebcdd49fa5a87cd.tar.gz ayatana-ido-1545345255210e8fbf781c2bbebcdd49fa5a87cd.tar.bz2 ayatana-ido-1545345255210e8fbf781c2bbebcdd49fa5a87cd.zip |
Port from Glib's g_object_newv to g_object_new_with_properties.
-rw-r--r-- | src/idoalarmmenuitem.c | 45 | ||||
-rw-r--r-- | src/idoappointmentmenuitem.c | 46 | ||||
-rw-r--r-- | src/idolocationmenuitem.c | 36 | ||||
-rw-r--r-- | src/idoprogressmenuitem.c | 20 | ||||
-rw-r--r-- | src/idousermenuitem.c | 28 |
5 files changed, 98 insertions, 77 deletions
diff --git a/src/idoalarmmenuitem.c b/src/idoalarmmenuitem.c index 817d6a8..c9cfcd9 100644 --- a/src/idoalarmmenuitem.c +++ b/src/idoalarmmenuitem.c @@ -46,51 +46,56 @@ ido_alarm_menu_item_new_from_model (GMenuItem * menu_item, guint n; gint64 i64; gchar * str; + const gchar * names[4] = {0}; + GValue * values; + const guint n_max = 4; IdoBasicMenuItem * ido_menu_item; - GParameter parameters[8]; /* create the ido_menu_item */ n = 0; + values = g_new0(GValue, n_max); if (g_menu_item_get_attribute (menu_item, G_MENU_ATTRIBUTE_LABEL, "s", &str)) { - GParameter p = { "text", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_STRING); - g_value_take_string (&p.value, str); - parameters[n++] = p; + names[n] = "text"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } if (TRUE) { - GParameter p = { "icon", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_OBJECT); - g_value_take_object (&p.value, g_themed_icon_new_with_default_fallbacks ("alarm-symbolic")); - parameters[n++] = p; + names[n] = "icon"; + g_value_init (&values[n], G_TYPE_OBJECT); + g_value_take_object (&values[n], g_themed_icon_new_with_default_fallbacks ("alarm-symbolic")); + n++; } if (g_menu_item_get_attribute (menu_item, "x-canonical-time-format", "s", &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; + names[n] = "format"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } if (g_menu_item_get_attribute (menu_item, "x-canonical-time", "x", &i64)) { - GParameter p = { "date-time", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_DATE_TIME); - g_value_take_boxed (&p.value, g_date_time_new_from_unix_local (i64)); - parameters[n++] = p; + names[n] = "date-time"; + g_value_init (&values[n], G_TYPE_DATE_TIME); + g_value_take_boxed (&values[n], g_date_time_new_from_unix_local (i64)); + n++; } - g_assert (n <= G_N_ELEMENTS (parameters)); - ido_menu_item = g_object_newv (IDO_TYPE_TIME_STAMP_MENU_ITEM, n, parameters); + g_assert (n <= G_N_ELEMENTS (names)); + g_assert (n <= n_max); + ido_menu_item = IDO_BASIC_MENU_ITEM(g_object_new_with_properties (IDO_TYPE_TIME_STAMP_MENU_ITEM, n, names, values)); for (i=0; i<n; i++) - g_value_unset (¶meters[i].value); + g_value_unset (&values[i]); + g_free(names); /* add an ActionHelper */ diff --git a/src/idoappointmentmenuitem.c b/src/idoappointmentmenuitem.c index 0d6a3d2..1b537ed 100644 --- a/src/idoappointmentmenuitem.c +++ b/src/idoappointmentmenuitem.c @@ -89,50 +89,54 @@ ido_appointment_menu_item_new_from_model (GMenuItem * menu_item, gint64 i64; gchar * str; IdoBasicMenuItem * ido_menu_item; - GParameter parameters[8]; + const gchar * names[4] = {0}; + GValue * values; + const guint n_max = 4; /* create the ido_menu_item */ n = 0; + values = g_new0(GValue, n_max); if (g_menu_item_get_attribute (menu_item, G_MENU_ATTRIBUTE_LABEL, "s", &str)) { - GParameter p = { "text", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_STRING); - g_value_take_string (&p.value, str); - parameters[n++] = p; + names[n] = "text"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } if (g_menu_item_get_attribute (menu_item, "x-canonical-color", "s", &str)) { - GParameter p = { "icon", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_OBJECT); - g_value_take_object (&p.value, create_color_icon_pixbuf (str)); - parameters[n++] = p; - g_free (str); + names[n] = "icon"; + g_value_init (&values[n], G_TYPE_OBJECT); + g_value_take_object (&values[n], create_color_icon_pixbuf (str)); + g_free(str); + n++; } if (g_menu_item_get_attribute (menu_item, "x-canonical-time-format", "s", &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; + names[n] = "format"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } if (g_menu_item_get_attribute (menu_item, "x-canonical-time", "x", &i64)) { - GParameter p = { "date-time", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_DATE_TIME); - g_value_take_boxed (&p.value, g_date_time_new_from_unix_local (i64)); - parameters[n++] = p; + names[n] = "date-time"; + g_value_init (&values[n], G_TYPE_DATE_TIME); + g_value_take_boxed (&values[n], g_date_time_new_from_unix_local (i64)); + n++; } - g_assert (n <= G_N_ELEMENTS (parameters)); - ido_menu_item = g_object_newv (IDO_TYPE_TIME_STAMP_MENU_ITEM, n, parameters); + g_assert (n <= G_N_ELEMENTS (names)); + g_assert (n <= n_max); + ido_menu_item = IDO_BASIC_MENU_ITEM(g_object_new_with_properties (IDO_TYPE_TIME_STAMP_MENU_ITEM, n, names, values)); for (i=0; i<n; i++) - g_value_unset (¶meters[i].value); + g_value_unset (&values[i]); /* add an ActionHelper */ diff --git a/src/idolocationmenuitem.c b/src/idolocationmenuitem.c index eb6b38b..4361e50 100644 --- a/src/idolocationmenuitem.c +++ b/src/idolocationmenuitem.c @@ -296,41 +296,45 @@ ido_location_menu_item_new_from_model (GMenuItem * menu_item, guint n; gchar * str; IdoLocationMenuItem * ido_location; - GParameter parameters[4]; + const gchar * names[3]; + GValue * values; + const guint n_max = 3; /* create the ido_location */ n = 0; + values = g_new0(GValue, n_max); if (g_menu_item_get_attribute (menu_item, "label", "s", &str)) { - GParameter p = { "text", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_STRING); - g_value_take_string (&p.value, str); - parameters[n++] = p; + names[n] = "text"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } if (g_menu_item_get_attribute (menu_item, "x-canonical-timezone", "s", &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; + names[n] = "timezone"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } if (g_menu_item_get_attribute (menu_item, "x-canonical-time-format", "s", &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; + names[n] = "format"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } - g_assert (n <= G_N_ELEMENTS (parameters)); - ido_location = g_object_newv (IDO_LOCATION_MENU_ITEM_TYPE, n, parameters); + g_assert (n <= G_N_ELEMENTS (names)); + g_assert (n <= n_max); + ido_location = IDO_LOCATION_MENU_ITEM(g_object_new_with_properties (IDO_LOCATION_MENU_ITEM_TYPE, n, names, values)); for (i=0; i<n; i++) - g_value_unset (¶meters[i].value); + g_value_unset (&values[i]); /* give it an ActionHelper */ diff --git a/src/idoprogressmenuitem.c b/src/idoprogressmenuitem.c index 4fda202..004682e 100644 --- a/src/idoprogressmenuitem.c +++ b/src/idoprogressmenuitem.c @@ -58,25 +58,29 @@ ido_progress_menu_item_new_from_model (GMenuItem * menu_item, guint n; gchar * str; IdoBasicMenuItem * ido_menu_item; - GParameter parameters[4]; + const gchar * names[1] = {0}; + GValue * values; + const guint n_max = 1; /* create the ido menuitem */; n = 0; + values = g_new0(GValue, n_max); if (g_menu_item_get_attribute (menu_item, "label", "s", &str)) { - GParameter p = { "text", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_STRING); - g_value_take_string (&p.value, str); - parameters[n++] = p; + names[n] = "text"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } - g_assert (n <= G_N_ELEMENTS (parameters)); - ido_menu_item = g_object_newv (IDO_TYPE_BASIC_MENU_ITEM, n, parameters); + g_assert (n <= G_N_ELEMENTS (names)); + g_assert (n <= n_max); + ido_menu_item = IDO_BASIC_MENU_ITEM(g_object_new_with_properties (IDO_TYPE_BASIC_MENU_ITEM, n, names, values)); for (i=0; i<n; i++) - g_value_unset (¶meters[i].value); + g_value_unset (&values[i]); /* give it an ActionHelper */ diff --git a/src/idousermenuitem.c b/src/idousermenuitem.c index bbb7916..f4e146b 100644 --- a/src/idousermenuitem.c +++ b/src/idousermenuitem.c @@ -415,35 +415,39 @@ user_menu_item_new_from_model (GMenuItem * menuitem, gchar * str; gchar * action; GVariant * v; - GParameter parameters[4]; + const gchar * names [2]; + GValue * values; + const guint n_max = 2; /* create the ido_user */ n = 0; + values = g_new0(GValue, n_max); if (g_menu_item_get_attribute (menuitem, G_MENU_ATTRIBUTE_LABEL, "s", &str)) { - GParameter p = { "label", G_VALUE_INIT }; - g_value_init (&p.value, G_TYPE_STRING); - g_value_take_string (&p.value, str); - parameters[n++] = p; + names[n] = "label"; + g_value_init (&values[n], G_TYPE_STRING); + g_value_take_string (&values[n], str); + n++; } if ((v = g_menu_item_get_attribute_value (menuitem, G_MENU_ATTRIBUTE_ICON, NULL))) { - GParameter p = { "icon", G_VALUE_INIT }; + names[n] = "icon"; GIcon * icon = g_icon_deserialize (v); - g_value_init (&p.value, G_TYPE_OBJECT); - g_value_take_object (&p.value, icon); + g_value_init (&values[n], G_TYPE_OBJECT); + g_value_take_object (&values[n], icon); g_variant_unref (v); - parameters[n++] = p; + n++; } - g_assert (n <= G_N_ELEMENTS (parameters)); - ido_user = g_object_newv (IDO_USER_MENU_ITEM_TYPE, n, parameters); + g_assert (n <= G_N_ELEMENTS (names)); + g_assert (n <= n_max); + ido_user = IDO_USER_MENU_ITEM(g_object_new_with_properties (IDO_USER_MENU_ITEM_TYPE, n, names, values)); for (i=0; i<n; i++) - g_value_unset (¶meters[i].value); + g_value_unset (&values[i]); /* gie it an ActionHelper */ |