Re: how to clear out a ComboBoxEntry

2006-08-18 Thread Iago Rubio
On Thu, 2006-08-17 at 12:22 -0400, shawn bright wrote:
 Hey there,
 i am using pygtk to build an app.
 i am using a gtk ComboBoxEntry with the convienence methods
 like insert_text() , remove_text()
 Does anyone know how to completely empty one out ?
 ie, remove all entries at once ?

If you're using those calls, your combo box uses a list store as tree
model so the function below will suffice.

void remove_all (GtkComboBox *combo_box)
{
  GtkTreeModel* model;
  model = gtk_combo_box_get_model (combo_box);
  gtk_list_store_clear (GTK_LIST_STORE(model));
}

Hope this helps.
-- 
Iago Rubio

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


Re: Fwd: GtkTreeView, GtkListStore and more...

2006-08-18 Thread Iago Rubio
On Thu, 2006-08-17 at 18:34 +0200, Fernando Apesteguía wrote:
 Thanks,
[snip fixed stuff]
 Can you point me to an example on how to traverse a GtkListStore?

/* # example 1 - the quick and cheap, only for list  */

void
traverse_store (GtkListStore *store)
{
  gboolean valid;

  valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(store), iter);

  while( valid ){
 /* do stuff as 
gtk_tree_model_get (GTK_TREE_MODEL(store), iter, ... )
 */
 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(store), iter);   
  }
}   

/* # example 2 - works for all  */

gboolean foreach_func (GtkTreeModel *model,
   GtkTreePath *path,
   GtkTreeIter *iter,
   gpointer data)
{
   // do stuff

   if( want_to_stop )
  return TRUE;
   else // want to continue
  return FALSE;
}

void
traverse_model (GtkTreeModel *model)
{
   gtk_tree_model_foreach  (model, foreach_func, NULL);
}



Hope this helps.
-- 
Iago Rubio

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

Fullscreen application running?

2006-08-18 Thread Unique User
Hi All,
I am writing an application which pops up a message   at random  
interval.  Before showing the message, I want to check whether a full  
screen application(movie,game etc.)   is running. How can I do this? I am  
writing this application in pygtk.


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


Re: Fullscreen application running?

2006-08-18 Thread tomas
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Fri, Aug 18, 2006 at 03:13:34PM +0530, Unique User wrote:
 Hi All,
   I am writing an application which pops up a message   at random  
 interval.  Before showing the message, I want to check whether a full  
 screen application(movie,game etc.)   is running. How can I do this? I am  
 writing this application in pygtk.

Grrr. I *hate* those apps which by all means try to take control of my
whole display. Grrr.

(sorry. I just had to say that -- feels better now :)

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

iD8DBQFE5ZWZBcgs9XrR2kYRAq3LAJ9d8MQE/MOCkpEZgF5gW7uB1tdD6gCcDBfO
RRoOzEK3XLM2DovAruoUtVY=
=x45N
-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: how to clear out a ComboBoxEntry

2006-08-18 Thread shawn bright
It does help, thanks. No need for me to persue this on a more difficult
plane than necessary.
thanks
shawn

On 8/18/06, Iago Rubio [EMAIL PROTECTED] wrote:

 On Thu, 2006-08-17 at 12:22 -0400, shawn bright wrote:
  Hey there,
  i am using pygtk to build an app.
  i am using a gtk ComboBoxEntry with the convienence methods
  like insert_text() , remove_text()
  Does anyone know how to completely empty one out ?
  ie, remove all entries at once ?

 If you're using those calls, your combo box uses a list store as tree
 model so the function below will suffice.

 void remove_all (GtkComboBox *combo_box)
 {
   GtkTreeModel* model;
   model = gtk_combo_box_get_model (combo_box);
   gtk_list_store_clear (GTK_LIST_STORE(model));
 }

 Hope this helps.
 --
 Iago Rubio

 ___
 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


Signal Handling problems with own data

2006-08-18 Thread NicolasA

