U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » GTK theming a reality
GTK theming a reality [message #6742] Sun, 26 November 2006 01:20 Go to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
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
Re: GTK theming a reality [message #6764 is a reply to message #6742] Sun, 26 November 2006 18:30 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
great work, Mirek!

it realy looks much better!

Bas
Re: GTK theming a reality [message #6766 is a reply to message #6764] Sun, 26 November 2006 21:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
ScrollBar theming ("chameleonization") in GTK is now finished as well.

We really start to look native Smile

Mirek
Re: GTK theming a reality [message #6769 is a reply to message #6766] Sun, 26 November 2006 22:01 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Hi,

we have the problem of upper and lower case includes once again.
Had to change include definitions of DLIHEADER from draw/*.dli to Draw/*.dli in Draw.h and DrawX11.cpp since my directory is uppercase.

Matthias
Re: GTK theming a reality [message #6771 is a reply to message #6769] Sun, 26 November 2006 22:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Sorry, already fixed... (I hope).

I know this is stupid problem, but for me it is very convenient (almost the only possibility) to share the disk partition with sources between Win and Linux.

Mirek
Re: GTK theming a reality [message #6772 is a reply to message #6769] Sun, 26 November 2006 22:20 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
No problm, if all problems would have been so simple to solve Smile.

Another problem is missing implementation of CtrlFrame::OverPaint.
I simply copied Ctrl::OverPaint (which seems to basically be a placeholder) and it worked.
But after starting new ide, I get DLL not found, investigating ...

Matthias


931b81e7ea53320dccc37375b34b38c3
Re: GTK theming a reality [message #6774 is a reply to message #6772] Sun, 26 November 2006 23:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Already fixed, just sync new version. A lot was done today.

Mirek
Re: GTK theming a reality [message #6775 is a reply to message #6772] Sun, 26 November 2006 23:27 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
masu wrote on Sun, 26 November 2006 22:20

But after starting new ide, I get DLL not found, investigating ...

I did not activate "use shared libs" for building Rolling Eyes .

Matthias
Re: GTK theming a reality [message #6791 is a reply to message #6775] Tue, 28 November 2006 13:56 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
I noticed in "Output mode ..." that three-state checkbox is also missing from within GTK.
Are you going to emulate it somehow like in Win?

Matthias
Re: GTK theming a reality [message #6813 is a reply to message #6742] Wed, 29 November 2006 11:47 Go to previous messageGo to next message
guido is currently offline  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? Cool

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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
guido wrote on Wed, 29 November 2006 05:47



Congratulations!

Already working on icon theming? Cool



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 Go to previous messageGo to next message
guido is currently offline  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 #6827 is a reply to message #6826] Wed, 29 November 2006 20:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Will you try? I think should be relatively easy (CtrlLib/ChGtk.cpp)

Mirek
Re: GTK theming a reality [message #6830 is a reply to message #6827] Thu, 30 November 2006 20:52 Go to previous messageGo to next message
guido is currently offline  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 #6831 is a reply to message #6830] Thu, 30 November 2006 20:58 Go to previous messageGo to next message
guido is currently offline  guido
Messages: 169
Registered: April 2006
Experienced Member
Addendum:

Should better be

int xdpi = 96*1024;


I suppose.

Guido
Re: GTK theming a reality [message #6833 is a reply to message #6831] Thu, 30 November 2006 21:04 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
guido wrote on Thu, 30 November 2006 20:58

Addendum:

Should better be

int xdpi = 96*1024;


I suppose.

Guido

Why?
My dpi setting is 75, so this would not work.
Your first solution seems to be right.

Matthias
Re: GTK theming a reality [message #6835 is a reply to message #6833] Thu, 30 November 2006 21:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
masu wrote on Thu, 30 November 2006 15:04

guido wrote on Thu, 30 November 2006 20:58

Addendum:

Should better be

int xdpi = 96*1024;


I suppose.

Guido

Why?
My dpi setting is 75, so this would not work.
Your first solution seems to be right.

Matthias


I think Guido just assigns a default value so it does not crash if retrieval from gtk fails.

Mirek
Re: GTK theming a reality [message #6836 is a reply to message #6833] Thu, 30 November 2006 21:27 Go to previous messageGo to next message
guido is currently offline  guido
Messages: 169
Registered: April 2006
Experienced Member
masu wrote on Thu, 30 November 2006 21:04

guido wrote on Thu, 30 November 2006 20:58

Addendum:

Should better be

int xdpi = 96*1024;


I suppose.

Guido

Why?
My dpi setting is 75, so this would not work.
Your first solution seems to be right.

Matthias


Only used as default, in case Gtk doesn't return a dpi value (although I doubt that can happen). 96dpi is the GTK default anyway, according to the docs, and Mirek used it as default too.

Guido
Re: GTK theming a reality [message #6837 is a reply to message #6835] Thu, 30 November 2006 21:29 Go to previous messageGo to next message
guido is currently offline  guido
Messages: 169
Registered: April 2006
Experienced Member
Mirek beat me to it Very Happy
Watching UEFA-Cup, that's my excuse Cool

Guido
Re: GTK theming a reality [message #6838 is a reply to message #6837] Thu, 30 November 2006 21:37 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Yes, now I see it Rolling Eyes .
By the way, thanks Guido for fixing the other problem Smile .

Matthias
Re: GTK theming a reality [message #6839 is a reply to message #6838] Thu, 30 November 2006 21:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
(now in uppsrc, thanks guido).

Mirek
Re: GTK theming a reality [message #6840 is a reply to message #6839] Thu, 30 November 2006 21:58 Go to previous messageGo to next message
mirek is currently offline  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 Go to previous messageGo to next message
masu is currently offline  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 #6842 is a reply to message #6841] Thu, 30 November 2006 22:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
As I am basically redefining the whole interface in U++/.dli and I am using it in just single .cpp file, I have simplified it by "merging" all GTK/GDK/GOBJ pointer types into single one - G_obj (defined in U++).

Mirek
Re: GTK theming a reality [message #6843 is a reply to message #6841] Thu, 30 November 2006 22:54 Go to previous messageGo to next message
mirek is currently offline  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 #6844 is a reply to message #6843] Thu, 30 November 2006 23:07 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
luzr wrote on Thu, 30 November 2006 22:54

Afaik, GdkPixbuf is not drawable...

Mirek

Yes, you are right, as usual Wink.

Matthias
Re: GTK theming a reality [message #6871 is a reply to message #6830] Sat, 02 December 2006 10:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
When I set the font size to "8", the font is different in U++ and Ubuntu. Therefore I tried to alter the code to

	Draw::SetStdFont(Font(fontname, (fontheight * xdpi + 512*72) / (1024*72)));



(rounding the value). This seems to work OK for me, please check with your platforms...

Mirek
Re: GTK theming a reality [message #6878 is a reply to message #6871] Sun, 03 December 2006 00:16 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
This is ok for on my system Smile .
BTW, what was the problem with the pixbuf.

Edit: Size is ok, but I always get default font Arial.

Matthias

[Updated on: Sun, 03 December 2006 00:30]

Report message to a moderator

Re: GTK theming a reality [message #6883 is a reply to message #6878] Sun, 03 December 2006 12:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
masu wrote on Sat, 02 December 2006 18:16


BTW, what was the problem with the pixbuf.



"prototype" widget was set into "insensitive" state for some reason (most likely as result of fact that our hacking of GTK to make it display things for us is really very fragile). Therefore it returned "insensitive" map.

Quote:


Edit: Size is ok, but I always get default font Arial.



What font have you set? (Just name).

Mirek
Re: GTK theming a reality [message #6887 is a reply to message #6883] Sun, 03 December 2006 15:17 Go to previous messageGo to next message
masu is currently offline  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
Re: GTK theming a reality [message #6890 is a reply to message #6887] Sun, 03 December 2006 16:37 Go to previous messageGo to next message
guido is currently offline  guido
Messages: 169
Registered: April 2006
Experienced Member
masu wrote on Sun, 03 December 2006 15:17

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


Indeed, going DejaVu Sans -> DejaVu Serif for the GTK default font has no effect on upp apps Confused

Guido
Re: GTK theming a reality [message #6950 is a reply to message #6890] Tue, 05 December 2006 19:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Font name issue fixed.

Mirek
Re: GTK theming a reality [message #6952 is a reply to message #6950] Tue, 05 December 2006 20:48 Go to previous messageGo to next message
iplayfast is currently offline  iplayfast
Messages: 47
Registered: February 2006
Member
In Draw/Draw.h there are some case sensitive issues for Linux compiles.

#define DLIMODULE GTK
#define DLIHEADER <draw/gtk.dli>
#include <Core/dli_header.h>

#define DLIMODULE GDK
#define DLIHEADER <draw/gdk.dli>
#include <Core/dli_header.h>

#define DLIMODULE GOBJ
#define DLIHEADER <draw/gobj.dli>
#include <Core/dli_header.h>


should be

#define DLIMODULE GTK
#define DLIHEADER <Draw/gtk.dli>
#include <Core/dli_header.h>

#define DLIMODULE GDK
#define DLIHEADER <Draw/gdk.dli>
#include <Core/dli_header.h>

#define DLIMODULE GOBJ
#define DLIHEADER <Draw/gobj.dli>
#include <Core/dli_header.h>
Re: GTK theming a reality [message #6953 is a reply to message #6952] Tue, 05 December 2006 21:27 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
This should have already been resolved.
Please see prior posts

http://www.arilect.com/upp/forum/index.php?t=msg&&th =1707&goto=6769#msg_6769
and
http://www.arilect.com/upp/forum/index.php?t=msg&&th =1707&goto=6771#msg_6771

Matthias
Re: GTK theming a reality [message #6954 is a reply to message #6953] Tue, 05 December 2006 21:37 Go to previous messageGo to next message
iplayfast is currently offline  iplayfast
Messages: 47
Registered: February 2006
Member
Well I downloaded last night from the dupp-developent 611-dev4 (from Nov 27) and this was the problem I ran into. It's easy to check for yourself.
Re: GTK theming a reality [message #6956 is a reply to message #6954] Tue, 05 December 2006 21:58 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
I see, then it was overlapped action.
At least the uvs version is fixed Smile.

Matthias
Re: GTK theming a reality [message #6997 is a reply to message #6950] Wed, 06 December 2006 23:02 Go to previous message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
luzr wrote on Tue, 05 December 2006 19:56

Font name issue fixed.

Thanks, looks very nice, now Very Happy .

Matthias
Previous Topic: TrayIcon Win32 fixed some misbehaviour....
Next Topic: New Vector optimization reduces Linux executable size by 0.8%
Goto Forum:
  


Current Time: Sat Apr 25 17:51:49 GMT+2 2026

Total time taken to generate the page: 0.01458 seconds