splash window

2004-03-03 Thread francex
Hi,

when splash screen is made by this code:

***

GtkWidget *splash_window;
GtkWidget *vbox;
static struct timespec const req = { 1, 0};

splash_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position (GTK_WINDOW (splash_window), GTK_WIN_POS_CENTER);

vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(splash_window), vbox);
gtk_widget_show(vbox);

gtk_widget_realize(splash_window);
gdk_window_set_decorations(splash_window-window, 0);
{
GdkPixbuf* pixbuf;
GtkWidget *image;

pixbuf = gdk_pixbuf_new_from_file(image_file_path,NULL);
image = gtk_image_new_from_pixbuf(pixbuf);

gtk_container_add(GTK_CONTAINER(vbox), image);
gtk_widget_realize(image);
g_object_unref(pixbuf);

gtk_widget_show(image);
}

gtk_widget_show(splash_window);
gdk_window_process_updates(splash_window-window, TRUE);

while(g_main_context_pending(NULL))
  g_main_context_iteration (NULL, TRUE);

nanosleep(req, NULL);

/* other code */
do_anything();

gtk_widget_destroy(splash_window);

***

I got a grey box at center of the screen. If I restart program quickly,
image is loaded correctly. Why?
(I have noticed that with or without gdk_window_process_updates(splash_window-window,
TRUE); I got same effect)
(code above it's found on gnome mail archive)

Thanks
Francesco

__
Tiscali ADSL SENZA CANONE:
Attivazione GRATIS, contributo adesione GRATIS, modem GRATIS,
50 ore di navigazione GRATIS.  ABBONARTI TI COSTA SOLO UN CLICK!
http://point.tiscali.it/adsl/index.shtml



___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: What DWI does [was Re: GnuCash page on GO site]

2004-03-03 Thread Rodrigo Moya
On Wed, 2004-03-03 at 09:45 -0600, Linas Vepstas wrote:
 
 Suppose I approached the glib gobject folks, and told them that
 they should merge gobjects with libgda.

this does not make any sense. There is really no need for that. If you
want to add extensible stuff to GObjects, you can define generic
interfaces or classes, and then have them implemented somewhere else,
like in libgda, qof, etc

 
 Its possible that maybe I could use libgda for this instead;
 however, I'm concerned that gnucash uses a number of fancy
 constructs, and so it would be impossible without hacking 
 the guts of libgda.  Worse, these hacks might not be accepted
 as patches by the libgda developers.

well, if they are ugly hacks, of course they won't be accepted. If, on
the contrary, are well thought and designed solutions, they will be
accepted immediately.

cheers

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


How to set background/foreground on button, entry, or label?

2004-03-03 Thread Tony Denault
Hi All,

After doing some research and hacking, I wrote some code to set the
foreground / backgroud color of a button, entry,  label. This is still a
confusing part of GTK 2.x., an internet search on this question resulted
in lots of partial answers, vague description on how it should work,
but no clear answer that work across all widgets.

I am posting this code to:
  1. Provide a working example on how I did it.
  2. Maybe the experts can improve on it, or show better methods.
  3. Maybe it (or an improved version) can be put in the faq.

There are still some problems:

1. The Entry widget's cursor doesn'tt change with the 'Text' color. In
   my example, the bg color  cursor is black = invisible cursor!

2. Different widgets use different properites in the style. I still
   don't understand the numberous style-fd, bg, light, dark, mid, text, base.

3. Tried using gtk_widget_modify_fg()/gtk_widget_modify_bg(), but
   never could get them to work on all widgets. So I used
   MyStyleSetItemColor() - a function from my 1.2x code.

code is below my .signature.

Tony

/---\
| Tony Denault | Email: [EMAIL PROTECTED] |
| Institute for Astronomy  |  Phone: (808) 932-2378 |
| 640 North Aohoku Place   |Fax: (808) 933-0737 |
| Hilo, Hawaii 96720   ||
\---/

#include gtk/gtk.h

void MyStyleSetItemColor( GdkColor color, char item, GtkStyle * style);

int main (int argc, char *argv[])
{
   GtkWidget * base,
 * table,
 * entry,
 * button,
 * label,
 * ebox;

   GtkStyle * style_default,
* style_entry_YB,
* style_button_YB;
   GdkColor black = { 0, 0, 0, 0 } ,   // should use gdk_colormap_alloc_color()
yellow = {0, 65535, 65535, 0 };

   gtk_init(argc, argv);

   /* define some styles to apply to my widgets */
   style_default = gtk_widget_get_default_style();

   /* this style works for entry */
   style_entry_YB  = gtk_style_copy( style_default );
   MyStyleSetItemColor( black,   's', style_entry_YB);  // s=base (entry,bg)
   MyStyleSetItemColor( yellow,  't', style_entry_YB ); // t=Text (entry,fg)

   /* this style works for buttons */
   style_button_YB  = gtk_style_copy( style_default );
   MyStyleSetItemColor( black,  'b', style_button_YB );  // b=bg (button,bg)
   MyStyleSetItemColor( yellow, 'f', style_button_YB ); // f=fg (button,fg)

   base = gtk_window_new( GTK_WINDOW_TOPLEVEL );
   table = gtk_table_new( 1, 5, TRUE );
   gtk_container_add (GTK_CONTAINER (base), table);

   /* button - using style_button_YB */
   button = gtk_button_new_with_label( button);
   gtk_widget_set_style(GTK_BIN (button)-child, style_button_YB);
   gtk_widget_set_style(button, style_button_YB);
   gtk_table_attach_defaults (GTK_TABLE(table), button, 0, 1, 0, 1);
   gtk_widget_show(button);

   /* entry - using style_entry_YB */
   entry = gtk_entry_new( );
   gtk_entry_set_text( GTK_ENTRY(entry), Entry);
   gtk_entry_set_width_chars( GTK_ENTRY(entry), 5);
   gtk_table_attach_defaults (GTK_TABLE(table), entry, 2, 3, 0, 1);
   gtk_widget_set_style(entry, style_entry_YB);
   gtk_widget_show(entry);

   /* label w/ event box for backgroud color */
   ebox = gtk_event_box_new();
   label = gtk_label_new(label );
   gtk_container_add( GTK_CONTAINER(ebox), label );
   gtk_widget_set_style( label, style_button_YB);   // change label fg color
   gtk_widget_set_style( ebox, style_button_YB);// bg color provided by ebox
   gtk_table_attach_defaults (GTK_TABLE(table), ebox, 4, 5, 0, 1);
   gtk_widget_show(label);
   gtk_widget_show(ebox);

   gtk_widget_show(table);
   gtk_widget_show( base );
   gtk_main ();
   return 0;
}

/*---
**  MyStyleSetItemColor() - Helper function to change a style.
**---
*/
void MyStyleSetItemColor(
   GdkColor   color,/* The allocated color to be added to the style */
   char   item, /* the item to which the color is to be applied */
/* 'f' = foreground; 'b' = background; */
/* 'l' = light;  'd' = dark; */
/* 'm' = mid;'t' = text; */
/* 's' = base.  */
   GtkStyle * style /* The old style - changes made to a copy */
)
{
   int i;
   switch ( item )
   {
  case 'f':
  case 'F':
 for ( i = 0; i  5; i++ )
style-fg[i] = color;
 break;
  case 'b':
  case 'B':
 for ( i = 0; i  5; i++ )
style-bg[i] = color;
 break;
  case 'l':
  case 'L':
 for ( i = 0; i  5; i++ )
style-light[i] = color;
 break;
  case 'd':