[gtk+/treeview-refactor-staging: 2/7] Removed the private sharing of internal treeview macros from gtktreeprivate.h



commit 04a91fc437cde419acb14d807e929d42eb852225
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Tue Nov 30 15:28:14 2010 +0900

    Removed the private sharing of internal treeview macros from gtktreeprivate.h
    
    Added them directly to gtktreeview.c.

 gtk/gtkfilechooserdefault.c |    6 ++-
 gtk/gtktreeprivate.h        |  116 +-----------------------------------------
 gtk/gtktreeview.c           |  116 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+), 114 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 1ae5758..a3de75b 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -2998,14 +2998,18 @@ shortcuts_compute_drop_position (GtkFileChooserDefault   *impl,
   GdkRectangle cell;
   int row;
   int bookmarks_index;
+  int header_height = 0;
 
   tree_view = GTK_TREE_VIEW (impl->browse_shortcuts_tree_view);
 
+  if (gtk_tree_view_get_headers_visible (tree_view))
+    header_height = _gtk_tree_view_get_header_height (tree_view);
+
   bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
 
   if (!gtk_tree_view_get_path_at_pos (tree_view,
                                       x,
-				      y - TREE_VIEW_HEADER_HEIGHT (tree_view),
+				      y - header_height,
                                       path,
                                       &column,
                                       NULL,
diff --git a/gtk/gtktreeprivate.h b/gtk/gtktreeprivate.h
index 1a5f9b3..d018bdc 100644
--- a/gtk/gtktreeprivate.h
+++ b/gtk/gtktreeprivate.h
@@ -32,51 +32,11 @@ G_BEGIN_DECLS
 
 typedef enum
 {
-  GTK_TREE_VIEW_IS_LIST = 1 << 0,
-  GTK_TREE_VIEW_SHOW_EXPANDERS = 1 << 1,
-  GTK_TREE_VIEW_IN_COLUMN_RESIZE = 1 << 2,
-  GTK_TREE_VIEW_ARROW_PRELIT = 1 << 3,
-  GTK_TREE_VIEW_HEADERS_VISIBLE = 1 << 4,
-  GTK_TREE_VIEW_DRAW_KEYFOCUS = 1 << 5,
-  GTK_TREE_VIEW_MODEL_SETUP = 1 << 6,
-  GTK_TREE_VIEW_IN_COLUMN_DRAG = 1 << 7
-} GtkTreeViewFlags;
-
-typedef enum
-{
   GTK_TREE_SELECT_MODE_TOGGLE = 1 << 0,
   GTK_TREE_SELECT_MODE_EXTEND = 1 << 1
 }
 GtkTreeSelectMode;
 
-enum
-{
-  DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
-  DRAG_COLUMN_WINDOW_STATE_ORIGINAL = 1,
-  DRAG_COLUMN_WINDOW_STATE_ARROW = 2,
-  DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT = 3,
-  DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT = 4
-};
-
-enum
-{
-  RUBBER_BAND_OFF = 0,
-  RUBBER_BAND_MAYBE_START = 1,
-  RUBBER_BAND_ACTIVE = 2
-};
-
-#define GTK_TREE_VIEW_SET_FLAG(tree_view, flag)   G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
-#define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
-#define GTK_TREE_VIEW_FLAG_SET(tree_view, flag)   ((tree_view->priv->flags&flag)==flag)
-#define TREE_VIEW_HEADER_HEIGHT(tree_view)        (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_HEADERS_VISIBLE)?tree_view->priv->header_height:0)
-#define TREE_VIEW_COLUMN_REQUESTED_WIDTH(column)  (CLAMP (column->requested_width, (column->min_width!=-1)?column->min_width:column->requested_width, (column->max_width!=-1)?column->max_width:column->requested_width))
-#define TREE_VIEW_DRAW_EXPANDERS(tree_view)       (!GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_IS_LIST)&&GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_SHOW_EXPANDERS))
-
- /* This lovely little value is used to determine how far away from the title bar
-  * you can move the mouse and still have a column drag work.
-  */
-#define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
-
 typedef struct _GtkTreeViewColumnReorder GtkTreeViewColumnReorder;
 struct _GtkTreeViewColumnReorder
 {
@@ -309,76 +269,6 @@ struct _GtkTreeViewPrivate
   guint vscroll_policy : 1;
 };
 
-#ifdef __GNUC__
-
-#define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
-     if (!(expr))                                                       \
-       {                                                                \
-         g_log (G_LOG_DOMAIN,                                           \
-                G_LOG_LEVEL_CRITICAL,                                   \
-		"%s (%s): assertion `%s' failed.\n"                     \
-	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
-		"and the GtkTreeModel.  This generally means that the model has changed\n"\
-		"without letting the view know.  Any display from now on is likely to\n"  \
-		"be incorrect.\n",                                                        \
-                G_STRLOC,                                               \
-                G_STRFUNC,                                              \
-                #expr);                                                 \
-         return ret;                                                    \
-       };                               }G_STMT_END
-
-#define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
-     if (!(expr))                                                       \
-       {                                                                \
-         g_log (G_LOG_DOMAIN,                                           \
-                G_LOG_LEVEL_CRITICAL,                                   \
-		"%s (%s): assertion `%s' failed.\n"                     \
-	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
-		"and the GtkTreeModel.  This generally means that the model has changed\n"\
-		"without letting the view know.  Any display from now on is likely to\n"  \
-		"be incorrect.\n",                                                        \
-                G_STRLOC,                                               \
-                G_STRFUNC,                                              \
-                #expr);                                                 \
-         return;                                                        \
-       };                               }G_STMT_END
-
-#else
-
-#define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
-     if (!(expr))                                                       \
-       {                                                                \
-         g_log (G_LOG_DOMAIN,                                           \
-                G_LOG_LEVEL_CRITICAL,                                   \
-		"file %s: line %d: assertion `%s' failed.\n"       \
-	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
-		"and the GtkTreeModel.  This generally means that the model has changed\n"\
-		"without letting the view know.  Any display from now on is likely to\n"  \
-		"be incorrect.\n",                                                        \
-                __FILE__,                                               \
-                __LINE__,                                               \
-                #expr);                                                 \
-         return ret;                                                    \
-       };                               }G_STMT_END
-
-#define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
-     if (!(expr))                                                       \
-       {                                                                \
-         g_log (G_LOG_DOMAIN,                                           \
-                G_LOG_LEVEL_CRITICAL,                                   \
-		"file %s: line %d: assertion '%s' failed.\n"            \
-	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
-		"and the GtkTreeModel.  This generally means that the model has changed\n"\
-		"without letting the view know.  Any display from now on is likely to\n"  \
-		"be incorrect.\n",                                                        \
-                __FILE__,                                               \
-                __LINE__,                                               \
-                #expr);                                                 \
-         return;                                                        \
-       };                               }G_STMT_END
-#endif
-
-
 /* functions that shouldn't be exported */
 void         _gtk_tree_selection_internal_select_node (GtkTreeSelection  *selection,
 						       GtkRBNode         *node,
@@ -415,9 +305,9 @@ void         _gtk_tree_view_remove_editable           (GtkTreeView       *tree_v
                                                        GtkCellEditable   *cell_editable);
 
 void       _gtk_tree_view_install_mark_rows_col_dirty (GtkTreeView *tree_view);
-void             _gtk_tree_view_column_autosize          (GtkTreeView       *tree_view,
-							  GtkTreeViewColumn *column);
-
+void         _gtk_tree_view_column_autosize           (GtkTreeView       *tree_view,
+						       GtkTreeViewColumn *column);
+gint         _gtk_tree_view_get_header_height         (GtkTreeView       *tree_view);
 
 GtkTreeSelection* _gtk_tree_selection_new                (void);
 GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView      *tree_view);
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index a8b1790..22b7a5b 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -135,6 +135,115 @@
  */
 
 
+typedef enum
+{
+  GTK_TREE_VIEW_IS_LIST = 1 << 0,
+  GTK_TREE_VIEW_SHOW_EXPANDERS = 1 << 1,
+  GTK_TREE_VIEW_IN_COLUMN_RESIZE = 1 << 2,
+  GTK_TREE_VIEW_ARROW_PRELIT = 1 << 3,
+  GTK_TREE_VIEW_HEADERS_VISIBLE = 1 << 4,
+  GTK_TREE_VIEW_DRAW_KEYFOCUS = 1 << 5,
+  GTK_TREE_VIEW_MODEL_SETUP = 1 << 6,
+  GTK_TREE_VIEW_IN_COLUMN_DRAG = 1 << 7
+} GtkTreeViewFlags;
+
+enum
+{
+  DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
+  DRAG_COLUMN_WINDOW_STATE_ORIGINAL = 1,
+  DRAG_COLUMN_WINDOW_STATE_ARROW = 2,
+  DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT = 3,
+  DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT = 4
+};
+
+enum
+{
+  RUBBER_BAND_OFF = 0,
+  RUBBER_BAND_MAYBE_START = 1,
+  RUBBER_BAND_ACTIVE = 2
+};
+
+#define GTK_TREE_VIEW_SET_FLAG(tree_view, flag)   G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
+#define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
+#define GTK_TREE_VIEW_FLAG_SET(tree_view, flag)   ((tree_view->priv->flags&flag)==flag)
+#define TREE_VIEW_HEADER_HEIGHT(tree_view)        (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_HEADERS_VISIBLE)?tree_view->priv->header_height:0)
+#define TREE_VIEW_COLUMN_REQUESTED_WIDTH(column)  (CLAMP (column->requested_width, (column->min_width!=-1)?column->min_width:column->requested_width, (column->max_width!=-1)?column->max_width:column->requested_width))
+#define TREE_VIEW_DRAW_EXPANDERS(tree_view)       (!GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_IS_LIST)&&GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_SHOW_EXPANDERS))
+
+ /* This lovely little value is used to determine how far away from the title bar
+  * you can move the mouse and still have a column drag work.
+  */
+#define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
+
+#ifdef __GNUC__
+
+#define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
+     if (!(expr))                                                       \
+       {                                                                \
+         g_log (G_LOG_DOMAIN,                                           \
+                G_LOG_LEVEL_CRITICAL,                                   \
+		"%s (%s): assertion `%s' failed.\n"                     \
+	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
+		"and the GtkTreeModel.  This generally means that the model has changed\n"\
+		"without letting the view know.  Any display from now on is likely to\n"  \
+		"be incorrect.\n",                                                        \
+                G_STRLOC,                                               \
+                G_STRFUNC,                                              \
+                #expr);                                                 \
+         return ret;                                                    \
+       };                               }G_STMT_END
+
+#define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
+     if (!(expr))                                                       \
+       {                                                                \
+         g_log (G_LOG_DOMAIN,                                           \
+                G_LOG_LEVEL_CRITICAL,                                   \
+		"%s (%s): assertion `%s' failed.\n"                     \
+	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
+		"and the GtkTreeModel.  This generally means that the model has changed\n"\
+		"without letting the view know.  Any display from now on is likely to\n"  \
+		"be incorrect.\n",                                                        \
+                G_STRLOC,                                               \
+                G_STRFUNC,                                              \
+                #expr);                                                 \
+         return;                                                        \
+       };                               }G_STMT_END
+
+#else
+
+#define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
+     if (!(expr))                                                       \
+       {                                                                \
+         g_log (G_LOG_DOMAIN,                                           \
+                G_LOG_LEVEL_CRITICAL,                                   \
+		"file %s: line %d: assertion `%s' failed.\n"       \
+	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
+		"and the GtkTreeModel.  This generally means that the model has changed\n"\
+		"without letting the view know.  Any display from now on is likely to\n"  \
+		"be incorrect.\n",                                                        \
+                __FILE__,                                               \
+                __LINE__,                                               \
+                #expr);                                                 \
+         return ret;                                                    \
+       };                               }G_STMT_END
+
+#define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
+     if (!(expr))                                                       \
+       {                                                                \
+         g_log (G_LOG_DOMAIN,                                           \
+                G_LOG_LEVEL_CRITICAL,                                   \
+		"file %s: line %d: assertion '%s' failed.\n"            \
+	        "There is a disparity between the internal view of the GtkTreeView,\n"    \
+		"and the GtkTreeModel.  This generally means that the model has changed\n"\
+		"without letting the view know.  Any display from now on is likely to\n"  \
+		"be incorrect.\n",                                                        \
+                __FILE__,                                               \
+                __LINE__,                                               \
+                #expr);                                                 \
+         return;                                                        \
+       };                               }G_STMT_END
+#endif
+
 #define GTK_TREE_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
 #define GTK_TREE_VIEW_PRIORITY_SCROLL_SYNC (GTK_TREE_VIEW_PRIORITY_VALIDATE + 2)
 #define GTK_TREE_VIEW_TIME_MS_PER_IDLE 30
@@ -9614,6 +9723,13 @@ _gtk_tree_view_queue_draw_node (GtkTreeView        *tree_view,
     }
 }
 
+gint
+_gtk_tree_view_get_header_height (GtkTreeView *tree_view)
+{
+  return tree_view->priv->header_height;
+}
+
+
 static void
 gtk_tree_view_queue_draw_path (GtkTreeView        *tree_view,
                                GtkTreePath        *path,



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