question about GIO and GVolumeMonitor

2009-06-22 Thread Julien Martin
Hello,

I am playing about with GTK and GIO and I am trying to list the first
volume, mount and drive. My code is as follows:

*#include 
#include 
#include 
#include 
#include 

int main(int argc, char** argv) {

GVolumeMonitor * monitor;
GList * drives;
GList * mounts;
GList * volumes;
char * mount_name;
char * drive_name;
char * volume_name;

gtk_init(&argc, &argv);

monitor = g_volume_monitor_get();
drives =
g_volume_monitor_get_connected_drives(G_VOLUME_MONITOR(monitor));
mounts = g_volume_monitor_get_mounts(G_VOLUME_MONITOR(monitor));
volumes = g_volume_monitor_get_volumes(G_VOLUME_MONITOR(monitor));

GVolume * volume = (GVolume *) volumes->data;
GDrive * drive = (GDrive *) drives->data;
GMount * mount = (GMount *) mounts->data;

volume_name = g_volume_get_name(volume);
drive_name = g_drive_get_name(drive);
mount_name = g_mount_get_name(mount);

g_print("%s\n", volume_name);

g_free(mount_name);
g_free(drive_name);
g_free(volume_name);

gtk_main();

return (EXIT_SUCCESS);

}*

I get a segmentation fault as if it was indicating that there were no volume
nor any mount on my machine... (note that I don't get this problem with the
drive.)

Can anyone help?

Thanks,

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


Re: transparent cairo rendering

2009-06-22 Thread Jose Hevia
2009/6/18 Paul Davis :
> On Thu, Jun 18, 2009 at 11:30 AM, Jose
> Hevia wrote:
>> Hi, I have been fighting for a long time with a very simple program I
>> can't make work the way it should.
>>
>> The question is:
>>
>> Is that a bug or is it my fault?
>
> why are there calls to gtk_widget_show() from your expose handler?
>

:-)
Because I didn't know how to make it working, and gtk_widget_show
could send a sign to update the widget. It doesn't work without it
either.

As you can see, I used a rectangle too, in theory that is not
necessary, for the same reason, and disable the clipping mask too with
cairo_reset_clip, and set cairo_set_operator (cr, CAIRO_OPERATOR_OVER)
that is the default( theorically ).

I could make it work if I redraw manually(by a function copying
pixels) the surface, but this is not the way it should work, if cairo
uses hardware acceleration, I lost it.

here:
http://cairographics.org/operators/#clipmask

it says that source puts the alpha value and the color, this is not
what is doing. Seems like a bug to me.

Thanks for your help.
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: transparent cairo rendering

