[glib/wip/menus: 19/35] Rename some parameters



commit 1f66378540f3a145a0db8cc0338bfb740fd1dcda
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Jul 11 01:50:49 2011 +0200

    Rename some parameters
    
     - change "index_" to "position"
    
     - replace "attribute_quark" and "link_quark" with "attribute" and "link"

 gio/gmenu.c      |   42 +++++++++++++++++++++---------------------
 gio/gmenu.h      |   18 +++++++++---------
 gio/gmenumodel.c |   52 ++++++++++++++++++++++++++--------------------------
 gio/gmenumodel.h |   18 +++++++++---------
 4 files changed, 65 insertions(+), 65 deletions(-)
---
diff --git a/gio/gmenu.c b/gio/gmenu.c
index c5a8500..03bf5d3 100644
--- a/gio/gmenu.c
+++ b/gio/gmenu.c
@@ -55,30 +55,30 @@ g_menu_get_n_items (GMenuModel *model)
 
 static void
 g_menu_get_item_attributes (GMenuModel  *model,
-                            gint         index_,
+                            gint         position,
                             GHashTable **quark_table,
                             GHashTable **string_table,
                             GVariant   **dictionary)
 {
   GMenu *menu = G_MENU (model);
 
-  *quark_table = g_array_index (menu->priv->items, struct item, index_).attributes;
+  *quark_table = g_array_index (menu->priv->items, struct item, position).attributes;
 }
 
 static void
 g_menu_get_item_links (GMenuModel  *model,
-                       gint         index_,
+                       gint         position,
                        GHashTable **quark_table,
                        GHashTable **string_table)
 {
   GMenu *menu = G_MENU (model);
 
-  *quark_table = g_array_index (menu->priv->items, struct item, index_).links;
+  *quark_table = g_array_index (menu->priv->items, struct item, position).links;
 }
 
 void
 g_menu_insert_item (GMenu     *menu,
-                    gint       index_,
+                    gint       position,
                     GMenuItem *item)
 {
   struct item new_item;
@@ -86,16 +86,16 @@ g_menu_insert_item (GMenu     *menu,
   g_return_if_fail (G_IS_MENU (menu));
   g_return_if_fail (G_IS_MENU_ITEM (item));
 
-  if (index_ < 0 || index_ > menu->priv->items->len)
-    index_ = menu->priv->items->len;
+  if (position < 0 || position > menu->priv->items->len)
+    position = menu->priv->items->len;
 
 
   new_item.attributes = g_hash_table_ref (item->attributes);
   new_item.links = g_hash_table_ref (item->links);
   item->cow = TRUE;
 
-  g_array_insert_val (menu->priv->items, index_, new_item);
-  g_menu_model_items_changed (G_MENU_MODEL (menu), index_, 0, 1);
+  g_array_insert_val (menu->priv->items, position, new_item);
+  g_menu_model_items_changed (G_MENU_MODEL (menu), position, 0, 1);
 }
 
 void
@@ -128,14 +128,14 @@ g_menu_new (void)
 
 void
 g_menu_insert (GMenu       *menu,
-               gint         index_,
+               gint         position,
                const gchar *label,
                const gchar *detailed_action)
 {
   GMenuItem *menu_item;
 
   menu_item = g_menu_item_new (label, detailed_action);
-  g_menu_insert_item (menu, index_, menu_item);
+  g_menu_insert_item (menu, position, menu_item);
   g_object_unref (menu_item);
 }
 
@@ -159,14 +159,14 @@ g_menu_append (GMenu       *menu,
 
 void
 g_menu_insert_section (GMenu       *menu,
-                       gint         index_,
+                       gint         position,
                        const gchar *label,
                        GMenuModel  *section)
 {
   GMenuItem *menu_item;
 
   menu_item = g_menu_item_new_section (label, section);
-  g_menu_insert_item (menu, index_, menu_item);
+  g_menu_insert_item (menu, position, menu_item);
   g_object_unref (menu_item);
 }
 
@@ -189,14 +189,14 @@ g_menu_append_section (GMenu       *menu,
 
 void
 g_menu_insert_submenu (GMenu       *menu,
-                       gint         index_,
+                       gint         position,
                        const gchar *label,
                        GMenuModel  *submenu)
 {
   GMenuItem *menu_item;
 
   menu_item = g_menu_item_new_submenu (label, submenu);
-  g_menu_insert_item (menu, index_, menu_item);
+  g_menu_insert_item (menu, position, menu_item);
   g_object_unref (menu_item);
 }
 
@@ -336,11 +336,11 @@ g_menu_item_class_init (GMenuItemClass *class)
 
 void
 g_menu_item_set_attribute_value (GMenuItem *menu_item,
-                                 GQuark     attribute_quark,
+                                 GQuark     attribute,
                                  GVariant  *value)
 {
   g_return_if_fail (G_IS_MENU_ITEM (menu_item));
-  g_return_if_fail (attribute_quark != 0);
+  g_return_if_fail (attribute != 0);
 
   g_menu_item_clear_cow (menu_item);
 
@@ -352,7 +352,7 @@ g_menu_item_set_attribute_value (GMenuItem *menu_item,
 
 void
 g_menu_item_set_attribute (GMenuItem   *menu_item,
-                           GQuark       attribute_quark,
+                           GQuark       attribute,
                            const gchar *format_string,
                            ...)
 {
@@ -374,11 +374,11 @@ g_menu_item_set_attribute (GMenuItem   *menu_item,
 
 void
 g_menu_item_set_link (GMenuItem  *menu_item,
-                      GQuark      link_quark,
-                      GMenuModel *link)
+                      GQuark      link,
+                      GMenuModel *model)
 {
   g_return_if_fail (G_IS_MENU_ITEM (menu_item));
-  g_return_if_fail (link_quark != 0);
+  g_return_if_fail (link != 0);
 
   g_menu_item_clear_cow (menu_item);
 
diff --git a/gio/gmenu.h b/gio/gmenu.h
index 286820c..4a56236 100644
--- a/gio/gmenu.h
+++ b/gio/gmenu.h
@@ -59,17 +59,17 @@ GMenu *                 g_menu_new                                      (void);
 void                    g_menu_freeze                                   (GMenu              *menu);
 
 void                    g_menu_insert_item                              (GMenu              *menu,
-                                                                         gint                index,
+                                                                         gint                position,
                                                                          GMenuItem          *item);
 void                    g_menu_prepend_item                             (GMenu              *menu,
                                                                          GMenuItem          *item);
 void                    g_menu_append_item                              (GMenu              *menu,
                                                                          GMenuItem          *item);
 void                    g_menu_remove                                   (GMenu              *menu,
-                                                                         gint                index);
+                                                                         gint                position);
 
 void                    g_menu_insert                                   (GMenu              *menu,
-                                                                         gint                index,
+                                                                         gint                position,
                                                                          const gchar        *label,
                                                                          const gchar        *detailed_action);
 void                    g_menu_prepend                                  (GMenu              *menu,
@@ -80,7 +80,7 @@ void                    g_menu_append                                   (GMenu
                                                                          const gchar        *detailed_action);
 
 void                    g_menu_insert_section                           (GMenu              *menu,
-                                                                         gint                index,
+                                                                         gint                position,
                                                                          const gchar        *label,
                                                                          GMenuModel         *section);
 void                    g_menu_prepend_section                          (GMenu              *menu,
@@ -91,7 +91,7 @@ void                    g_menu_append_section                           (GMenu
                                                                          GMenuModel         *section);
 
 void                    g_menu_insert_submenu                           (GMenu              *menu,
-                                                                         gint                index,
+                                                                         gint                position,
                                                                          const gchar        *label,
                                                                          GMenuModel         *submenu);
 void                    g_menu_prepend_submenu                          (GMenu              *menu,
@@ -113,15 +113,15 @@ GMenuItem *             g_menu_item_new_section                         (const g
                                                                          GMenuModel         *section);
 
 void                    g_menu_item_set_attribute_value                 (GMenuItem          *menu_item,
-                                                                         GQuark              attribute_quark,
+                                                                         GQuark              attribute,
                                                                          GVariant           *value);
 void                    g_menu_item_set_attribute                       (GMenuItem          *menu_item,
-                                                                         GQuark              attribute_quark,
+                                                                         GQuark              attribute,
                                                                          const gchar        *format_string,
                                                                          ...);
 void                    g_menu_item_set_link                            (GMenuItem          *menu_item,
-                                                                         GQuark              link_quark,
-                                                                         GMenuModel         *link);
+                                                                         GQuark              link,
+                                                                         GMenuModel         *model);
 void                    g_menu_item_set_label                           (GMenuItem          *menu_item,
                                                                          const gchar        *label);
 void                    g_menu_item_set_submenu                         (GMenuItem          *menu_item,
diff --git a/gio/gmenumodel.c b/gio/gmenumodel.c
index 7fb33a7..5e33805 100644
--- a/gio/gmenumodel.c
+++ b/gio/gmenumodel.c
@@ -253,7 +253,7 @@ g_menu_model_real_iterate_item_attributes (GMenuModel *model,
 static GVariant *
 g_menu_model_real_get_item_attribute_value (GMenuModel         *model,
                                             gint                item_index,
-                                            GQuark              attribute_quark,
+                                            GQuark              attribute,
                                             const GVariantType *expected_type)
 {
   GHashTable *string_table = NULL;
@@ -266,7 +266,7 @@ g_menu_model_real_get_item_attribute_value (GMenuModel         *model,
 
   if (quark_table != NULL)
     {
-      value = g_hash_table_lookup (quark_table, GINT_TO_POINTER (attribute_quark));
+      value = g_hash_table_lookup (quark_table, GINT_TO_POINTER (attribute));
 
       if (value != NULL)
         {
@@ -279,7 +279,7 @@ g_menu_model_real_get_item_attribute_value (GMenuModel         *model,
 
   else if (string_table != NULL)
     {
-      value = g_hash_table_lookup (string_table, g_quark_to_string (attribute_quark));
+      value = g_hash_table_lookup (string_table, g_quark_to_string (attribute));
 
       if (value != NULL)
         {
@@ -291,7 +291,7 @@ g_menu_model_real_get_item_attribute_value (GMenuModel         *model,
     }
 
   else if (dictionary != NULL)
-    value = g_variant_lookup_value (dictionary, g_quark_to_string (attribute_quark), expected_type);
+    value = g_variant_lookup_value (dictionary, g_quark_to_string (attribute), expected_type);
 
   if (string_table != NULL)
     g_hash_table_unref (string_table);
@@ -352,27 +352,27 @@ g_menu_model_real_iterate_item_links (GMenuModel *model,
 static GMenuModel *
 g_menu_model_real_get_item_link (GMenuModel *model,
                                  gint        item_index,
-                                 GQuark      link_quark)
+                                 GQuark      link)
 {
   GHashTable *string_table = NULL;
   GHashTable *quark_table = NULL;
-  GMenuModel *link = NULL;
+  GMenuModel *value = NULL;
 
   G_MENU_MODEL_GET_CLASS (model)
     ->get_item_links (model, item_index, &quark_table, &string_table);
 
   if (quark_table != NULL)
-    link = g_hash_table_lookup (quark_table, GINT_TO_POINTER (link_quark));
+    value = g_hash_table_lookup (quark_table, GINT_TO_POINTER (link));
 
   else if (string_table != NULL)
-    link = g_hash_table_lookup (string_table, g_quark_to_string (link_quark));
+    value = g_hash_table_lookup (string_table, g_quark_to_string (link));
 
   if (string_table != NULL)
     g_hash_table_unref (string_table);
   if (quark_table != NULL)
     g_hash_table_unref (quark_table);
 
-  return link ? g_object_ref (link) : NULL;
+  return value ? g_object_ref (value) : NULL;
 }
 
 static void
@@ -419,7 +419,7 @@ g_menu_model_get_item (GMenuModel     *model,
   g_return_if_fail (G_IS_MENU_MODEL (model));
 
   item->model = model;
-  item->index_ = item_index;
+  item->position = item_index;
 }
 
 GMenuAttributeIter *
@@ -433,17 +433,17 @@ g_menu_model_iterate_item_attributes (GMenuModel *model,
 GVariant *
 g_menu_model_get_item_attribute_value (GMenuModel         *model,
                                        gint                item_index,
-                                       GQuark              attribute_quark,
+                                       GQuark              attribute,
                                        const GVariantType *expected_type)
 {
   return G_MENU_MODEL_GET_CLASS (model)
-    ->get_item_attribute_value (model, item_index, attribute_quark, expected_type);
+    ->get_item_attribute_value (model, item_index, attribute, expected_type);
 }
 
 gboolean
 g_menu_model_get_item_attribute (GMenuModel  *model,
                                  gint         item_index,
-                                 GQuark       attribute_quark,
+                                 GQuark       attribute,
                                  const gchar *format_string,
                                  ...)
 {
@@ -453,7 +453,7 @@ g_menu_model_get_item_attribute (GMenuModel  *model,
 
   expected_type = NULL; /* XXX devine the type, ensure no '&' */
 
-  value = g_menu_model_get_item_attribute_value (model, item_index, attribute_quark, expected_type);
+  value = g_menu_model_get_item_attribute_value (model, item_index, attribute, expected_type);
   if (value == NULL)
     return FALSE;
 
@@ -476,19 +476,19 @@ g_menu_model_iterate_item_links (GMenuModel *model,
 GMenuModel *
 g_menu_model_get_item_link (GMenuModel *model,
                             gint        item_index,
-                            GQuark      link_quark)
+                            GQuark      link)
 {
   return G_MENU_MODEL_GET_CLASS (model)
-    ->get_item_link (model, item_index, link_quark);
+    ->get_item_link (model, item_index, link);
 }
 
 void
 g_menu_model_items_changed (GMenuModel *model,
-                            gint        index_,
+                            gint        position,
                             gint        removed,
                             gint        added)
 {
-  g_signal_emit (model, g_menu_model_items_changed_signal, 0, index_, removed, added);
+  g_signal_emit (model, g_menu_model_items_changed_signal, 0, position, removed, added);
 }
 
 G_DEFINE_ABSTRACT_TYPE (GMenuAttributeIter, g_menu_attribute_iter, G_TYPE_OBJECT)
@@ -652,20 +652,20 @@ g_menu_link_iter_class_init (GMenuLinkIterClass *class)
 GMenuAttributeIter *
 g_menu_model_item_iterate_attributes (GMenuModelItem *item)
 {
-  return g_menu_model_iterate_item_attributes (item->model, item->index_);
+  return g_menu_model_iterate_item_attributes (item->model, item->position);
 }
 
 GVariant *
 g_menu_model_item_get_attribute_value (GMenuModelItem     *item,
-                                       GQuark              attribute_quark,
+                                       GQuark              attribute,
                                        const GVariantType *expected_type)
 {
-  return g_menu_model_get_item_attribute_value (item->model, item->index_, attribute_quark, expected_type);
+  return g_menu_model_get_item_attribute_value (item->model, item->position, attribute, expected_type);
 }
 
 gboolean
 g_menu_model_item_get_attribute (GMenuModelItem *item,
-                                 GQuark          attribute_quark,
+                                 GQuark          attribute,
                                  const gchar    *format_string,
                                  ...)
 {
@@ -675,7 +675,7 @@ g_menu_model_item_get_attribute (GMenuModelItem *item,
 
   expected_type = NULL; /* XXX devine the type, ensure no '&' */
 
-  value = g_menu_model_get_item_attribute_value (item->model, item->index_, attribute_quark, expected_type);
+  value = g_menu_model_get_item_attribute_value (item->model, item->position, attribute, expected_type);
   if (value == NULL)
     return FALSE;
 
@@ -690,12 +690,12 @@ g_menu_model_item_get_attribute (GMenuModelItem *item,
 GMenuLinkIter *
 g_menu_model_item_iterate_links (GMenuModelItem *item)
 {
-  return g_menu_model_iterate_item_links (item->model, item->index_);
+  return g_menu_model_iterate_item_links (item->model, item->position);
 }
 
 GMenuModel *
 g_menu_model_item_get_link (GMenuModelItem *item,
-                            GQuark          link_quark)
+                            GQuark          link)
 {
-  return g_menu_model_get_item_link (item->model, item->index_, link_quark);
+  return g_menu_model_get_item_link (item->model, item->position, link);
 }
diff --git a/gio/gmenumodel.h b/gio/gmenumodel.h
index e74f7de..7ff3801 100644
--- a/gio/gmenumodel.h
+++ b/gio/gmenumodel.h
@@ -73,7 +73,7 @@ struct _GMenuModelClass
                                                               gint                item_index);
   GVariant *            (*get_item_attribute_value)         (GMenuModel          *model,
                                                              gint                 item_index,
-                                                             GQuark               attribute_quark,
+                                                             GQuark               attribute,
                                                              const GVariantType  *expected_type);
 
   void                  (*get_item_links)                   (GMenuModel          *model,
@@ -84,7 +84,7 @@ struct _GMenuModelClass
                                                              gint                 item_index);
   GMenuModel *          (*get_item_link)                    (GMenuModel          *model,
                                                              gint                 item_index,
-                                                             GQuark               link_quark);
+                                                             GQuark               link);
 };
 
 GType                   g_menu_model_get_type                           (void) G_GNUC_CONST;
@@ -99,18 +99,18 @@ GMenuAttributeIter *    g_menu_model_iterate_item_attributes            (GMenuMo
                                                                          gint                item_index);
 GVariant *              g_menu_model_get_item_attribute_value           (GMenuModel         *model,
                                                                          gint                item_index,
-                                                                         GQuark              attribute_quark,
+                                                                         GQuark              attribute,
                                                                          const GVariantType *expected_type);
 gboolean                g_menu_model_get_item_attribute                 (GMenuModel         *model,
                                                                          gint                item_index,
-                                                                         GQuark              attribute_quark,
+                                                                         GQuark              attribute,
                                                                          const gchar        *format_string,
                                                                          ...);
 GMenuLinkIter *         g_menu_model_iterate_item_links                 (GMenuModel         *model,
                                                                          gint                item_index);
 GMenuModel *            g_menu_model_get_item_link                      (GMenuModel         *model,
                                                                          gint                item_index,
-                                                                         GQuark              link_quark);
+                                                                         GQuark              link);
 
 void                    g_menu_model_items_changed                      (GMenuModel         *model,
                                                                          gint                position,
@@ -195,20 +195,20 @@ struct _GMenuModelItem
 {
   /*< private >*/
   GMenuModel *model;
-  gint index_;
+  gint position;
 };
 
 GMenuAttributeIter *    g_menu_model_item_iterate_attributes            (GMenuModelItem     *item);
 GVariant *              g_menu_model_item_get_attribute_value           (GMenuModelItem     *item,
-                                                                         GQuark              attribute_quark,
+                                                                         GQuark              attribute,
                                                                          const GVariantType *expected_type);
 gboolean                g_menu_model_item_get_attribute                 (GMenuModelItem     *item,
-                                                                         GQuark              attribute_quark,
+                                                                         GQuark              attribute,
                                                                          const gchar        *format_string,
                                                                          ...);
 GMenuLinkIter *         g_menu_model_item_iterate_links                 (GMenuModelItem     *item);
 GMenuModel *            g_menu_model_item_get_link                      (GMenuModelItem     *item,
-                                                                         GQuark              link_quark);
+                                                                         GQuark              link);
 
 G_END_DECLS
 



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