Re: Callback Question

2008-04-14 Thread Matí­as Alejandro Torres
Alexander Semenov escribió:
 Hi. Perhaps, this discussion was related to threads?
   
   
 Thank you all for this! Especialy for the long example, but, it was just 
 an example.
 I've made an application that works perfectly on Linux but in Window$ it 
 crashes a lot!
 I've been trying to find a solution (actually a clue of what the problem 
 might be) in any discussion I was able to find about GTK crashes in the 
 internet.
 In one of these discussions it was said that gtk functions can't be 
 called inside callbacks, that it wasn't safe yet. That, if you call any 
 gtk function inside a callback, it should be done using 
 g_object_idle_add. Unfortunatly I didn't check the date of the 
 discussion, maybe, it is too old.

 Thanks.

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


   
No, no threads are involved.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Callback Question

2008-04-13 Thread Matí­as Alejandro Torres
Hi,

Can I call GTK Functions that modifies the GUI inside a callback?

Just an example:


/*CALLBACK*/
void text_to_upper_callback (GtkEntry *entry, gpointer data) {
/* I modify the GUI by setting the text of an entry */
gtk_entry_set_text (entry,
 g_utf8_strup (gtk_entry_get_text 
(entry), -1)));
}


void* init () {
[...]
g_signal_connect (entry, activate, (GCallback) 
text_to_upper_callback, NULL);
[...]
}


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


Re: Callback Question

2008-04-13 Thread Matí­as Alejandro Torres
Roman Makurin escribió:
 В Вск, 13/04/2008 в 15:46 -0300, Matí­as Alejandro Torres пишет:
   
 Hi,

 Can I call GTK Functions that modifies the GUI inside a callback?

 Just an example:


 /*CALLBACK*/
 void text_to_upper_callback (GtkEntry *entry, gpointer data) {
 /* I modify the GUI by setting the text of an entry */
 gtk_entry_set_text (entry,
  g_utf8_strup (gtk_entry_get_text 
 (entry), -1)));
 }


 void* init () {
 [...]
 g_signal_connect (entry, activate, (GCallback) 
 text_to_upper_callback, NULL);
 [...]
 }


 

 #include gtk/gtk.h

 static void destroy(GtkWidget *widget, gpointer data) {
   gtk_main_quit();
 }

 static void convert(GtkButton *button, GtkEntry *entry) {
   gtk_entry_set_text(entry, 
   g_utf8_strup(gtk_entry_get_text(entry), -1));
 }

 int main(int argc, char **argv) {
   GtkWidget *window, *entry, *button, *box;

   gtk_init(argc, argv);

   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW(window), Converter);
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
   gtk_window_set_resizable(GTK_WINDOW(window), FALSE);

   g_signal_connect(G_OBJECT(window), destroy,
   G_CALLBACK(destroy), NULL);

   box = gtk_hbox_new(FALSE, 0);
   entry = gtk_entry_new();
   button = gtk_button_new_with_mnemonic(_Convert);

   gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);

   g_signal_connect(G_OBJECT(button), clicked,
   G_CALLBACK(convert), entry);
   
   gtk_container_add(GTK_CONTAINER(window), box);
   gtk_widget_show_all(window);
   gtk_main();

   return 0;
 }

   
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 
Thank you all for this! Especialy for the long example, but, it was just 
an example.
I've made an application that works perfectly on Linux but in Window$ it 
crashes a lot!
I've been trying to find a solution (actually a clue of what the problem 
might be) in any discussion I was able to find about GTK crashes in the 
internet.
In one of these discussions it was said that gtk functions can't be 
called inside callbacks, that it wasn't safe yet. That, if you call any 
gtk function inside a callback, it should be done using 
g_object_idle_add. Unfortunatly I didn't check the date of the 
discussion, maybe, it is too old.

Thanks.

Matías.
___
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 use GList Double Link List

2007-12-25 Thread Matí­as Alejandro Torres
sumit kumar escribió:
 *gint pos;
 g_print(Enter Number1\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);

 g_print(Enter Number2\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);

 g_print(Enter Number3\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);

 g_print(Enter Number4\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);
 *
 It prints only last element I appened 4 times... 44, 44 ,44 ,44 if I
 appended 44 as last element.
 Whats wrong with this code??

   
