Re: 4am, school tomorrow, and these 5 lines of code are killing me!




Crap.  I'm having an episode, here.

Someone answered this for me and I deleted the email.  Now I'm back at
home and I don't remember what it said.

My apologies to the list, but could the person who so graciously answered
this forward me the answer again?

I still can't figure out when to use gchar *some_text[BUFSIZE] and when to
use GString *some_text, and how g_string_sprintf() uses either one of
those.

Thanks,
Derek 

> 	Help.  I have a text widget, a label widget, and I want the label
> to show the number of characters in my text widget.  I can't find any
> freakin' docs on the Gstring, or gchar, or g_char (or whatever the hell
> I'm supposed to use) so here's my fxn:
> 
> 
> void message_label_update(GtkWidget *text, GtkLabel *label)
> {
> 	guint message_length;
> 	GString *the_label_text;   /* what should this be?! */
> 	
> 	message_length = GTK_TEXT(text)->text_end - GTK_TEXT(text)->gap_size;
> 
> 	if (message_length == 1)
> 	{
> 	gtk_label_set(GTK_LABEL(label), "1 character");
> 	}
> 	else
> 	{
> 	g_string_sprintf(the_label_text,"%d characters", message_length);
> 	gtk_label_set(GTK_LABEL(label), &the_label_text);
> 	}	
> 
> }
> 
> 
> 	This is the warning I get when I try to compile:
> 
> MessageGordon.c: In function `message_label_update':
> MessageGordon.c:80: warning: passing arg 2 of `gtk_label_set' from
> incompatible pointer type 
> 
> 	Yes, I know I'm making a stupid mistake.  I don't care.  I've lost
> all sense of decency...somebody....PLEASE tell me what I'm doing
> wrong....blrchzz  psfft.... ack



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