sheet->selection_cell.row = 0;
sheet->selection_cell.col = 0;
- sheet->sheet_entry = NULL;
sheet->pixmap = NULL;
sheet->range.row0 = 0;
sheet->sheet_window = NULL;
sheet->sheet_window_width = 0;
sheet->sheet_window_height = 0;
- sheet->sheet_entry = NULL;
+ sheet->entry_widget = NULL;
+ sheet->entry_container = NULL;
sheet->button = NULL;
sheet->hoffset = 0;
"value_changed");
if (sheet->state == GTK_STATE_NORMAL)
- if (sheet->sheet_entry && GTK_WIDGET_MAPPED (sheet->sheet_entry))
+ if (sheet->entry_widget && GTK_WIDGET_MAPPED (sheet->entry_widget))
{
gtk_sheet_activate_cell (sheet, sheet->active_cell.row,
sheet->active_cell.col);
if (sheet->model) g_object_unref (sheet->model);
sheet->dispose_has_run = TRUE;
- /* destroy the entry */
- if (sheet->sheet_entry && GTK_IS_WIDGET (sheet->sheet_entry))
- {
- gtk_widget_destroy (sheet->sheet_entry);
- sheet->sheet_entry = NULL;
- }
-
+ g_object_unref (sheet->entry_container);
g_object_unref (sheet->button);
/* unref adjustments */
GDK_GC_FUNCTION |
GDK_GC_SUBWINDOW);
- if (sheet->sheet_entry->parent)
- {
- gtk_widget_ref (sheet->sheet_entry);
- gtk_widget_unparent (sheet->sheet_entry);
- }
- gtk_widget_set_parent_window (sheet->sheet_entry, sheet->sheet_window);
- gtk_widget_set_parent (sheet->sheet_entry, GTK_WIDGET (sheet));
+ gtk_widget_set_parent_window (sheet->entry_widget, sheet->sheet_window);
+ gtk_widget_set_parent (sheet->entry_widget, GTK_WIDGET (sheet));
gtk_widget_set_parent_window (sheet->button, sheet->sheet_window);
gtk_widget_set_parent (sheet->button, GTK_WIDGET (sheet));
gdk_window_show (sheet->row_title_window);
}
- if (!GTK_WIDGET_MAPPED (sheet->sheet_entry)
+ if (!GTK_WIDGET_MAPPED (sheet->entry_widget)
&& sheet->active_cell.row >= 0
&& sheet->active_cell.col >= 0 )
{
- gtk_widget_show (sheet->sheet_entry);
- gtk_widget_map (sheet->sheet_entry);
+ gtk_widget_show (sheet->entry_widget);
+ gtk_widget_map (sheet->entry_widget);
}
if (GTK_WIDGET_VISIBLE (sheet->button) &&
gdk_window_hide (sheet->row_title_window);
gdk_window_hide (widget->window);
- if (GTK_WIDGET_MAPPED (sheet->sheet_entry))
- gtk_widget_unmap (sheet->sheet_entry);
+ if (GTK_WIDGET_MAPPED (sheet->entry_widget))
+ gtk_widget_unmap (sheet->entry_widget);
if (GTK_WIDGET_MAPPED (sheet->button))
gtk_widget_unmap (sheet->button);
row = sheet->active_cell.row;
col = sheet->active_cell.col;
- gtk_widget_hide (sheet->sheet_entry);
- gtk_widget_unmap (sheet->sheet_entry);
+ gtk_widget_hide (sheet->entry_widget);
+ gtk_widget_unmap (sheet->entry_widget);
if (row != -1 && col != -1)
gdk_draw_pixmap (sheet->sheet_window,
gtk_widget_grab_focus (GTK_WIDGET (sheet));
- GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (sheet->sheet_entry), GTK_VISIBLE);
+ GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (sheet->entry_widget), GTK_VISIBLE);
}
if (sheet->state != GTK_SHEET_NORMAL) return;
if (GTK_SHEET_IN_SELECTION (sheet)) return;
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (sheet->sheet_entry), GTK_VISIBLE);
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET (sheet->entry_widget), GTK_VISIBLE);
sheet_entry = GTK_ENTRY (gtk_sheet_get_entry (sheet));
gtk_sheet_entry_set_max_size (sheet);
gtk_sheet_size_allocate_entry (sheet);
- gtk_widget_map (sheet->sheet_entry);
+ gtk_widget_map (sheet->entry_widget);
gtk_widget_grab_focus (GTK_WIDGET (sheet_entry));
&attributes) )
return ;
- if ( GTK_WIDGET_REALIZED (sheet->sheet_entry) )
+ if ( GTK_WIDGET_REALIZED (sheet->entry_widget) )
{
if (!GTK_WIDGET (sheet_entry)->style)
gtk_widget_ensure_style (GTK_WIDGET (sheet_entry));
style->font_desc = pango_font_description_copy (attributes.font_desc);
GTK_WIDGET (sheet_entry)->style = style;
- gtk_widget_size_request (sheet->sheet_entry, NULL);
+ gtk_widget_size_request (sheet->entry_widget, NULL);
GTK_WIDGET (sheet_entry)->style = previous_style;
if (style != previous_style)
{
- if (!GTK_IS_ITEM_ENTRY (sheet->sheet_entry))
+ if (!GTK_IS_ITEM_ENTRY (sheet->entry_widget))
{
style->bg[GTK_STATE_NORMAL] = previous_style->bg[GTK_STATE_NORMAL];
style->fg[GTK_STATE_NORMAL] = previous_style->fg[GTK_STATE_NORMAL];
shentry_allocation.width = column_width;
shentry_allocation.height = yyy_row_height (sheet, sheet->active_cell.row);
- if (GTK_IS_ITEM_ENTRY (sheet->sheet_entry))
+ if (GTK_IS_ITEM_ENTRY (sheet->entry_widget))
{
shentry_allocation.height -= 2 * CELLOFFSET;
shentry_allocation.y += CELLOFFSET;
}
}
- if (!GTK_IS_ITEM_ENTRY (sheet->sheet_entry))
+ if (!GTK_IS_ITEM_ENTRY (sheet->entry_widget))
{
shentry_allocation.x += 2;
shentry_allocation.y += 2;
shentry_allocation.height -= MIN (shentry_allocation.height, 3);
}
- gtk_widget_size_allocate (sheet->sheet_entry, &shentry_allocation);
+ gtk_widget_size_allocate (sheet->entry_widget, &shentry_allocation);
if (previous_style == style) g_object_unref (previous_style);
}
row = sheet->active_cell.row;
col = sheet->active_cell.col;
- if ( ! GTK_IS_ITEM_ENTRY (sheet->sheet_entry) )
+ if ( ! GTK_IS_ITEM_ENTRY (sheet->entry_widget) )
return;
- justification = GTK_ITEM_ENTRY (sheet->sheet_entry)->justification;
+ justification = GTK_ITEM_ENTRY (sheet->entry_widget)->justification;
switch (justification)
{
if (size != 0)
size += xxx_column_width (sheet, col);
- GTK_ITEM_ENTRY (sheet->sheet_entry)->text_max_size = size;
+ GTK_ITEM_ENTRY (sheet->entry_widget)->text_max_size = size;
}
static void
create_sheet_entry (GtkSheet *sheet)
{
- GtkWidget *widget;
- GtkWidget *parent;
- GtkWidget *entry;
- gint found_entry = FALSE;
-
- widget = GTK_WIDGET (sheet);
-
- if (sheet->sheet_entry)
+ if (sheet->entry_widget)
{
- /* avoids warnings */
- gtk_widget_ref (sheet->sheet_entry);
- gtk_widget_unparent (sheet->sheet_entry);
- gtk_widget_destroy (sheet->sheet_entry);
+ gtk_widget_unparent (sheet->entry_widget);
}
if (sheet->entry_type)
{
- if (!g_type_is_a (sheet->entry_type, GTK_TYPE_ENTRY))
- {
- parent = g_object_new (sheet->entry_type, NULL);
-
- sheet->sheet_entry = parent;
+ sheet->entry_container = g_object_new (sheet->entry_type, NULL);
+ g_object_ref_sink (sheet->entry_container);
+ sheet->entry_widget = gtk_sheet_get_entry (sheet);
- entry = gtk_sheet_get_entry (sheet);
- if (GTK_IS_ENTRY (entry))
- found_entry = TRUE;
- }
- else
+ if ( NULL == sheet->entry_widget)
{
- parent = g_object_new (sheet->entry_type, NULL);
- entry = parent;
- found_entry = TRUE;
+ g_warning ("Entry type is %s. It must be GtkEntry subclass, or a widget containing one. "
+ "Using default", g_type_name (sheet->entry_type));
+ g_object_unref (sheet->entry_container);
+ sheet->entry_widget = sheet->entry_container = gtk_item_entry_new ();
}
-
- if (!found_entry)
+ else
{
- g_warning ("Entry type must be GtkEntry subclass, using default");
- entry = gtk_item_entry_new ();
- sheet->sheet_entry = entry;
+ sheet->entry_widget = sheet->entry_container ;
}
- else
- sheet->sheet_entry = parent;
}
else
{
- entry = gtk_item_entry_new ();
- sheet->sheet_entry = entry;
+ sheet->entry_widget = sheet->entry_container = gtk_item_entry_new ();
+ g_object_ref_sink (sheet->entry_container);
}
- gtk_widget_size_request (sheet->sheet_entry, NULL);
+ gtk_widget_size_request (sheet->entry_widget, NULL);
if (GTK_WIDGET_REALIZED (sheet))
{
- gtk_widget_set_parent_window (sheet->sheet_entry, sheet->sheet_window);
- gtk_widget_set_parent (sheet->sheet_entry, GTK_WIDGET (sheet));
- gtk_widget_realize (sheet->sheet_entry);
+ gtk_widget_set_parent_window (sheet->entry_widget, sheet->sheet_window);
+ gtk_widget_set_parent (sheet->entry_widget, GTK_WIDGET (sheet));
+ gtk_widget_realize (sheet->entry_widget);
}
- g_signal_connect_swapped (entry, "key_press_event",
+ g_signal_connect_swapped (sheet->entry_widget, "key_press_event",
G_CALLBACK (gtk_sheet_entry_key_press),
sheet);
- gtk_widget_show (sheet->sheet_entry);
+ gtk_widget_show (sheet->entry_widget);
}
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
- g_return_val_if_fail (sheet->sheet_entry != NULL, NULL);
+ g_return_val_if_fail (sheet->entry_widget != NULL, NULL);
- if (GTK_IS_ENTRY (sheet->sheet_entry)) return (sheet->sheet_entry);
+ if (GTK_IS_ENTRY (sheet->entry_container))
+ return (sheet->entry_container);
- parent = GTK_WIDGET (sheet->sheet_entry);
+ //parent = GTK_WIDGET (sheet->entry_widget);
+ parent = sheet->entry_container;
if (GTK_IS_TABLE (parent)) children = GTK_TABLE (parent)->children;
if (GTK_IS_BOX (parent)) children = GTK_BOX (parent)->children;
{
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
- g_return_val_if_fail (sheet->sheet_entry != NULL, NULL);
+ g_return_val_if_fail (sheet->entry_widget != NULL, NULL);
- return (sheet->sheet_entry);
+ return (sheet->entry_widget);
}
sheet->voffset = - value;
- if (GTK_WIDGET_REALIZED (sheet->sheet_entry) &&
+ if (GTK_WIDGET_REALIZED (sheet->entry_widget) &&
sheet->state == GTK_SHEET_NORMAL &&
sheet->active_cell.row >= 0 && sheet->active_cell.col >= 0 &&
!gtk_sheet_cell_isvisible (sheet, sheet->active_cell.row,
gtk_sheet_cell_clear (sheet,
sheet->active_cell.row,
sheet->active_cell.col);
- gtk_widget_unmap (sheet->sheet_entry);
+ gtk_widget_unmap (sheet->entry_widget);
}
gtk_sheet_position_children (sheet);
}
sheet->hoffset = - value;
- if (GTK_WIDGET_REALIZED (sheet->sheet_entry) &&
+ if (GTK_WIDGET_REALIZED (sheet->entry_widget) &&
sheet->state == GTK_SHEET_NORMAL &&
sheet->active_cell.row >= 0 && sheet->active_cell.col >= 0 &&
!gtk_sheet_cell_isvisible (sheet, sheet->active_cell.row,
sheet->active_cell.row,
sheet->active_cell.col);
- gtk_widget_unmap (sheet->sheet_entry);
+ gtk_widget_unmap (sheet->entry_widget);
}
gtk_sheet_position_children (sheet);
(* callback) (child->widget, callback_data);
}
- if (sheet->button)
+
+ if (sheet->button && sheet->button->parent)
(* callback) (sheet->button, callback_data);
- if (sheet->sheet_entry)
- (* callback) (sheet->sheet_entry, callback_data);
+
+ if (sheet->entry_container && GTK_IS_CONTAINER (sheet->entry_container))
+ (* callback) (sheet->entry_container, callback_data);
}
g_free (child);
}
+ gtk_widget_unparent (sheet->button);
}
static void