You're not alocating new space, the pos pointer is always pointing at 
the same cell, which by the way is never initialized. Also, when you use 
g_list_append you're passing a pointer to a pointer to an integer, and I 
don't think that's what you want. Do something like:

#include stdio.h
#include glib.h
#include glib/gprintf.h

int main (int argc, char **argv) {
GList *tmp, *list = NULL;
gint i, *element;

/* Appends 4 integers into list */
for (i=1; i5; i++) {
element = g_malloc (sizeof (gint));
g_printf (Enter Number %d: , i);
scanf (%d, element);
list = g_list_append (list, element);
}

/* Prints data in list */
tmp = list;
while (tmp) {
element = tmp-data;
g_printf (%d\n, *element);
tmp = g_list_next (tmp);
}

/* Frees the data in list */
tmp = list;
while (tmp) {
g_free (tmp-data);
tmp = g_list_next (tmp);
}

/* Frees the list structures */
g_list_free (list);

return 0;
}

GLib API Reference: http://developer.gnome.org/doc/API/2.0/glib/index.html
GLib Tutorial: http://gtk.org/tutorial/x2037.html
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Displaying a (simple) list of strings

2007-12-04 Thread Matí­as Alejandro Torres

An example of a GtkTreeView with a couple of strings.

About the 10 items limit I don't know how to do that. Maybe if you can 
get the requested size of a row ( gtk_cell_renderer_get_size () ), 
multiplying it by 10 and  setting this size to the GtkTreeView (plus 
headers and stuff) but is an error prone approach to me.
¿Anyway are you sure that limiting the amount of items that can be 
displayed is comfortable to the user? Maybe if you pack the widgets 
well, you won't need that.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Displaying a (simple) list of strings

2007-12-04 Thread Matí­as Alejandro Torres
Matí­as Alejandro Torres escribió:
 An example of a GtkTreeView with a couple of strings.

 About the 10 items limit I don't know how to do that. Maybe if you can 
 get the requested size of a row ( gtk_cell_renderer_get_size () ), 
 multiplying it by 10 and  setting this size to the GtkTreeView (plus 
 headers and stuff) but is an error prone approach to me.
 ¿Anyway are you sure that limiting the amount of items that can be 
 displayed is comfortable to the user? Maybe if you pack the widgets 
 well, you won't need that.
Delete this line from the example (I was just checking something):

gtk_cell_renderer_text_set_fixed_height_from_font 
((GtkCellRendererText*) renderer, 2);

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


Re: Application with plugins

2007-11-29 Thread Matí­as Alejandro Torres
Micah Carrick escribió:
 You may want to take a look at how Gedit created a GObject-based plugin 
 system.

 - Micah Carrick
   
Or the Pidgin plugin system.

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

Images in database

2007-10-15 Thread Matí­as Alejandro Torres
Hi,

I'm building an application which handles, let's say... people's 
information. This information is stored using sqlite which until now 
consisted only in human-readable data (text/integers/dates). But... now 
I need to handle images (GdkPixbufs) and I don't know how to store it, 
is perfectly safe using sqlite to store this GdkPixbufs too?

Now, a GTK question :P, I wan't to provide functionality to resize the 
images to fit the actual size of it's container visible area, how do I 
know the size of this area? The image is packed inside a GtkPaned.


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


Re: GtkTreeModelFilter and GtkTreeSortable

2007-10-10 Thread Matí­as Alejandro Torres
Kristian Rietveld escribió:
 See the API documentation here:

   http://pygtk.org/docs/pygtk/class-gtktreemodelsort.html

 To the constructor of gtk.TreeModelSort you want to pass in self.filter
 as child model.  Then set the resulting sort model as model to show in
 the tree view.


 regards,

 -kris.

   
 You want to wrap the GtkTreeModelFilter you create here in a
Hi again,

I did what you told me, it worked, but I have a few questions:


- I have to create a new GtkTreeModelSort everytime the child model is 
modified? or it gets resorted automatically? Example:

fiter = self.sortedModel.convert_iter_to_child_iter (None, siter)
miter = self.filter.convert_iter_to_child_iter (fiter)
self.model.remove (miter)

self.filter.refilter ()

