Re: [gtk-list] Re: widechar support



On Wed, 14 Apr 1999, Philip Brown wrote:

> If you switch the object creation type below, from label, to button, suddenly,
> the code does not work any more, and only prints out the string in
> ascii mode.
> 
> I consider this a bug. How about you?
> 
> 
> ############################################################
> 
> #include <gtk/gtk.h>
> 
> int main (int argc, char *argv[]){
>   GdkFont *kanji_font;
>   GtkStyle *style;
>   char labelstring[100],fontname[100];
>   GtkWidget *window, *label;
> 
>   sprintf(labelstring,"%c%c%c%c doubletest",0x31,0x2b,0x31,0x26);
> 
>   if (argc > 1) {
>       puts ("using kanji24 as font");
>       sprintf (fontname, "%s", "kanji24");
>     }  else   {
>       sprintf (fontname, "%s", "fixed");
>     }
>   gtk_init (&argc, &argv);
> 
>   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>   gtk_container_set_border_width (GTK_CONTAINER (window), 10);
>   label = gtk_label_new (labelstring);
>   /* change to label = gtk_button_new_with_label (labelstring); */

then GtkWidget*label will contain a pointer to the button, not the label.

>   kanji_font = gdk_font_load (fontname);
>   style = gtk_style_copy (gtk_widget_get_style (window));
>   gdk_font_unref (style->font);
>   style->font = kanji_font;
>   gdk_font_ref (style->font);
>   gtk_widget_set_style (label, style);

and you are altering the style of the button, not the label.


> 
>   gtk_container_add (GTK_CONTAINER (window), label);
>   gtk_widget_show (label);
>   gtk_widget_show (window);
>   gtk_main ();
> 
>   return (0);
> }

if you use button = gtk_button_new_with_label(), you'll have to change/apply
the style of GTK_BIN (button)->child to afefct the label.


---
ciaoTJ



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