Re: pthread_t through pthread_self?

2006-08-14 Thread Peter \Firefly\ Lund
On Sun, 13 Aug 2006, Luka Napotnik wrote:

 I'm interested if the function pthread_self() returns a valid pthread_t
 structure for threads, created with g_thread_new() so the pthread_t can
 be used with pthread_kill() ?

As long as you are working on top of POSIX, yes, it should.

pthread_kill() does perhaps do not do what you want:

http://docs.sun.com/app/docs/doc/816-5137/6mba5vpk4?a=view

http://users.du.se/~hjo/realtime/manuals/posix-threads/uguide/users-95.htm
   For example, sending a SIGKILL signal to a thread using pthread_kill()
   will terminate the entire process, not simply the target thread. SIGKILL
   is defined to terminate the entire process, regardless of the thread it
   is delivered to, or how it is sent.

You probably want to use pthread_cancel().

http://www2.yo-linux.com/cgi-bin/man.cgi?section=alltopic=pthread_cancel

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread rupert
I've gone through all the warning and now only get one warning on my +- 700
lines of code, now i have 3 warnings left wich I dont get away by now. Thx
for the advice to
go thorugh them, my old teacher told me we can ignore them :(.
I packed the tree into a struct and now access the parts with treedata.iter.
But when i start the programm it seems there is a problem with the iterator
in the function(works fine in the main programm).

this is my struct(which will be scalled down wen the rest works)

static struct treedata {
GtkListStore *store;
GtkWidget *tree;
GtkTreeIter   iter;
GtkTreeSelection *select;
GtkCellRenderer *renderer;
GtkCellRenderer *pixrender;
GtkTreeViewColumn *column_init;
GtkTreeViewColumn *column_mount;
GtkTreeViewColumn *column_device;
GtkTreeViewColumn *column_name;
GtkTreeViewColumn *column_mountpoint;
GtkTreeViewColumn *column_passkey;
GdkPixbuf*pixbuf_mapper_yes;
GdkPixbuf*pixbuf_mapper_no;
GdkPixbuf*pixbuf_mount_yes;
GdkPixbuf*pixbuf_mount_no;
GdkPixbuf *pixbuf_mapper;
GdkPixbuf *pixbuf_mount;
GdkPixbuf *pixbuf;
 }treedata;

the function which should updat the image in the treeview:

void crypto_mount_set_pixbuf(struct treedata *treedata){

GtkTreeIter iter = treedata-iter;
//GtkTreeModel *store = treedata-store;

g_print(test);

/*change DATEN into a variable loop which extracts all the rows*/
if(crypto_mount_check(DATEN))
{
treedata-pixbuf_mount = gdk_pixbuf_new_from_file(pics/mount.png,
NULL);
gtk_list_store_set(treedata-store, iter, MOUNT_COLUMN,
treedata-pixbuf_mount, -1);
g_object_unref(treedata-pixbuf_mount);

}else{

treedata-pixbuf_mount =
gdk_pixbuf_new_from_file(pics/unmount.png, NULL);
gtk_list_store_set(treedata-store, iter, MOUNT_COLUMN,
treedata-pixbuf_mount, -1);
g_object_unref(treedata-pixbuf_mount);
}
return;
}

and the timeout

 g_timeout_add(100, crypto_mount_set_pixbuf, treedata);

Strangely the function seems to stop, because i only get 1 test on the bash:
(cryptomaster:11056): Gtk-CRITICAL **: gtk_list_store_set: assertion
`iter-stamp == list_store-stamp' failed


I have split my project into different files, if its neccesary i could
append an tarball
to my mails, if its better for you to see a solution to my problems.

greetings

On 8/5/06, [EMAIL PROTECTED]  [EMAIL PROTECTED] wrote:

 On Sat, Aug 05, 2006 at 10:18:24AM +0200, rupert wrote:
  On 8/3/06, David Ne?as (Yeti) [EMAIL PROTECTED]  wrote:
 [...]
  but how can I pass all the Information like the treestore, itert.., with
 the
  g_timeout_add(), because it only allows me one filed for data to pass.

 As Yeti already pointed out, build a struct to hold it all, alloc it,
 pass pointer to struct (and don't forget to free when done ;-)

 Or, if you are sure that there's only one struct in use at a time, use a
 static (but this is a dirty technique which will haunt you at night,
 believe me).

  g_timeout_add(100, crypto_mount_set_pixbuf, pixbuf_mount);
 
  and that's all.  However, if you use some images repeatedly,
   register them as stock icons or load the pixbufs only once
   and reuse them.
 
 
  I have no idea how to do this.
  Could you please link me to an example,
  from reading the reference i dont get is how to use it correctly:

 A quick and dirty thing I use to do (when the complexity of doing stock
 item things scares me -- I'm easily scared by complexity, you know) is
 something like:

 | #define NRPICS 4
 | typedef enum {
 |   sheep,
 |   cow,
 |   petunia,
 |   alien
 | } mypic;
 |
 | static GdkPixbuf *getpix(mypic pic)
 | {
 |   /* Returns pixbuf corresponding to whohas */
 |   static GdkPixbuf *pix[NRPICS];
 |   static char *fname[NRPICS] = {
 | /path/to/sheep.png,
 | /path/to/cow.png,
 | /path/to/petunia.png,
 | /path/to/alien.png,
 |   };
 |   if(pic0 || picalien) pic = alien;
 |   if(!pix[pic]) /* not yet realized */
 | pix[pic] = gdk_pixbuf_new_from_file(fname[pic], NULL);
 |   return pix[pic];
 | }

 Modify to own taste.

 Of course, you can get all fancy and read the list of files from a
 config file ant that -- but from some point on you might be better off
 reading up about all this stock stuff (which is far more
 theme-friendly), for example here:

   http://developer.gnome.org/doc/API/2.0/gtk/gtk-Themeable-Stock-Images.html
 

 HTH
 -- tomás


 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.1 (GNU/Linux)

 iD8DBQFE1LD8Bcgs9XrR2kYRAszjAJ9GVUzSV5SBUvj1rEGNTO6BbTEToQCfa99y
 rfR9JFz9GVfZYDeinj+s5NE=
 =YZqa
 -END PGP SIGNATURE-



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

Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread Peter \Firefly\ Lund
On Mon, 14 Aug 2006, rupert wrote:

Strangely the function seems to stop, because i only get 1 test on the bash:
(cryptomaster:11056): Gtk-CRITICAL **: gtk_list_store_set: assertion
`iter-stamp == list_store-stamp' failed

And how, pray tell, do you get your iterator initialized? ;)
The snippet you showed just copied the iterator in the struct into your 
local iterator -- but how do you get a sensible value into the iterator in 
the struct?

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread rupert
On 8/14/06, Peter Firefly Lund [EMAIL PROTECTED] wrote:

 On Mon, 14 Aug 2006, rupert wrote:

 Strangely the function seems to stop, because i only get 1 test on the
 bash:
 (cryptomaster:11056): Gtk-CRITICAL **: gtk_list_store_set: assertion
 `iter-stamp == list_store-stamp' failed

 And how, pray tell, do you get your iterator initialized? ;)
 The snippet you showed just copied the iterator in the struct into your
 local iterator -- but how do you get a sensible value into the iterator in
 the struct?

mmh, i have a function that fills the treeview

void make_list(GtkListStore *store, GtkTreeIter iter, gpointer
pixbuf_mapper_yes, gpointer pixbuf_mapper_no, gpointer pixbuf_mount_yes,
gpointer pixbuf_mount_no){

GKeyFile *crypto_keys;
gchar **groups;
gint i;
gsize grouplength;
gchar *device=NULL, *mapper=NULL, *mountpoint=NULL, *keyfile=NULL;
gboolean  password;
GdkPixbuf *pixbuf_mapper=NULL, *pixbuf_mount=NULL;


crypto_keys = g_key_file_new();
g_key_file_load_from_file(crypto_keys,
/home/Programmierung/GTK_Projects/crypto_master/src/crypto.ini,
G_KEY_FILE_NONE, NULL) ;

groups = g_key_file_get_groups(crypto_keys, grouplength);


for(i=0; igrouplength; i++)
{
   // g_print(NR: %d\n, i);
device = g_key_file_get_string(crypto_keys, groups[i], device,
NULL);
mapper = g_key_file_get_string(crypto_keys, groups[i],
mapperdevice, NULL);
mountpoint = g_key_file_get_string(crypto_keys, groups[i],
mountpoint, NULL);
password = g_key_file_get_boolean(crypto_keys, groups[i],
password, NULL);
keyfile = g_key_file_get_string(crypto_keys, groups[i], keyfile,
NULL);

//g_print(\n %s, device);
//g_print(\n %s, mapper);
//g_print(\n %s, mountpoint);
//g_print(\n %s, password);
//g_print(\n %s, keyfile);

if(crypto_mapper_check(mapper))
pixbuf_mapper = pixbuf_mapper_yes;
else
pixbuf_mapper = pixbuf_mapper_no;

 //mapper = g_key_file_get_string(crypto_keys, groups[i],
mapperdevice, NULL);

if(crypto_mount_check(mountpoint))
 pixbuf_mount = pixbuf_mount_yes;
else
 pixbuf_mount = pixbuf_mount_no;

 //mountpoint = g_key_file_get_string(crypto_keys, groups[i],
mountpoint, NULL);


   gtk_list_store_append(store, iter);
   gtk_list_store_set(store, iter,
INIT_COLUMN, pixbuf_mapper,
MOUNT_COLUMN, pixbuf_mount,
DEVICE_COLUMN, device,
NAME_COLUMN, mapper,
MOUNTPOINT_COLUMN, mountpoint,
PASSKEY_COLUMN, keyfile,
-1);

//g_print(PASS: %d, password);
if(password)
gtk_list_store_set(store, iter,  PASSKEY_COLUMN, NULL, -1);

}


/* free the strings */
g_strfreev(groups);
g_free(device);
g_free(mapper);
g_free(mountpoint);
   // g_free(password);
g_free(keyfile);

g_object_unref(pixbuf_mapper);
g_object_unref(pixbuf_mount);

}

which gets started here, before the timeout

make_list(treedata.store, treedata.iter, treedata.pixbuf_mapper_yes,
treedata.pixbuf_mapper_no, treedata.pixbuf_mount_yes,
treedata.pixbuf_mount_no);

hope thats the part you are asking for

-Peter

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread Peter \Firefly\ Lund
On Mon, 14 Aug 2006, rupert wrote:

 void make_list(GtkListStore *store, GtkTreeIter iter, gpointer
 pixbuf_mapper_yes, gpointer pixbuf_mapper_no, gpointer pixbuf_mount_yes,
 gpointer pixbuf_mount_no){

Notice the lack of * in front of the variable iter.

 make_list(treedata.store, treedata.iter, treedata.pixbuf_mapper_yes,
 treedata.pixbuf_mapper_no, treedata.pixbuf_mount_yes,
 treedata.pixbuf_mount_no);

and likewise the lack of  in front of treedata.iter.

 hope thats the part you are asking for

It was and it explains the symptoms perfectly :)

Now go and read up on parameter passing in C -- especially how C really 
always uses call-by-value and how call-by-reference is only supported by 
doing it manually.

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread Peter \Firefly\ Lund
On Mon, 14 Aug 2006, Lance Dillon wrote:

 The problem is your code doesn't seem to initialize iter in any way. 
 Before you call make_list, you should probably do something like this:

No, no.  make_list() by itself is fine.  It sets its local iter in every 
iteration through the call to gtk_list_store_append().

The problem is that the global treedata.iter doesn't get set by the call 
to make_list().

If it /had/ been a call-by-reference parameter, then it would have been 
set to point to the last item in the model (which is perhaps also not what 
Rupert wanted but at least /something/ would happen).

 gtk_tree_model_get_iter_first(treedata.store,treedata.iter);

 This initializes iter to the beginning of the treemodel.
 Then you can call make_list().

1) Not necessary at all before calling make_list().
2) might be nice anyway -- but after calling make_list or perhaps inside 
the callback function.

But actually, the real question is: why keep a global iterator around in 
the first place?

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread Lance Dillon
(I hate yahoo's quoting)

- Original Message 
From: Peter Firefly Lund [EMAIL PROTECTED]
To: Lance Dillon [EMAIL PROTECTED]
Cc: gtk-app-devel-list@gnome.org
Sent: Monday, August 14, 2006 8:07:43 AM
Subject: Re: Key-value file parser, howto get all groups and create loop from 
them

On Mon, 14 Aug 2006, Lance Dillon wrote:

 The problem is your code doesn't seem to initialize iter in any way. 
 Before you call make_list, you should probably do something like this:

No, no.  make_list() by itself is fine.  It sets its local iter in every 
iteration through the call to gtk_list_store_append().
---

Okay, I see that..



But actually, the real question is: why keep a global iterator around in 
the first place?



I agree.  Iterators (both tree and text) get invalidated often, and they only 
seem to be valid if you use before making any other changes.




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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread rupert
On 8/14/06, Peter Firefly Lund [EMAIL PROTECTED] wrote:

 On Mon, 14 Aug 2006, rupert wrote:

  void make_list(GtkListStore *store, GtkTreeIter iter, gpointer
  pixbuf_mapper_yes, gpointer pixbuf_mapper_no, gpointer pixbuf_mount_yes,
  gpointer pixbuf_mount_no){

 Notice the lack of * in front of the variable iter.


got this fixed, didnt do it the first time, but now does ;)

 make_list(treedata.store, treedata.iter, treedata.pixbuf_mapper_yes,
  treedata.pixbuf_mapper_no, treedata.pixbuf_mount_yes,
  treedata.pixbuf_mount_no);

 and likewise the lack of  in front of treedata.iter.


dito

 hope thats the part you are asking for

 It was and it explains the symptoms perfectly :)

 Now go and read up on parameter passing in C -- especially how C really
 always uses call-by-value and how call-by-reference is only supported by
 doing it manually.

i will try to do...

thx for the hel, with adding the tip lanve gave its working somehow now,
but i had to do some changes:

 gtk_tree_model_get_iter_first(treedata-store,treedata-iter);
i have this line now before make_list and also in the function that updates
the
pixbuf.
Now i have to extract one field from every single line, so that i update the
pixbuf in
each line.

im gratefull for your help, thx.


-Peter

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread Peter \Firefly\ Lund
On Mon, 14 Aug 2006, rupert wrote:

 thx for the hel, with adding the tip lanve gave its working somehow now,
 but i had to do some changes:

 gtk_tree_model_get_iter_first(treedata-store,treedata-iter);
 i have this line now before make_list and also in the function that updates
 the
 pixbuf.

The next improvement you should try is to remove the iter field from the 
struct, remove the gtk_tree_model_get_iter_first() call before the call to 
make_list() and put a gtk_tree_model_get_iter_first() call into your 
callback function (probably as the first line of code after the 
declarations of the local variables).

Iterators are usually just used as a special kind of loop variables -- you 
don't make loop variables global just so you can use the same loop 
variable in another loop inside a completely unrelated function.  Or so 
that you can initialize a local loop variable to whatever value was left 
in the global loop variable from the last executed loop somewhere else.

Just get rid of it.

 Now i have to extract one field from every single line, so that i update the
 pixbuf in
 each line.

use gtk_tree_model_iter_next() inside your loop.  You can use it instead 
of normal loop variable: just call it until it returns FALSE.

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread rupert
its getting good,  somehow i packed the gtk_tree_model_iter_next in a do
while loop,
when i have no return in the loop it show all the lines once(it should show
it every 100ms) , when i add a return it always loops(but loops) at the
first line.


void crypto_mount_set_pixbuf(struct treedata *treedata){

gchar *mountpoint;
GtkTreeIter iter;
gtk_tree_model_get_iter_first(treedata-store,iter);

do
{
gtk_tree_model_get(treedata-store, iter, MOUNTPOINT_COLUMN,
mountpoint, -1);
g_print(MOUNTPOINT_COLUMN: %s\n, mountpoint);
/*
if(crypto_mount_check(mountpoint))
{
g_print(%s FOUND\n, mountpoint);
treedata-pixbuf_mount =
gdk_pixbuf_new_from_file(pics/mount.png, NULL);
gtk_list_store_set(treedata-store, treedata-iter,
MOUNT_COLUMN, treedata-pixbuf_mount, -1);
g_object_unref(treedata-pixbuf_mount);
return;
}
else
{
g_print(%s NOT FOUND\n, mountpoint);
treedata-pixbuf_mount =
gdk_pixbuf_new_from_file(pics/unmount.png, NULL);
gtk_list_store_set(treedata-store, treedata-iter,
MOUNT_COLUMN, treedata-pixbuf_mount, -1);
g_object_unref(treedata-pixbuf_mount);
return;
}
*/
}while(gtk_tree_model_iter_next(treedata-store, iter));

}

On 8/14/06, Peter Firefly Lund [EMAIL PROTECTED] wrote:

 On Mon, 14 Aug 2006, rupert wrote:

  thx for the hel, with adding the tip lanve gave its working somehow now,
  but i had to do some changes:
 
  gtk_tree_model_get_iter_first(treedata-store,treedata-iter);
  i have this line now before make_list and also in the function that
 updates
  the
  pixbuf.

 The next improvement you should try is to remove the iter field from the
 struct, remove the gtk_tree_model_get_iter_first() call before the call to
 make_list() and put a gtk_tree_model_get_iter_first() call into your
 callback function (probably as the first line of code after the
 declarations of the local variables).

 Iterators are usually just used as a special kind of loop variables -- you
 don't make loop variables global just so you can use the same loop
 variable in another loop inside a completely unrelated function.  Or so
 that you can initialize a local loop variable to whatever value was left
 in the global loop variable from the last executed loop somewhere else.

 Just get rid of it.

  Now i have to extract one field from every single line, so that i update
 the
  pixbuf in
  each line.

 use gtk_tree_model_iter_next() inside your loop.  You can use it instead
 of normal loop variable: just call it until it returns FALSE.

 -Peter

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


Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread rupert
grrr, simple as most of the time:

void crypto_mount_set_pixbuf(struct treedata *treedata){

gchar *mountpoint;
GtkTreeIter iter;
gtk_tree_model_get_iter_first(treedata-store,iter);


do
{
gtk_tree_model_get(treedata-store, iter, MOUNTPOINT_COLUMN,
mountpoint, -1);
g_print(MOUNTPOINT_COLUMN: %s\n, mountpoint);

if(crypto_mount_check(mountpoint))
{
g_print(%s FOUND\n, mountpoint);
treedata-pixbuf_mount =
gdk_pixbuf_new_from_file(pics/mount.png, NULL);
gtk_list_store_set(treedata-store, iter, MOUNT_COLUMN,
treedata-pixbuf_mount, -1);
g_object_unref(treedata-pixbuf_mount);

}
else
{
g_print(%s NOT FOUND\n, mountpoint);
treedata-pixbuf_mount =
gdk_pixbuf_new_from_file(pics/unmount.png, NULL);
gtk_list_store_set(treedata-store, iter, MOUNT_COLUMN,
treedata-pixbuf_mount, -1);
g_object_unref(treedata-pixbuf_mount);

}

}while(gtk_tree_model_iter_next(treedata-store, iter));
gtk_tree_model_get_iter_first(treedata-store,iter);
}


I have to give me a timeframe of a day or two before asking question,(this
gets a note on the monitor.)...

so long
On 8/14/06, rupert [EMAIL PROTECTED] wrote:

 its getting good,  somehow i packed the gtk_tree_model_iter_next in a do
 while loop,
 when i have no return in the loop it show all the lines once(it should
 show it every 100ms) , when i add a return it always loops(but loops) at the
 first line.


 void crypto_mount_set_pixbuf(struct treedata *treedata){

 gchar *mountpoint;
 GtkTreeIter iter;
 gtk_tree_model_get_iter_first(treedata-store,iter);

 do
 {
 gtk_tree_model_get(treedata-store, iter, MOUNTPOINT_COLUMN,
 mountpoint, -1);
 g_print(MOUNTPOINT_COLUMN: %s\n, mountpoint);
 /*

 if(crypto_mount_check(mountpoint))
 {
 g_print(%s FOUND\n, mountpoint);

 treedata-pixbuf_mount =
 gdk_pixbuf_new_from_file(pics/mount.png, NULL);
 gtk_list_store_set(treedata-store, treedata-iter,
 MOUNT_COLUMN, treedata-pixbuf_mount, -1);

 g_object_unref(treedata-pixbuf_mount);
 return;
 }
 else
 {
 g_print(%s NOT FOUND\n, mountpoint);

 treedata-pixbuf_mount =
 gdk_pixbuf_new_from_file(pics/unmount.png, NULL);
 gtk_list_store_set(treedata-store, treedata-iter,
 MOUNT_COLUMN, treedata-pixbuf_mount, -1);

 g_object_unref(treedata-pixbuf_mount);
 return;
 }
 */
 }while(gtk_tree_model_iter_next(treedata-store, iter));

 }

 On 8/14/06, Peter Firefly Lund [EMAIL PROTECTED] wrote:

  On Mon, 14 Aug 2006, rupert wrote:
 
   thx for the hel, with adding the tip lanve gave its working somehow
  now,
   but i had to do some changes:
  
   gtk_tree_model_get_iter_first(treedata-store,treedata-iter);
   i have this line now before make_list and also in the function that
  updates
   the
   pixbuf.
 
  The next improvement you should try is to remove the iter field from the
  struct, remove the gtk_tree_model_get_iter_first() call before the call
  to
  make_list() and put a gtk_tree_model_get_iter_first() call into your
  callback function (probably as the first line of code after the
  declarations of the local variables).
 
  Iterators are usually just used as a special kind of loop variables --
  you
  don't make loop variables global just so you can use the same loop
  variable in another loop inside a completely unrelated function.  Or so
  that you can initialize a local loop variable to whatever value was left
  in the global loop variable from the last executed loop somewhere else.
 
  Just get rid of it.
 
   Now i have to extract one field from every single line, so that i
  update the
   pixbuf in
   each line.
 
  use gtk_tree_model_iter_next() inside your loop.  You can use it instead
 
  of normal loop variable: just call it until it returns FALSE.
 
  -Peter
 


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


Re: Fwd: Systray icon..

2006-08-14 Thread James Scott Jr
I was able to compile it, after a few minor changes.  If you wanting to
use it on a linux platform download my example for this url.
http://mysite.verizon.net/skoona/id2.html

The example program demonstrates adding and removing an icon, adding
tooltips, popup-menus to an icon, etc.

Let me know, if you cannot compile my example.
James,

On Mon, 2006-08-14 at 00:35 -0500, Samuel Cormier-Iijima wrote:

 eggstatusicon. it was a while ago, so maybe they've updated it, but I
 remember that eggtrayicon was what i needed (putting an icon in the
 systray)
 
 On 8/14/06, James Scott Jr [EMAIL PROTECTED] wrote:
 
   Tried compiling what? eggtrayicon.c, edgestatusicon.c ?  What was the
  error-code/messages ?
   James,
 
 
   On Sun, 2006-08-13 at 10:58 -0500, Samuel Cormier-Iijima wrote:
   I tried compiling it once, and it didn't seem to work with GTK 2.0... :-)
 
  On 8/13/06, Enrico [EMAIL PROTECTED] wrote:
   Fernando Apesteguía pronuncio' le seguenti parole il 11/08/2006 17:09:
Using eggtrayicon.c and eggtrayicon.h
   
Best regards
   
  
   Many thanks for the help! I have noticed that there is also an
   edgestatusicon.c and an edgestatusicon.h, what is the difference?
  
   Thanks
  
   Enrico
   ___
   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
 
 
 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Key-value file parser, howto get all groups and create loop from them

2006-08-14 Thread Peter \Firefly\ Lund
On Mon, 14 Aug 2006, rupert wrote:

 void crypto_mount_set_pixbuf(struct treedata *treedata){

 gchar *mountpoint;
 GtkTreeIter iter;
 gtk_tree_model_get_iter_first(treedata-store,iter);


A couple of stylistic points:
  1) put the opening brace as the first thing on the next line
  2) add an empty line between the variable declarations and the first line 
of code (the gtk_tree_model_get_iter_first() call).
  3) put a space after the ',' that separetes the arguments to 
gtk_tree_moedl_get_iter_first().

In Java the normal thing seems to be to put the brace on the first 
line, the way you did (except that they would add a space between 
')' and '{').

Different languages have different idioms.

Almost *all* C programmers would agree with 1, 2, and 3 above.

 do
 {

Most C programmers would put these on the same line as 'do {' (note the 
space).

   gtk_tree_model_get(treedata-store, iter, MOUNTPOINT_COLUMN,
 mountpoint, -1);
 g_print(MOUNTPOINT_COLUMN: %s\n, mountpoint);

 if(crypto_mount_check(mountpoint))
 {

Likewise.

 g_print(%s FOUND\n, mountpoint);
 treedata-pixbuf_mount =
 gdk_pixbuf_new_from_file(pics/mount.png, NULL);
   gtk_list_store_set(treedata-store, iter, MOUNT_COLUMN,
 treedata-pixbuf_mount, -1);
 g_object_unref(treedata-pixbuf_mount);

 }
 else
 {

Most C programmers would put these three on the same line: '} else {'.

 g_print(%s NOT FOUND\n, mountpoint);
 treedata-pixbuf_mount =
 gdk_pixbuf_new_from_file(pics/unmount.png, NULL);
   gtk_list_store_set(treedata-store, iter, MOUNT_COLUMN,
 treedata-pixbuf_mount, -1);
 g_object_unref(treedata-pixbuf_mount);

   }

 }while(gtk_tree_model_iter_next(treedata-store, iter));

Almost all C programmers would have a space between '{' and 'while'.
Most would also have a space between 'while' and '(', as 'while' is a 
keyword, not a function call (the same goes for 'if', 'for', 'switch').

 gtk_tree_model_get_iter_first(treedata-store,iter);

No need to do the final gtk_tree_model_get_iter_first().  I mean, iter is 
a local variable and you are done with it and besides it gets destroyed 
anyway as soon as the function returns...

 }


 I have to give me a timeframe of a day or two before asking question,(this
 gets a note on the monitor.)...

;)

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


Re: Bug in GLib, libglade, libc??

2006-08-14 Thread Samuel Cormier-Iijima
Hi,

First of all, this should really be better documented elsewhere, but
valgrind has some problems debugging and profiling multithreaded code
(such as Gtk/Glib). To get some more accurate results, try the
following:

G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --show-reachable myapp

Some more of these environment variables are documented here:
http://developer.gnome.org/doc/API/2.0/glib/glib-running.html

Also, if you're using lists and strings and such, you might want to
use the GLib API's instead of hand-rolling your own. Things such as
GSList, GList, and GString can make your life a lot easier, depending
on what you're doing.

Finally, you shouldn't be using g_free on GObjects (such as GtkWidgets
and *I think* the GladeXML). Rather, use gtk_widget_destroy or
g_object_unref. GLib uses reference counting so that you don't have to
worry too much about memory management.

If trying these things doesn't work, you can always post the code ;-)

Cheers,
Samuel

On 8/14/06, Fabricio Rocha [EMAIL PROTECTED] wrote:
 Thank you very much, Yeti and Samuel, for your replies!

 I really believe that there is something wrong in MY code, and not in
 libglade, nor libc, nor GTK, etc., that makes my program react so
 different every time I compile and run it. However, I still could not
 figure what exactly is wrong.

 I have a suspicion from my lack of practice in C: a module of my
 program uses a structured type which must contain, as its last member, a
 dynamic list of strings, i.e., pointers to gchars (**list). Sometimes I
 need to fill only the first string, and sometimes I will need more than
 one string. So I suspect that each attempt to set a value for one of
 these pointers cause a serious corruption of other areas of the program,
 like the GTK stuff in memory. I have tried to assign values to this
 (these) pointers both with g_strdup and by creating a local, initialized
 array and assigning its address to the pointer. Neither worked. Do you
 think I should give each pointer a malloc'd space somewhere in memory,
 and then strcpy the value to this pointer?

 By the way, I have read a lot of GDB and Valgrind docs, and still 
 could
 not get anything from them. My application is one of those standard
 libglade apps with a main() function that only loads a main window from
 the XML and show it, and I really don´t understand some things from
 Valgrind:

 - Conditional jump or move depends on uninitialised values, which is
 by itself not so bad, according to Valgrind docs;

 - Syscall param write (buf) points to uninitialised byte(s) in the
 lines which calls gtk_init(argc, argv) and gtk_init(); which, if I am
 right, is normal as there is nothing passed to the application in the
 command line;

 - Various Invalid read of size 4 (...) Address 0x is 24 bytes
 inside a block of size 25 alloc´d caused by the line with
 glade_xml_signal_autoconnect. Hey, what is wrong if an address is
 WITHIN the alloc´d block?? And look that, until now, there is *not* code
 of myself, it is just what every libglade example tells!

 - Invalid free() / delete / delete[] in the lines right after
 gtk_main(), where I try to g_free both the pointers to the loaded XML
 file and the main window widget. I have set breakpoints in GDB right
 before these lines and they HAD non-NULL values until here...

 - The program finishes with surprising 141kB possibly lost and 931kB
 (!) still reachable memory leaks. I can´t figure out what exactly is
 causing such a memory waste -- the only thing the program does until now
 is loading and closing the main window and a dialog window! In
 GTK/libglade programming, could you point out which are the most common
 to-check things to avoid that?

 Please, sorry for such a big post, but I hope you understand that, as
 Yeti said, I am really *trying* to debug the thing by myself, instead of
 just coming here and shout but until now I couldn´t really find any
 big clue with GDB, and, although Valgrind is really impressive, it does
 not tell much about *what* to do for newbies like me -- as a friend
 said, it is like going to a physician who says hmm, it looks like you
 have fluid in your left lung, but does not tell you how it happened and
 what to do then...

 Thank you again and best regards to all!

 Fabricio Rocha
 Brasilia, Brasil




 ___
 O Yahoo! está de cara nova. Venha conferir!
 http://br.yahoo.com


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


Re: Bug in GLib, libglade, libc??

2006-08-14 Thread John Coppens
On Tue, 15 Aug 2006 00:57:06 -0300
Fabricio Rocha [EMAIL PROTECTED] wrote:

   I have a suspicion from my lack of practice in C: a module of
 my program uses a structured type which must contain, as its last
 member, a dynamic list of strings, i.e., pointers to gchars (**list).
 Sometimes I need to fill only the first string, and sometimes I will
 need more than ...

Hi Fabricio.

Why don't you leave the administration of that list to GList? Check it
out. it is part of glib and very simple to use! And you can add as many
strings as you like, too.

John

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


Re: Bug in GLib, libglade, libc??

2006-08-14 Thread tomas
On Tue, Aug 15, 2006 at 12:57:06AM -0300, Fabricio Rocha wrote:
 Thank you very much, Yeti and Samuel, for your replies!
 
[...]
   I have a suspicion from my lack of practice in C: a module of my 
 program uses a structured type which must contain, as its last member, a 
 dynamic list of strings, i.e., pointers to gchars (**list). Sometimes I 
 need to fill only the first string, and sometimes I will need more than 
 one string. So I suspect that each attempt to set a value for one of 
 these pointers cause a serious corruption of other areas of the program, 
 like the GTK stuff in memory. I have tried to assign values to this 
 (these) pointers both with g_strdup and by creating a local, initialized 
 array and assigning its address to the pointer. Neither worked. Do you 
 think I should give each pointer a malloc'd space somewhere in memory, 
 and then strcpy the value to this pointer?

This one indeed looks suspicious, so your hunch might be well sounded
;-)

As far as C cis concerned, gchar **list is just a pointer to a pointer
to a char (or a pointer to a char array -- C does not make a difference
here. See a good C reference for this. I'd recommend Kerninghan 
Ritchies classic book which albeit old is extremely clear in those
basics. For a quick lookup, this
ttp://www.cs.cf.ac.uk/Dave/C/node10.html#SECTION00103
has some details on pointers, arrays and all that).

The upshot is, you'd better make sure that **list points to whatever
makes sense in your context. But we'll never know for sure if you don't
show us the code :-)

   By the way, I have read a lot of GDB and Valgrind docs, and still could 
 not get anything from them. [...]

Gdb and valgrind are powerful tools, but you'll have to have a good
working model of what is going on inside your program to make sense of
them. For example, gdb is quite at a loss with stray pointer problems.
With those, the fault pokes a hole somewhere which might well trip up
the application much later, at a seemingly unrelated place (e.g. when
ten layers of functions have returned, stumbling over the corrupt stack
area or when the memory allocator trees to free something at a place
where memory has been corrupted). Go find that then :-)

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