Hi, I am a newbie in gnome/gtk+ programming, and I have created a GUI that
will perform some sign-in functions with a server. The user interface
consists of a button called Sign-In and two text entries for username and
password.
I have inserted a g_signal_connect function in my program giving it as
arguments the button, the clicked signal, and the function on_sign_in
which I have written to perform the communication with the server.
The problem I have is with the fourth argument of the g_signal_connect
function. In the API it says that the last argument should be a gpointer to
data. In my case I want to pass two widgets(the two text entries)so that
when my function is called, to access the two text entries, grab their
contents and validate the username and password with the server. How can I
pass both the text entry widgets to the function that is called after the
emission of the button click signal?
I have read all the examples in the gtk tutorial, I have 3 books on gnome
and gtk but I haven't found a single example which shows how to pass more
that 1 widget to the function.
Do I have to use the Gobject, which function of the API should I use?
And if more than one widgets can be passed to the function, how can I access
them ?

I would appreciate your help very much,
Nicolas.
-- 
View this message in context: 
http://www.nabble.com/Signal-Handling-problems-with-own-data-tf2127300.html#a5869944
Sent from the Gtk+ - Apps Dev forum at Nabble.com.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal Handling problems with own data

2006-08-18 Thread John Coppens
On Fri, 18 Aug 2006 07:03:41 -0700 (PDT)
NicolasA [EMAIL PROTECTED] wrote:

 In my case I want to pass two widgets(the two text entries)so that
 when my function is called, to access the two text entries, grab their
 contents and validate the username and password with the server. How
 can I pass both the text entry widgets to the function that is called
 after the emission of the button click signal?

You can make a struct with the pointers to two widgets inside, 

struct {
  GetWidget *name, *pass;
} myTwoWidgets;

or an array of two pointers

GtkWidget *myTwoWidgets[2]

and pass a pointer to the struct/array as data. In both cases you will
have to typecast the gpointer in the handler to the corresponding type.

If you're using Glade, you can also pass the reference to the parent
window, and do lookup_widget (parent, ) for each widget inside the
handler.

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


Re: Signal Handling problems with own data

2006-08-18 Thread Iago Rubio
On Fri, 2006-08-18 at 07:03 -0700, NicolasA wrote:
 I have read all the examples in the gtk tutorial, I have 3 books on gnome
 and gtk but I haven't found a single example which shows how to pass more
 that 1 widget to the function.

Here you've got a full example:

// save as test.c  compile with:
// gcc -g test.c -o test `pkg-config --cflags --libs gtk+-2.0`
// run with ./test

#include gtk/gtk.h

typedef struct _TwoWidgets {
  GtkWidget *entry_name;
  GtkWidget *entry_password;
} TwoWidgets;

void dlg_response (GtkDialog *dialog,
   gint   arg1,
   gpointer   user_data)
{
  g_free (user_data);
  gtk_widget_destroy (GTK_WIDGET(dialog));
  gtk_main_quit();
}

void button_clicked (GtkButton *button,
 gpointer   user_data)   
{
  TwoWidgets* widgets;
  
  widgets = (TwoWidgets*) user_data;
  
  g_print(Name: %s\nPassword: %s\n\n,
  gtk_entry_get_text (GTK_ENTRY(widgets-entry_name)),
  gtk_entry_get_text (GTK_ENTRY(widgets-entry_password)));
}

int main(int argc, char **argv)
{
  GtkWidget *dialog, *dialog_vbox;
  GtkWidget *entry_name,*entry_password;
  GtkWidget *button;
  static GdkPixbuf *pixbuf;
  GtkTreeModel *model;
  TwoWidgets *widgets;
  
  gtk_init (argc, argv);
  
  dialog = gtk_dialog_new();  
  dialog_vbox = GTK_DIALOG (dialog)-vbox;
  gtk_widget_show (dialog_vbox);

  entry_name = gtk_entry_new  ();
  gtk_widget_show (entry_name);
  gtk_box_pack_start (GTK_BOX (dialog_vbox), entry_name, TRUE, TRUE, 0);
  
  entry_password = gtk_entry_new  ();
  gtk_widget_show (entry_password);
  gtk_box_pack_start (GTK_BOX (dialog_vbox), entry_password, TRUE, TRUE,
0);

  button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
  gtk_widget_show (button);
  gtk_box_pack_start (GTK_BOX (dialog_vbox), button, FALSE, FALSE, 0);
  
  widgets = g_malloc(sizeof(TwoWidgets));
  widgets-entry_name = entry_name;
  widgets-entry_password = entry_password;
  
  g_signal_connect ( button,
  clicked, 
  G_CALLBACK (button_clicked),
  widgets );
  
  g_signal_connect ( dialog,
  response, 
  G_CALLBACK (dlg_response),
  widgets );  
  
  gtk_widget_show (dialog);
  gtk_main ();
  
  return 0;
}



 Do I have to use the Gobject, which function of the API should I use?

