Weird problem with GTK+ 2.10.6



Hi there!

Maybe problem, which affect isn't a bug in GTK+, maybe it's occurred by
something else, I don't know. Here's short description. I write small multi
thread application in C language. Whole code is based on GTK+/GLib and
GObject. I have problem with dealing with GtkProgressBar. Window, which
contains GtkProgressBar widget is created in separated thread. Firstly i
make this progress bar pulsing for a while using g_timeout_add () and after
few seconds I remove this source and try to set progress bar's fraction to
0.0. after executing gtk_progress_bar_set_fraction () GUI starts behaving
very funny. Whole program still works, it creates new windows but it doesn't
show widget inside those windows and doesn't update already existing widgets
(when I move mouse pointer on already existing button etc.), it looks like
this:

http://img509.imageshack.us/img509/5880/zrzutekranury1.png

This is normal behavior (when gtk_progress_bar_set_fraction () is removed
from code):

http://img217.imageshack.us/img217/4130/zrzutekranu6vj6.png

when in situation on first screenshot I click in place, where normally is
"OK" button, program behaves normally ?!

Here's some code:

*****    this function creates window:     ******

GtkWidget   *goofy_gui_get_progress_dlg  (GoofyFile  *file)  {
   GladeXML    *xml;
   GtkWidget   *dialog;
   GtkWidget   *tmp_widget;
   gchar       *size_string = goofy_file_size_to_string (file->file_size);

   xml = glade_xml_new (GUI_FILE_PATH, "progress_dlg", NULL);
   dialog = glade_xml_get_widget (xml, "progress_dlg");

   /* Set labels etc. in window */
   tmp_widget = goofy_gui_get_widget (dialog, "file_name_lb");
   gtk_label_set_text (GTK_LABEL (tmp_widget), file->file_name);
   tmp_widget = goofy_gui_get_widget (dialog, "file_size_lb");
   gtk_label_set_text (GTK_LABEL (tmp_widget), size_string);
   tmp_widget = glade_xml_get_widget (xml, "progress_bar");
   gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (tmp_widget), 0.05);

   /* Connect signals */
   g_signal_connect (dialog, "delete-event", G_CALLBACK
(on_send_progress_dlg_delete_event), file);
   tmp_widget = goofy_gui_get_widget (dialog, "cancel_but");
   g_signal_connect (tmp_widget, "clicked", G_CALLBACK
(on_send_progress_cancel_but_clicked), file);
   tmp_widget = goofy_gui_get_widget (dialog, "close_but");
   g_signal_connect (tmp_widget, "clicked", G_CALLBACK
(on_send_progress_close_but_clicked), file);


   /* allocated memory */
   g_free (size_string);

   /* Show window */
   goofy_gui_show_widget (dialog);

   return dialog;
}

***** this make progress bar pulsing *****

void        goofy_gui_set_progress_bar_pulsing  (GtkProgressBar    *pbar,
                                                gboolean           status)
{
   guint    source_id;
   if (status == TRUE) {
       source_id = g_timeout_add (100, (GSourceFunc)
_goofy_gui_progress_bar_pulsing, pbar);
       g_object_set_data (G_OBJECT (pbar), "pulse-source-id",
GINT_TO_POINTER (source_id));
   }
   else   {
       source_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pbar),
"pulse-source-id"));
       g_source_remove (source_id);
       /* Clear progress bar */
       gtk_progress_bar_set_fraction (pbar, 0.0);
   }
}

******   This code deal with window in separated thread
********************/
gdk_threads_enter ();
dialog = goofy_gui_get_progress_dlg (GOOFY_FILE (file_send));
tmp_widget = goofy_gui_get_widget (dialog, "main_lb");
gtk_label_set_markup (GTK_LABEL (tmp_widget), _("<span
size=\"x-large\"><b>Sending file</b></span>"));
tmp_widget = goofy_gui_get_widget (dialog, "name_host_ip_lb");
gtk_label_set_text (GTK_LABEL (tmp_widget), _("Destination host's IP:"));
tmp_widget = goofy_gui_get_widget (dialog, "host_ip_lb");
gtk_label_set_text (GTK_LABEL (tmp_widget), GOOFY_SOCKET
(file_send)->ip_address);
gdk_threads_leave ();

/* some code here   */

gdk_threads_enter ();
tmp_widget = goofy_gui_get_widget (dialog, "progress_bar");
goofy_gui_set_progress_bar_pulsing (GTK_PROGRESS_BAR (tmp_widget), TRUE);
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (tmp_widget),
_("Connecting..."));
gdk_threads_leave ();

/* ... other code... */
gdk_threads_enter ();
tmp_widget = goofy_gui_get_widget (dialog, "progress_bar");
goofy_gui_set_progress_bar_pulsing (GTK_PROGRESS_BAR (tmp_widget), FALSE);
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (tmp_widget), _("Connected"));
gdk_threads_leave ();


******    this sis 'goofy_gui_show_widget ' function, which is workaround
for problem with dealing with GTK under win32   ******
void    goofy_gui_show_widget   (GtkWidget  *widget)    {
   g_timeout_add (5, _goofy_show_widget, widget);
}

static gboolean    _goofy_show_widget   (gpointer  data)    {
   gtk_widget_show (GTK_WIDGET (data));
   gdk_flush ();

   return FALSE;
}



The most suprising thing is that this problem occurs only on my Ubuntu
6.10(GTK+
v2.10.6). On Ubuntu 5.10 on Windows XP (both with GTK+v2.10.6) it works
normally. When I remove gtk_progress_bar_set_fraction () from code it runs
normally on all systems. Is it something wrong with
gtk_progress_bar_set_fraction () or with Ubuntu 6.10?!

--
Pozdrawiam!
Tom



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