[gnumeric] Plug leak.



commit d7e341fcccea138dd61ed0e0f9d760d79560670c
Author: Morten Welinder <terra gnome org>
Date:   Thu Jan 1 19:25:17 2015 -0500

    Plug leak.

 src/dialogs/ChangeLog            |    2 +
 src/dialogs/dialog-cell-format.c |   64 +++++++++++++++++++-------------------
 2 files changed, 34 insertions(+), 32 deletions(-)
---
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index e86c436..2053c08 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,5 +1,7 @@
 2015-01-01  Morten Welinder  <terra gnome org>
 
+       * dialog-cell-format.c (build_validation_error_combo): Plug leak.
+
        * dialog-sheet-order.c (dialog_sheet_order): Fix icon handling.
 
        * dialog-about.c (dialog_about): Update copyright.
diff --git a/src/dialogs/dialog-cell-format.c b/src/dialogs/dialog-cell-format.c
index 9c2db31..8fd9713 100644
--- a/src/dialogs/dialog-cell-format.c
+++ b/src/dialogs/dialog-cell-format.c
@@ -1809,44 +1809,44 @@ cb_validation_rebuild (G_GNUC_UNUSED void *ignored,
 static void
 build_validation_error_combo (GtkComboBox *box)
 {
-       GdkPixbuf *pixbuf;
        GtkListStore *store;
-       GtkTreeIter iter;
        GtkCellRenderer *renderer;
+       struct {
+               const char *text;
+               const char *icon_name;
+       } items[] = {
+               {
+                       N_("None          (silently accept invalid input)"),
+                       GTK_STOCK_STOP
+               },
+               {
+                       N_("Warning     (accept/discard invalid input)"),
+                       GTK_STOCK_DIALOG_WARNING
+               },
+               {
+                       N_("Information (allow invalid input)"),
+                       GTK_STOCK_DIALOG_INFO
+               }
+       };
+       unsigned ui;
 
        store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
        gtk_combo_box_set_model (box, GTK_TREE_MODEL (store));
 
-       gtk_list_store_append (store, &iter);
-       gtk_list_store_set (store, &iter,
-                           1, _("None          (silently accept invalid input)"),
-                           -1);
-
-       pixbuf = gtk_widget_render_icon_pixbuf (GTK_WIDGET (box), GTK_STOCK_STOP,
-                                        GTK_ICON_SIZE_BUTTON);
-       gtk_list_store_append (store, &iter);
-       gtk_list_store_set (store, &iter,
-                           0, pixbuf,
-                           1, _("Stop            (never allow invalid input)"),
-                           -1);
-
-       pixbuf = gtk_widget_render_icon_pixbuf (GTK_WIDGET (box),
-                                        GTK_STOCK_DIALOG_WARNING,
-                                        GTK_ICON_SIZE_BUTTON);
-       gtk_list_store_append (store, &iter);
-       gtk_list_store_set (store, &iter,
-                           0, pixbuf,
-                           1, _("Warning     (accept/discard invalid input)"),
-                           -1);
-
-       pixbuf = gtk_widget_render_icon_pixbuf (GTK_WIDGET (box),
-                                        GTK_STOCK_DIALOG_INFO,
-                                        GTK_ICON_SIZE_BUTTON);
-       gtk_list_store_append (store, &iter);
-       gtk_list_store_set (store, &iter,
-                           0, pixbuf,
-                           1, _("Information (allow invalid input)"),
-                           -1);
+       for (ui = 0; ui < G_N_ELEMENTS (items); ui++) {
+               GdkPixbuf *pixbuf =
+                       gtk_widget_render_icon_pixbuf (GTK_WIDGET (box),
+                                                      items[ui].icon_name,
+                                                      GTK_ICON_SIZE_BUTTON);
+               GtkTreeIter iter;
+
+               gtk_list_store_append (store, &iter);
+               gtk_list_store_set (store, &iter,
+                                   0, pixbuf,
+                                   1, _(items[ui].text),
+                                   -1);
+               g_object_unref (pixbuf);
+       }
 
        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (box),


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