You can use g_object_set_data and g_object_get_data on the button that
will be passed to the clicked callback:

// save as test2.c  compile with:
// gcc -g test2.c -o test2 `pkg-config --cflags --libs gtk+-2.0`
// run with ./test2

#include gtk/gtk.h

void dlg_response (GtkDialog *dialog,
   gint   arg1,
   gpointer   user_data)
{
  gtk_widget_destroy (GTK_WIDGET(dialog));
  gtk_main_quit();
}

void button_clicked (GtkButton *button,
 gpointer   user_data)  
{
  gpointer *name, *password;

  name = g_object_get_data (G_OBJECT(button), entry_name);
  password = g_object_get_data (G_OBJECT(button), entry_password);

  if( name  password ){
g_print(Name: %s\nPassword: %s\n\n,
  gtk_entry_get_text (GTK_ENTRY(name)),
  gtk_entry_get_text (GTK_ENTRY(password)));
  }
}

int main(int argc, char **argv)
{
  GtkWidget *dialog, *dialog_vbox;
  GtkWidget *entry_name,*entry_password;
  GtkWidget *button;
  static GdkPixbuf *pixbuf;
  GtkTreeModel *model;
  
  gtk_init (argc, argv);
  
  dialog = gtk_dialog_new();  
  dialog_vbox = GTK_DIALOG (dialog)-vbox;
  gtk_widget_show (dialog_vbox);

  entry_name = gtk_entry_new  ();
  gtk_widget_show (entry_name);
  gtk_box_pack_start (GTK_BOX (dialog_vbox), entry_name, TRUE, TRUE, 0);
  
  entry_password = gtk_entry_new  ();
  gtk_widget_show (entry_password);
  gtk_box_pack_start (GTK_BOX (dialog_vbox), entry_password, TRUE, TRUE,
0);

  button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
  gtk_widget_show (button);
  gtk_box_pack_start (GTK_BOX (dialog_vbox), button, FALSE, FALSE, 0);
  
  g_object_set_data (G_OBJECT(button), 
 entry_name, entry_name);
  g_object_set_data (G_OBJECT(button), 
 entry_password, entry_password);
 
  g_signal_connect ( button,
  clicked, 
  G_CALLBACK (button_clicked),
  NULL );
  
  g_signal_connect ( dialog,
  response, 
  G_CALLBACK (dlg_response),
  NULL );  
  
  gtk_widget_show (dialog);
  gtk_main ();
  
  return 0;
}


 And if more than one widgets can be passed to the function, how can I access
 them ?

This depends on the method you used.
-- 
Iago Rubio

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org

Re: Signal Handling problems with own data

2006-08-18 Thread NicolasA

Thank you both for the useful advice, you have just saved my life  :)))

-- 
View this message in context: 
http://www.nabble.com/Signal-Handling-problems-with-own-data-tf2127300.html#a5871939
Sent from the Gtk+ - Apps Dev forum at Nabble.com.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Fullscreen application running?

2006-08-18 Thread Edward Catmur
On Fri, 2006-08-18 at 15:13 +0530, Unique User wrote:
 Hi All,
   I am writing an application which pops up a message   at random  
 interval.  Before showing the message, I want to check whether a full  
 screen application(movie,game etc.)   is running. How can I do this? I am  
 writing this application in pygtk.

Look at fullscreen_window_exists() in src/daemon.c in
notification-daemon (0.3.5 tarball, or in trac[1]). 

It's in C, but should be fairly trivial to port to Python.

You'll need wnck-python, which is in gnome-python-desktop.

Ed


[1]
http://trac.galago-project.org/browser/trunk/notification-daemon/src/daemon.c?rev=2550

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