[glade] glade-editor-property: use literal format strings



commit ff9f27f5637530857c2c051b521559bcf99bac97
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Dec 21 11:05:00 2013 -0500

    glade-editor-property: use literal format strings
    
    Refactor glade_eprop_object_dialog_title() to make use of literal format
    strings instead of storing the format string into a variable.
    
    It is my opinion that this change also improves readability of the
    function in question by reducing the complexity and redundancy of the
    checks.
    
    This fixes the build which was broken on clang due to the use of
    -Werror=format-nonliteral.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720884

 gladeui/glade-editor-property.c |   53 ++++++++++++++++++++++----------------
 1 files changed, 31 insertions(+), 22 deletions(-)
---
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index e539ffe..790eff1 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -3033,35 +3033,44 @@ glade_eprop_object_view (gboolean radio)
 static gchar *
 glade_eprop_object_dialog_title (GladeEditorProperty *eprop)
 {
-  GladeWidgetAdaptor *adaptor;
+  gboolean parentless;
   GParamSpec *pspec;
-  const gchar *format;
 
+  parentless = glade_property_class_parentless_widget (eprop->priv->klass);
   pspec = glade_property_class_get_pspec (eprop->priv->klass);
 
-  if (glade_property_class_parentless_widget (eprop->priv->klass))
-    format = GLADE_IS_PARAM_SPEC_OBJECTS (pspec) ?
-        _("Choose parentless %s type objects in this project") :
-        _("Choose a parentless %s in this project");
+  if (GLADE_IS_PARAM_SPEC_OBJECTS (pspec))
+    {
+      const gchar *typename = g_type_name (glade_param_spec_objects_get_type (GLADE_PARAM_SPEC_OBJECTS 
(pspec)));
+
+      if (parentless)
+        return g_strdup_printf (_("Choose parentless %s type objects in this project"), typename);
+      else
+        return g_strdup_printf (_("Choose %s type objects in this project"), typename);
+    }
   else
-    format = GLADE_IS_PARAM_SPEC_OBJECTS (pspec) ?
-        _("Choose %s type objects in this project") :
-        _("Choose a %s in this project");
+    {
+      GladeWidgetAdaptor *adaptor;
+      const gchar *title;
 
-  if (GLADE_IS_PARAM_SPEC_OBJECTS (pspec))
-    return g_strdup_printf (format, g_type_name
-                            (glade_param_spec_objects_get_type
-                             (GLADE_PARAM_SPEC_OBJECTS (pspec))));
-  else if ((adaptor =
-            glade_widget_adaptor_get_by_type (pspec->value_type)) != NULL)
-    return g_strdup_printf (format, glade_widget_adaptor_get_title (adaptor));
-
-  /* Fallback on type name (which would look like "GtkButton"
-   * instead of "Button" and maybe not translated).
-   */
-  return g_strdup_printf (format, g_type_name (pspec->value_type));
-}
+      adaptor = glade_widget_adaptor_get_by_type (pspec->value_type);
 
+      if (adaptor != NULL)
+        title = glade_widget_adaptor_get_title (adaptor);
+      else
+        {
+          /* Fallback on type name (which would look like "GtkButton"
+           * instead of "Button" and maybe not translated).
+           */
+          title = g_type_name (pspec->value_type);
+        }
+
+      if (parentless)
+        return g_strdup_printf (_("Choose a parentless %s in this project"), title);
+      else
+        return g_strdup_printf (_("Choose a %s in this project"), title);
+    }
+}
 
 gboolean
 glade_editor_property_show_object_dialog (GladeProject *project,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]