]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcellrenderer.c
Remove trailing commas
[~andy/gtk] / gtk / gtkcellrenderer.c
index b9a11813d0e455704c0dac01c38dc2acb5949b61..28d200fd8e191c7fd9ae8e023807cda43df45687 100644 (file)
  */
 
 #include <config.h>
-#include "gtkalias.h"
 #include "gtkcellrenderer.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
+#include "gtkprivate.h"
 #include "gtktreeprivate.h"
+#include "gtkalias.h"
 
-static void gtk_cell_renderer_init       (GtkCellRenderer      *cell);
-static void gtk_cell_renderer_class_init (GtkCellRendererClass *class);
 static void gtk_cell_renderer_get_property  (GObject              *object,
                                             guint                 param_id,
                                             GValue               *value,
@@ -74,34 +73,7 @@ enum {
 
 static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
 
-
-GType
-gtk_cell_renderer_get_type (void)
-{
-  static GType cell_type = 0;
-
-  if (!cell_type)
-    {
-      static const GTypeInfo cell_info =
-      {
-        sizeof (GtkCellRendererClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-        (GClassInitFunc) gtk_cell_renderer_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-        sizeof (GtkCellRenderer),
-       0,              /* n_preallocs */
-        (GInstanceInitFunc) gtk_cell_renderer_init,
-       NULL,           /* value_table */
-      };
-
-      cell_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkCellRenderer", 
-                                         &cell_info, G_TYPE_FLAG_ABSTRACT);
-    }
-
-  return cell_type;
-}
+G_DEFINE_ABSTRACT_TYPE (GtkCellRenderer, gtk_cell_renderer, GTK_TYPE_OBJECT)
 
 static void
 gtk_cell_renderer_init (GtkCellRenderer *cell)
@@ -139,12 +111,12 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
    * cell.  For example, an editable cell renderer could be written to cancel
    * editing when the user presses Escape. 
    *
-   * See also: gtk_cell_renderer_editing_canceled()
+   * See also: gtk_cell_renderer_stop_editing().
    *
    * Since: 2.4
    */
   cell_renderer_signals[EDITING_CANCELED] =
-    g_signal_new ("editing-canceled",
+    g_signal_new (I_("editing-canceled"),
                  G_OBJECT_CLASS_TYPE (object_class),
                  G_SIGNAL_RUN_FIRST,
                  G_STRUCT_OFFSET (GtkCellRendererClass, editing_canceled),
@@ -189,7 +161,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
    * Since: 2.6
    */
   cell_renderer_signals[EDITING_STARTED] =
-    g_signal_new ("editing-started",
+    g_signal_new (I_("editing-started"),
                  G_OBJECT_CLASS_TYPE (object_class),
                  G_SIGNAL_RUN_FIRST,
                  G_STRUCT_OFFSET (GtkCellRendererClass, editing_started),
@@ -206,8 +178,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                      P_("Editable mode of the CellRenderer"),
                                                      GTK_TYPE_CELL_RENDERER_MODE,
                                                      GTK_CELL_RENDERER_MODE_INERT,
-                                                     G_PARAM_READABLE |
-                                                     G_PARAM_WRITABLE));
+                                                     GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_VISIBLE,
@@ -215,14 +186,14 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                         P_("visible"),
                                                         P_("Display the cell"),
                                                         TRUE,
-                                                        G_PARAM_READWRITE));
+                                                        GTK_PARAM_READWRITE));
   g_object_class_install_property (object_class,
                                   PROP_SENSITIVE,
                                   g_param_spec_boolean ("sensitive",
                                                         P_("Sensitive"),
                                                         P_("Display the cell sensitive"),
                                                         TRUE,
-                                                        G_PARAM_READWRITE));
+                                                        GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_XALIGN,
@@ -232,8 +203,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                       0.0,
                                                       1.0,
                                                       0.5,
-                                                      G_PARAM_READABLE |
-                                                      G_PARAM_WRITABLE));
+                                                      GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_YALIGN,
@@ -243,8 +213,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                       0.0,
                                                       1.0,
                                                       0.5,
-                                                      G_PARAM_READABLE |
-                                                      G_PARAM_WRITABLE));
+                                                      GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_XPAD,
@@ -254,8 +223,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                      0,
                                                      G_MAXUINT,
                                                      0,
-                                                     G_PARAM_READABLE |
-                                                     G_PARAM_WRITABLE));
+                                                     GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_YPAD,
@@ -265,8 +233,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                      0,
                                                      G_MAXUINT,
                                                      0,
