Problem with GTK fonts
- From: Victor Vicente Mateos <drzoidberg wanadoo es>
- To: gtk-devel-list gnome org
- Subject: Problem with GTK fonts
- Date: Tue, 9 Jul 2002 03:18:50 +0200
Hi!
I've got a problem with fonts in GTK. I've made a simple example which consist
on a main window with a label. With a button press in the main window, a
GtkFontSelectionDialog appears to select a font to apply to the label. I
think I do the process correctly, but when I change sometimes the font, a
violation-segment occurs and the following error message:
GLib-CRITICAL **: file gcache.c: line 160 (g_cache_remove) : assertion `node
!= NULL` failed
Thanks for all
The example code is:
#include <gtk/gtk.h>
static void change_name (GtkWidget *widget);
static gint accept_cb (GtkWidget *widget, gpointer data);
static gint cancel_cb (GtkWidget *widget, gpointer data);
static gint press_cb (GtkWidget *widget, gpointer data);
GtkWidget *label;
gint main (gint argc, gchar *argv[])
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC
(gtk_main_quit),
NULL);
gtk_widget_show_all (window);
gtk_widget_add_events (window, GDK_BUTTON_PRESS_MASK);
gtk_signal_connect (GTK_OBJECT (window), "button_press_event",
GTK_SIGNAL_FUNC (press_cb),
NULL);
label = gtk_label_new ("Example");
gtk_container_add (GTK_CONTAINER (window), label);
gtk_widget_show (label);
gtk_main ();
return 0;
}
static void change_name (GtkWidget *widget)
{
GtkWidget *dlg;
dlg = gtk_font_selection_dialog_new ("");
gtk_signal_connect (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (dlg)->ok_button),
"pressed", GTK_SIGNAL_FUNC (accept_cb), (gpointer) dlg);
gtk_signal_connect (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG
(dlg)->cancel_button),
"pressed", GTK_SIGNAL_FUNC (cancel_cb), (gpointer) dlg);
gtk_widget_show (dlg);
}
static gint accept_cb (GtkWidget *widget, gpointer data)
{
GtkFontSelectionDialog *dlg;
GtkStyle *style;
dlg = GTK_FONT_SELECTION_DIALOG (data);
style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (data)));
style->font = gtk_font_selection_dialog_get_font (dlg);
gtk_widget_set_style (label, style);
gtk_widget_destroy (GTK_WIDGET (dlg));
return TRUE;
}
static gint press_cb (GtkWidget *widget, gpointer data)
{
change_name (label);
return TRUE;
}
static gint cancel_cb (GtkWidget *widget, gpointer data)
{
gtk_widget_destroy (GTK_WIDGET (data));
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]