Re: gtk_widget_modify_style causes App to crash



On Tue, 27 Nov 2001 15:20:39 -0300
Rajesh Padalia <rpadalia qatar net qa> wrote:

Hi,

I am using following code to set font of Rows in Clist. It works but
causes Application to crash after setting font few times. Any
ideas? Appreciate your help in sorting out this problem.

GtkRcStyle * rcstyle = gtk_rc_style_new();
rcstyle->font_name = Font_Selected;
(gchar * Font_Selected is set through GnomeFontPicker)
gtk_widget_modify_style(GTK_CLIST(alarm_clist), rcstyle));
gtk_rc_style_unref(rcstyle);


Here is an example from an application I wrote. It has some glade-specific
code lines, but the general idea is the same:

void setcallstyle(gint row) {
  GdkColor color1, color2, color3, color4;
  GtkStyle *newstyle;
  GtkWidget *log;
  
  log = lookup_widget(mainwindow, "logclist");

  /* set colors */
  color1.red   = 0x0000;  /* light blue */
  color1.green = 0x0000;
  color1.blue  = 0xcd00;
  color2.red   = 0xffff;  /* white */
  color2.green = 0xffff;
  color2.blue  = 0xffff;
  color3.red   = 0xcccc;  /* light gray */
  color3.green = 0xcccc;
  color3.blue  = 0xcccc;
  color4.red   = 0x4924;  /* dark slate blue */
  color4.green = 0x3cf3;
  color4.blue  = 0x8e38;
  /* set style of the new row */
  newstyle = gtk_style_copy(log->style);
  newstyle->base[GTK_STATE_NORMAL] = color1;
  newstyle->fg[GTK_STATE_NORMAL] = color2;
  newstyle->bg[GTK_STATE_SELECTED] = color3;
  newstyle->fg[GTK_STATE_SELECTED] = color4;
  gdk_font_unref(newstyle->font);
  newstyle->font = gdk_font_load("-adobe-helvetica-bold-r-*-*-*-120-*-*-*-*-*-*");
  gtk_clist_set_cell_style(GTK_CLIST(log), row, 3, newstyle);
}


Thanks

Rajesh Padalia


Joop
-- 
Joop Stakenborg
FOM-instituut Rijnhuizen
tel. 030-6096862



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]