Font antialiasing on X (was: Re: Font Contrast)

2006-02-13 Thread Gus Koppel
MEA-Mike.Friedrichs wrote:

 This may be the wrong place, but since I have a question about Gnome, 
 which is built with GTK+, I may be in the right place.
 
 I have installed Novell's Suse 10.0 and having problems getting the 
 font to show their true colors and sharpness on the edges.
 
 When I pick the font color to be black on a white back ground, the 
 black always shows some gray tones, and ragged on the edges.  I've 
 tried as black as I am allowed but always ends up with gray tones.
 
 There must be some setting that allows me to get good clean black characters.
 
 By, the way I'm using *.ttf fonts.  I've also imported the fonts from 
 my XP machine, this was an recommendation, but not the solution.

This question is related to rather generic X-Windows behaviour and
neither to Gnome nor GTK+ nor application programming, indeed. For
instance, the same applies to QT-based applications (KDE). Anyway:

The font rendering effect you're referring to is called antialiasing.
It's meant to make fonts appear smoother on screen, especially at small
sizes or low screen resolutions, by using intermediate colours at the
edges. The same effect basically takes place on MS-Windows font
rendering and in nearly all modern 3D games, btw.

While this effect is considered an improvement of display quality by the
majority of users, some users may not like it or there may be some
situations (certain fonts at certain sizes) when antialiasing seems not
appropriate and may rather worsen the appearance.

Hence, the effect can be turned off. In X-Windows it's nowadays
controlled by the Xft + Fontconfig library. Unfortunately AFAIK there is
no way to thoroughly configure use of antialiasing via Gnome, so you
will likely have to edit the config file manually. The advantage of
doing so is, that you can not only turn on or off antialiasing entirely,
but also enable or disable it for particular fonts at particular sizes
and such stuff.

The file to edit should be /etc/fonts/font.conf. It's an XML file, so
you may need some basic knowledge about XML to understand it.
Unfortunately it has a rather complex (I'd say: bloated) structure, so
it may not be easy to understand. Anyway, you can turn off antialiasing
entirely by inserting a statement like this:

 match target=font
   edit name=antialias mode=assignboolfalse/bool/edit
 /match

For further information see also:

http://en.wikipedia.org/wiki/Font_rasterization
http://en.wikipedia.org/wiki/Antialias
http://www.fontconfig.org/fontconfig-user.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/x-fonts.html
http://keithp.com/~keithp/talks/xtc2001/paper/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Font antialiasing on X (was: Re: Font Contrast)

2006-02-13 Thread John Cupitt
On 2/13/06, Gus Koppel [EMAIL PROTECTED] wrote:
 Hence, the effect can be turned off. In X-Windows it's nowadays
 controlled by the Xft + Fontconfig library. Unfortunately AFAIK there is
 no way to thoroughly configure use of antialiasing via Gnome, so you
 will likely have to edit the config file manually.

GNOME does have some GUI for font rendering configuration: it might be
worth trying that (if you haven't) before attacking the XML config
files.

Click System / Preferences / Font, then try selecting Best contrast.
If you click Details ... you can change some more settings, such as
RGB order and hinting.

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Threads/IPC/???

2006-02-13 Thread Tristan Van Berkom

Ed Kutrzyba wrote:

I am developing an application that controls a Data  Collection
System.  I used glade and anjuta for my GUI and C backend control coding.
 My program works great, but I need to add some extra backround tasks:

1) I need to run a script (perl or bash) on demand without interfering
with my program.  i.e. the script runs in the background so GTK is still
responsive.


This should be what you're looking for:
http://developer.gnome.org/doc/API/2.0/glib/glib-Spawning-Processes.html#g-spawn-async


2) I need to spawn a task to perform some background operations.  i.e.
get time from an add in board, arm and disarm an interrupt routine that
time tags an external signal -- need to start and stop this on demand.


