Re: timeout function not called

2007-10-04 Thread James Scott Jr
On Thu, 2007-10-04 at 13:27 -0700, [EMAIL PROTECTED] wrote:

> Thanks James for giving me my first experience with Thread programming!
> I tried the code you sent me, but unfortunately, I still can't get the  
> progress_update
> function to run, looks like it never gets called. Any idea why this  
> might be happening?
> growPart still runs.
> 
> Thanks,
> 
> Vicki
> 


The code i offered is really high level - almost sudo code.  I prefer to
evaluate a fuller example, if you care to post the whole program - or
email it to me and I will email it back.

Things I would be interested in would be as follows;
1. did you do away with the fork() and wait() calls?
2. did you compile it with something like this - with gthread included?
"# gcc -Wall `pkg-config --libs --cflags gtk+-2.0 glib-2.0
gthread-2.0` program.c "
3. Did you call g_thread_init() in main(). ?
/*
 * Initialize GLib thread support and GTK
 */
g_type_init ();
g_thread_init (NULL);
gdk_threads_init ();
gtk_init (&argc, &argv);
/* create app window */
/* create progress bar dialog */

/*
 * enter the GTK main loop
 */
gdk_threads_enter ();
gtk_main ();
gdk_flush ();
gdk_threads_leave ();
return (0);

4. How long does growPart() run? longer than 100ms
the g_timeout_add() is only for 50ms, and it waits 50ms before
making the first call kinda short, try 250 or 400

5. Assuming your created a dialog box for the progress bar and thats is
is visible it should have ran.  Stick a g_debug("update"); in the
progress_update() routine after the call to gtk_progress_bar_pulse()

6. I'm thinking the most likely cause is how the program was compiled.
send me some code to look at!

James,

> 
> [Hide Quoted Text]
> GTK program before.  The ret=wait(null) causes execution to stop at that
> 
> point and wait for growPart() to finish.  A way to get around the  
> logistics of fork() is to use threads directly.  Consider the following;
> 
> /* globals */
> gboolean  b_pulse_control = FALSE
> GThread  *grow_thread_id = NULL;
> gint   global_ret = 0;
> 
> 
> b_pulse_control = TRUE;
> timer = g_timeout_add(50, (GSourceFunc) progress_update,
> (gpointer)progressbar);
> 
> grow_thread_id = g_thread_create ( growPart_thread, &b_pulse_control,
> TRUE, NULL);
> 
> 
> static gboolean progress_update (gpointer progressbar)
> {
>   if (b_pulse_control)
>  {
>   gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressbar));
>   return true;
>  } else {
>  global_ret = GPOINTER_TO_INT( g_thread_join (grow_thread)  );
>  return FALSE;
>  }
> 
> }
> 
> static gpointer growPart_thread(gpointer b_pulse)
> {
> 
>   /* do work */
>   growPart();
> 
>   *b_pulse = FALSE;
>   g_thread_exit( GINT_TO_POINTER( 1 ) );
> 
> }
> 
> I would do the passing of control values via a structure to avoid  the  
> use of globals,
> but this should work for you.
> 
> 
> --
> Invent your own San Diego at sandiego.com!
> 
> 
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: timeout function not called

2007-10-04 Thread v_wishful
Thanks James for giving me my first experience with Thread programming!
I tried the code you sent me, but unfortunately, I still can't get the  
progress_update
function to run, looks like it never gets called. Any idea why this  
might be happening?
growPart still runs.

Thanks,

Vicki


[Hide Quoted Text]
GTK program before.  The ret=wait(null) causes execution to stop at that

point and wait for growPart() to finish.  A way to get around the  
logistics of fork() is to use threads directly.  Consider the following;

/* globals */
gboolean  b_pulse_control = FALSE
GThread  *grow_thread_id = NULL;
gint   global_ret = 0;


b_pulse_control = TRUE;
timer = g_timeout_add(50, (GSourceFunc) progress_update,
(gpointer)progressbar);

grow_thread_id = g_thread_create ( growPart_thread, &b_pulse_control,
TRUE, NULL);


static gboolean progress_update (gpointer progressbar)
{
  if (b_pulse_control)
 {
  gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressbar));
  return true;
 } else {
 global_ret = GPOINTER_TO_INT( g_thread_join (grow_thread)  );
 return FALSE;
 }

}

static gpointer growPart_thread(gpointer b_pulse)
{

  /* do work */
  growPart();

  *b_pulse = FALSE;
  g_thread_exit( GINT_TO_POINTER( 1 ) );

}

I would do the passing of control values via a structure to avoid  the  
use of globals,
but this should work for you.


--
Invent your own San Diego at sandiego.com!


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


Add a Scrollbar

2007-10-04 Thread omar . crea
A simple question:
what is the best way to add a vertical scrollbar to a widget?
In my case the widget is a notebook tab containing some frames (it shows many
contents), so I have to handle the case in which the frames overlap the tab's
height, including a scrollbar to browse them.
Thanks in advance. Regards,

Omar


This message was sent using IMP, the Internet Messaging Program.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


ComboBox and TreeView issues

2007-10-04 Thread omar . crea
Hi everybody.
I obtain the following errors when launching my application that contains a
notebook, and in one of its page there are three combobox with the associated
treeviews:

(when opening the tab)
barcode_buttons[2561]: GLIB CRITICAL ** Gtk - gtk_tree_store_get_path: assertion
`iter->user_data != NULL' failed
barcode_buttons[2561]: GLIB CRITICAL ** Gtk - gtk_tree_store_get_path: assertion
`iter->user_data != NULL' failed
barcode_buttons[2561]: GLIB CRITICAL ** Gtk - gtk_tree_store_get_path: assertion
`iter->user_data != NULL' failed

