forked from AuroraMiddleware/gtk
Added "edit_only" argument to gtk_cell_area_activate()
This argument allows the caller to specify that only an editable cell should start editing but an activatable cell should not toggle it's state, this is important for public apis like gtk_tree_view_set_cursor_on_cell() which are only intended to programatically bring attention to the editing of a specific row or cell but not actually change any data. GtkTreeView & CellAreaScaffold updated for the last minute api change.
This commit is contained in:
parent
46c49ee260
commit
2f4e451075
@ -401,7 +401,8 @@ static gboolean gtk_cell_area_real_activate (GtkCellArea
|
||||
GtkCellAreaContext *context,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
GtkCellRendererState flags,
|
||||
gboolean edit_only);
|
||||
|
||||
/* GtkCellLayoutIface */
|
||||
static void gtk_cell_area_cell_layout_init (GtkCellLayoutIface *iface);
|
||||
@ -1254,14 +1255,23 @@ gtk_cell_area_real_activate (GtkCellArea *area,
|
||||
GtkCellAreaContext *context,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
GtkCellRendererState flags,
|
||||
gboolean edit_only)
|
||||
{
|
||||
GtkCellAreaPrivate *priv = area->priv;
|
||||
GdkRectangle renderer_area;
|
||||
GtkCellRenderer *activate_cell = NULL;
|
||||
GtkCellRendererMode mode;
|
||||
|
||||
if (priv->focus_cell)
|
||||
{
|
||||
g_object_get (priv->focus_cell, "mode", &mode, NULL);
|
||||
|
||||
if (gtk_cell_renderer_get_visible (priv->focus_cell) &&
|
||||
(edit_only ? mode == GTK_CELL_RENDERER_MODE_EDITABLE :
|
||||
mode != GTK_CELL_RENDERER_MODE_INERT))
|
||||
activate_cell = priv->focus_cell;
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *cells, *l;
|
||||
@ -1274,13 +1284,16 @@ gtk_cell_area_real_activate (GtkCellArea *area,
|
||||
{
|
||||
GtkCellRenderer *renderer = l->data;
|
||||
|
||||
if (gtk_cell_renderer_is_activatable (renderer))
|
||||
g_object_get (renderer, "mode", &mode, NULL);
|
||||
|
||||
if (gtk_cell_renderer_get_visible (renderer) &&
|
||||
(edit_only ? mode == GTK_CELL_RENDERER_MODE_EDITABLE :
|
||||
mode != GTK_CELL_RENDERER_MODE_INERT))
|
||||
activate_cell = renderer;
|
||||
}
|
||||
g_list_free (cells);
|
||||
}
|
||||
|
||||
|
||||
if (activate_cell)
|
||||
{
|
||||
/* Get the allocation of the focused cell.
|
||||
@ -2813,6 +2826,8 @@ gtk_cell_area_focus (GtkCellArea *area,
|
||||
* @widget: the #GtkWidget that @area is rendering on
|
||||
* @cell_area: the size and location of @area relative to @widget's allocation
|
||||
* @flags: the #GtkCellRendererState flags for @area for this row of data.
|
||||
* @edit_only: if %TRUE then only cell renderers that are %GTK_CELL_RENDERER_MODE_EDITABLE
|
||||
* will be activated.
|
||||
*
|
||||
* Activates @area, usually by activating the currently focused
|
||||
* cell, however some subclasses which embed widgets in the area
|
||||
@ -2827,11 +2842,12 @@ gtk_cell_area_activate (GtkCellArea *area,
|
||||
GtkCellAreaContext *context,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
GtkCellRendererState flags,
|
||||
gboolean edit_only)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CELL_AREA (area), FALSE);
|
||||
|
||||
return GTK_CELL_AREA_GET_CLASS (area)->activate (area, context, widget, cell_area, flags);
|
||||
return GTK_CELL_AREA_GET_CLASS (area)->activate (area, context, widget, cell_area, flags, edit_only);
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,7 +246,8 @@ struct _GtkCellAreaClass
|
||||
GtkCellAreaContext *context,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
GtkCellRendererState flags,
|
||||
gboolean edit_only);
|
||||
|
||||
/*< private >*/
|
||||
|
||||
@ -398,7 +399,8 @@ gboolean gtk_cell_area_activate (GtkCellArea
|
||||
GtkCellAreaContext *context,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
GtkCellRendererState flags,
|
||||
gboolean edit_only);
|
||||
gboolean gtk_cell_area_focus (GtkCellArea *area,
|
||||
GtkDirectionType direction);
|
||||
void gtk_cell_area_set_focus_cell (GtkCellArea *area,
|
||||
|
@ -874,7 +874,8 @@ static void gtk_tree_view_put (GtkTreeView *tree_
|
||||
gint width,
|
||||
gint height);
|
||||
static gboolean gtk_tree_view_start_editing (GtkTreeView *tree_view,
|
||||
GtkTreePath *cursor_path);
|
||||
GtkTreePath *cursor_path,
|
||||
gboolean edit_only);
|
||||
static void gtk_tree_view_stop_editing (GtkTreeView *tree_view,
|
||||
gboolean cancel_editing);
|
||||
static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
|
||||
@ -10615,7 +10616,7 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view,
|
||||
if (!tree_view->priv->shift_pressed && start_editing &&
|
||||
tree_view->priv->focus_column)
|
||||
{
|
||||
if (gtk_tree_view_start_editing (tree_view, cursor_path))
|
||||
if (gtk_tree_view_start_editing (tree_view, cursor_path, FALSE))
|
||||
{
|
||||
gtk_tree_path_free (cursor_path);
|
||||
return TRUE;
|
||||
@ -13348,7 +13349,7 @@ gtk_tree_view_set_cursor_on_cell (GtkTreeView *tree_view,
|
||||
if (focus_cell)
|
||||
gtk_tree_view_column_focus_cell (focus_column, focus_cell);
|
||||
if (start_editing)
|
||||
gtk_tree_view_start_editing (tree_view, path);
|
||||
gtk_tree_view_start_editing (tree_view, path, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15374,7 +15375,8 @@ _gtk_tree_view_remove_editable (GtkTreeView *tree_view,
|
||||
|
||||
static gboolean
|
||||
gtk_tree_view_start_editing (GtkTreeView *tree_view,
|
||||
GtkTreePath *cursor_path)
|
||||
GtkTreePath *cursor_path,
|
||||
gboolean edit_only)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GdkRectangle cell_area;
|
||||
@ -15414,7 +15416,7 @@ gtk_tree_view_start_editing (GtkTreeView *tree_view,
|
||||
_gtk_tree_view_column_get_context (focus_column),
|
||||
GTK_WIDGET (tree_view),
|
||||
&cell_area,
|
||||
flags))
|
||||
flags, edit_only))
|
||||
retval = TRUE;
|
||||
|
||||
return retval;
|
||||
|
@ -848,7 +848,8 @@ cell_area_scaffold_activate (CellAreaScaffold *scaffold)
|
||||
cell_area.height = data->size;
|
||||
|
||||
gtk_cell_area_apply_attributes (priv->area, priv->model, &iter, FALSE, FALSE);
|
||||
gtk_cell_area_activate (priv->area, priv->context, widget, &cell_area, GTK_CELL_RENDERER_FOCUSED);
|
||||
gtk_cell_area_activate (priv->area, priv->context, widget, &cell_area,
|
||||
GTK_CELL_RENDERER_FOCUSED, FALSE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user