On linux, usually we implement hardware abstraction at the kernel
module level, so your interrupt handleing stuff should usually
not be in user-space; assuming this is all setup; you can interface
with a kernel driver's file desctiptor like any other; check
for read/write conditions with GIOChannel/GIOWatch.

Cheers,
  -Tristan
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Sockets with GTK 2.8.9 on WIN32

2006-02-13 Thread Gabriele Greco

Daniel Atallah wrote:

That is one of the changes that were made in Glib 2.8.x.  All of the
win32 GIOChannel stuff was changed such that it'll leave your sockets
in non-blocking mode.  See this bug report for more information: 
http://bugzilla.gnome.org/show_bug.cgi?id=147392
  
This seems very strange for me since glib 2.8 on Unix does not behave 
this way.


How can GTK be used as a multiplatform development system if it behave 
in different ways for the different platform it supports?

Basically, if you want your socket to be non-blocking, you have to
make it so in the input function every time it is triggered.
  
So I've to add something like this in my input function (error checking 
omitted):


#ifdef WIN32
   unsigned long par = 0;
   ioctlsocket(fd, FIONBIO, par);
#endif

This is quite ugly.

I thought that I had seen this in the documentation somewhere, but
apparently not.
  

I've not found anything related to GLIB 2.6 - 2.8 differences at least at:

http://www.gtk.org/api/

(incompatible differences seems related to 2.0 - 2.2 migration)

Bye,
Gabry


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Threads/IPC/???

2006-02-13 Thread Gus Koppel
Ed Kutrzyba wrote:

 I am developing an application that controls a Data  Collection
 System.  I used glade and anjuta for my GUI and C backend control coding.
   My program works great, but I need to add some extra backround tasks:
 
 1) I need to run a script (perl or bash) on demand without interfering
 with my program.  i.e. the script runs in the background so GTK is still
 responsive.

http://developer.gnome.org/doc/API/2.0/glib/glib-Spawning-Processes.html#g-spawn-async
 
 2) I need to spawn a task to perform some background operations.  i.e.
 get time from an add in board, arm and disarm an interrupt routine that
 time tags an external signal -- need to start and stop this on demand.
 
 What is the best way to do this?

http://developer.gnome.org/doc/API/2.0/glib/glib-Spawning-Processes.html#g-spawn-async-with-pipes

In general, see:
http://developer.gnome.org/doc/API/2.0/glib/glib-Spawning-Processes.html

 I have some code from the vendor to control the add in board, I just
 need to massage it to fit into my app, my way.

See also:
http://mail.gnome.org/archives/gtk-app-devel-list/2004-April/msg00171.html
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Sockets with GTK 2.8.9 on WIN32

2006-02-13 Thread Tor Lillqvist
Gabriele Greco writes:
  This seems very strange for me since glib 2.8 on Unix does not behave 
  this way.

Well, Windows isn't Unix, so is it really that surprising that some
things are fundamentally different?

With hindsight it's easy to say that the affected APIs and
abstractions in GLib should perhaps have been designed differently so
that any Unix/Windows differences could have been better hidden. But,
we have to make use of what we have now.

Actually, I think that the original thoughts were that the affected
GLib APIs (GPollFDs, GMainLoop, etc) could have been much more
platform specific. Owen says in bug #120299:

I don't think usage and contents of GPollFD needs to be or
should be portable across Win32/Unix, though changing how
it works is probably an API change on Win32.

My original conception was that GMainLoop would be significantly
different on different operating systems, though GPollFD *
crept into more of the API (g_main_context_query()) for
GTK+-2.x.

That many things then turned out to be implementable on Windows
without requiring ifdefs in GLib-using code was an unexpected positive
surprise. Or something like that...

  How can GTK be used as a multiplatform development system if it behave 
  in different ways for the different platform it supports?

You just have to take those things that behave differently into
account in your code.

