Problem with multiple selection in TreeView

2010-08-22 Thread Salvatore De Paolis
Hi,

I'm using GTK+ 2.20.1 and I notice a wrong behavior on the multiple selection.
I've connected a callback to the signal cursor-changed and within of if I
get the selection in this way:

sel = gtk_tree_view_get_selection(list_view);
model = gtk_tree_view_get_model(list_view);
rows = gtk_tree_selection_get_selected_rows(sel, model);

list_view is a GtkListStore data structure.
So when I selected with keyboard I can see here a multiple selection but
when using the mouse and holding shift it never happens and just give
a one-row selection.

I also noticed that when I click two times it works as expected, 
like click to select the first row, press shift, click to select the fourth 
row, click again on the fourth row.

It has the shape of the bug to me but I hope I'm missing something :)

Regards,

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

Re: Snow effect over a GtkWindow

2010-08-22 Thread Matteo Landi
Hi guys,
I'm here to share with you the script I created in order to achieve
the falling snow effect: I hope you enjoy it.

#!/usr/bin/python
# -*- coding: utf-8 -*-

Show of how to create a full-screen transparent window used to reproduce
the effect of objects falling over your desktop.


from __future__ import division
import sys
from math import sin
from random import random

import cairo
import gobject
import gtk
from gtk import gdk


class OverlayWindow(object):
Full-screen transparent window.


def __init__(self, symbol, color, nelem):
Constructor.

Other than create a window to draw things, we have to generate a list
of objects (3d-coordinates).

Keywords:
symbol symbol displayed on screen.
color color of the symbol.
nelem number of elements to display.

self.symbol = symbol
self.color = map(lambda v: int(v, 16) / 255,
 [color[:2], color[2:4], color[4:6]])
self.bin = [[3 * random() - 1.5, 2 * random() - 1, 2 * random()]
for _ in xrange(nelem)]
self.time = 0L

screen = gdk.screen_get_default()

# Create off-screen contexts.
width, height = screen.get_width(), screen.get_height()
ratio = width / height
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
self.context = cairo.Context(self.surface)
self.context.scale(width * 0.5 / ratio, height / 2)
self.context.translate(ratio, 1)

# Create a full-screen window specifying we are entirely responsible
# for drawing the background of the widget.
win = gtk.Window()
win.set_app_paintable(True)
#win.fullscreen()

# Let's try to use a colormap supporting transparency
colormap = screen.get_rgba_colormap()
if colormap:
win.set_colormap(colormap)

win.connect('delete-event', gtk.main_quit)
win.connect('expose-event', self.expose_cb)
win.show()

gobject.timeout_add(66, self.refresh, win)

def expose_cb(self, widget, event):
Output the content of the ImageSurface on the window context.

context = widget.window.cairo_create()

# clip the context in order to display only the exposed area
context.rectangle(event.area.x, event.area.y,
  event.area.width, event.area.height)
context.clip()

# make the background transparent
context.set_operator(cairo.OPERATOR_SOURCE)
context.set_source_rgba(0, 0, 0, 0)

# paint the content of the off-screen surface
#context.set_source_surface(self.surface)
context.paint()

return False

def refresh(self, widget):
Draw things over the off-screen context, and queue a redraw.

width, height = widget.window.get_size()
self.draw(self.context)
widget.queue_draw()

return True

def draw(self, context):
Draw the objects over the window.

The movement of each objects follows a sinusoidal behavior based on the
time variable.

Keywords:
context context used to draw.

symbol = self.symbol
time = self.time

context.set_operator(cairo.OPERATOR_SOURCE)
context.set_source_rgba(0, 0, 0, 0)
context.paint()

context.set_operator(cairo.OPERATOR_OVER)

for (i, item) in enumerate(self.bin):
x, y, z = item

x1 = (x + .1 * sin(time + i / 10)) / z
y1 = y / z
font_size = .05 / z

x_bearing, y_bearing, width, height = \
context.text_extents(symbol)[:4]
context.move_to(x1 - width / 2 - x_bearing,
y1 - height / 2 - y_bearing)

r, g, b = map(lambda v: v / (z + 1), self.color)
context.set_source_rgb(r, g, b)
context.set_font_size(font_size)
context.save()
context.rotate(time + i / 10)
context.show_text(symbol)
context.restore()

y = -1 if y1  1 else y + 0.005
item[1] = y

self.time += 0.05


def main():
overlay = OverlayWindow('❄', '99CCFF', 200)
gtk.main()


if __name__ == '__main__':
main()


Regards,
Matteo

On Sun, Dec 27, 2009 at 8:10 PM, Matteo Landi landima...@gmail.com wrote:
 Thanks for the hint.

 On Sun, Dec 27, 2009 at 6:41 PM, Liam R E Quin l...@holoweb.net wrote:
 On Sun, 2009-12-27 at 16:27 +0100, Matteo Landi wrote:
 Hi all,
 for fun I'm trying to reproduce snowflakes falling down on my
 fullscreen gtk app.

 I'd say look at xsnow if it's still around.

 Liam


 --
 Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
 Pictures from old books: http://fromoldbooks.org/
 Ankh: irc.sorcery.net irc.gnome.org www.advogato.org





 --
 Matteo Landi
 

Re: Windows printing problem

2010-08-22 Thread James
On Fri, 2010-08-20 at 15:55 +1000, James wrote:
 Hi,
 
 I've refined the code a bit.
 
 This I can print to PDF using pdfFactory Pro, and it is displayed in the
 pdfFactory Pro preview window properly, but Windows always errors out on
 the actual printing.
 
 Printing direct to the printer (HP laserjet) also causes windows to
 report an error trying to print.
 
 (The printer works fine for every other app on Windows and Ubuntu).
 
 Draw page code below.

snip

Ok, I think I found the reason the darn thing wont print under windows.
It seems that because I have about 1 lines drawn in cairo onto the
print surface, the printer chucks a fit.  Now I draw to a separate cairo
surface and copy to the print context, which generates somewhat fuzzy
lines, but at least works.

Is there something I can do to improve the fuzzy lines?

James.

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