Re: [gtk-list] Re: GtkText and GdkFont



Well, thanks a lot .. I guess I should also give a tip: make sure you set
the styles before you call gtk_widget_show(), otherwise the styles dont
take effect :)

Thanks for the help,
-Chuck
 On Tue, 21 Jul 1998, Andrew Homyk wrote:

%Chuck Mason wrote:
%> 
%> I guess I am, too, writing for help in an application I am writing.  So:
%> 
%> In my application I created a GtkText widget and placed it into the window
%> I need. My question is how to change the font in the GtkText edit area...
%> I know how to load the GdkFont (in fact, I did too), and use
%> gtk_text_insert() with the font I want, but my problem is that when
%> editing, the text edit area defaults back to the default font. If I try to
%> use gtk_widget_set_style() with a new Style->font (for my font i use in
%> gtk_text_insert) all the text on the menus, dialogs, everything changes,
%> except for the edit area in GtkText.. Anyone know of a way to fix it so
%> that the GtkText is always a certain font, and not only when text_insert
%> is used.. ?
%> 
%> -Chuck
%
%Chuck - I had the same problem, and this sorta worked as a solution
%(also let me change the bg color of the text which was causing problems
%too).  What I found works is that you should create the text box early,
%as one of the first widgets, apply the style with
%gtk_widget_set_style(), then do another gtk_widget_set_style(window,
%gtk_style_new());  which worked for me:
%(this isn't my exact code, just typed this in now, should work though)
%-----------------------------------------------------
%#include <gtk/gtk.h>
%
%void delete(GtkWidget *widget, gpointer data)
%{
%	gtk_main_quit();
%}
%
%
%int main(int argc, char *argv[])
%{
%	GtkWidget *window;
%	GtkWidget *text;
%	GtkWidget *tbox;
%	GtkWidget *vbox;
%	GtkStyle  *style;
%	GdkFont   *font;
%
%	gtk_init(&argc, &argv);
%
%	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
%	gtk_window_set_title(GTK_WINDOW(window), "Test");
%	gtk_signal_connect(GTK_OBJECT(window), "delete_event",
%		GTK_SIGNAL_FUNC(delete), NULL);
%
%
%	vbox = gtk_vbox_new(FALSE, 2);
%	gtk_container_add(GTK_CONTAINER(window), vbox);
%	gtk_widget_show(vbox);
%
%	text = gtk_text_new(NULL, NULL);
%	gtk_text_set_editable(GTK_TEXT(text), TRUE);
%	style = gtk_style_new();
%	font = gdk_font_load("-misc-fixed-medium-r-normal-*-120-*-*-*-*-*-*");
%	
%	style->font = font;
%	gtk_widget_set_style(text, style);
%
%	gtk_widget_set_style(window, gtk_style_new());
%
%	tbox = gtk_entry_new();
%	gtk_box_pack_start(GTK_BOX(vbox), text, TRUE, TRUE, 0);
%	gtk_widget_show(text);
%	gtk_box_pack_start(GTK_BOX(vbox), tbox, TRUE, TRUE, 0);
%	gtk_widget_show(tbox);
%
%	gtk_widget_show(window);
%
%	gtk_main();
%	return 0;
%}
%-------------------------------------------------
%
%Hope that helps some
%
%-Andrew
%
%-- 
%To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
%


--------------------------------------------------------------
Chuck Mason		              || "The world is full of
chuckjr@sundial.net                   ||  painted pictures 
------------------------------------- ||  which yet to have 
semu - http://emu.simplenet.com/semu/ ||  its 1000 words."--Me
==============================================================



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