-                                                     G_PARAM_READABLE |
-                                                     G_PARAM_WRITABLE));
+                                                     GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_WIDTH,
@@ -276,8 +243,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
-                                                    G_PARAM_READABLE |
-                                                    G_PARAM_WRITABLE));
+                                                    GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_HEIGHT,
@@ -287,8 +253,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
-                                                    G_PARAM_READABLE |
-                                                    G_PARAM_WRITABLE));
+                                                    GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_IS_EXPANDER,
@@ -296,8 +261,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                         P_("Is Expander"),
                                                         P_("Row has children"),
                                                         FALSE,
-                                                        G_PARAM_READABLE |
-                                                        G_PARAM_WRITABLE));
+                                                        GTK_PARAM_READWRITE));
 
 
   g_object_class_install_property (object_class,
@@ -306,8 +270,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                         P_("Is Expanded"),
                                                         P_("Row is an expander row, and is expanded"),
                                                         FALSE,
-                                                        G_PARAM_READABLE |
-                                                        G_PARAM_WRITABLE));
+                                                        GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                   PROP_CELL_BACKGROUND,
@@ -315,7 +278,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                        P_("Cell background color name"),
                                                        P_("Cell background color as a string"),
                                                        NULL,
-                                                       G_PARAM_WRITABLE));
+                                                       GTK_PARAM_WRITABLE));
 
   g_object_class_install_property (object_class,
                                   PROP_CELL_BACKGROUND_GDK,
@@ -323,10 +286,10 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
                                                       P_("Cell background color"),
                                                       P_("Cell background color as a GdkColor"),
                                                       GDK_TYPE_COLOR,
-                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));
+                                                      GTK_PARAM_READWRITE));
 
 
-#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))
+#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE))
 
   ADD_SET_PROP ("cell-background-set", PROP_CELL_BACKGROUND_SET,
                 P_("Cell background set"),
@@ -455,7 +418,7 @@ gtk_cell_renderer_set_property (GObject      *object,
        else
          g_warning ("Don't know color `%s'", g_value_get_string (value));
 
-       g_object_notify (object, "cell_background_gdk");
+       g_object_notify (object, "cell-background-gdk");
       }
       break;
     case PROP_CELL_BACKGROUND_GDK:
@@ -481,7 +444,7 @@ set_cell_bg_color (GtkCellRenderer *cell,
       if (!cell->cell_background_set)
         {
          cell->cell_background_set = TRUE;
-         g_object_notify (G_OBJECT (cell), "cell_background_set");
+         g_object_notify (G_OBJECT (cell), "cell-background-set");
        }
 
       priv->cell_background.red = color->red;
@@ -493,7 +456,7 @@ set_cell_bg_color (GtkCellRenderer *cell,
       if (cell->cell_background_set)
         {
          cell->cell_background_set = FALSE;
-         g_object_notify (G_OBJECT (cell), "cell_background_set");
+         g_object_notify (G_OBJECT (cell), "cell-background-set");
        }
     }
 }
@@ -508,12 +471,13 @@ set_cell_bg_color (GtkCellRenderer *cell,
  * @width: location to return width needed to render a cell, or %NULL
  * @height: location to return height needed to render a cell, or %NULL
  *
- * Obtains the width and height needed to render the cell. Used by view widgets
- * to determine the appropriate size for the cell_area passed to
- * gtk_cell_renderer_render().  If @cell_area is not %NULL, fills in the x and y
- * offsets (if set) of the cell relative to this location.  Please note that the
- * values set in @width and @height, as well as those in @x_offset and @y_offset
- * are inclusive of the xpad and ypad properties.
+ * Obtains the width and height needed to render the cell. Used by view 
+ * widgets to determine the appropriate size for the cell_area passed to
+ * gtk_cell_renderer_render().  If @cell_area is not %NULL, fills in the
+ * x and y offsets (if set) of the cell relative to this location. 
+ *
+ * Please note that the values set in @width and @height, as well as those 
+ * in @x_offset and @y_offset are inclusive of the xpad and ypad properties.
  **/
 void
 gtk_cell_renderer_get_size (GtkCellRenderer *cell,
@@ -555,7 +519,8 @@ gtk_cell_renderer_get_size (GtkCellRenderer *cell,
  * @cell: a #GtkCellRenderer
  * @window: a #GdkDrawable to draw to
  * @widget: the widget owning @window
- * @background_area: entire cell area (including tree expanders and maybe padding on the sides)
+ * @background_area: entire cell area (including tree expanders and maybe 
+ *    padding on the sides)
  * @cell_area: area normally rendered by a cell renderer
  * @expose_area: area that actually needs updating
  * @flags: flags that affect rendering
@@ -567,7 +532,6 @@ gtk_cell_renderer_get_size (GtkCellRenderer *cell,
  * blank space around the cell, and also the area containing the tree expander;
  * so the @background_area rectangles for all cells tile to cover the entire
  * @window.  @expose_area is a clip rectangle.
- *
  **/
 void
 gtk_cell_renderer_render (GtkCellRenderer     *cell,
@@ -588,19 +552,13 @@ gtk_cell_renderer_render (GtkCellRenderer     *cell,
 
   if (cell->cell_background_set && !selected)
     {
-      GdkColor color;
-      GdkGC *gc;
-
-      color.red = priv->cell_background.red;
-      color.green = priv->cell_background.green;
-      color.blue = priv->cell_background.blue;
-
-      gc = gdk_gc_new (window);
-      gdk_gc_set_rgb_fg_color (gc, &color);
-      gdk_draw_rectangle (window, gc, TRUE,
-                          background_area->x, background_area->y,
-                          background_area->width, background_area->height);
-      g_object_unref (gc);
+      cairo_t *cr = gdk_cairo_create (window);
+
+      gdk_cairo_rectangle (cr, background_area);
+      gdk_cairo_set_source_color (cr, &priv->cell_background);
+      cairo_fill (cr);
+      
+      cairo_destroy (cr);
     }
 
   GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell,
@@ -617,14 +575,15 @@ gtk_cell_renderer_render (GtkCellRenderer     *cell,
  * @cell: a #GtkCellRenderer
  * @event: a #GdkEvent
  * @widget: widget that received the event
- * @path: widget-dependent string representation of the event location; e.g. for #GtkTreeView, a string representation of #GtkTreePath
- * @background_area: background area as passed to @gtk_cell_renderer_render
- * @cell_area: cell area as passed to @gtk_cell_renderer_render
+ * @path: widget-dependent string representation of the event location; 
+ *    e.g. for #GtkTreeView, a string representation of #GtkTreePath
+ * @background_area: background area as passed to gtk_cell_renderer_render()
+ * @cell_area: cell area as passed to gtk_cell_renderer_render()
  * @flags: render flags
  *
- * Passes an activate event to the cell renderer for possible processing.  Some
- * cell renderers may use events; for example, #GtkCellRendererToggle toggles
- * when it gets a mouse click.
+ * Passes an activate event to the cell renderer for possible processing.  
+ * Some cell renderers may use events; for example, #GtkCellRendererToggle 
+ * toggles when it gets a mouse click.
  *
  * Return value: %TRUE if the event was consumed/handled
  **/
@@ -659,9 +618,10 @@ gtk_cell_renderer_activate (GtkCellRenderer      *cell,
  * @cell: a #GtkCellRenderer
  * @event: a #GdkEvent
  * @widget: widget that received the event
- * @path: widget-dependent string representation of the event location; e.g. for #GtkTreeView, a string representation of #GtkTreePath
- * @background_area: background area as passed to @gtk_cell_renderer_render
- * @cell_area: cell area as passed to @gtk_cell_renderer_render
+ * @path: widget-dependent string representation of the event location; 
+ *    e.g. for #GtkTreeView, a string representation of #GtkTreePath
+ * @background_area: background area as passed to gtk_cell_renderer_render()
+ * @cell_area: cell area as passed to gtk_cell_renderer_render()
  * @flags: render flags
  * 
  * Passes an activate event to the cell renderer for possible processing.
@@ -766,13 +726,15 @@ gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
  * gtk_cell_renderer_editing_canceled:
  * @cell: A #GtkCellRenderer
  * 
- * Causes the cell renderer to emit the "editing-canceled" signal.  This
- * function is for use only by implementations of cell renderers that need to
- * notify the client program that an editing process was canceled and the
- * changes were not committed.
+ * Causes the cell renderer to emit the #GtkCellRenderer::editing-canceled 
+ * signal.  
+ *
+ * This function is for use only by implementations of cell renderers that 
+ * need to notify the client program that an editing process was canceled 
+ * and the changes were not committed.
  *
  * Since: 2.4
- * Deprecated: Use gtk_cell_renderer_stop_editing() instead
+ * Deprecated: 2.6: Use gtk_cell_renderer_stop_editing() instead
  **/
 void
 gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell)
@@ -788,9 +750,12 @@ gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell)
  * @canceled: %TRUE if the editing has been canceled
  * 
  * Informs the cell renderer that the editing is stopped.
- * If @canceled is %TRUE, the cell renderer will emit the "editing-canceled" 
- * signal. This function should be called by cell renderer implementations 
- * in response to the "editing-done" signal of #GtkCellEditable.
+ * If @canceled is %TRUE, the cell renderer will emit the 
+ * #GtkCellRenderer::editing-canceled signal. 
+ *
+ * This function should be called by cell renderer implementations 
+ * in response to the #GtkCellEditable::editing-done signal of 
+ * #GtkCellEditable.
  *
  * Since: 2.6
  **/
@@ -808,3 +773,5 @@ gtk_cell_renderer_stop_editing (GtkCellRenderer *cell,
     }
 }
 
+#define __GTK_CELL_RENDERER_C__
+#include "gtkaliasdef.c"