2009-06-22 Thread Jose Hevia
Seems to me that when I say:
 Draw me a rectangle that is (0,0,0(black),0(and transparent)...

he says

oh, is transparent, so I don't need to paint it,

But the problem appears if there was something out there (not
transparent) and want to make it transparent, you can't, unless you
make a function to make it pixel by pixel.

That would explain why it works the first renderings and can't paint
over something already painted, although destroyed and recreated.
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


beginner needs help with "casting" with gtk

2009-06-22 Thread Julien Martin
Hello,
I have the following callback function:

*static void hello(GtkWidget *widget, gpointer data) {
gchar * _data = (gchar *) data;
g_print(_data);
g_print("\n");
}*

wich I call as follows:
*
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(hello), "hello
toto");*

I get the following warning each time I compile:

*warning: the format is not a litteral string and no format argument*

Can anyone please help?
I need to "cast" the data variable to gchar *. What am I doing wrong?

Thanks in advance,

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


Re: Injecting input inside a gtk program?

2009-06-22 Thread Dan Kegel
On Thu, Jun 18, 2009 at 5:46 PM, Dan Kegel wrote:
> How does one inject keystrokes in a gtk program?

http://mail.gnome.org/archives/gtk-app-devel-list/2004-July/msg00016.html
shows how to do it with
gdk_keymap_get_entries_for_keyval() and gtk_main_do_event().

(Presumably if you want to send input to a specific window
you would call that window's methods instead, but
that doesn't work if you want the keystrokes to
be processed via IME's, etc.)
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Injecting input inside a gtk program?

2009-06-22 Thread Dan Kegel
On Mon, Jun 22, 2009 at 7:32 AM, Dan Kegel wrote:
> On Thu, Jun 18, 2009 at 5:46 PM, Dan Kegel wrote:
>> How does one inject keystrokes in a gtk program?
>
> http://mail.gnome.org/archives/gtk-app-devel-list/2004-July/msg00016.html
> shows how to do it with
> gdk_keymap_get_entries_for_keyval() and gtk_main_do_event().

but don't forget to read the followup,
http://mail.gnome.org/archives/gtk-app-devel-list/2004-July/msg00036.html
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


gtk.TreeModel.iter_children() method, how often should it be called?

2009-06-22 Thread Gerald Britton
Hi -- I think I have a problem but I'm not sure since I'm relatively
new to the TreeModel and how it works.  Here's the scenario:

I use TreeModel to display rows of data from a database.  Upon
startup, the TreeModel is built and I notice two calls to the
gtk.TreeModel.iter_children() method.  Later, I change some data in
one of the rows.  The next time the TreeModel is built,
gtk.TreeModel.iter_children() is called thousands of times before the
display is refreshed. Oh, the database has less than 50 rows of data
in it!

So, two questions:

1. Is this normal (I hope not!) behavior?

2. What tells the TreeModel to stop calling
gtk.TreeModel.iter_children()?  How does the TM know that it has done
everything it needs to do before displaying the tree?

--
Gerald Britton
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Implementing zoom and pan on pygtk

2009-06-22 Thread Billy Okal
hello

I am new to pygtk but familiar with python. I am trying to build a 
simple gui that allows zooming and panning (using arrows in 4 
directions) of images(maps) in png and svg formats. However I 
can't get the zooming an panning to work. Could someone offer 
help on this. I really need it fast so that I can start so real work 
using images. I already tried to use scrolling to implement the 
panning but I couldn't make it.

I show the images like this
im = gtk.Image()
im.set_from_file("something.png")
.
.
win.show_all


so far I  have this
I have buttons eg for zoomout;
self.z_out = gtk.Button(stock=gtk.STOCK_ZOOM_OUT)
self.z_in.connect("clicked", self.zoomin, width, height)

then I have this function
def zoomout(self, widget, width, height):
w, h = hzoomout(width, height)
im = self.image
pixbuf = gtk.gdk.pixbuf_new_from_file("bremen.png")
scaled_buf = 
pixbuf.scale_simple(w,h,gtk.gdk.INTERP_BILINEAR)
im.set_from_pixbuf(scaled_buf)
im.show()

hzoomout is just a small function that computes the new height 
and width based on some scale

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


Re: Implementing zoom and pan on pygtk

2009-06-22 Thread Pierre-Luc Beaudoin
On Mon, 2009-06-22 at 20:13 +0200, Billy Okal wrote:
> I am trying to build a simple gui that allows zooming and panning
> (using arrows in 4 directions) of images(maps) in png and svg formats.

If you want a map widget, why not reuse a pre-existing one such as
libchamplain (which has Python bindings)?

Pierre-Luc


signature.asc
Description: This is a digitally signed message part
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


implementing zoom and pan in pygtk

2009-06-22 Thread Billy Okal
hello

I am new to pygtk but familiar with python. I am trying to build a 
simple gui that allows zooming and panning (using arrows in 4 
directions) of images(maps) in png and svg formats. However I 
can't get the zooming an panning to work. Could someone offer 
help on this. I really need it fast so that I can start so real work 
using images. I already tried to use scrolling to implement the 
panning but I couldn't make it.

I show the images like this
im = gtk.Image()
im.set_from_file("something.png")
.
.
win.show_all


so far I  have this
I have buttons eg for zoomout;
self.z_out = gtk.Button(stock=gtk.STOCK_ZOOM_OUT)
self.z_in.connect("clicked", self.zoomin, width, height)

then I have this function
def zoomout(self, widget, width, height):
w, h = hzoomout(width, height)
im = self.image
pixbuf = gtk.gdk.pixbuf_new_from_file("bremen.png")
scaled_buf = 
pixbuf.scale_simple(w,h,gtk.gdk.INTERP_BILINEAR)
im.set_from_pixbuf(scaled_buf)
im.show()

hzoomout is just a small function that computes the new height 
and width based on some scale

Thanks in advance
-- 


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


Re: gtk.TreeModel.iter_children() method, how often should it be called?

2009-06-22 Thread Tadej Borovšak
Hi.

> 1. Is this normal (I hope not!) behavior?

I'm not sure about 1000, but calling this function a lot is normal if
you make major changes to your model while attached to GtkTreeView.

> 2. What tells the TreeModel to stop calling
> gtk.TreeModel.iter_children()?  How does the TM know that it has done
> everything it needs to do before displaying the tree?

Try detaching model from tree view before doing any major change.
Sample code would look something like this (in C):
 CODE ---
model = gtk_tree_view_get_model( GTK_TREE_VIEW( tree ) );
g_object_ref( G_OBJECT( model ) );
gtk_tree_view_set_model( GTK_TREE_VIEW( tree ), NULL );

/* Make changes */

gtk_tree_view_set_model( GTK_TREE_VIEW( tree ), model );
g_object_unref( G_OBJECT( model ) );
 /CODE -

Hope this helps.

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


[no subject]

2009-06-22 Thread SRAVAN KUMAR malyala
sravankumar...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list