[glade--]HELP ME!!!

MIGUELMMC <[email protected]>
Newsgroups gmane.comp.gnome.glademm
Message-ID <[email protected]>
Hello.

I need help.

I am trying to paint images with create_from_xpm_data and
Gtk::Image::set..., but the window is not refreshing (like
Update_Data(true or false) in MS-Windows) under these circumstances:

If //pixmap1->set(brkpt) window refreshes good.
If pixmap1->set(brkpt):
     If usleep(x) -> x is > 500000 more or less: good
     If usleep(x) -> x is < 500000 or another value small: Freezed!

What is wrong?
Thanks in advance.

Here is the code:
(sorry, a lot of lines :( )

----------------------------------------------------------------------
Makefile:

all: project.o window1.o window1_glade.o
	g++ -g -o project project.o window1.o window1_glade.o `pkg-config
--libs gtkmm-2.0 gthread-2.0`

project.o: project.cc
	g++ -g -c project.cc `pkg-config --cflags gtkmm-2.0 gthread-2.0`

window1.o: window1.cc
	g++ -g -c window1.cc `pkg-config --cflags gtkmm-2.0 gthread-2.0`

window1_glade.o: window1_glade.cc
	g++ -c window1_glade.cc `pkg-config --cflags gtkmm-2.0`

clean:
	rm -f *.o
	rm -f project

----------------------------------------------------------------------
project.cc:

// generated 2003/2/23 19:38:41 CET by miguel@linux.
// using glademm V1.1.3b
//
// newer (non customized) versions of this file go to proyecto3.cc_new

// This file is for your program, I won't touch it again!

#include <gtkmm/main.h>

#include "window1.hh"

int main(int argc, char **argv)
{  
   
   Gtk::Main m(&argc, &argv);
	Glib::thread_init();

window1 *window1 = new class window1();
   m.run(*window1);
delete window1;
   return 0;
}

----------------------------------------------------------------------
window1.cc

// generated 2003/2/23 19:38:41 CET by miguel@linux.
// using glademm V1.1.3b
//
// newer (non customized) versions of this file go to window1.cc_new

// This file is for your program, I won't touch it again!

#include "window1.hh"
#include <stdio.h>
#include <unistd.h>
#include <sigc++/class_slot.h>

window1::window1() : counter(0)
{
	brkpt = Gdk::Pixbuf::create_from_xpm_data(brkpt_xpm);
	led_red = Gdk::Pixbuf::create_from_xpm_data(bitmap_r_xpm);

	Glib::Thread *const the_thread =
Glib::Thread::create(SigC::slot_class(*this,&window1::thread),false);
}

void window1::on_togglebutton1_toggled()
{
	char text[10];

	sprintf(text,"%d",counter);
	entry1->set_text(text);
	counter++;
	if(counter%2)
		pixmap1->set(brkpt);
	else
		pixmap1->set(led_red);
}

void window1::thread()
{
	char text[10];

	while(1)
	{
		sprintf(text,"%d",counter);
		printf("Counter: %d\n",counter);
		counter++;
		usleep(50000);
		entry1->set_text(text);
		//pixmap1->set(brkpt);

		/*if(counter%2)
			pixmap1->set(brkpt);
		else
			pixmap1->set(led_red);
		*/
	}	
}

----------------------------------------------------------------------
window1.hh

// generated 2003/2/23 19:38:41 CET by miguel@linux.
// using glademm V1.1.3b
//
// newer (non customized) versions of this file go to window1.hh_new

// you might replace
//    class foo : public foo_glade { ... };
// by
//    typedef foo_glade foo;
// if you didn't make any modifications to the widget

#ifndef _WINDOW1_HH
#  include "window1_glade.hh"
#  define _WINDOW1_HH

#include "../pixmaps/brkpt.xpm"
#include "../pixmaps/bitmap_r.xpm"

class window1 : public window1_glade
{  
	Glib::RefPtr<Gdk::Pixbuf> brkpt;
	Glib::RefPtr<Gdk::Pixbuf> led_red;

	int counter;

        void on_togglebutton1_toggled();

	public:
		window1();
		void thread();
};
#endif


----------------------------------------------------------------------
window1_glade.cc

// generated 2003/2/23 19:38:41 CET by miguel@linux.
// using glademm V1.1.3b
//
// DO NOT EDIT THIS FILE ! It was created using
// glade-- --gtkmmversion 2.1.3 proyecto3.glade
// for gtk 1.2.10 and gtkmm 2.1.3
//
// Please modify the corresponding derived classes in ./src/window1.cc

#include "window1_glade.hh"
#include <gtkmm/togglebutton.h>
#include "../pixmaps/bitmap_r.xpm"
#include <gtkmm/box.h>

window1_glade::window1_glade(
) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{  
   
   Gtk::Window *window1 = this;
   entry1 = manage(new class Gtk::Entry());
   
   Gtk::ToggleButton *togglebutton1 = manage(new class
Gtk::ToggleButton("togglebutton1"));
   Glib::RefPtr<Gdk::Bitmap> _pixmap1_mask;
   Glib::RefPtr<Gdk::Pixmap> _pixmap1_pixmap =
Gdk::Pixmap::create_from_xpm(get_default_colormap(), _pixmap1_mask,
bitmap_r_xpm);
   pixmap1 = manage(new class Gtk::Image(_pixmap1_pixmap, _pixmap1_mask));
   
   Gtk::VBox *vbox1 = manage(new class Gtk::VBox(false, 0));
   entry1->set_flags(Gtk::CAN_FOCUS);
   entry1->set_visibility(true);
   entry1->set_editable(true);
   entry1->set_text("");
   togglebutton1->set_flags(Gtk::CAN_FOCUS);
   togglebutton1->set_relief(Gtk::RELIEF_NORMAL);
   togglebutton1->set_active(false);
   pixmap1->set_alignment(0.5,0.5);
   pixmap1->set_padding(0,0);
   vbox1->pack_start(*entry1, Gtk::PACK_SHRINK, 0);
   vbox1->pack_start(*togglebutton1, Gtk::PACK_SHRINK, 0);
   vbox1->pack_start(*pixmap1);
   window1->set_title("window1");
   window1->set_modal(false);
   window1->set_position(Gtk::WIN_POS_NONE);
   window1->add(*vbox1);
   entry1->show();
   togglebutton1->show();
   pixmap1->show();
   vbox1->show();
   window1->show();
   togglebutton1->signal_toggled().connect(SigC::slot(*this,
&window1_glade::on_togglebutton1_toggled));
}

window1_glade::~window1_glade()
{  
}

----------------------------------------------------------------------
window1_glade.hh

// generated 2003/2/23 19:38:41 CET by miguel@linux.
// using glademm V1.1.3b
//
// DO NOT EDIT THIS FILE ! It was created using
// glade-- --gtkmmversion 2.1.3 proyecto3.glade
// for gtk 1.2.10 and gtkmm 2.1.3
//
// Please modify the corresponding derived classes in ./src/window1.hh
and./src/window1.cc

#ifndef _WINDOW1_GLADE_HH
#  define _WINDOW1_GLADE_HH

#include <gtkmm/window.h>
#include <gtkmm/entry.h>
#include <gtkmm/image.h>

class window1_glade : public Gtk::Window
{  
protected:
        
        class Gtk::Entry *entry1;
        class Gtk::Image *pixmap1;
        
        window1_glade();
        
        ~window1_glade();
private:
        virtual void on_togglebutton1_toggled() = 0;
};
#endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.