Help Regarding GNOME accessibility with our GTK based application



Now we are facing a peculiar problem while trying to build our application with GTK.

When we try to build application with threads we see that its objects are not accessible. But, the same code when we try without threads we see that we are able to access the objects

also attached the sample codes for the same

Hope you can bring us some light in solving



#include <gtk/gtk.h>

GtkWidget* window = NULL;

gpointer main_callback(gpointer data)
{
	gtk_main();
}

void dispInit(int argc, char* argv[])
{
	g_thread_init(NULL);
	gdk_threads_init();

	/* Lock thread */
	gdk_threads_enter();

	strcat(FDKCheckScreenName, getValFromConfig("screennumber"));		
  	printf("Initializing the display library\n");
    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_resize((GtkWindow*)window, 640, 480);

	g_thread_create(main_caallback, NULL, FALSE, NULL);
	
	/* Unlock Thread */
	gdk_threads_leave();
}

int main(int argc, char *argv[])
{
	dispInit(argc, argv);
	return 0;
}

#include <gtk/gtk.h>

gint count = 0;
char buf[5];
GtkWidget* window1 = NULL;


void increase(GtkWidget *widget, gpointer label)
{
  count++;

  sprintf(buf, "%d", count);
  gtk_label_set_text(GTK_LABEL(label), buf);
}

void decrease(GtkWidget *widget, gpointer label)
{
  count--;

  sprintf(buf, "%d", count);
  gtk_label_set_text(GTK_LABEL(label), buf);
}

void dispInit(int argc, char* argv[])
{
  char logBuf[128] = { '\0' };
  GtkWidget *label;
  GtkWidget *frame;
  GtkWidget *plus;
  GtkWidget *minus;

  gtk_init(&argc, &argv);

  window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  gtk_window_set_position(GTK_WINDOW(window1), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window1), 250, 180);
  gtk_window_set_title(GTK_WINDOW(window1), "+-");

  frame = gtk_fixed_new();
  gtk_container_add(GTK_CONTAINER(window1), frame);

  plus = gtk_button_new_with_label("+");
  gtk_widget_set_size_request(plus, 80, 35);
  gtk_fixed_put(GTK_FIXED(frame), plus, 50, 20);

  minus = gtk_button_new_with_label("-");
  gtk_widget_set_size_request(minus, 80, 35);
  gtk_fixed_put(GTK_FIXED(frame), minus, 50, 80);

  label = gtk_label_new("0");
  gtk_fixed_put(GTK_FIXED(frame), label, 190, 58); 

  gtk_widget_show_all(window1);

  g_signal_connect(window1, "destroy",
      G_CALLBACK (gtk_main_quit), NULL);

  g_signal_connect(plus, "clicked", 
      G_CALLBACK(increase), label);

  g_signal_connect(minus, "clicked", 
      G_CALLBACK(decrease), label);

  gtk_widget_show_all(window1);

  gtk_main();

  return;

}

int main(int argc, char *argv[])
{
	dispInit(argc, argv);
	return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]