Home » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » GTK theming a reality
|
|
|
|
|
|
|
|
|
Re: GTK theming a reality [message #6813 is a reply to message #6742] |
Wed, 29 November 2006 11:47   |
guido
Messages: 169 Registered: April 2006
|
Experienced Member |
|
|
luzr wrote on Sun, 26 November 2006 01:20 | After a couple of weeks of pretty messy development, kick-off of GTK chameleon is now in main sources.
At the moment, it just reads system colors and font and "chameleonises" Button, Option and Switch, but obviously, even so little makes a huge difference...
Please test! And test with as many themes as possible...
BTW, you do not have to have GTK development headers installed to develop with U++ - GTK is loaded at runtime. Actually, it does not have to be even present either - in that case, U++ default theme is used (after an attempt to read KDE colors and font...))
Mirek
|
Congratulations!
Already working on icon theming?
Currently it shares a problem I got with Firefox 2.0 (1.5 was OK) in that application font is two points too big. I can make it smaller by increasing the Xserver DPI setting from 72 to 120, but than the other GTK apps have tiny fonts.
Could you please tell me, how the font size is retreived?
Guido
|
|
|
Re: GTK theming a reality [message #6814 is a reply to message #6813] |
Wed, 29 November 2006 11:57   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
guido wrote on Wed, 29 November 2006 05:47 |
Congratulations!
Already working on icon theming? 
|
That is the next step. Actually, there is not too many icons import now (only for message boxes and OK Cancel buttons).
Well, I can also import "common" icons for Cut/Copy/Paste, but maybe I will do so rather on "app demand". There is also a problem with icon size...
Quote: |
Currently it shares a problem I got with Firefox 2.0 (1.5 was OK) in that application font is two points too big. I can make it smaller by increasing the Xserver DPI setting from 72 to 120, but than the other GTK apps have tiny fonts.
Could you please tell me, how the font size is retreived?
|
Sure:
char *font_name = "";
GOBJ().g_object_get(GTK().gtk_settings_get_default(), "gtk-font-name", &font_name, NULL);
const char *q = strrchr(font_name, ' ');
if(q) {
int h = atoi(q);
String face(font_name, q);
int ii = Font::FindFaceNameIndex(face);
if(ii < 0)
if(ToUpper(face[0]) == 'M')
ii = Font::COURIER;
else
if(ToUpper(face[0]) == 'S' && ToUpper(face[1]) == 'e')
ii = Font::ROMAN;
else
ii = Font::ARIAL;
Draw::SetStdFont(Font(ii, h ? h * 96 / 72 : 13));
}
(in short, it expects h * 96 / 72 converts retrieved point size to 96dpi screen pixels).
For me, font is exactly as big as in other gnome apps. But as you already noted, I tend to oversimplify things, maybe this simple height retrieval needs to take into account more factors?
Mirek
|
|
|
Re: GTK theming a reality [message #6826 is a reply to message #6814] |
Wed, 29 November 2006 20:12   |
guido
Messages: 169 Registered: April 2006
|
Experienced Member |
|
|
luzr wrote on Wed, 29 November 2006 11:57 |
Sure:
char *font_name = "";
GOBJ().g_object_get(GTK().gtk_settings_get_default(), "gtk-font-name", &font_name, NULL);
const char *q = strrchr(font_name, ' ');
if(q) {
int h = atoi(q);
String face(font_name, q);
int ii = Font::FindFaceNameIndex(face);
if(ii < 0)
if(ToUpper(face[0]) == 'M')
ii = Font::COURIER;
else
if(ToUpper(face[0]) == 'S' && ToUpper(face[1]) == 'e')
ii = Font::ROMAN;
else
ii = Font::ARIAL;
Draw::SetStdFont(Font(ii, h ? h * 96 / 72 : 13));
}
(in short, it expects h * 96 / 72 converts retrieved point size to 96dpi screen pixels).
For me, font is exactly as big as in other gnome apps. But as you already noted, I tend to oversimplify things, maybe this simple height retrieval needs to take into account more factors?
Mirek
|
From the GTK2 docs:
"""
The "gtk-xft-dpi" property
"gtk-xft-dpi" gint : Read / Write
Resolution for Xft, in 1024 * dots/inch. -1 to use default value.
Allowed values: [-1,1048576]
Default value: -1
"""
Maybe use that in your formula?
Guido
|
|
|
|
Re: GTK theming a reality [message #6830 is a reply to message #6827] |
Thu, 30 November 2006 20:52   |
guido
Messages: 169 Registered: April 2006
|
Experienced Member |
|
|
luzr wrote on Wed, 29 November 2006 20:29 | Will you try? I think should be relatively easy (CtrlLib/ChGtk.cpp)
Mirek
|
Ok. Here my take:
char *font_name = "";
GOBJ().g_object_get(GTK().gtk_settings_get_default(), "gtk-font-name", &font_name, NULL);
int xdpi;
GOBJ().g_object_get(GTK().gtk_settings_get_default(), "gtk-xft-dpi", &xdpi, NULL);
int fontname = Font::ARIAL;
int fontheight = 13;
const char *q = strrchr(font_name, ' ');
if(q) {
int h = atoi(q);
if(h)
fontheight = h;
String face(font_name, q);
if(Font::FindFaceNameIndex(face) < 0)
if(ToUpper(face[0]) == 'M')
fontname = Font::COURIER;
else
if(ToUpper(face[0]) == 'S' && ToUpper(face[1]) == 'e')
fontname = Font::ROMAN;
}
Draw::SetStdFont(Font(fontname, (fontheight * xdpi) / (1024*72)));
ChLookFn(GtkLookFn);
I looked at the GDK docs, and that's the math there.
Incidentally, I fixed a allocation bug, which I noticed GTK complain about, when starting a sample app from a terminal.
The last line, is the fixed one:
ChSet("ScrollBarOverThumb", m != GetGTK(w, 0, 0, "slider", GTK_SLIDER|GTK_VAL1, 16, 32));
GTK().gtk_widget_destroy(w);
GTK().gtk_object_sink(adj);
Add to gtk.dli:
FN(void, gtk_object_sink, (G_obj *widget))
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 19:25:28 CEST 2025
Total time taken to generate the page: 0.01406 seconds
|