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: 14290 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))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: GTK theming a reality [message #6840 is a reply to message #6839] |
Thu, 30 November 2006 21:58   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
BTW, I am just trying to get icons, but there is strange problem:
I am getting only the sort of alpha channel (no colors and perhaps that alpha is one of channels).
Code fragments used are:
ImageDraw iw(cx + 2 * margin, cy + 2 * margin);
iw.DrawRect(0, 0, cx + 2 * margin, cy + 2 * margin, back);
static G_obj *cm = GDK().gdk_x11_colormap_foreign_new(
GDK().gdkx_visual_get(XVisualIDFromVisual(Xvisual)), Xcolormap);
G_obj *gw = GDK().gdk_pixmap_foreign_new(iw.GetDrawable());
GDK().gdk_drawable_set_colormap(gw, cm);
(above is common for painting widget elements too, so there most likely is not problem).
G_obj *b = GTK().gtk_widget_render_icon(widget, detail, state, NULL);
GDK().gdk_draw_pixbuf(gw, NULL, b, 0, 0, 0, 0, -1, -1, shadow, 0, 0);
GOBJ().g_object_unref(b);
(I am iterating state and shadow using several values to investigate the issue, all of them are just alphas...)
Any ideas?
Mirek
|
|
|
|
| Re: GTK theming a reality [message #6841 is a reply to message #6840] |
Thu, 30 November 2006 22:45   |
masu
Messages: 378 Registered: February 2006
|
Senior Member |
|
|
| luzr wrote on Thu, 30 November 2006 21:58 |
G_obj *b = GTK().gtk_widget_render_icon(widget, detail, state, NULL);
GDK().gdk_draw_pixbuf(gw, NULL, b, 0, 0, 0, 0, -1, -1, shadow, 0, 0);
GOBJ().g_object_unref(b);
|
Looking into the API docs, it should be:
GdkPixbuf *b = GTK().gtk_widget_render_icon(widget, detail, state, NULL);
GDK().gdk_draw_pixbuf(gw, NULL, b, 0, 0, 0, 0, -1, -1, shadow, 0, 0);
GOBJ().g_object_unref(b);
and widget has to be != NULL, but I think this is the case. Otherwise one should call gdk_drawable_set_colormap() on b again.
Matthias
|
|
|
|
|
|
| Re: GTK theming a reality [message #6843 is a reply to message #6841] |
Thu, 30 November 2006 22:54   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
| masu wrote on Thu, 30 November 2006 16:45 |
| luzr wrote on Thu, 30 November 2006 21:58 |
G_obj *b = GTK().gtk_widget_render_icon(widget, detail, state, NULL);
GDK().gdk_draw_pixbuf(gw, NULL, b, 0, 0, 0, 0, -1, -1, shadow, 0, 0);
GOBJ().g_object_unref(b);
|
Looking into the API docs, it should be:
GdkPixbuf *b = GTK().gtk_widget_render_icon(widget, detail, state, NULL);
GDK().gdk_draw_pixbuf(gw, NULL, b, 0, 0, 0, 0, -1, -1, shadow, 0, 0);
GOBJ().g_object_unref(b);
Otherwise one should call gdk_drawable_set_colormap() on b again.
Matthias
|
Afaik, GdkPixbuf is not drawable...
Mirek
|
|
|
|
|
|
|
|
|
|
|
|
| Re: GTK theming a reality [message #6887 is a reply to message #6883] |
Sun, 03 December 2006 15:17   |
masu
Messages: 378 Registered: February 2006
|
Senior Member |
|
|
| luzr wrote on Sun, 03 December 2006 12:44 | What font have you set? (Just name).
|
It is simply called "Sans", but it does matter what font I choose, it is always Arial in theIDE even after restarting theIDE.
Matthias
931b81e7ea53320dccc37375b34b38c3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 25 12:57:51 GMT+2 2026
Total time taken to generate the page: 0.00872 seconds
|