diff options
author | Jonathan Blandford <jrb@redhat.com> | 2001-09-18 17:52:42 +0000 |
---|---|---|
committer | Jonathan Blandford <jrb@src.gnome.org> | 2001-09-18 17:52:42 +0000 |
commit | c45ee0bf85dd61abb6a8469265274c2265772af9 (patch) | |
tree | b04d5845f8536c5c4cf1969dd7abb6c5f2c5d666 /gtk | |
parent | f724f836ec03c39c00abc983011e393b56b2c2d1 (diff) | |
download | gtk+-c45ee0bf85dd61abb6a8469265274c2265772af9.tar.gz |
Get rid of broken "can_edit" and "can_activate" properties in favor of
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
"can_activate" properties in favor of
GTK_CELL_RENDERER_MODE_INERT, GTK_CELL_RENDERER_MODE_ACTIVATABLE,
and GTK_CELL_RENDERER_MODE_EDITABLE
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcellrenderer.c | 63 | ||||
-rw-r--r-- | gtk/gtkcellrenderer.h | 10 | ||||
-rw-r--r-- | gtk/gtkcellrenderertoggle.c | 4 | ||||
-rw-r--r-- | gtk/gtktreeviewcolumn.c | 9 |
4 files changed, 31 insertions, 55 deletions
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index 08cc3fbb11..f468247a6b 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -34,8 +34,7 @@ static void gtk_cell_renderer_set_property (GObject *object, enum { PROP_ZERO, - PROP_CAN_ACTIVATE, - PROP_CAN_EDIT, + PROP_MODE, PROP_VISIBLE, PROP_XALIGN, PROP_YALIGN, @@ -77,8 +76,7 @@ gtk_cell_renderer_get_type (void) static void gtk_cell_renderer_init (GtkCellRenderer *cell) { - cell->can_activate = FALSE; - cell->can_edit = FALSE; + cell->mode = GTK_CELL_RENDERER_MODE_INERT; cell->visible = TRUE; cell->width = -1; cell->height = -1; @@ -100,24 +98,16 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class) class->get_size = NULL; g_object_class_install_property (object_class, - PROP_CAN_ACTIVATE, - g_param_spec_boolean ("can_activate", - _("can_activate"), - _("Cell can get activate events."), - FALSE, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); + PROP_MODE, + g_param_spec_enum ("mode", + _("mode"), + _("Editable mode of the CellRenderer"), + GTK_TYPE_CELL_RENDERER_MODE, + GTK_CELL_RENDERER_MODE_INERT, + G_PARAM_READABLE | + G_PARAM_WRITABLE)); g_object_class_install_property (object_class, - PROP_CAN_EDIT, - g_param_spec_boolean ("can_edit", - _("can_edit"), - _("Cell supports CellEditable interface."), - FALSE, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, PROP_VISIBLE, g_param_spec_boolean ("visible", _("visible"), @@ -222,11 +212,8 @@ gtk_cell_renderer_get_property (GObject *object, switch (param_id) { - case PROP_CAN_ACTIVATE: - g_value_set_boolean (value, cell->can_activate); - break; - case PROP_CAN_EDIT: - g_value_set_boolean (value, cell->can_edit); + case PROP_MODE: + g_value_set_enum (value, cell->mode); break; case PROP_VISIBLE: g_value_set_boolean (value, cell->visible); @@ -272,25 +259,9 @@ gtk_cell_renderer_set_property (GObject *object, switch (param_id) { - case PROP_CAN_ACTIVATE: - cell->can_activate = g_value_get_boolean (value); - g_object_notify (object, "can_activate"); - /* can_activate and can_edit are mutually exclusive */ - if (cell->can_activate && cell->can_edit) - { - cell->can_edit = FALSE; - g_object_notify (object, "can_edit"); - } - break; - case PROP_CAN_EDIT: - cell->can_edit = g_value_get_boolean (value); - g_object_notify (object, "can_edit"); - /* can_activate and can_edit are mutually exclusive */ - if (cell->can_activate && cell->can_edit) - { - cell->can_activate = FALSE; - g_object_notify (object, "can_activate"); - } + case PROP_MODE: + cell->mode = g_value_get_enum (value); + g_object_notify (object, "mode"); break; case PROP_VISIBLE: cell->visible = g_value_get_boolean (value); @@ -457,7 +428,7 @@ gtk_cell_renderer_activate (GtkCellRenderer *cell, { g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE); - if (! cell->can_activate) + if (cell->mode != GTK_CELL_RENDERER_MODE_ACTIVATABLE) return FALSE; if (GTK_CELL_RENDERER_GET_CLASS (cell)->activate == NULL) @@ -499,7 +470,7 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell, { g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), NULL); - if (! cell->can_edit) + if (cell->mode != GTK_CELL_RENDERER_MODE_EDITABLE) return NULL; if (GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing == NULL) diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h index 0a1624a51b..2468d735af 100644 --- a/gtk/gtkcellrenderer.h +++ b/gtk/gtkcellrenderer.h @@ -35,6 +35,13 @@ typedef enum GTK_CELL_RENDERER_SORTED = 1 << 3 } GtkCellRendererState; +typedef enum +{ + GTK_CELL_RENDERER_MODE_INERT, + GTK_CELL_RENDERER_MODE_ACTIVATABLE, + GTK_CELL_RENDERER_MODE_EDITABLE, +} GtkCellRendererMode; + #define GTK_TYPE_CELL_RENDERER (gtk_cell_renderer_get_type ()) #define GTK_CELL_RENDERER(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRenderer)) #define GTK_CELL_RENDERER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER, GtkCellRendererClass)) @@ -58,8 +65,7 @@ struct _GtkCellRenderer guint16 xpad; guint16 ypad; - guint can_activate : 1; - guint can_edit : 1; + guint mode : 2; guint visible : 1; guint is_expander : 1; guint is_expanded : 1; diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c index 6f33ff9087..fac7dd7bd9 100644 --- a/gtk/gtkcellrenderertoggle.c +++ b/gtk/gtkcellrenderertoggle.c @@ -103,7 +103,7 @@ gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltoggle) { celltoggle->active = FALSE; celltoggle->radio = FALSE; - GTK_CELL_RENDERER (celltoggle)->can_activate = TRUE; + GTK_CELL_RENDERER (celltoggle)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; GTK_CELL_RENDERER (celltoggle)->xpad = 2; GTK_CELL_RENDERER (celltoggle)->ypad = 2; } @@ -289,7 +289,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell, state = GTK_STATE_ACTIVE; } } - else if (! cell->can_activate) + else if (cell->mode == GTK_CELL_RENDERER_MODE_INERT) { state = GTK_STATE_INSENSITIVE; } diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 5be1875472..5226658f20 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -2238,16 +2238,15 @@ _gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column, GdkRectangle *cell_area, guint flags) { - gboolean visible, can_activate, can_edit; + gboolean visible, mode; g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), FALSE); g_object_get (G_OBJECT (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell), "visible", &visible, - "can_activate", &can_activate, - "can_edit", &can_edit, + "mode", &mode, NULL); - if (visible && can_activate) + if (visible && mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE) { if (gtk_cell_renderer_activate (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell, event, @@ -2258,7 +2257,7 @@ _gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column, flags)) return TRUE; } - else if (visible && can_edit) + else if (visible && mode == GTK_CELL_RENDERER_MODE_EDITABLE) { *editable_widget = gtk_cell_renderer_start_editing (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell, event, |