remove all gtk3 conditionals
[claws.git] / src / gtk / gtkcmctree.c
index 5e81c98eac3f4adf8f5980f5defe1fb036a58459..a31ed1b039ee9f5b6128200f2d9717831f14b910 100644 (file)
@@ -65,11 +65,7 @@ gtk_cmctree_pos_get_type (void)
       { GTK_CMCTREE_POS_AFTER, "GTK_CMCTREE_POS_AFTER", "after" },
       { 0, NULL, NULL }
     };
-#if GLIB_CHECK_VERSION(2,10,0)
     etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreePos"), values);
-#else
-    etype = g_enum_register_static ("GtkCMCTreePos", values);
-#endif
   }
   return etype;
 }
@@ -82,11 +78,7 @@ gtk_cmctree_line_style_get_type (void)
       { GTK_CMCTREE_LINES_NONE, "GTK_CMCTREE_LINES_NONE", "none" },
       { 0, NULL, NULL }
     };
-#if GLIB_CHECK_VERSION(2,10,0)
     etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeLineStyle"), values);
-#else
-    etype = g_enum_register_static ("GtkCMCTreeLineStyle", values);
-#endif
   }
   return etype;
 }
@@ -100,11 +92,7 @@ gtk_cmctree_expander_style_get_type (void)
       { GTK_CMCTREE_EXPANDER_TRIANGLE, "GTK_CMCTREE_EXPANDER_TRIANGLE", "triangle" },
       { 0, NULL, NULL }
     };
-#if GLIB_CHECK_VERSION(2,10,0)
     etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeExpanderStyle"), values);
-#else
-    etype = g_enum_register_static ("GtkCMCTreeExpanderStyle", values);
-#endif
   }
   return etype;
 }
@@ -122,11 +110,7 @@ gtk_cmctree_expansion_type_get_type (void)
       { GTK_CMCTREE_EXPANSION_TOGGLE_RECURSIVE, "GTK_CMCTREE_EXPANSION_TOGGLE_RECURSIVE", "toggle-recursive" },
       { 0, NULL, NULL }
     };
-#if GLIB_CHECK_VERSION(2,10,0)
-    etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeExpansionType"), values);
-#else
-    etype = g_enum_register_static ("GtkCMCTreeExpansionType", values);
-#endif
+   etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeExpansionType"), values);
   }
   return etype;
 }
@@ -377,6 +361,8 @@ gtk_cmctree_get_type (void)
                        sizeof (GtkCMCTree),
                        0,      /* n_preallocs */
                        (GInstanceInitFunc) gtk_cmctree_init,
+
+                       (const GTypeValueTable *) NULL  /* value table */
       };
 
        ctree_type = g_type_register_static (GTK_TYPE_CMCLIST, "GtkCMCTree", &ctree_info, (GTypeFlags)0);
