[devhelp] BookManager: some cosmetic code changes



commit d986d1be5a8e46a19dea0963133a7750ac493137
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Dec 22 20:18:12 2017 +0100

    BookManager: some cosmetic code changes
    
    - Do not align variable names on the same column, because when adding a
    variable with a long type it's cumbersome to adapt the alignment for all
    other variables.
    - Space out the functions in the header, to have IMHO a better
    readability.
    - "Attach" the "*" (pointer) to the return value type, not the function
    name. The pointer is part of the return value.

 src/dh-book-manager.c |   40 +++++++++++++++++++++-------------------
 src/dh-book-manager.h |   22 +++++++++++++---------
 2 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/src/dh-book-manager.c b/src/dh-book-manager.c
index a1e5104..0d2fec3 100644
--- a/src/dh-book-manager.c
+++ b/src/dh-book-manager.c
@@ -39,24 +39,24 @@
 
 typedef struct {
         DhBookManager *book_manager;
-        GFile         *file;
+        GFile *file;
 } NewPossibleBookData;
 
 typedef struct {
         /* The list of all DhBooks* found in the system */
-        GList      *books;
+        GList *books;
 
         /* GFile* -> GFileMonitor* */
         GHashTable *monitors;
 
         /* List of book names (gchar*) currently disabled */
-        GSList     *books_disabled;
+        GSList *books_disabled;
 
         /* List of DhLanguage* with at least one book enabled */
-        GList      *languages;
+        GList *languages;
 
         /* Whether books should be grouped by language */
-        guint       group_by_language : 1;
+        guint group_by_language : 1;
 } DhBookManagerPrivate;
 
 enum {
@@ -284,7 +284,7 @@ book_manager_get_book_path (const gchar *base_path,
         };
         gchar *tmp;
         gchar *book_path;
-        guint  i;
+        guint i;
 
         for (i = 0; suffixes[i]; i++) {
                 tmp = g_build_filename (base_path, name, NULL);
@@ -296,6 +296,7 @@ book_manager_get_book_path (const gchar *base_path,
                 }
                 g_free (book_path);
         }
+
         return NULL;
 }
 
@@ -428,7 +429,7 @@ static void
 book_manager_book_deleted_cb (DhBook   *book,
                               gpointer  user_data)
 {
-        DhBookManager     *book_manager = user_data;
+        DhBookManager *book_manager = user_data;
         DhBookManagerPrivate *priv = dh_book_manager_get_instance_private (book_manager);
         GList *li;
 
@@ -480,6 +481,7 @@ book_manager_find_book_in_disabled_list (GSList *books_disabled,
                         return li;
                 }
         }
+
         return NULL;
 }
 
@@ -487,9 +489,9 @@ static void
 book_manager_book_enabled_cb (DhBook   *book,
                               gpointer  user_data)
 {
-        DhBookManager     *book_manager = user_data;
+        DhBookManager *book_manager = user_data;
         DhBookManagerPrivate *priv = dh_book_manager_get_instance_private (book_manager);
-        GSList            *li;
+        GSList *li;
 
         li = book_manager_find_book_in_disabled_list (priv->books_disabled,
                                                       book);
@@ -513,9 +515,9 @@ static void
 book_manager_book_disabled_cb (DhBook   *book,
                                gpointer  user_data)
 {
-        DhBookManager     *book_manager = user_data;
+        DhBookManager *book_manager = user_data;
         DhBookManagerPrivate *priv = dh_book_manager_get_instance_private (book_manager);
-        GSList            *li;
+        GSList *li;
 
         li = book_manager_find_book_in_disabled_list (priv->books_disabled,
                                                       book);
@@ -623,9 +625,9 @@ static gboolean
 book_manager_new_possible_book_cb (gpointer user_data)
 {
         NewPossibleBookData *data = user_data;
-        gchar               *file_path;
-        gchar               *file_basename;
-        gchar               *book_path;
+        gchar *file_path;
+        gchar *file_basename;
+        gchar *book_path;
 
         file_path = g_file_get_path (data->file);
         file_basename = g_file_get_basename (data->file);
@@ -655,7 +657,7 @@ book_manager_booklist_monitor_event_cb (GFileMonitor      *file_monitor,
                                         GFileMonitorEvent  event_type,
                                         gpointer           user_data)
 {
-        DhBookManager       *book_manager = user_data;
+        DhBookManager *book_manager = user_data;
         NewPossibleBookData *data;
 
         /* In the book manager we only handle events for new directories
@@ -682,9 +684,9 @@ static void
 book_manager_monitor_path (DhBookManager *book_manager,
                            const gchar   *path)
 {
-        GFileMonitor      *file_monitor;
-        GFile             *file;
         DhBookManagerPrivate *priv;
+        GFileMonitor *file_monitor;
+        GFile *file;
 
         priv = dh_book_manager_get_instance_private (book_manager);
 
@@ -731,7 +733,7 @@ static void
 book_manager_add_from_dir (DhBookManager *book_manager,
                            const gchar   *dir_path)
 {
-        GDir        *dir;
+        GDir *dir;
         const gchar *name;
 
         g_return_if_fail (book_manager);
@@ -788,7 +790,7 @@ book_manager_add_books_in_data_dir (DhBookManager *book_manager,
 static void
 populate (DhBookManager *book_manager)
 {
-        const gchar * const * system_dirs;
+        const gchar * const *system_dirs;
 
         book_manager_add_books_in_data_dir (book_manager,
                                             g_get_user_data_dir ());
diff --git a/src/dh-book-manager.h b/src/dh-book-manager.h
index 9a59a6a..459ba6f 100644
--- a/src/dh-book-manager.h
+++ b/src/dh-book-manager.h
@@ -41,21 +41,25 @@ struct _DhBookManagerClass {
         GObjectClass parent_class;
 };
 
-GType          dh_book_manager_get_type              (void) G_GNUC_CONST;
-DhBookManager *dh_book_manager_get_singleton         (void);
-GList         *dh_book_manager_get_books             (DhBookManager *book_manager);
-gboolean       dh_book_manager_get_group_by_language (DhBookManager *book_manager);
-void           dh_book_manager_set_group_by_language (DhBookManager *book_manager,
-                                                      gboolean       group_by_language);
+GType           dh_book_manager_get_type                (void) G_GNUC_CONST;
+
+DhBookManager * dh_book_manager_get_singleton           (void);
+
+GList *         dh_book_manager_get_books               (DhBookManager *book_manager);
+
+gboolean        dh_book_manager_get_group_by_language   (DhBookManager *book_manager);
+
+void            dh_book_manager_set_group_by_language   (DhBookManager *book_manager,
+                                                         gboolean       group_by_language);
 
 G_DEPRECATED
-DhBookManager *dh_book_manager_new                   (void);
+DhBookManager * dh_book_manager_new                     (void);
 
 G_DEPRECATED
-void           dh_book_manager_populate              (DhBookManager *book_manager);
+void            dh_book_manager_populate                (DhBookManager *book_manager);
 
 G_GNUC_INTERNAL
-void           _dh_book_manager_unref_singleton      (void);
+void            _dh_book_manager_unref_singleton        (void);
 
 G_END_DECLS
 


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