1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/* $Header: /home/jcb/MahJong/newmj/RCS/lazyfixed.c,v 12.1 2020/05/30 17:27:18 jcb Exp $
* lazyfixed.c
* A slight variation on the GTK+ fixed widget.
* It doesn't call queue_resize when children removed;
* this can reduce flickering in widgets with many children.
* Of course, it means that you must call gtk_widget_queue_resize manually
* if you *do* want to remove something and have the size change.
* Also, of course, if you remove a non-window widget, nothing will
* happen until the next time something causes redisplay.
*/
/****************** COPYRIGHT STATEMENT **********************
* This file is Copyright (c) 2001 by J. C. Bradfield. *
* This file may be used under the terms of the *
* GNU Lesser General Public License (any version). *
* The moral rights of the author are asserted. *
* *
***************** DISCLAIMER OF WARRANTY ********************
* This code is not warranted fit for any purpose. See the *
* LICENCE file for further information. *
* *
*************************************************************/
#include "lazyfixed.h"
G_DEFINE_TYPE(LazyFixed, lazy_fixed, GTK_TYPE_FIXED)
static void lazy_fixed_remove(GtkContainer *container, GtkWidget *widget);
static void
lazy_fixed_class_init(LazyFixedClass *klass)
{
GtkContainerClass *container_class = GTK_CONTAINER_CLASS(klass);
/* override the remove method to not queue resize */
container_class->remove = lazy_fixed_remove;
}
static void
lazy_fixed_init(LazyFixed *fixed UNUSED)
{
/* nothing to initialize */
}
GtkWidget*
lazy_fixed_new(void)
{
return g_object_new(LAZY_FIXED_TYPE, NULL);
}
static void
lazy_fixed_remove(GtkContainer *container, GtkWidget *widget)
{
GtkContainerClass *parent_class;
g_return_if_fail(IS_LAZY_FIXED(container));
g_return_if_fail(GTK_IS_WIDGET(widget));
/* Call the parent class's remove method to properly remove from child list */
parent_class = GTK_CONTAINER_CLASS(lazy_fixed_parent_class);
if (parent_class->remove) {
parent_class->remove(container, widget);
}
}
void
lazy_fixed_put(LazyFixed *fixed, GtkWidget *widget, gint x, gint y)
{
g_return_if_fail(IS_LAZY_FIXED(fixed));
g_return_if_fail(GTK_IS_WIDGET(widget));
gtk_fixed_put(GTK_FIXED(fixed), widget, x, y);
}
void
lazy_fixed_move(LazyFixed *fixed, GtkWidget *widget, gint x, gint y)
{
g_return_if_fail(IS_LAZY_FIXED(fixed));
g_return_if_fail(GTK_IS_WIDGET(widget));
gtk_fixed_move(GTK_FIXED(fixed), widget, x, y);
}
|