[glade] GladeGtkGrid: Fix "format not a string literal" warning



commit c672658a16b80f7569d05fb65636778a754abe06
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Apr 26 15:18:57 2016 +0200

    GladeGtkGrid: Fix "format not a string literal" warning
    
    glade-gtk-grid.c: In function ‘glade_gtk_grid_child_insert_remove_action’:
    glade-gtk-grid.c:496:3: error: format not a string literal, argument types not checked 
[-Werror=format-nonliteral]
       glade_command_push_group (group_format, glade_widget_get_name (parent));
       ^~~~~~~~~~~~~~~~~~~~~~~~
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765612

 plugins/gtk+/glade-gtk-grid.c |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-grid.c b/plugins/gtk+/glade-gtk-grid.c
index 1f71c14..78a7551 100644
--- a/plugins/gtk+/glade-gtk-grid.c
+++ b/plugins/gtk+/glade-gtk-grid.c
@@ -38,6 +38,13 @@ typedef struct
   gint height;
 } GladeGridAttachments;
 
+typedef enum {
+  GROUP_ACTION_INSERT_ROW,
+  GROUP_ACTION_INSERT_COLUMN,
+  GROUP_ACTION_REMOVE_COLUMN,
+  GROUP_ACTION_REMOVE_ROW
+} GroupAction;
+
 static gboolean glade_gtk_grid_configure_begin (GladeFixed  *fixed,
                                                GladeWidget *child,
                                                GtkWidget   *grid);
@@ -477,7 +484,7 @@ static void
 glade_gtk_grid_child_insert_remove_action (GladeWidgetAdaptor *adaptor, 
                                            GObject            *container, 
                                            GObject            *object, 
-                                           const gchar        *group_format, 
+                                           GroupAction         group_action,
                                            const gchar        *n_row_col, 
                                            const gchar        *attach1,    /* should be smaller (top/left) 
attachment */
                                            const gchar        *attach2,      /* should be larger (bot/right) 
attachment */
@@ -493,7 +500,24 @@ glade_gtk_grid_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
                            attach1, &child_pos, NULL);
 
   parent = glade_widget_get_from_gobject (container);
-  glade_command_push_group (group_format, glade_widget_get_name (parent));
+
+  switch (group_action)
+    {
+      case GROUP_ACTION_INSERT_ROW:
+        glade_command_push_group (_("Insert Row on %s"), glade_widget_get_name (parent));
+        break;
+      case GROUP_ACTION_INSERT_COLUMN:
+        glade_command_push_group (_("Insert Column on %s"), glade_widget_get_name (parent));
+        break;
+      case GROUP_ACTION_REMOVE_COLUMN:
+        glade_command_push_group (_("Remove Column on %s"), glade_widget_get_name (parent));
+        break;
+      case GROUP_ACTION_REMOVE_ROW:
+        glade_command_push_group (_("Remove Row on %s"), glade_widget_get_name (parent));
+        break;
+      default:
+        g_assert_not_reached ();
+    }
 
   children = glade_widget_adaptor_get_children (adaptor, container);
   /* Make sure widgets does not get destroyed */
@@ -594,14 +618,14 @@ glade_gtk_grid_child_action_activate (GladeWidgetAdaptor *adaptor,
   if (strcmp (action_path, "insert_row/after") == 0)
     {
       glade_gtk_grid_child_insert_remove_action (adaptor, container, object,
-                                                 _("Insert Row on %s"),
+                                                 GROUP_ACTION_INSERT_ROW,
                                                  "n-rows", "top-attach",
                                                  "height", FALSE, TRUE);
     }
   else if (strcmp (action_path, "insert_row/before") == 0)
     {
       glade_gtk_grid_child_insert_remove_action (adaptor, container, object,
-                                                 _("Insert Row on %s"),
+                                                 GROUP_ACTION_INSERT_ROW,
                                                  "n-rows", "top-attach",
                                                  "height",
                                                  FALSE, FALSE);
@@ -609,28 +633,28 @@ glade_gtk_grid_child_action_activate (GladeWidgetAdaptor *adaptor,
   else if (strcmp (action_path, "insert_column/after") == 0)
     {
       glade_gtk_grid_child_insert_remove_action (adaptor, container, object,
-                                                 _("Insert Column on %s"),
+                                                 GROUP_ACTION_INSERT_COLUMN,
                                                  "n-columns", "left-attach",
                                                  "width", FALSE, TRUE);
     }
   else if (strcmp (action_path, "insert_column/before") == 0)
     {
       glade_gtk_grid_child_insert_remove_action (adaptor, container, object,
-                                                 _("Insert Column on %s"),
+                                                 GROUP_ACTION_INSERT_COLUMN,
                                                  "n-columns", "left-attach",
                                                  "width", FALSE, FALSE);
     }
   else if (strcmp (action_path, "remove_column") == 0)
     {
       glade_gtk_grid_child_insert_remove_action (adaptor, container, object,
-                                                 _("Remove Column on %s"),
+                                                 GROUP_ACTION_REMOVE_COLUMN,
                                                  "n-columns", "left-attach",
                                                  "width", TRUE, FALSE);
     }
   else if (strcmp (action_path, "remove_row") == 0)
     {
       glade_gtk_grid_child_insert_remove_action (adaptor, container, object,
-                                                 _("Remove Row on %s"),
+                                                 GROUP_ACTION_REMOVE_ROW,
                                                  "n-rows", "top-attach",
                                                  "height", TRUE, FALSE);
     }


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