self.sortedModel = gtk.TreeModelSort (self.filter)
self.sortedModel.set_sort_func 
(gui.patientsmodel.PATIENT_OBJECT_COLUMN, 
gui.patientsmodel.patient_sort_func)
self.sortedModel.set_sort_column_id 
(gui.patientsmodel.PATIENT_OBJECT_COLUMN, gtk.SORT_ASCENDING)
  
tv.set_model (self.sortedModel)

- About efficiency, everytime I set's the sortedModel to the GtkTreeView 
it takes a few seconds (like 2 secs) to display it. It takes about the 
same with both ways, recreating the sortedModel again and ... well... 
not recreating it (but I don't know if I can do this). There's about 
2.000 rows in the model, is this normal? Suggestions?


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


Re: GtkTreeModelFilter and GtkTreeSortable

2007-09-30 Thread Matí­as Alejandro Torres
Kristian Rietveld escribió:
 To the constructor of gtk.TreeModelSort you want to pass in self.filter
 as child model.  Then set the resulting sort model as model to show in
 the tree view.
   
Okey, I'll do that. I should have seen that before :-[ . Thanks for the 
help!
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkTreeModelFilter and GtkTreeSortable

2007-09-29 Thread Matí­as Alejandro Torres
Andrew Cowie escribió:
 On Fri, 2007-09-28 at 23:49 -0300, Matí­as Alejandro Torres wrote: 
 My problem is that GtkTreeModelFilter does not implements the 
 GtkTreeSortable interface and I lost the sorting capabilities that I 
 used to have.
 

 It's been a while since I worked on the code in question, but I had a
 GtkTreeView that had both GtkTreeModelSort and GtkTreeModelFilter going
 on at the same time. You nest them. Something like:

 listStore = gtk_list_store_new(...);
 filteredStore = gtk_tree_model_filter_new(listStore, NULL);
 sortedStore = gtk_tree_model_sort_new_with_model(filteredStore);

 view = gtk_tree_view_new_with_model(sortedStore);

   


Thank you both for your reply.

I'm working on python, and I can't find functions to add the sortable 
functions to an instance of a GtkTreeModel.

Let's say I have a method that receives a GtkListStore that is sortable:


/* This funcion calls set_model */

def database_changed_cb (self, ccontroller, db, patients):
self.db = db
self.patients = patients
if patients:
model = gui.patientsmodel.PatientsModel (patients)
model.set_sortable (True) /* Adds the sort_funcs */
self.set_model (model)
else:
self.set_model (None)

/* This one receives the model and update the GUI */
def set_model (self, model):
if model:
self.filter = model.filter_new ()
self.filter.set_visible_func (self.patient_filter_callback)
self.patientsBox.tree_view.set_model (self.filter)
self.unblock_signals ()
self.patient_selected_callback ()
self.patientsBox.set_sensitive (True)
else:
self.filter = None
self.patientsBox.tree_view.set_model (None)
self.patientsBox.set_sensitive (False)
self.patient_selected_callback ()
self.block_signals ()


I append these functions to make clear what i'm trying to do. hope this 
help you to help me :P, thanks.

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


Re: Conversion functions.

2007-09-06 Thread Matí­as Alejandro Torres
Magnus Myrefors escribió:
 Hi,
   Ok, here's a small part of it. The whole file is about
 2400 rows. I can read over approximately 95 % of it ok
 but the rest is somewhat corrupted. I think it is
 the function g_ascii_isdigit() that fails sometimes which 
 leaves a uncompleted conversion. I am about to try another
 way without this function.

 /Magnus
  
 On Wed, 05 Sep 2007 16:29:02 -0300
 Matí­as Alejandro Torres [EMAIL PROTECTED] wrote:

   
 What's the input file like? Can you attach a part of it? If you do
 so, I can make a try on reading it.

 Matías
 
 

  Longtitude  Latitude   Altitude  IntervalTime  HeartRate  Speed

 --

 1134:17.64662 59.84263 15  10  0  11.45

 1135:17.64661 59.84266 15  10  0  12.59

 1136:17.64661 59.84269 14  10  0  10.89

 1137:17.64660 59.84272 14  10  0  10.83

 1138:17.64659 59.84275 13  10  0  12.58

 1139:17.64659 59.84278 13  10  0  11.19

 1140:17.64658 59.84281 13  10  0  11.76

 1141:17.64656 59.84284 13  10  0  12.08

 1142:17.64655 59.84286 12  10  0  11.95
Here's the minimal program to read that. The reading part is kind of 
crappy but it works with that example.
The reading part reads char by char. Using the g_ascii_is_digit only to 
skip the header.



Matias

/* BEGIN */

#include stdio.h
#include stdlib.h
#include gtk/gtk.h
#include glib.h
#include glib/gstdio.h

typedef enum {
MODEL_LOG,
MODEL_LATITUDE,
MODEL_ALTITUDE,
MODEL_INTERVAL,
MODEL_HEARTBEAT,
MODEL_SPEED,
MODEL_NUM_COLUMNS
} ModelColumns;

typedef struct _Data {
gchar *log;
gdouble latitude;
gint altitude;
gint interval;
gint heartbeat;
gdouble speed;
} Data;


GtkTreeModel *
do_model (GSList *list)
{
GSList *act;
GtkListStore *store;

store = gtk_list_store_new (MODEL_NUM_COLUMNS, G_TYPE_STRING, 
G_TYPE_DOUBLE, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_DOUBLE);
   
act = list;
while (act != NULL) {
GtkTreeIter iter;
Data * data = act-data;
   
gtk_list_store_append (store, iter);
gtk_list_store_set (store, iter,
MODEL_LOG, data-log,
MODEL_LATITUDE, data-latitude,
MODEL_ALTITUDE, data-altitude,
MODEL_INTERVAL, data-interval,
MODEL_HEARTBEAT, data-heartbeat,
MODEL_SPEED, data-speed, -1);
   
act = g_slist_next (act);
}
   
return GTK_TREE_MODEL (store);
}

GtkWidget *do_window (GtkTreeModel *model) {
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
GtkWidget *tree_view = gtk_tree_view_new ();
GtkWidget *scroll;
GtkCellRenderer *rend;
GtkTreeViewColumn *col;

tree_view = gtk_tree_view_new ();
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (tree_view));

rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (Longitude, rend, 
text, MODEL_LOG, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);

rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (Latitude, rend, 
text, MODEL_LATITUDE, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);

rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (Altitude, rend, 
text, MODEL_ALTITUDE, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
   
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (Interval, rend, 
text, MODEL_INTERVAL, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
   
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (Heartbeat, rend, 
text, MODEL_HEARTBEAT, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
   
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (Speed, rend, 
text, MODEL_SPEED,  NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
   
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);
gtk_widget_set_size_request (tree_view, -1, 300);
   
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), 
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   
gtk_container_add (GTK_CONTAINER (scroll), tree_view);
gtk_container_add (GTK_CONTAINER (window), scroll);
   
return window;
}

GSList* reader (FILE *file)
{
Data *data;
gchar c;
gchar tmp [50];
int campo = 0, cont = 0;
GSList *list = NULL;
   
while (c != EOF) {
campo = 0;
cont = 0;
   
c = fgetc (file

Re: Conversion functions.

2007-09-06 Thread Matí­as Alejandro Torres
Jaja, so it wasn't crappy, it was **crap*.* :P
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Conversion functions.

2007-09-05 Thread Matí­as Alejandro Torres
What's the input file like? Can you attach a part of it? If you do so, I 
can make a try on reading it.

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

Re: Getting a GdkPixbufs from a GtkTextBuffer

2007-09-03 Thread Matí­as Alejandro Torres
Jonathan Winterflood escribió:
 Hi,

 Can't you just keep a reference to the pixbuf ?

 Jonathan

The problem with that approch is that I have to keep track for every 
pixbuf in the TextBuffer if its deleted or moved. It's doable but I 
rather not :P

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


GtkWidget inside a GtkMenuItem

2007-09-03 Thread Matí­as Alejandro Torres
Hi,


I want to pack a GtkHScale inside a GtkMenuItem, I knew from the 
beggining that this was not going to work but... what a %·$$! I did 
this with the gtk_container_add function BUT the GtkHScale widget does 
not appears to be  receiving signals, like if it's in insensitive state.

Is there something I could do to make the widget inside the GtkMenuItem 
to  work? Is there a GtkWidgetMenuItem implemented somewhere? Please Help!

Thanks in advance.

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


g_main_loop and persistant connections

2007-07-08 Thread Matí­as Alejandro Torres
Hi, I'm having problems to design a python network application, that is 
like a messenger.

In this app, the user would be able to send and receive messages. There 
are persistant connections involved, mainly because it is possible to 
receive messages asyncronously.

I would like to handle these permanent connections in differents 
threads, so the GUI doesn't halt when sending, receiving or even 
wainting a message, but

*How the main thread (the GUI, locked in g_main_loop) is awaken by the 
connection handler threads when a message arrives
*
I don't understand how the connection threads call functions that should 
be run in the main thread when this one is iterating the main loop. *Can 
different threads make modifications in the widgets?* (using the 
appropiate locks, barriers when needed).

Can someone point to a nice howto/tutorial about this? Any help would be 
appreciate since I've never written an application like this and I am 
kind of fully-lost about this.

Thanks in advance, even for reading up to here.

Matías

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


Re: new window from button

2007-07-02 Thread Matí­as Alejandro Torres

brad smith escribió:

Hello everyone,
I am trying to open a new window(that has a text view widget) from a
button on the main window. I have looked for examples but could not
find any.(or maybe I just do not know what I am looking for)
Thanks in advance,
Brad
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

  

Here's an example. Is this what you were looking for?

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

Re: Newbie Question: How i can use glib-2.0 in my c-programm ?

2007-06-26 Thread Matí­as Alejandro Torres
Kai Szymanski escribió:
 Hi!

 As i search the web for a util-library that i can use in my c-programms,
 i found glib-2.0. So i decide to install it on my system (debian 4.0 -
 libglib-2.0 and libglib-2.0-dev). When i try to use it, i did'nt work.
 The Source (a simple test):

 -- Snip
 #include stdio.h

 #include glib-2.0/glib.h

 void main(int argc, char *argv) {
 gstring *gs = NULL;
 }

 -- Snip

 db03:/home/ks/src/test/Release# gcc -o test test.c -I
 /usr/include/glib-2.0/ -I /usr/lib/glib-2.0/include/
 test.c: In function `main':
 test.c:6: Fehler: »gstring« nicht deklariert (erste Benutzung in dieser
 Funktion)
 test.c:6: Fehler: (Jeder nicht deklarierte Bezeichner wird nur einmal
 aufgeführt
 test.c:6: Fehler: für jede Funktion in der er auftritt.)
 test.c:6: Fehler: »gs« nicht deklariert (erste Benutzung in dieser Funktion)
 test.c:5: Warnung: Rückgabetyp von »main« ist nicht »int«

 -- Snip

 Sorry, german text. It say's:
 test.c:6: Error: »gstring« not declared

 Hmmm :)

 Thanks for your help.

 CU,
Kai.

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

   

First, note that the type is GString not gstring. Remember C is case 
sensitive.

Example:

#include glib.h

int main ()
{
GString *gstr = g_string_new (Hola);
printf  (GString: %s\n, gstr-str);
g_string_free (gstr, TRUE);
return 0;
}


Compile like this:

gcc `pkg-config --cflags glib-2.0` -o test test.c `pkg-config --libs 
glib-2.0`



Matias.

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


Fwd: button_press_event signal in GtkCellRendererToggle

2007-04-15 Thread Matí­as Alejandro Torres

Solved, I missed the toggled signal on the cell renderer.
___
gtk-app-devel-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

button_press_event signal in GtkCellRendererToggle

2007-04-14 Thread Matí­as Alejandro Torres
Hi,

How can i add a GtkCellRendererToggle the button_press_event signal 
without making a new widget?

I have a GtkTreeView with a CheckBox (GtkCellRendererToggle) in it and I 
want the user modify its value by clicking on it. How can I do this?

Thanks in advance. Matias.

___
gtk-app-devel-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problem related to treeview

2007-03-16 Thread Matí­as Alejandro Torres
sumit kumar escribió:
  Hi all,
 i have problem related to treeview.
 I am showing list of member in window using treeview. Now I want to select
 one out of this list and after selecting that member a window should be
 created with that member name.How i can do that?
 what API i should use to connect callback to the liststore enries?? I
 storing member names using liststore.

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

   
You can connect a callback funtion to the signal row-activated of a 
treeview (emited when you double click a row).
For example,

/* Creates a model */
GtkTreeModel * function create_model ();

/* Creates the treeview */
GtkWidget * function create_treeview ();

void row_activated_callback (GtkTreeView 
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeView.html 
*tree_view, GtkTreePath 
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeModel.html#GtkTreePath 
*path, GtkTreeViewColumn 
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html 
*column, gpointer 
http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gpointer 
user_data)
{
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
GtkWidget *window;
GtkWidget *label;
gchar *membername;

gtk_tree_model_get_iter (model, path, iter);
gtk_tree_model_get (model, iter, MEMBER_NAME_COLUMN, membername, -1);
   
label = gtk_label_new (membername);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_add (GTK_CONTAINER (window), label);

gtk_widget_show_all (window);
}

/* Assign a model to the treeview, connects the row-activated */
void bla ()
{
GtkTreeModel *model = create_model ();
GtkTreeView *treeview = create_treeview ();

gtk_tree_view_set_model (treeview, model);
g_signal_connect (G_OBJECT (treeview), row-activated, (GCallback) 
row_activated_callback, NULL);

[...]
}

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


Re: text entry validation

2007-03-13 Thread Matí­as Alejandro Torres

 void
 on_bt_validate_clicked (GtkButton   *button,
 gpointer user_data)
 {

 if (dont know how to check)..) 

 {


 }
 else/***check if not correct then display dialog box*/

 GtkWidget *dialog1;
 dialog1 = create_dialog1 ();
 gtk_widget_show (dialog1);

 }
   

Maybe something like this will help:

void
on_bt_validate_clicked (GtkButton   *button,
GtkEntry*entry)
{
gboolean hasdigit = FALSE;
const gchar * string = gtk_entry_get_text (entry);
gint length = strlen (string);
gint i = 0;

while ((i  length)  (!hasdigit))
{
hasdigit = g_ascii_isdigit (string [i]);
i++;
}

if (hasdigit)
/* Show dialog */
else
/* Do something else */
}

The function g_ascii_isdigit checks wheter a character is an ASCII digit (0-9). 

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


Re: text entry validation

2007-03-13 Thread Matí­as Alejandro Torres



void
on_bt_validate_clicked (GtkButton   *button,* gpointer user_data*)  
{

*GtkWidget *entry;*
[.]
}

there is no error but nothing is displayed and the application is
closed...please help

thanks


  
Well, the code i sent you to my surprise, did things right the first 
time I tried it.
The error with your code, is that you don't understand the way signals 
are connected:


When you connect a signal you use the g_signal_connect function that 
connects a GCallback 
http://developer.gnome.org/doc/API/2.0/gobject/gobject-Closures.html#GCallback 
function to a signal for a particular object.

From the code i attach with this email:

g_signal_connect (G_OBJECT (button), clicked, (GCallback) 
entry_validation, *entry);*


*button:* the putton that will emit emit the signal.
*clicked:* the signal
*entry_validation:* the function that will respond to the signal
*entry:* here you can pass data that the entry_validation function will 
receive, it is not necesary (you can specify NULL). Here we use so the 
entry_validation function knows the entry where the text is.


What you did wrong was create a new entry in the callback function that 
knows nothing about the other entry where you wrote the text.


Look at the file I attached, it works just fine, at least in my linux. 
If you're in linux you can compile it with:


gcc `pkg-config --cflags gtk+-2.0` -o entryvalidation entryvalidation.c 
`pkg-config --libs gtk+-2.0`



Please read this: GTK+-2.0 Tutorial http://gtk.org/tutorial/. It shows 
how to connect and handle signals. Respond to the list so the messages 
related to this thread are not interrupted.


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

Re: Cyclic Dependency

2007-03-11 Thread Matí­as Alejandro Torres


 Add

 G_END_DECLS
 #include category.h
 G_BEGIN_DECLS

   

Thanks! I added that and it work just fine. Is there any documentation 
that explain what these macros do? The API reference of GLib gives a 
very short explanation: Used (along with G_END_DECLS 
http://developer.gnome.org/doc/API/2.0/glib/glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS)
 
to bracket header files.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


not enough variable arguments to fit a sentinel?

2007-02-12 Thread Matí­as Alejandro Torres
What about this warning

181:dialog = gtk_file_chooser_dialog_new (_(Select where to save 
contacts.),
182: NULL,
183: 
GTK_FILE_CHOOSER_ACTION_SAVE,
184: NULL);


contacts.c:184: warning: not enough variable arguments to fit a sentinel

Note: I do not add the buttons here because it is done with 
gtk_file_chooser_add_button somewhere else.

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