(when closing the tab)
barcode_buttons[2561]: GLIB CRITICAL ** GLib-GObject - g_object_unref: assertion
`G_IS_OBJECT (object)' failed
barcode_buttons[2561]: GLIB CRITICAL ** GLib-GObject - g_object_get_data:
assertion `G_IS_OBJECT (object)' failed
barcode_buttons[2561]: GLIB WARNING ** Gtk - gtktreemodel.c:1949: bad row
reference, proxy has no outstanding row references
barcode_buttons[2561]: GLIB CRITICAL ** GLib-GObject - g_object_get_data:
assertion `G_IS_OBJECT (object)' failed
barcode_buttons[2561]: GLIB WARNING ** Gtk - gtktreemodel.c:1949: bad row
reference, proxy has no outstanding row references

What they means?

I use the following code to create a model for the tree:

GtkTreeModel *
190create_model ( void ) {
191
192GtkTreeIter iter;
193GtkTreeStore *store = NULL;
194GtkTreeSelection *select = NULL;
195GtkWidget *treeview = NULL;
196ll *tmp = top->ref->first;
197
198store = gtk_tree_store_new(NUM_COL, G_TYPE_STRING);
199
200gtk_tree_store_append(store, &iter, NULL);
201gtk_tree_store_set(store, &iter,
202  STRING_COL, "",
203  -1);
204
205while (tmp != NULL) {
206   gtk_tree_store_append(store, &iter, NULL);
207   gtk_tree_store_set(store, &iter,
208 STRING_COL, tmp->contenuto,
209 -1);
210   tmp = tmp->next;
211   }
212
213treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
214select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
215gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
216
217return GTK_TREE_MODEL(store);
218 }

and this one to create a text renderer:

void add_renderer ( GtkComboBox *combo ) {
273
274GtkCellRenderer *render = NULL;
275GtkTreePath *path = NULL;
276GtkTreeModel *mod = NULL;
277GtkTreeIter iter;
278
279render = gtk_cell_renderer_text_new();
280gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), render, TRUE);
281gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), render,
282  "text", STRING_COL,
283  NULL);
284
285path = gtk_tree_path_new_from_indices(0, 1, -1);
286mod = gtk_combo_box_get_model(combo);
287gtk_tree_model_get_iter(mod, &iter, path);
288gtk_tree_path_free(path);
289gtk_combo_box_set_active_iter(combo, &iter);
290
291 }

then I use this code to get data from the combobox:

369result = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(c.dataCombo),
&iter);
370model = gtk_combo_box_get_model(GTK_COMBO_BOX(c.dataCombo));
371gtk_tree_model_get(model, &iter,
372  STRING_COL, &tf.data,
373  -1);
374printf("Getted data: %s\n", tf.data);
375g_object_unref(model);

Thanks in advance,

Omar


This message was sent using IMP, the Internet Messaging Program.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problem with gtk threads...

2007-10-04 Thread Tor Lillqvist
> >From the threads, I need to update the UI.

The overwhelming consensus, I think, is that even if possible (on X11,
with proper use of the gdk locking functions etc), this is a bad idea.
Instead, call g_timeout_add() in your threads to schedule functions to
be run in the main GUI thread, and have these functions then update
the GUI.

> The information contained in this electronic message and any attachments
> to this message are intended [etc]

You will probably be more flamed for this part than you will get
useful answers to your technical question. Lawyerspeak like this is
utterly stupid to add to messages sent to public mailing lists that
are archived publicly and readable by anybody.

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


Problem with gtk threads...

2007-10-04 Thread Suma H S
hi,
I am creating a threaded Gtk Application where threads
are used for doing some time consuming computations. 
>From the threads, I need to update the UI. I have surrounded 
the Gtk code with gdk_threads_enter() and gdk_threads_leave(). 
The code works fine, however I have encountered two instances 
where the application hangs:

1) when I try to create and show a pop_up window from the thread,
in the line gtk_window_show(pop_up_window).

2) when I update the contents of the treeview using list_store_set, in the
line gtk_tree_view_set_model()

Anyone has any idea why this happens?

Thanks in advance,
Suma  H S



The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments contained in it.

Contact your Administrator for further information.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Gtksourceview 2.0 and pygtksourceview 2.0 binaries for win32

2007-10-04 Thread Bilel Remmache
Dear all,
I've compiled and made available binaries for gtksourceview 2.0 and
pygtksourceview 2.0 python bindings.  They are available at:

http://code.google.com/p/bpad/wiki/GtksourceviewForWindows

I've tested them on Windows XP using python 2.5 and gtk-2.10.13.  If
you have any problems please let me know.

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


Re: GnomeVFS, gvfs, and FUSE

2007-10-04 Thread Mikael Hallendal
4 okt 2007 kl. 01.00 skrev Micah Carrick:

Hi Micah,

> I have been reading that GnomeVFS should be avoided in the future. I
> have a GNOME application which works on text files opened locally or
> remotely via FTP and SSH using GnomeVFS.
>
> Should I move towards other options, such as FUSE? Is GVFS going to be
> the "next" GnomeVFS?

GnomeVFS is planned to be replaced by GVFS but it's going to take a  
while so unless you want to beta test the GVFS implementation I  
suggest you stick with GnomeVFS for the while being. You should be  
able to port over to the new VFS fairly easy when it is released.

Cheers,
   Mikael Hallendal

-- 
Imendio AB, http://www.imendio.com



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