[Glade-devel] [Glade3] Problems with GtkTable
Cornet Mickael
mickael_cornet@yahoo.fr
Thu, 26 Aug 2004 09:47:13 +0200 (CEST)
--0-1936272083-1093506433=:42651
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Id:
Content-Disposition: inline
Hi,
I finaly found and correct the problem. I rewrite the
void GLADEGTK_API
glade_gtk_table_set_n_common (GObject *object, GValue
*value, gboolean for_rows)
(glade-gtk.c line 405)
function.
Like I said before, I am a beginner in GTK & Glade
developping so I prefer do not make a patch but submit
my version (I'm sure of my "GTK quality" of my work).
I can make a patch if my function is OK.
With this modification, we can add/remove rows/columns
without problems in Glade3. I hope it will interesting
you.
I continue to use Glade3 and if I found other
problems, I'll post again.
Glade3 is a great work. Thanks.
(You can find my "patch function" as attachement)
Mickaël
Mickaël wrote:
>I've got this idea, but with Glade2 no problem, when
>we add or remove a row or a column, no crash and we
>can see the good number of rows/column on screen.
I've
>ran Glade2 on the same system, that's why I think
<there is a problem with Glade3.
>Mickaël
--- Shane Butler <shane_b@users.sourceforge.net> a
écrit :
> BTW Mickael, have you checked to see what glade2 is
> doing to make tables
> smaller? If there is a "work around" or a better way
> to do it glade2
> might have already figured it out...
> Regards, Shane
>
> On Tue, 2004-08-24 at 00:45, Cornet Mickael wrote:
>
> > Thanks Shane.
> >
> > I test gtk_table_resize() on line 469 and it
> > effectively set the good value.
> >
> > I noticed that we can increase number of rows and
> > columns (4,5,....) the table is redrawn with
> > correct
> > rows and columns but if we decrease it, the
> > display
> > stay at the max value, very strange...
> >
> > Glade crashes when number of column is 1.
> >
> > I continue to debugging
> >
> > Mickael
> >
Vous manquez d’espace pour stocker vos mails ?
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com
--0-1936272083-1093506433=:42651
Content-Type: text/x-patch; name="glade-gtk.c.patch"
Content-Description: glade-gtk.c.patch
Content-Disposition: inline; filename="glade-gtk.c.patch"
glade-gtk.c
line 405:
void GLADEGTK_API
glade_gtk_table_set_n_common (GObject *object, GValue *value, gboolean for_rows)
{
GladeWidget *widget;
GtkTable *table;
int new_size;
int old_size;
int i, j;
table = GTK_TABLE (object);
g_return_if_fail (GTK_IS_TABLE (table));
new_size = g_value_get_int (value);
old_size = for_rows ? table->nrows : table->ncols;
if (new_size == old_size)
return;
if (new_size < 1)
return;
widget = glade_widget_get_from_gtk_widget (GTK_WIDGET (table));
g_return_if_fail (widget != NULL);
if (new_size > old_size) {
if (for_rows) {
gtk_table_resize (table, new_size, table->ncols);
for (i = 0; i < table->ncols; i++)
for (j = old_size; j < table->nrows; j++)
{
gtk_table_attach_defaults (table, glade_placeholder_new (),
i, i + 1, j, j + 1);
}
} else {
gtk_table_resize (table, table->nrows, new_size);
for (i = old_size; i < table->ncols; i++)
for (j = 0; j < table->nrows; j++)
{
gtk_table_attach_defaults (table, glade_placeholder_new (),
i, i + 1, j, j + 1);
}
}
} else {
GList *list;
GList *list_to_free = NULL;
for (list = table->children; list; list = list->next)
{
GtkTableChild *child;
child = list->data;
if(!child)continue;
gint start = for_rows ? child->top_attach : child->left_attach;
gint end = for_rows ? child->bottom_attach : child->right_attach;
/* We need to completely remove it */
if (start >= new_size) {
list_to_free = g_list_append(list_to_free,child);
continue;
}
/* If the widget spans beyond the new border, we should resize it to fit on the new table */
if (end > new_size)
gtk_container_child_set (GTK_CONTAINER (table), GTK_WIDGET (child),
for_rows ? "bottom_attach" : "right_attach",
new_size, NULL);
}
if(list_to_free)
for (list_to_free = g_list_first(list_to_free); list_to_free; list_to_free = list_to_free->next)
{
GtkTableChild *child;
child = list_to_free->data;
gtk_container_remove (GTK_CONTAINER (table), child->widget);
}
g_list_free (list_to_free);
gtk_table_resize (table,
for_rows ? new_size : table->nrows,
for_rows ? table->ncols : new_size);
}
g_object_set_data (object, "glade_nb_placeholders", GINT_TO_POINTER (new_size * (for_rows ? table->ncols : table->nrows)));
}
--0-1936272083-1093506433=:42651--