[balsa/wip/gtk4] toolbar-factory and -prefs: Simplify API



commit 86d02482cd5f0e63a3ccb74c021f4b995c922c84
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat May 26 14:28:07 2018 -0400

    toolbar-factory and -prefs: Simplify API
    
    The 'position' argument to balsa_toolbar_model_insert_icon() was always
    -1, meaning to append the icon. Remove it, and rename the method to
    balsa_toolbar_model_append_icon.

 src/toolbar-factory.c | 13 ++++---------
 src/toolbar-factory.h |  3 +--
 src/toolbar-prefs.c   |  5 ++---
 3 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index 5c510a810..0ac059497 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -379,9 +379,8 @@ balsa_toolbar_model_is_standard(BalsaToolbarModel *model)
 /* Add an icon to the list of current icons in a BalsaToolbarModel.
  */
 void
-balsa_toolbar_model_insert_icon(BalsaToolbarModel *model,
-                                gchar             *icon,
-                                gint               position)
+balsa_toolbar_model_append_icon(BalsaToolbarModel * model,
+                                gchar             * icon)
 {
     const gchar *real_button = balsa_toolbar_sanitize_id(icon);
 
@@ -390,13 +389,9 @@ balsa_toolbar_model_insert_icon(BalsaToolbarModel *model,
 
         entry.action = g_strdup(g_hash_table_lookup(model->legal, real_button));
         entry.icon   = g_strdup(real_button);
-        if (position >= 0)
-            g_array_insert_val(model->current, position, entry);
-        else
-            g_array_append_val(model->current, entry);
-    } else {
+        g_array_append_val(model->current, entry);
+    } else
         g_warning(_("Unknown toolbar icon ā€œ%sā€"), icon);
-    }
 }
 
 
diff --git a/src/toolbar-factory.h b/src/toolbar-factory.h
index 5d2395d07..6575a0415 100644
--- a/src/toolbar-factory.h
+++ b/src/toolbar-factory.h
@@ -72,8 +72,7 @@ GHashTable *balsa_toolbar_model_get_legal(BalsaToolbarModel *model);
 GArray     *balsa_toolbar_model_get_current(BalsaToolbarModel *model);
 gboolean    balsa_toolbar_model_is_standard(BalsaToolbarModel *model);
 void        balsa_toolbar_model_insert_icon(BalsaToolbarModel *model,
-                                            gchar             *icon,
-                                            gint               position);
+                                            gchar             *icon);
 void balsa_toolbar_model_delete_icon(BalsaToolbarModel *model,
                                      gchar             *icon);
 void balsa_toolbar_model_clear(BalsaToolbarModel *model);
diff --git a/src/toolbar-prefs.c b/src/toolbar-prefs.c
index ecfd3f2b8..ef5c274ab 100644
--- a/src/toolbar-prefs.c
+++ b/src/toolbar-prefs.c
@@ -702,9 +702,8 @@ tp_page_refresh_preview(ToolbarPage * page)
 
         gtk_tree_model_get(model, &iter, TP_ITEM_COLUMN, &item, -1);
         if (item >= 0 && item < toolbar_button_count)
-            balsa_toolbar_model_insert_icon(page->model,
-                                            toolbar_buttons[item].pixmap_id,
-                                            -1);
+            balsa_toolbar_model_append_icon(page->model,
+                                            toolbar_buttons[item].pixmap_id);
     }
 }
 


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