Commit fa6e6928 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

centralize all the editing code

Tue Sep 18 18:46:54 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
	the editing code

	* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
	reason to call it beyond emiting the two signals.

	* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
	to GtkEntry.
parent a15d5c36
Tue Sep 18 18:46:54 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
the editing code
* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
reason to call it beyond emiting the two signals.
* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
to GtkEntry.
Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcellrenderertext.[ch] gtk/gtktexttag.[ch]
......@@ -25,6 +36,7 @@ Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtklabel.c: Use gtk_style_get_font() instead of
style->font.
>>>>>>> 1.2293
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
......
Tue Sep 18 18:46:54 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
the editing code
* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
reason to call it beyond emiting the two signals.
* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
to GtkEntry.
Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcellrenderertext.[ch] gtk/gtktexttag.[ch]
......@@ -25,6 +36,7 @@ Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtklabel.c: Use gtk_style_get_font() instead of
style->font.
>>>>>>> 1.2293
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
......
Tue Sep 18 18:46:54 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
the editing code
* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
reason to call it beyond emiting the two signals.
* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
to GtkEntry.
Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcellrenderertext.[ch] gtk/gtktexttag.[ch]
......@@ -25,6 +36,7 @@ Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtklabel.c: Use gtk_style_get_font() instead of
style->font.
>>>>>>> 1.2293
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
......
Tue Sep 18 18:46:54 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
the editing code
* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
reason to call it beyond emiting the two signals.
* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
to GtkEntry.
Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcellrenderertext.[ch] gtk/gtktexttag.[ch]
......@@ -25,6 +36,7 @@ Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtklabel.c: Use gtk_style_get_font() instead of
style->font.
>>>>>>> 1.2293
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
......
Tue Sep 18 18:46:54 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
the editing code
* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
reason to call it beyond emiting the two signals.
* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
to GtkEntry.
Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcellrenderertext.[ch] gtk/gtktexttag.[ch]
......@@ -25,6 +36,7 @@ Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtklabel.c: Use gtk_style_get_font() instead of
style->font.
>>>>>>> 1.2293
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
......
Tue Sep 18 18:46:54 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
the editing code
* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
reason to call it beyond emiting the two signals.
* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
to GtkEntry.
Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcellrenderertext.[ch] gtk/gtktexttag.[ch]
......@@ -25,6 +36,7 @@ Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtklabel.c: Use gtk_style_get_font() instead of
style->font.
>>>>>>> 1.2293
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
......
Tue Sep 18 18:46:54 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_start_editing): centralize all
the editing code
* gtk/gtkcelleditable.c: Got rid of stop_editing, as there was no
reason to call it beyond emiting the two signals.
* gtk/gtkentry.c (gtk_entry_class_init): add "has_frame" property
to GtkEntry.
Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcellrenderertext.[ch] gtk/gtktexttag.[ch]
......@@ -25,6 +36,7 @@ Wed Sep 12 11:21:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtklabel.c: Use gtk_style_get_font() instead of
style->font.
>>>>>>> 1.2293
Tue Sep 18 13:51:35 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.h (enum): Get rid of broken "can_edit" and
......
......@@ -78,21 +78,24 @@ void
gtk_cell_editable_start_editing (GtkCellEditable *cell_editable,
GdkEvent *event)
{
}
g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
g_return_if_fail (GTK_CELL_EDITABLE_GET_IFACE (cell_editable)->start_editing != NULL);
void
gtk_cell_editable_stop_editing (GtkCellEditable *cell_editable)
{
(* GTK_CELL_EDITABLE_GET_IFACE (cell_editable)->start_editing) (cell_editable, event);
}
void
gtk_cell_editable_editing_done (GtkCellEditable *cell_editable)
{
g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
g_signal_emit_by_name (cell_editable, "editing_done");
}
void
gtk_cell_editable_remove_widget (GtkCellEditable *cell_editable)
{
g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
g_signal_emit_by_name (cell_editable, "remove_widget");
}
......@@ -44,7 +44,6 @@ struct _GtkCellEditableIface
/* virtual table */
void (* start_editing) (GtkCellEditable *cell_editable,
GdkEvent *event);
void (* stop_editing) (GtkCellEditable *cell_editable);
};
......@@ -52,7 +51,6 @@ GType gtk_cell_editable_get_type (void) G_GNUC_CONST;
void gtk_cell_editable_start_editing (GtkCellEditable *cell_editable,
GdkEvent *event);
void gtk_cell_editable_stop_editing (GtkCellEditable *cell_editable);
void gtk_cell_editable_editing_done (GtkCellEditable *cell_editable);
void gtk_cell_editable_remove_widget (GtkCellEditable *cell_editable);
......
......@@ -443,7 +443,6 @@ gtk_cell_renderer_activate (GtkCellRenderer *cell,
flags);
}
/**
* gtk_cell_renderer_start_editing:
* @cell: a #GtkCellRenderer
......
......@@ -76,6 +76,7 @@ enum {
PROP_EDITABLE,
PROP_MAX_LENGTH,
PROP_VISIBILITY,
PROP_HAS_FRAME,
PROP_INVISIBLE_CHAR,
PROP_ACTIVATES_DEFAULT,
PROP_WIDTH_CHARS,
......@@ -414,7 +415,16 @@ gtk_entry_class_init (GtkEntryClass *class)
_("FALSE displays the \"invisible char\" instead of the actual text (password mode)"),
TRUE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class,
PROP_HAS_FRAME,
g_param_spec_boolean ("has_frame",
_("Has Frame"),
_("FALSE removes outside bevel from entry."),
TRUE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class,
PROP_INVISIBLE_CHAR,
g_param_spec_unichar ("invisible_char",
_("Invisible character"),
......@@ -787,6 +797,10 @@ gtk_entry_set_property (GObject *object,
gtk_entry_set_visibility (entry, g_value_get_boolean (value));
break;
case PROP_HAS_FRAME:
gtk_entry_set_has_frame (entry, g_value_get_boolean (value));
break;
case PROP_INVISIBLE_CHAR:
gtk_entry_set_invisible_char (entry, g_value_get_uint (value));
break;
......@@ -830,6 +844,9 @@ gtk_entry_get_property (GObject *object,
case PROP_VISIBILITY:
g_value_set_boolean (value, entry->visible);
break;
case PROP_HAS_FRAME:
g_value_set_boolean (value, entry->has_frame);
break;
case PROP_INVISIBLE_CHAR:
g_value_set_uint (value, entry->invisible_char);
break;
......@@ -3382,11 +3399,13 @@ gtk_entry_set_has_frame (GtkEntry *entry,
g_return_if_fail (GTK_IS_ENTRY (entry));
setting = (setting != FALSE);
if (entry->has_frame != setting)
gtk_widget_queue_resize (GTK_WIDGET (entry));
if (entry->has_frame == setting)
return;
gtk_widget_queue_resize (GTK_WIDGET (entry));
entry->has_frame = setting;
g_object_notify (G_OBJECT (entry), "has_frame");
}
/**
......
......@@ -105,6 +105,7 @@ struct _GtkTreeViewPrivate
gint drag_column_x;
GtkTreeViewColumn *expander_column;
GtkTreeViewColumn *edited_column;
/* Focus code */
GtkTreeViewColumn *focus_column;
......@@ -268,6 +269,12 @@ GtkTreePath *_gtk_tree_view_find_path (GtkTreeView *tree_v
GtkRBTree *tree,
GtkRBNode *node);
void _gtk_tree_view_update_size (GtkTreeView *tree_view);
void _gtk_tree_view_child_move_resize (GtkTreeView *tree_view,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
void _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column);
......@@ -286,6 +293,10 @@ gboolean _gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column,
GdkRectangle *background_area,
GdkRectangle *cell_area,
guint flags);
void _gtk_tree_view_column_start_editing (GtkTreeViewColumn *tree_column,
GtkCellEditable *editable_widget);
void _gtk_tree_view_column_stop_editing (GtkTreeViewColumn *tree_column);
GtkTreeSelection* _gtk_tree_selection_new (void);
GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view);
......
......@@ -215,12 +215,12 @@ gtk_tree_sortable_has_default_sort_func (GtkTreeSortable *sortable)
{
GtkTreeSortableIface *iface;
g_return_if_fail (GTK_IS_TREE_SORTABLE (sortable));
g_return_val_if_fail (GTK_IS_TREE_SORTABLE (sortable), FALSE);
iface = GTK_TREE_SORTABLE_GET_IFACE (sortable);
g_return_if_fail (iface != NULL);
g_return_if_fail (iface->has_default_sort_func != NULL);
g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (iface->has_default_sort_func != NULL, FALSE);
(* iface->has_default_sort_func) (sortable);
return (* iface->has_default_sort_func) (sortable);
}
......@@ -382,7 +382,14 @@ static void gtk_tree_view_put (GtkTreeView *tree_
gint y,
gint width,
gint height);
static void gtk_tree_view_start_editing (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
GtkCellEditable *cell_editable,
GdkRectangle *cell_area,
GdkEvent *event,
guint flags);
static void gtk_tree_view_stop_editing (GtkTreeView *tree_view);
static GtkContainerClass *parent_class = NULL;
static guint tree_view_signals[LAST_SIGNAL] = { 0 };
......@@ -1547,6 +1554,8 @@ gtk_tree_view_button_press (GtkWidget *widget,
{
GtkTreeIter iter;
GtkCellEditable *cell_editable = NULL;
/* FIXME: get the right flags */
guint flags = 0;
column = list->data;
......@@ -1589,15 +1598,17 @@ gtk_tree_view_button_press (GtkWidget *widget,
(GdkEvent *)event,
path_string,
&background_area,
&cell_area, 0))
&cell_area, flags))
{
if (cell_editable != NULL)
{
gtk_tree_view_put (tree_view,
GTK_WIDGET (cell_editable),
cell_area.x, cell_area.y, cell_area.width, cell_area.height);
gtk_cell_editable_start_editing (cell_editable,
(GdkEvent *)event);
gtk_tree_view_stop_editing (tree_view);
gtk_tree_view_start_editing (tree_view,
column,
cell_editable,
&cell_area,
(GdkEvent *)event,
flags);
}
g_free (path_string);
gtk_tree_path_free (path);
......@@ -4243,6 +4254,41 @@ gtk_tree_view_put (GtkTreeView *tree_view,
gtk_widget_set_parent (child_widget, GTK_WIDGET (tree_view));
}
void
_gtk_tree_view_child_move_resize (GtkTreeView *tree_view,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height)
{
GtkTreeViewChild *child = NULL;
GList *list;
GdkRectangle allocation;
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
g_return_if_fail (GTK_IS_WIDGET (widget));
for (list = tree_view->priv->children; list; list = list->next)
{
if (((GtkTreeViewChild *)list->data)->widget == widget)
{
child = list->data;
break;
}
}
if (child == NULL)
return;
allocation.x = child->x = x;
allocation.y = child->y = y;
allocation.width = child->width = width;
allocation.height = child->height = height;
if (GTK_WIDGET_REALIZED (widget))
gtk_widget_size_allocate (widget, &allocation);
}
/* TreeModel Callbacks
*/
......@@ -9102,3 +9148,42 @@ gtk_tree_view_search_init (GtkWidget *entry,
}
}
static void
gtk_tree_view_remove_widget (GtkCellEditable *cell_editable,
GtkTreeView *tree_view)
{
g_return_if_fail (tree_view->priv->edited_column != NULL);
_gtk_tree_view_column_stop_editing (tree_view->priv->edited_column);
gtk_container_remove (GTK_CONTAINER (tree_view),
GTK_WIDGET (cell_editable));
}
static void
gtk_tree_view_start_editing (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
GtkCellEditable *cell_editable,
GdkRectangle *cell_area,
GdkEvent *event,
guint flags)
{
tree_view->priv->edited_column = column;
_gtk_tree_view_column_start_editing (column, GTK_CELL_EDITABLE (cell_editable));
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
gtk_tree_view_put (tree_view,
GTK_WIDGET (cell_editable),
cell_area->x, cell_area->y, cell_area->width, cell_area->height);
gtk_cell_editable_start_editing (GTK_CELL_EDITABLE (cell_editable),
(GdkEvent *)event);
gtk_widget_grab_focus (GTK_WIDGET (cell_editable));
g_signal_connect (cell_editable, "remove_widget", G_CALLBACK (gtk_tree_view_remove_widget), tree_view);
}
static void
gtk_tree_view_stop_editing (GtkTreeView *tree_view)
{
if (tree_view->priv->edited_column == NULL)
return;
gtk_cell_editable_editing_done (tree_view->priv->edited_column->editable_widget);
gtk_cell_editable_remove_widget (tree_view->priv->edited_column->editable_widget);
}
......@@ -2339,3 +2339,19 @@ gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column)
gtk_widget_queue_resize (tree_column->tree_view);
}
void
_gtk_tree_view_column_start_editing (GtkTreeViewColumn *tree_column,
GtkCellEditable *cell_editable)
{
g_return_if_fail (tree_column->editable_widget == NULL);
tree_column->editable_widget = cell_editable;
}
void
_gtk_tree_view_column_stop_editing (GtkTreeViewColumn *tree_column)
{
g_return_if_fail (tree_column->editable_widget != NULL);
tree_column->editable_widget = NULL;
}
......@@ -64,6 +64,7 @@ struct _GtkTreeViewColumn
GtkWidget *arrow;
GtkWidget *alignment;
GdkWindow *window;
GtkCellEditable *editable_widget;
gfloat xalign;
guint property_changed_signal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment