Commit 92841cb9 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Make a GtkCellEditable (get_widget_window_size): Change to let it honor

Tue Sep 25 12:34:42 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtkentry.c: Make a GtkCellEditable
	(get_widget_window_size): Change to let it honor size_allocate
	when a CellEditable.

	* gtk/gtktreeview.c: M-x clean-line-ends.  Lots of focus and
	editable changes.
	(gtk_tree_view_set_cursor): Now you can set the cursor
	horizontally, as well as start editing.

	* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
	code to look more like the other check buttons.

	* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
	Change the way we calculate cell size.

	* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.

	* demos/gtk-demo/sizegroup.c: Add mnemonics.

	* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
	Fix logic.

	* gtk/gtkcellrenderertext.c: Change to be editable.

	* gtk/gtkcellrenderertoggle.c: Change to be activatable.

	* test/testtreesort.c: Fix misspelling

	* test/testreecolumns.c: Add mnemonics.

	* test/testreeedit.c: New test program.
parent 8a2d408d
Tue Sep 25 12:34:42 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkentry.c: Make a GtkCellEditable
(get_widget_window_size): Change to let it honor size_allocate
when a CellEditable.
* gtk/gtktreeview.c: M-x clean-line-ends. Lots of focus and
editable changes.
(gtk_tree_view_set_cursor): Now you can set the cursor
horizontally, as well as start editing.
* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
code to look more like the other check buttons.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
Change the way we calculate cell size.
* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.
* demos/gtk-demo/sizegroup.c: Add mnemonics.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
Fix logic.
* gtk/gtkcellrenderertext.c: Change to be editable.
* gtk/gtkcellrenderertoggle.c: Change to be activatable.
* test/testtreesort.c: Fix misspelling
* test/testreecolumns.c: Add mnemonics.
* test/testreeedit.c: New test program.
2001-09-25 Havoc Pennington <hp@pobox.com>
* gtk/gtkwindow.c: Put notes in gtk_window_set_has_frame(),
......
Tue Sep 25 12:34:42 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkentry.c: Make a GtkCellEditable
(get_widget_window_size): Change to let it honor size_allocate
when a CellEditable.
* gtk/gtktreeview.c: M-x clean-line-ends. Lots of focus and
editable changes.
(gtk_tree_view_set_cursor): Now you can set the cursor
horizontally, as well as start editing.
* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
code to look more like the other check buttons.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
Change the way we calculate cell size.
* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.
* demos/gtk-demo/sizegroup.c: Add mnemonics.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
Fix logic.
* gtk/gtkcellrenderertext.c: Change to be editable.
* gtk/gtkcellrenderertoggle.c: Change to be activatable.
* test/testtreesort.c: Fix misspelling
* test/testreecolumns.c: Add mnemonics.
* test/testreeedit.c: New test program.
2001-09-25 Havoc Pennington <hp@pobox.com>
* gtk/gtkwindow.c: Put notes in gtk_window_set_has_frame(),
......
Tue Sep 25 12:34:42 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkentry.c: Make a GtkCellEditable
(get_widget_window_size): Change to let it honor size_allocate
when a CellEditable.
* gtk/gtktreeview.c: M-x clean-line-ends. Lots of focus and
editable changes.
(gtk_tree_view_set_cursor): Now you can set the cursor
horizontally, as well as start editing.
* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
code to look more like the other check buttons.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
Change the way we calculate cell size.
* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.
* demos/gtk-demo/sizegroup.c: Add mnemonics.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
Fix logic.
* gtk/gtkcellrenderertext.c: Change to be editable.
* gtk/gtkcellrenderertoggle.c: Change to be activatable.
* test/testtreesort.c: Fix misspelling
* test/testreecolumns.c: Add mnemonics.
* test/testreeedit.c: New test program.
2001-09-25 Havoc Pennington <hp@pobox.com>
* gtk/gtkwindow.c: Put notes in gtk_window_set_has_frame(),
......
Tue Sep 25 12:34:42 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkentry.c: Make a GtkCellEditable
(get_widget_window_size): Change to let it honor size_allocate
when a CellEditable.
* gtk/gtktreeview.c: M-x clean-line-ends. Lots of focus and
editable changes.
(gtk_tree_view_set_cursor): Now you can set the cursor
horizontally, as well as start editing.
* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
code to look more like the other check buttons.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
Change the way we calculate cell size.
* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.
* demos/gtk-demo/sizegroup.c: Add mnemonics.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
Fix logic.
* gtk/gtkcellrenderertext.c: Change to be editable.
* gtk/gtkcellrenderertoggle.c: Change to be activatable.
* test/testtreesort.c: Fix misspelling
* test/testreecolumns.c: Add mnemonics.
* test/testreeedit.c: New test program.
2001-09-25 Havoc Pennington <hp@pobox.com>
* gtk/gtkwindow.c: Put notes in gtk_window_set_has_frame(),
......
Tue Sep 25 12:34:42 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkentry.c: Make a GtkCellEditable
(get_widget_window_size): Change to let it honor size_allocate
when a CellEditable.
* gtk/gtktreeview.c: M-x clean-line-ends. Lots of focus and
editable changes.
(gtk_tree_view_set_cursor): Now you can set the cursor
horizontally, as well as start editing.
* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
code to look more like the other check buttons.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
Change the way we calculate cell size.
* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.
* demos/gtk-demo/sizegroup.c: Add mnemonics.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
Fix logic.
* gtk/gtkcellrenderertext.c: Change to be editable.
* gtk/gtkcellrenderertoggle.c: Change to be activatable.
* test/testtreesort.c: Fix misspelling
* test/testreecolumns.c: Add mnemonics.
* test/testreeedit.c: New test program.
2001-09-25 Havoc Pennington <hp@pobox.com>
* gtk/gtkwindow.c: Put notes in gtk_window_set_has_frame(),
......
Tue Sep 25 12:34:42 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkentry.c: Make a GtkCellEditable
(get_widget_window_size): Change to let it honor size_allocate
when a CellEditable.
* gtk/gtktreeview.c: M-x clean-line-ends. Lots of focus and
editable changes.
(gtk_tree_view_set_cursor): Now you can set the cursor
horizontally, as well as start editing.
* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
code to look more like the other check buttons.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
Change the way we calculate cell size.
* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.
* demos/gtk-demo/sizegroup.c: Add mnemonics.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
Fix logic.
* gtk/gtkcellrenderertext.c: Change to be editable.
* gtk/gtkcellrenderertoggle.c: Change to be activatable.
* test/testtreesort.c: Fix misspelling
* test/testreecolumns.c: Add mnemonics.
* test/testreeedit.c: New test program.
2001-09-25 Havoc Pennington <hp@pobox.com>
* gtk/gtkwindow.c: Put notes in gtk_window_set_has_frame(),
......
Tue Sep 25 12:34:42 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkentry.c: Make a GtkCellEditable
(get_widget_window_size): Change to let it honor size_allocate
when a CellEditable.
* gtk/gtktreeview.c: M-x clean-line-ends. Lots of focus and
editable changes.
(gtk_tree_view_set_cursor): Now you can set the cursor
horizontally, as well as start editing.
* gtk/gtkstyle.c (gtk_default_draw_check): changing toggle drawing
code to look more like the other check buttons.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_get_size):
Change the way we calculate cell size.
* gtk/gtkmarshal.list (VOID:STRING,STRING): new marshaller.
* demos/gtk-demo/sizegroup.c: Add mnemonics.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_get_size): Fix docs.
Fix logic.
* gtk/gtkcellrenderertext.c: Change to be editable.
* gtk/gtkcellrenderertoggle.c: Change to be activatable.
* test/testtreesort.c: Fix misspelling
* test/testreecolumns.c: Add mnemonics.
* test/testreeedit.c: New test program.
2001-09-25 Havoc Pennington <hp@pobox.com>
* gtk/gtkwindow.c: Put notes in gtk_window_set_has_frame(),
......
......@@ -43,12 +43,12 @@ static GtkItemFactoryEntry menu_items[] =
{ "/File/sep1", NULL, menuitem_cb, 0, "<Separator>" },
{ "/File/_Quit", "<control>Q", menuitem_cb, 0, "<StockItem>", GTK_STOCK_QUIT },
{ "/_Preferences", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/_Color", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/Color/_Red", NULL, menuitem_cb, 0, "<RadioItem>" },
{ "/_Preferences/Color/_Green", NULL, menuitem_cb, 0, "/Preferences/Color/Red" },
{ "/_Preferences", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/_Color", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/Color/_Red", NULL, menuitem_cb, 0, "<RadioItem>" },
{ "/_Preferences/Color/_Green", NULL, menuitem_cb, 0, "/Preferences/Color/Red" },
{ "/_Preferences/Color/_Blue", NULL, menuitem_cb, 0, "/Preferences/Color/Red" },
{ "/_Preferences/_Shape", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/_Shape", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/Shape/_Square", NULL, menuitem_cb, 0, "<RadioItem>" },
{ "/_Preferences/Shape/_Rectangle", NULL, menuitem_cb, 0, "/Preferences/Shape/Square" },
{ "/_Preferences/Shape/_Oval", NULL, menuitem_cb, 0, "/Preferences/Shape/Rectangle" },
......
......@@ -52,7 +52,7 @@ add_row (GtkTable *table,
GtkWidget *option_menu;
GtkWidget *label;
label = gtk_label_new (label_text);
label = gtk_label_new_with_mnemonic (label_text);
gtk_misc_set_alignment (GTK_MISC (label), 0, 1);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, row, row + 1,
......@@ -60,6 +60,7 @@ add_row (GtkTable *table,
0, 0);
option_menu = create_option_menu (options);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu);
gtk_size_group_add_widget (size_group, option_menu);
gtk_table_attach (GTK_TABLE (table), option_menu,
1, 2, row, row + 1,
......@@ -137,8 +138,8 @@ do_sizegroup (void)
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
gtk_container_add (GTK_CONTAINER (frame), table);
add_row (GTK_TABLE (table), 0, size_group, "Foreground", color_options);
add_row (GTK_TABLE (table), 1, size_group, "Background", color_options);
add_row (GTK_TABLE (table), 0, size_group, "_Foreground", color_options);
add_row (GTK_TABLE (table), 1, size_group, "_Background", color_options);
/* And another frame holding line style options
*/
......@@ -151,11 +152,11 @@ do_sizegroup (void)
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
gtk_container_add (GTK_CONTAINER (frame), table);
add_row (GTK_TABLE (table), 0, size_group, "Dashing", dash_options);
add_row (GTK_TABLE (table), 1, size_group, "Line ends", end_options);
add_row (GTK_TABLE (table), 0, size_group, "_Dashing", dash_options);
add_row (GTK_TABLE (table), 1, size_group, "_Line ends", end_options);
/* And a check button to turn grouping on and off */
check_button = gtk_check_button_new_with_label ("Enable grouping");
check_button = gtk_check_button_new_with_mnemonic ("_Enable grouping");
gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
......
......@@ -30,7 +30,7 @@ HOW THE GTKTREEVIEWCOLUMN STORES SIZE:
======================================
There are a number of size related fields in the GtkTreeViewColumn
structure:
structure. These are all valid after realization:
sizing The sizing method to use when calculating the size
of the column. Can be grow_only, resizable, auto, and fixed.
......
......@@ -318,7 +318,9 @@ gtk_cell_renderer_set_property (GObject *object,
* 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.
* 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,
......@@ -329,29 +331,24 @@ gtk_cell_renderer_get_size (GtkCellRenderer *cell,
gint *width,
gint *height)
{
gint *real_width = NULL;
gint *real_height = NULL;
gint *real_width = width;
gint *real_height = height;
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
if (width)
if (width && cell->width != -1)
{
if (cell->width == -1)
real_width = width;
else
*width = cell->width;
real_width = NULL;
*width = cell->width;
}
if (height)
if (height && cell->height != -1)
{
if (cell->height == -1)
real_height = height;
else
*height = cell->height;
real_height = NULL;
*height = cell->height;
}
if (real_width || real_height)
GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, real_width, real_height);
GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, real_width, real_height);
}
/**
......@@ -364,15 +361,13 @@ gtk_cell_renderer_get_size (GtkCellRenderer *cell,
* @expose_area: area that actually needs updating
* @flags: flags that affect rendering
*
* Invokes the virtual render function of the #GtkCellRenderer. The
* three passed-in rectangles are areas of @window. Most renderers
* will draw to @cell_area; the xalign, yalign, xpad, and ypad fields
* of the #GtkCellRenderer should be honored with respect to
* @cell_area. @background_area includes the 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. Cell renderers can use the @background_area to draw custom expanders, for
* example. @expose_area is a clip rectangle.
* Invokes the virtual render function of the #GtkCellRenderer. The three
* passed-in rectangles are areas of @window. Most renderers will draw within
* @cell_area; the xalign, yalign, xpad, and ypad fields of the #GtkCellRenderer
* should be honored with respect to @cell_area. @background_area includes the
* 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
......@@ -384,11 +379,6 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
GdkRectangle *expose_area,
GtkCellRendererState flags)
{
/* It's actually okay to pass in a NULL cell, as we run into that
* a lot
*/
if (cell == NULL)
return;
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
......@@ -407,8 +397,8 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
* @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()
* @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
......@@ -449,8 +439,8 @@ gtk_cell_renderer_activate (GtkCellRenderer *cell,
* @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()
* @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.
......
......@@ -19,6 +19,9 @@
#include <stdlib.h>
#include "gtkcellrenderertext.h"
#include "gtkeditable.h"
#include "gtkentry.h"
#include "gtksignal.h"
#include "gtkintl.h"
static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext);
......@@ -48,7 +51,18 @@ static void gtk_cell_renderer_text_render (GtkCellRenderer *cell,
GdkRectangle *expose_area,
guint flags);
static GtkCellEditable *gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
enum {
EDITED,
LAST_SIGNAL
};
enum {
PROP_0,
......@@ -94,6 +108,9 @@ enum {
};
static gpointer parent_class;
static guint text_cell_renderer_signals [LAST_SIGNAL];
#define GTK_CELL_RENDERER_TEXT_PATH "gtk-cell-renderer-text-path"
GtkType
gtk_cell_renderer_text_get_type (void)
......@@ -128,7 +145,7 @@ gtk_cell_renderer_text_init (GtkCellRendererText *celltext)
GTK_CELL_RENDERER (celltext)->yalign = 0.5;
GTK_CELL_RENDERER (celltext)->xpad = 2;
GTK_CELL_RENDERER (celltext)->ypad = 2;
GTK_CELL_RENDERER (celltext)->mode = GTK_CELL_RENDERER_MODE_EDITABLE;
celltext->fixed_height_rows = -1;
celltext->font = pango_font_description_new ();
}
......@@ -148,7 +165,8 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class)
cell_class->get_size = gtk_cell_renderer_text_get_size;
cell_class->render = gtk_cell_renderer_text_render;
cell_class->start_editing = gtk_cell_renderer_text_start_editing;
g_object_class_install_property (object_class,
PROP_TEXT,
g_param_spec_string ("text",
......@@ -390,6 +408,17 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class)
ADD_SET_PROP ("underline_set", PROP_UNDERLINE_SET,
_("Underline set"),
_("Whether this tag affects underlining"));
text_cell_renderer_signals [EDITED] =
gtk_signal_new ("edited",
GTK_RUN_LAST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCellRendererTextClass, edited),
gtk_marshal_VOID__STRING_STRING,
GTK_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_STRING);
}
static void
......@@ -1135,12 +1164,12 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
if (x_offset)
{
*x_offset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad));
*x_offset = MAX (*x_offset, 0) + cell->xpad;
*x_offset = MAX (*x_offset, 0);
}
if (y_offset)
{
*y_offset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad));
*y_offset = MAX (*y_offset, 0) + cell->ypad;
*y_offset = MAX (*y_offset, 0);
}
}
......@@ -1202,7 +1231,7 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
g_object_unref (G_OBJECT (gc));
}
gtk_paint_layout (widget->style,
window,
state,
......@@ -1210,12 +1239,60 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
cell_area,
widget,
"cellrenderertext",
cell_area->x + x_offset,
cell_area->y + y_offset,
cell_area->x + x_offset + cell->xpad,
cell_area->y + y_offset + cell->ypad,
layout);
g_object_unref (G_OBJECT (layout));
}
static void
gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
gpointer data)
{
gchar *path;
gchar *new_text;
path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH);
new_text = gtk_entry_get_text (GTK_ENTRY (entry));
gtk_signal_emit (GTK_OBJECT (data), text_cell_renderer_signals[EDITED], path, new_text);
}
static GtkCellEditable *
gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags)
{
GtkCellRendererText *celltext;
GtkWidget *entry;
celltext = GTK_CELL_RENDERER_TEXT (cell);
/* If the cell isn't editable we return NULL. */
if (celltext->editable == FALSE)
return NULL;
entry = g_object_new (GTK_TYPE_ENTRY,
"has_frame", FALSE,
NULL);
gtk_entry_set_text (GTK_ENTRY (entry), celltext->text);
g_object_set_data_full (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH, g_strdup (path), g_free);
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
gtk_widget_show (entry);
gtk_signal_connect (GTK_OBJECT (entry),
"editing_done",
G_CALLBACK (gtk_cell_renderer_text_editing_done),
celltext);
return GTK_CELL_EDITABLE (entry);
}
/**
* gtk_cell_renderer_text_set_fixed_height_from_font:
......@@ -1226,8 +1303,9 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
* "y_pad" property set on it. Further changes in these properties do not
* affect the height, so they must be accompanied by a subsequent call to this
* function. Using this function is unflexible, and should really only be used
* if calculating the size of a cell is too slow. If @no_rows is -1, then the
* fixed height is unset, and the height is determined by the properties again.
* if calculating the size of a cell is too slow (ie, a massive number of cells
* displayed). If @number_of_rows is -1, then the fixed height is unset, and
* the height is determined by the properties again.
**/
void
gtk_cell_renderer_text_set_fixed_height_from_font (GtkCellRendererText *renderer,
......
......@@ -79,6 +79,10 @@ struct _GtkCellRendererText
struct _GtkCellRendererTextClass
{
GtkCellRendererClass parent_class;
void (* edited) (GtkCellRendererText *cell_renderer_text,
gchar *path,
gchar *new_text);
};
GtkType gtk_cell_renderer_text_get_type (void);
......
......@@ -62,6 +62,7 @@ enum {
enum {
PROP_ZERO,
PROP_ACTIVATABLE,
PROP_ACTIVE,
PROP_RADIO
};
......@@ -101,6 +102,7 @@ gtk_cell_renderer_toggle_get_type (void)
static void
gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltoggle)
{
celltoggle->activatable = TRUE;
celltoggle->active = FALSE;
celltoggle->radio = FALSE;
GTK_CELL_RENDERER (celltoggle)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
......@@ -130,6 +132,15 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_ACTIVATABLE,
g_param_spec_boolean ("activatable",
_("Activatable"),
_("The toggle button can be activated"),
TRUE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_RADIO,
g_param_spec_boolean ("radio",
......@@ -163,6 +174,9 @@ gtk_cell_renderer_toggle_get_property (GObject *object,
case PROP_ACTIVE:
g_value_set_boolean (value, celltoggle->active);
break;
case PROP_ACTIVATABLE:
g_value_set_boolean (value, celltoggle->activatable);
break;
case PROP_RADIO:
g_value_set_boolean (value, celltoggle->radio);
break;
......@@ -187,6 +201,10 @@ gtk_cell_renderer_toggle_set_property (GObject *object,
celltoggle->active = g_value_get_boolean (value);
g_object_notify (G_OBJECT(object), "active");
break;
case PROP_ACTIVATABLE:
celltoggle->activatable = g_value_get_boolean (value);
g_object_notify (G_OBJECT(object), "activatable");
break;
case PROP_RADIO:
celltoggle->radio = g_value_get_boolean (value);
g_object_notify (G_OBJECT(object), "radio");
......@@ -241,13 +259,13 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
{
if (x_offset)
{
*x_offset = cell->xalign * (cell_area->width - calc_width - (2 * cell->xpad));
*x_offset = MAX (*x_offset, 0) + cell->xpad;
*x_offset = cell->xalign * (cell_area->width - calc_width);
*x_offset = MAX (*x_offset, 0);
}
if (y_offset)
{
*y_offset = cell->yalign * (cell_area->height - calc_height - (2 * cell->ypad));
*y_offset = MAX (*y_offset, 0) + cell->ypad;
*y_offset = cell->yalign * (cell_area->height - calc_height);
*y_offset = MAX (*y_offset, 0);
}
}
}
......@@ -281,21 +299,17 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
{
if (GTK_WIDGET_HAS_FOCUS (widget))
{
state = GTK_STATE_SELECTED;
}
state = GTK_STATE_SELECTED;
else
{
state = GTK_STATE_ACTIVE;
}
state = GTK_STATE_ACTIVE;
}
else if (cell->mode == GTK_CELL_RENDERER_MODE_INERT)
else if (celltoggle->activatable)
{
state = GTK_STATE_INSENSITIVE;
state = GTK_STATE_NORMAL;
}
else
{
state = GTK_STATE_NORMAL;
state = GTK_STATE_INSENSITIVE;
}
if (celltoggle->radio)
......@@ -306,7 +320,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
cell_area, widget, "cellradio",
cell_area->x + x_offset + cell->xpad,
cell_area->y + y_offset + cell->ypad,
width, height);
width - 1, height - 1);
}
else
{
......@@ -316,7 +330,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
cell_area, widget, "cellcheck",
cell_area->x + x_offset + cell->xpad,
cell_area->y + y_offset + cell->ypad,
width, height);
width - 1, height - 1);
}
}
......@@ -330,24 +344,15 @@ gtk_cell_renderer_toggle_activate (GtkCellRenderer *cell,
guint flags)
{
GtkCellRendererToggle *celltoggle;
gboolean retval = FALSE;
celltoggle = GTK_CELL_RENDERER_TOGGLE (cell);
switch (event->type)
if (celltoggle->activatable)
{