[devhelp] Sidebar: some cosmetic code changes



commit fa4826aaa54b0ba4333029328a64c5a6a5d83fc7
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Dec 31 21:25:14 2017 +0100

    Sidebar: 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-sidebar.c |   54 ++++++++++++++++++++++++++----------------------------
 src/dh-sidebar.h |   30 +++++++++++++++++-------------
 2 files changed, 43 insertions(+), 41 deletions(-)
---
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index 570be35..185e92d 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -21,11 +21,8 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "config.h"
 #include "dh-sidebar.h"
-
 #include <string.h>
-
 #include "dh-keyword-model.h"
 #include "dh-book.h"
 #include "dh-book-tree.h"
@@ -56,17 +53,18 @@
  */
 
 typedef struct {
-        DhBookTree              *book_tree;
-        GtkScrolledWindow       *sw_book_tree;
+        GtkEntry *entry;
+
+        DhBookTree *book_tree;
+        GtkScrolledWindow *sw_book_tree;
 
-        GtkEntry                *entry;
-        DhKeywordModel          *hitlist_model;
-        GtkTreeView             *hitlist_view;
-        GtkScrolledWindow       *sw_hitlist;
+        DhKeywordModel *hitlist_model;
+        GtkTreeView *hitlist_view;
+        GtkScrolledWindow *sw_hitlist;
 
-        GCompletion             *completion;
-        guint                    idle_complete_id;
-        guint                    idle_filter_id;
+        GCompletion *completion;
+        guint idle_complete_id;
+        guint idle_filter_id;
 } DhSidebarPrivate;
 
 enum {
@@ -86,8 +84,8 @@ sidebar_filter_idle_cb (DhSidebar *sidebar)
         DhSidebarPrivate *priv;
         const gchar *search_text;
         const gchar *book_id;
-        DhLink      *book_link;
-        DhLink      *link;
+        DhLink *book_link;
+        DhLink *link;
 
         priv = dh_sidebar_get_instance_private (sidebar);
 
@@ -228,9 +226,9 @@ sidebar_hitlist_button_press_cb (GtkTreeView    *hitlist_view,
                                  DhSidebar      *sidebar)
 {
         DhSidebarPrivate *priv = dh_sidebar_get_instance_private (sidebar);
-        GtkTreePath  *path;
-        GtkTreeIter   iter;
-        DhLink       *link;
+        GtkTreePath *path;
+        GtkTreeIter iter;
+        DhLink *link;
 
         gtk_tree_view_get_path_at_pos (hitlist_view, event->x, event->y, &path,
                                        NULL, NULL, NULL);
@@ -274,9 +272,9 @@ sidebar_entry_key_press_event_cb (GtkEntry    *entry,
 
         if (event->keyval == GDK_KEY_Return ||
             event->keyval == GDK_KEY_KP_Enter) {
-                GtkTreeIter  iter;
-                DhLink      *link;
-                gchar       *name;
+                GtkTreeIter iter;
+                DhLink *link;
+                gchar *name;
 
                 /* Get the first entry found. */
                 if (gtk_widget_is_visible (GTK_WIDGET (priv->hitlist_view)) &&
@@ -325,8 +323,8 @@ static gboolean
 sidebar_complete_idle_cb (DhSidebar *sidebar)
 {
         DhSidebarPrivate *priv = dh_sidebar_get_instance_private (sidebar);
-        const gchar  *search_text;
-        gchar        *completed = NULL;
+        const gchar *search_text;
+        gchar *completed = NULL;
 
         search_text = gtk_entry_get_text (priv->entry);
 
@@ -411,12 +409,12 @@ hitlist_cell_data_func (GtkTreeViewColumn *tree_column,
                         GtkTreeIter       *iter,
                         gpointer           data)
 {
-        DhLink       *link;
-        DhLinkType    link_type;
-        PangoStyle    style;
-        PangoWeight   weight;
-        gboolean      current_book_flag;
-        gchar        *name;
+        DhLink *link;
+        DhLinkType link_type;
+        PangoStyle style;
+        PangoWeight weight;
+        gboolean current_book_flag;
+        gchar *name;
 
         gtk_tree_model_get (hitlist_model, iter,
                             DH_KEYWORD_MODEL_COL_LINK, &link,
diff --git a/src/dh-sidebar.h b/src/dh-sidebar.h
index 42bbc2a..09289d9 100644
--- a/src/dh-sidebar.h
+++ b/src/dh-sidebar.h
@@ -22,14 +22,14 @@
 #define DH_SIDEBAR_H
 
 #include <gtk/gtk.h>
-#include "dh-link.h"
 #include "dh-book-manager.h"
+#include "dh-link.h"
 
 G_BEGIN_DECLS
 
-#define DH_TYPE_SIDEBAR           (dh_sidebar_get_type ())
-#define DH_SIDEBAR(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SIDEBAR, DhSidebar))
-#define DH_SIDEBAR_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SIDEBAR, DhSidebarClass))
+#define DH_TYPE_SIDEBAR            (dh_sidebar_get_type ())
+#define DH_SIDEBAR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SIDEBAR, DhSidebar))
+#define DH_SIDEBAR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SIDEBAR, DhSidebarClass))
 #define DH_IS_SIDEBAR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SIDEBAR))
 #define DH_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SIDEBAR))
 
@@ -44,19 +44,23 @@ struct _DhSidebarClass {
         GtkBoxClass parent_class;
 
         /* Signals */
-        void (*link_selected) (DhSidebar *search,
+        void (*link_selected) (DhSidebar *sidebar,
                                DhLink    *link);
 };
 
-GType      dh_sidebar_get_type (void);
-GtkWidget *dh_sidebar_new      (DhBookManager *book_manager);
+GType           dh_sidebar_get_type             (void);
+
+GtkWidget *     dh_sidebar_new                  (DhBookManager *book_manager);
+
+DhLink *        dh_sidebar_get_selected_book    (DhSidebar *sidebar);
+
+void            dh_sidebar_select_uri           (DhSidebar   *sidebar,
+                                                 const gchar *uri);
+
+void            dh_sidebar_set_search_string    (DhSidebar   *sidebar,
+                                                 const gchar *str);
 
-DhLink    *dh_sidebar_get_selected_book (DhSidebar *sidebar);
-void       dh_sidebar_select_uri        (DhSidebar   *sidebar,
-                                         const gchar *uri);
-void       dh_sidebar_set_search_string (DhSidebar   *sidebar,
-                                         const gchar *str);
-void       dh_sidebar_set_search_focus  (DhSidebar   *sidebar);
+void            dh_sidebar_set_search_focus     (DhSidebar *sidebar);
 
 G_END_DECLS
 


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