@@ -461,7 +447,7 @@ draw_expander (GtkCMCTree     *ctree,
   /* pixel offsets +/- 1 or +/- justification_factor here and there ..
    * to fill correctly, somewhat ... what do I do wrong?
    */
-  gdk_cairo_set_source_color(cr, &gtk_widget_get_style(GTK_WIDGET(ctree))->fg[GTK_STATE_NORMAL]);
+  gdk_cairo_set_source_color(cr, &gtk_widget_get_style(GTK_WIDGET(ctree))->text[GTK_STATE_NORMAL]);
   if (ctree_row->expanded)
   {
     gint tmp3 = PM_SIZE / 2;
@@ -617,6 +603,12 @@ draw_row (GtkCMCList     *clist,
 
   cm_return_if_fail (clist != NULL);
   widget = GTK_WIDGET (clist);
+
+  /* if the function is passed the pointer to the row instead of null,
+   * it avoids this expensive lookup */
+  if (!clist_row)
+    clist_row = (g_list_nth (clist->row_list, row))->data;
+
   style = clist_row->style ? clist_row->style : gtk_widget_get_style (widget);
 
   if (greybg.pixel == 0 &&
@@ -648,11 +640,6 @@ draw_row (GtkCMCList     *clist,
 
   ctree  = GTK_CMCTREE  (clist);
 
-  /* if the function is passed the pointer to the row instead of null,
-   * it avoids this expensive lookup */
-  if (!clist_row)
-    clist_row = (g_list_nth (clist->row_list, row))->data;
-
   /* rectangle of the entire row */
   row_rectangle.x = 0;
   row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
@@ -685,7 +672,7 @@ draw_row (GtkCMCList     *clist,
   if (clist_row->fg_set && state != GTK_STATE_SELECTED)
        fgcolor = &clist_row->foreground;
   else
-       fgcolor = &style->fg[clist_row->state];
+       fgcolor = &style->text[clist_row->state];
   /* draw the cell borders */
   if (area)
     {
@@ -942,7 +929,7 @@ draw_row (GtkCMCList     *clist,
        {
            cairo_set_line_width(cr, 1.0);
            cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
-           gdk_cairo_set_source_color(cr, &style->fg[GTK_STATE_NORMAL]);
+           gdk_cairo_set_source_color(cr, &style->text[GTK_STATE_NORMAL]);
            cairo_move_to (cr, row_rectangle.x, row_rectangle.y + 0.5);
            cairo_line_to (cr, row_rectangle.x + row_rectangle.width, row_rectangle.y + 0.5);
            cairo_move_to (cr, row_rectangle.x, row_rectangle.y + row_rectangle.height - 0.5);
@@ -1202,29 +1189,11 @@ gtk_cmctree_set_arg (GObject *object,
   switch (arg_id)
     {
     case ARG_N_COLUMNS: /* construct-only arg, only set at construction time */
-#if !GLIB_CHECK_VERSION(2,10,0)
-      cm_return_if_fail (clist->row_mem_chunk == NULL);
-#endif
       clist->columns = MAX (1, g_value_get_uint (value));
-#if !GLIB_CHECK_VERSION(2,10,0)
-      clist->row_mem_chunk = g_mem_chunk_new ("ctree row mem chunk",
-                                             sizeof (GtkCMCTreeRow),
-                                             sizeof (GtkCMCTreeRow)
-                                             * CLIST_OPTIMUM_SIZE,
-                                             G_ALLOC_AND_FREE);
-      clist->cell_mem_chunk = g_mem_chunk_new ("ctree cell mem chunk",
-                                              sizeof (GtkCMCell) * clist->columns,
-                                              sizeof (GtkCMCell) * clist->columns
-                                              * CLIST_OPTIMUM_SIZE,
-                                              G_ALLOC_AND_FREE);
-#endif
       ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
       break;
     case ARG_TREE_COLUMN: /* construct-only arg, only set at construction time */
       ctree->tree_column = g_value_get_uint (value);
-#if !GLIB_CHECK_VERSION(2,10,0)
-      if (clist->row_mem_chunk)
-#endif
         ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
       break;
     case ARG_INDENT:
@@ -1579,7 +1548,7 @@ gtk_cmctree_link (GtkCMCTree     *ctree,
          
          list_end->next = work->next;
          if (work->next)
-           list = work->next->prev = list_end;
+           work->next->prev = list_end;
          work->next = (GList *)node;
          list = (GList *)node;
          list->prev = work;
@@ -2562,13 +2531,8 @@ row_new (GtkCMCTree *ctree)
   int i;
 
   clist = GTK_CMCLIST (ctree);
-#if GLIB_CHECK_VERSION(2,10,0)
   ctree_row = g_slice_new (GtkCMCTreeRow);
   ctree_row->row.cell = g_slice_alloc (sizeof (GtkCMCell) * clist->columns);
-#else
-  ctree_row = g_chunk_new (GtkCMCTreeRow, (GMemChunk *)clist->row_mem_chunk);
-  ctree_row->row.cell = g_chunk_new (GtkCMCell, (GMemChunk *)clist->cell_mem_chunk);
-#endif
 
   for (i = 0; i < clist->columns; i++)
     {
@@ -2647,13 +2611,8 @@ row_delete (GtkCMCTree    *ctree,
       dnotify (ddata);
     }
 
-#if GLIB_CHECK_VERSION(2,10,0)  
   g_slice_free1 (sizeof (GtkCMCell) * clist->columns, ctree_row->row.cell);
   g_slice_free (GtkCMCTreeRow, ctree_row);
-#else
-  g_mem_chunk_free ((GMemChunk *)clist->cell_mem_chunk, ctree_row->row.cell);
-  g_mem_chunk_free ((GMemChunk *)clist->row_mem_chunk, ctree_row);
-#endif
 }
 
 static void
@@ -2910,7 +2869,8 @@ ctree_is_hot_spot (GtkCMCTree     *ctree,
   GtkCMCList *clist;
   gint xl;
   gint yu;
-  
+  gint hotspot_size;
+
   cm_return_val_if_fail (GTK_IS_CMCTREE (ctree), FALSE);
   cm_return_val_if_fail (node != NULL, FALSE);
 
@@ -2922,18 +2882,22 @@ ctree_is_hot_spot (GtkCMCTree     *ctree,
 
   tree_row = GTK_CMCTREE_ROW (node);
 
-  yu = (ROW_TOP_YPIXEL (clist, row) + (clist->row_height - PM_SIZE) / 2 -
+  hotspot_size = clist->row_height-2;
+  if (hotspot_size > clist->column[ctree->tree_column].area.width - 2)
+       hotspot_size = clist->column[ctree->tree_column].area.width - 2;
+
+  yu = (ROW_TOP_YPIXEL (clist, row) + (clist->row_height - hotspot_size) / 2 -
        (clist->row_height - 1) % 2);
 
   if (clist->column[ctree->tree_column].justification == GTK_JUSTIFY_RIGHT)
     xl = (clist->column[ctree->tree_column].area.x + 
          clist->column[ctree->tree_column].area.width - 1 + clist->hoffset -
-         (tree_row->level - 1) * ctree->tree_indent - PM_SIZE);
+         (tree_row->level - 1) * ctree->tree_indent - hotspot_size);
   else
     xl = (clist->column[ctree->tree_column].area.x + clist->hoffset +
          (tree_row->level - 1) * ctree->tree_indent);
 
-  return (x >= xl && x <= xl + PM_SIZE && y >= yu && y <= yu + PM_SIZE);
+  return (x >= xl && x <= xl + hotspot_size && y >= yu && y <= yu + hotspot_size);
 }
 
 /***********************************************************