Trust me, the implementation of watched GIOChannels for sockets on
Windows in GLib before 2.8 had a wholly different and more serious set
of problems and Unix/Windows differences. Those caused a lot of
problems when porting various GNOME platform libraries to Windows. See
discussion for instance in bugs #120299 and #147392. In the old
implementation there was a separate thread running per watched socket.

  So I've to add something like this in my input function (error checking 
  omitted):

  #ifdef WIN32
  unsigned long par = 0;
  ioctlsocket(fd, FIONBIO, par);
  #endif

Actually I don't think that will work. As long as a socket is being
watched (it has an event selection for it (WSAEventSelect()) in force)
you cannot turn the non-blockingness off.

Anyway, as you use GLib mainloop functionality and watched GIOchannels
in the first place, isn't your intention to avoid blocking calls in
your code? You perhaps want to handle reading requests from and
sending replies to multiple sockets in parallel with minimum delay?
Otherwise you could just use blocking recv() and send() all the time
without bothering with GIOChannels and GMainLoops, couldn't you?

So shouldn't you be using non-blocking mode on Unix, too, then? Aren't
you otherwise just knowing your recv()/send() calls won't block
(because they never do in your test environment), and when they then
occasionally *do* block, perhaps indefinitely, in the end-user
environment, you are in trouble?

  I've not found anything related to GLIB 2.6 - 2.8 differences at least at:
  
  http://www.gtk.org/api/

Yeah, the documentation needs to have a mention about it added.

--tml

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


gtk+ application on Cygwin for Windows

2006-02-13 Thread Deepak Thukral
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi guys,

I am developing an GTK2+ application on cygwin for win32. Lets us
not discuss about the code as its complied sucessfully.

1. I used -mms-bitfields
2. I used -mno-cygwin
3. All packages has been installed on cygwin, i am using `pkg-
config --cflags --libs gtk+-2.0`

- -L/usr/X11R6/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-
2.0 -lpangoxft-1.0 -lXft -lfreetype -lz -lXrender -lXext -
lfontconfig -lpangox-1.0 -lX11 -lpango-1.0 -lm -lgobject-2.0 -
lgmodule-2.0 -lglib-2.0 -lintl -liconv

Code has complied sucessfully, but when i am trying to execute this
file .. i am getting a Sorry for incon. windows has encountered
unknow error.

AppName: gtkapp.exe  AppVer: 0.0.0.0 ModName: cygwin1.dll
ModVer: 1005.19.0.0  Offset: 000136eb

This application is working fine with X-Server on Cygwin. Any Help
from your guys are appericiated.

Ciao


- 
Regards,
Deepak Thukral
http://niecdelhi.com/~deepak/
-BEGIN PGP SIGNATURE-
Note: This signature can be verified at https://www.hushtools.com/verify
Version: Hush 2.4

wkYEARECAAYFAkPvNjQACgkQndbxsd4OgL/bwQCfUcRZidVoINr5LrQT8h575JNpY48A
n0Xowq3TfFEnyMIj04rahFPZtfJn
=d/Kl
-END PGP SIGNATURE-




Concerned about your privacy? Instantly send FREE secure email, no account 
required
http://www.hushmail.com/send?l=480

Get the best prices on SSL certificates from Hushmail
https://www.hushssl.com?l=485

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Refreshing gtk window without any mouse/keyboard intervention

2006-02-13 Thread Nisha P Kurur


Hi,

We are trying to create a gtk application which should run without much of 
manual intervention. Few buttons are placed in a row and each button has 
an image at the top which changes to red on selection. This image changes 
to green when the button goes out of selection. So the whole process has 
to be done in a scan mode without any manual intervention.


The problem with our code (attached with this mail) is that the events are 
generated and the callback functions are called. But the window is not 
refreshed properly. The window gets updated only when there is any

mouse/keyboard movement.

Thanks in Advance,

Regards
Nisha
---
Nisha P Kurur
DON Lab (BSB 328)
Dept. of CSE
IITM, Chennai - 36
Phone (044) 2257 5364/9804/9853
--#include common.h

GtkWidget *window;
GtkWidget *table;
GtkWidget *button[9];
GtkWidget *image_enable[9];

static void button_pressed_callback(GtkWidget *widget, GdkEvent *event, 
gpointer image);
static void button_released_callback(GtkWidget *widget, GdkEvent *event, 
gpointer image);
void button_selection();

/* Create a new hbox with an image and a label packed into it
 * and return the box. */

static GtkWidget *xpm_label_box(gchar *label_text,  gchar *xpm_filename)
{
GtkWidget *box;
GtkWidget *label;
GtkWidget *image;

/* Create box for image and label */
box = gtk_vbox_new (FALSE, 0);

gtk_container_set_border_width (GTK_CONTAINER (box), 2);

/* Now on to the image stuff */
image = gtk_image_new_from_file (xpm_filename);

/* Create a label for the button */
label = gtk_label_new (label_text);

/* Pack the image and label into the box */
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);

gtk_widget_show (label);
gtk_widget_show (image);

return box;
}

/*
static void hiding_showing_images(GtkWidget *widget, gint index)
{
GtkWidget *image;
//  guint index = (guint *)img;
g_print(INDEX = %d, FLAG = %d \n,index ,flag);
if(flag == 1)
{
g_print(INSIDE LEAVE\n);
gtk_widget_hide(image_enable[index-1]);
image = gtk_image_new_from_file(radio_green.jpg);
gtk_table_attach_defaults (GTK_TABLE (table), image, index-1, 
index, 0, 1);
gtk_widget_show (image);
image_enable[index-1] = image;
flag = 0;
}
else
{
g_print(INSIDE ENTER\n);
gtk_widget_hide(image_enable[index-1]);
image = gtk_image_new_from_file(radio_red.jpg);
gtk_table_attach_defaults (GTK_TABLE (table), image, index-1, 
index, 0, 1);
gtk_widget_show (image);
image_enable[index-1] = image;
flag = 1;
}
}
*/

/* Callback method */

static void button_released_callback(GtkWidget *widget, GdkEvent *event, 
gpointer img)
{
GtkWidget *image;
guint index = (guint *)img;
g_print(INSIDE LEAVE\n);
gtk_widget_hide(image_enable[index-1]);
image = gtk_image_new_from_file(radio_green.jpg);
gtk_table_attach_defaults (GTK_TABLE (table), image, index-1, index, 0, 
1);
gtk_widget_show (image);
image_enable[index-1] = image;
}
static void button_pressed_callback(GtkWidget *widget, GdkEvent *event, 
gpointer img)
{
GtkWidget *image;
guint index = (guint *)img;
g_print(INSIDE ENTER\n);
gtk_widget_hide(image_enable[index-1]);
image = gtk_image_new_from_file(radio_red.jpg);
gtk_table_attach_defaults (GTK_TABLE (table), image, index-1, index, 0, 
1);
gtk_widget_show (image);
image_enable[index-1] = image;
}

static GtkWidget *create_button(guint index)
{
GtkWidget *box;
GtkWidget *button;
GtkWidget *image;

image = gtk_image_new_from_file(radio_green.jpg);
button = gtk_button_new();
switch(index)
{
case 1: 
 {
  box = xpm_label_box(   ABC   , soccer.gif);
  gtk_container_add (GTK_CONTAINER (button), box);
  gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 1, 2);
  gtk_table_attach_defaults (GTK_TABLE (table), image, 0, 1, 0, 1);
  image_enable[0] = image;
  g_signal_connect(G_OBJECT(button), button_press_event,
   G_CALLBACK (button_pressed_callback), (gpointer)index);
  g_signal_connect(G_OBJECT(button), button_release_event,
   G_CALLBACK(button_released_callback), (gpointer)index);

  break;
}
case 2:
{
  box = xpm_label_box(   DEF   , soccer.gif);
  gtk_container_add (GTK_CONTAINER (button), box);

GdkEventClient? How can I get client messages from X?

2006-02-13 Thread Andrew Shafer

Is there an event mask or something that needs to be set to get client
messages from the X server?

I'm trying to get client messages from X with the Atom
_NET_STARTUP_INFO.

I tried registering a filter with gdk_add_client_message_filter:

gdk_add_client_message_filter(gdk_atom_intern(_NET_STARTUP_INFO,FALSE),
 my_filter_func,
 NULL);

I can see the filter get added to the display, and I can see the message
broadcast using xmon or the libstartup-notification
test-watch-xmessages, but I never get into the callback.

Any direction or insight would be greatly appreciated. . .

Regards


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Refreshing gtk window without any mouse/keyboard intervention

2006-02-13 Thread Gus Koppel
Nisha P Kurur wrote:

 We are trying to create a gtk application which should run without much of 
 manual intervention. Few buttons are placed in a row and each button has 
 an image at the top which changes to red on selection. This image changes 
 to green when the button goes out of selection. So the whole process has 
 to be done in a scan mode without any manual intervention.
 
 The problem with our code (attached with this mail) is that the events are 
 generated and the callback functions are called. But the window is not 
 refreshed properly. The window gets updated only when there is any
 mouse/keyboard movement.

1. using the sleep() function in a GUI application is very bad
   programming style by all means, even if taking place in a custom
   thread. It's a relict of shell programming. You should rather use
   gtk_timeout_add() or g_timeout_add(). Probably you can even do without
   multiple threads then, which may avoid some hard to find bugs in the
   future and makes debugging much easier. See:

http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-timeout-add
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-timeout-add

2. you have to make sure that GTK+ can pass through its main loop for
   changes to be drawn. In a single-threaded application this would
   have to happen after your g_signal_emit_by_name() calls. See:

http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-main-iteration-do

3. you probably know that the switch-case tree of your example is  
   bloated, i.e. contains much redundancy which could (and probably
   should) be avoided. Of 7 statements, 3 are completely identical
   and the other ones could be unified by simply using your index
   variable instead of distinct constants to pass to the respective
   functions. Add a little list of const strings for the xpm_label_box()
   call and you can do completely without a switch-case, that is, with
   only 1 instead of 9 blocks of that code.

Golden rule of programming: _never_ use the copy  paste feature of your
text editor for more than three or four lines of code, especially not
multiple times! Write sub functions (or in this case: just restructure a
code block) instead.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk+ application on Cygwin for Windows

2006-02-13 Thread Tor Lillqvist
Deepak Thukral writes:
  I am developing an GTK2+ application on cygwin for win32.

You mean you don't want the application to use Cygwin? OK.

  2. I used -mno-cygwin

Yep.

  3. All packages has been installed on cygwin,

Bad move. What you have installed is apparently a Cygwin/X11 build of
GTK+.

  - -L/usr/X11R6/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-
  2.0 -lpangoxft-1.0 -lXft -lfreetype -lz -lXrender -lXext -
  lfontconfig -lpangox-1.0 -lX11 -lpango-1.0 -lm -lgobject-2.0 -
  lgmodule-2.0 -lglib-2.0 -lintl -liconv

As you see above, you are linking with the Cygwin GTK for X11, and
various Cygwin X libraries. This is very contradictory with using
-mno-cygwin.

  This application is working fine with X-Server on Cygwin. Any Help
  from your guys are appericiated.

You need to install the GTK+, Pango, atk and GLib developer and
run-time packages for Win32. Go to ftp://ftp.gtk.org/pub/gtk/v2.8/win32/ .
Remember to get the dependencies, too.

The .pc files included in the above packages are supposed to be used
with the Win32 port of pkg-config, which automatically translates the
prefix usd in a .pc file into the one where the package that includes
the .pc file is installed. (For this to work you should not move .pc
files out from where they are after unzipping. Instead, set up a
PKG_CONFIG_PATH if necessary.) If you use them with the Cygwin
pkg-config, you will have to manually edit them so the prefix matches
the path where you installed the packages.

--tml

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list