Re: Implement drag and drop between two TreeViews

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

On Tue, Oct 17, 2006 at 03:42:35PM +0100, Christopher Backhouse wrote:
 Hi
 
 I have two Treeviews (just lists, they use Liststore) and I want to be 
 able to drag entries from one into the other. What is the correct way to 
 do this?
 I call enable_model_drag_source on one list and enable_model_drag_dest 
 on the other - the gui behaves as if drag-and-drop will work and then 
 doesn't actually do it. Fair enough, I wasn't expecting it to be that 
 easy. So, I hook up to some of the more likely-looking signals and hack 
 this together
 
 def on_drag_data_recieved(self,widget,context,x,y,selection,myno,dunno):  
   
 (junk,paths)=context.get_source_widget().get_selection().get_selected_rows()

I have no clue about the Python bindings, but in C you have to implement
at least the other side (that is, the source) as a callback for the event
drag_data_get, which then makes the content available (dispatching on
the content type, that's how source and destination negotiate what type
to use). You register those same content types in the call to
gtk_tree_view_enable_model_drag_source().

Note that whithin the same app you can pass (pointers to) internal data
structures, whereas for cross-app drag-and-drop you have to convert the
thing somehow. But maybe the Python bindings handle the marshalling for
you.

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

iD8DBQFFNdvUBcgs9XrR2kYRAlNyAJ4tPXA0dstB01BlykqLPHFi6ysN4ACfULdi
m2a8hcBmOqJ8JgMwkfWowok=
=V9wk
-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: selecting menu button from key board

2006-10-18 Thread krithika.sivakumar
The default behavior on pressing return key on a menu item is to call
the handler for that menu item and close the menu. Can we override this
behavior? Because of this the submenu is displayed but the main menu is
not seen.

regards,
Krithika Sivakumar


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, October 18, 2006 1:09 PM
To: gtk-app-devel-list@gnome.org
Subject: Re: selecting menu button from key board



Actually I don't want a MenuBar.
I would like to keep it as a button from which the menu is popped out.

regards,
Krithika Sivakumar| Project Engineer | Wipro Technologies| Mobile:
9880502662 | www.wipro.com


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Necas
(Yeti)
Sent: Wednesday, October 18, 2006 11:42 AM
To: gtk-app-devel-list@gnome.org
Subject: Re: selecting menu button from key board

On Wed, Oct 18, 2006 at 11:19:45AM +0530, [EMAIL PROTECTED]
wrote:
 
 I have implemented a menu button.

Why?  GtkMenuBar+GtkMenuItem, GtkComboBox or
GtkToolbar+GtkMenuToolButton all provide this type of
behaviour.  Why they are not enough?

Yeti


--
Whatever.
___
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


reading events from USB

2006-10-18 Thread krithika.sivakumar
Hi All,

I am reading input events from a USB device. I want to map these events
to a mouse click event or
a key press event, so that it can be recognized by a GTK application
running on the same server.
Can I simulate the keyboard/mouse events to the kernel?

Is there any way to implement this?


regards,
Krithika Sivakumar 


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


Re: Implement drag and drop between two TreeViews

2006-10-18 Thread Christopher Backhouse
OK - I am now handling drag_data_get and drag_data_received. The data is 
passed using set_text, get_text in the SelectionData. This makes more 
logical sense and presumably would work between applications. I still 
have the same basic code as before though (with the same bugs). I still 
look up what is selected in the list to work out what to pass, and 
translate the drop coordinates, insert the row and set it up on the 
other end. Is this what I am supposed to do, or is there a neater way 
that which lets GTK do most of the work?


[EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On Tue, Oct 17, 2006 at 03:42:35PM +0100, Christopher Backhouse wrote:
 Hi

 I have two Treeviews (just lists, they use Liststore) and I want to be 
 able to drag entries from one into the other. What is the correct way to 
 do this?
 I call enable_model_drag_source on one list and enable_model_drag_dest 
 on the other - the gui behaves as if drag-and-drop will work and then 
 doesn't actually do it. Fair enough, I wasn't expecting it to be that 
 easy. So, I hook up to some of the more likely-looking signals and hack 
 this together

 def on_drag_data_recieved(self,widget,context,x,y,selection,myno,dunno): 
  
 (junk,paths)=context.get_source_widget().get_selection().get_selected_rows()
 
 I have no clue about the Python bindings, but in C you have to implement
 at least the other side (that is, the source) as a callback for the event
 drag_data_get, which then makes the content available (dispatching on
 the content type, that's how source and destination negotiate what type
 to use). You register those same content types in the call to
 gtk_tree_view_enable_model_drag_source().
 
 Note that whithin the same app you can pass (pointers to) internal data
 structures, whereas for cross-app drag-and-drop you have to convert the
 thing somehow. But maybe the Python bindings handle the marshalling for
 you.
 
 HTH
 - -- tomás
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.1 (GNU/Linux)
 
 iD8DBQFFNdvUBcgs9XrR2kYRAlNyAJ4tPXA0dstB01BlykqLPHFi6ysN4ACfULdi
 m2a8hcBmOqJ8JgMwkfWowok=
 =V9wk
 -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

How to determine if Gtk+ had been initialized

2006-10-18 Thread Paul Plaquette
Hi,

an application is using GTK+

It calls functions provide in a shared libary.

the library could present user interface based on GTK+ or not
depending on the application initialized Gtk+ or not (calling gtk-init 
()).

The question is : from the library, is there a way to know the caller  
had initialized Gtk+ ?

thanks
Paul
___
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 determine if Gtk+ had been initialized

2006-10-18 Thread Yeti
On Wed, Oct 18, 2006 at 10:34:51PM +0200, Paul Plaquette wrote:
 an application is using GTK+
 
 It calls functions provide in a shared libary.
 
 the library could present user interface based on GTK+ or not
 depending on the application initialized Gtk+ or not (calling gtk-init 
 ()).

This sounds a bit strange.  Shouldn't the application
tell the library whether it wants GUI or not?

 The question is : from the library, is there a way to know the caller  
 had initialized Gtk+ ?

There is no way to get the value of gtk_initialized from
gtkmain.  A fairly safe check for a GUI running is

if (gtk_main_level()  0)
   ...

However this fails when Gtk+ is initialized but no main loop
is running.

Yeti


--
Whatever.
___
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 determine if Gtk+ had been initialized

2006-10-18 Thread Daniel Atallah
On 10/18/06, Paul Plaquette [EMAIL PROTECTED] wrote:
 The question is : from the library, is there a way to know the caller
 had initialized Gtk+ ?

Just use gtk-init-check(), it will return TRUE even if it is already
initialized.
http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-init-check
___
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 determine if Gtk+ had been initialized

2006-10-18 Thread Yeti
On Wed, Oct 18, 2006 at 05:02:17PM -0400, Daniel Atallah wrote:
 On 10/18/06, Paul Plaquette [EMAIL PROTECTED] wrote:
  The question is : from the library, is there a way to know the caller
  had initialized Gtk+ ?
 
 Just use gtk-init-check(), it will return TRUE even if it is already
 initialized.

And if Gtk+ is *not* already initialized, it will attempt to
initialize it.

Yeti


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


Re: using cairo surfaces

2006-10-18 Thread Ivan Baldo
Hello Tommi.


El 18/10/06 04:41, Tommi Sakari Uimonen escribió:

 Hi, thanks for your answer!

You are welcome! I also get some help from people here so its nice 
to give something in return :).


 Yes, this I already did. But I still have problems with gtk regarding 
 what kind of widgets to use as the container and child. Currently the 
 child is GtkImage. The container is the hard part. I have managed to 
 use GtkHBox, but I would like to use something like GtkLayout, or 
 actually I don't know what would be best. The container has also some 
 cairo drawing, which draws on top of the child widgets.

Mmm... I don't quite understand what you are trying to accomplish so 
I don't know what to tell you here.
Are you sure you need a container and various child widgets?
Can you instead use only a GtkDrawingArea?


 Now, since the stored surface is the same height and width as the 
 whole widget, I set startPosH and startPosV to 0, otherwise the 
 rectangle to be drawn is not taken from the correct position in the 
 stored surface.

Yes, if your cached surface has the same dimensions as your 
current surface then you should use 0 there and use a cairo_rectangle 
with 0,0 and yourWidth,yourHeight to fill the cached surface in it.


 Or am I wrong? I'm not quite sure, maybe the next example lights 
 things up:

 Let's imagine the surfaces as two identical playing cards. If small 
 area on the center of the card needs to be redrawn, I just place the 
 new card on top of the old one and draw the needed area from the new 
 card, while other areas in the old card remain untouched. If I put 
 nonzero values to startPosH/V the cards are no longer aligned and 
 yields to incorrect result.

You are right.
Though, I don't understand: the new card and the old card are two 
cards or are the same card but you just want to modify a portion of it?
If the latter, then GTK already does the cache of the old card for 
you, you just need to draw what GTK tells you to draw and nothing more.
In the expose event, you have a parameter that is a GdkEventExpose, 
in it, you have some ways to find out what needs to be drawn. One way is 
to use the gdkEventExpose-area.x, area.y, area.width and area.height; 
that gives you the rectangle you need to draw (relative to your 
container, for example, a GtkImage or GtkDrawingArea). That method isn't 
the most performant one, the best one is to use the event-region 
information, which gives more exact information about what needs to be 
drawn.
You can tell Cairo what to draw and what to skip with:
gdk_cairo_region( myCairo_t, myGdkEventExpose-region );
cairo_clip( myCairo_t );
That speeds things up because Cairo doesn't draw things that it 
doesn't need, though AFAIK Cairo needs to be more smart about it and 
optimize things more, but at least it already do some things and likely 
it will just improve with time :). You can help it though: there are 
gdk_cairo_* functions to find out if a point is inside the region or 
not, you can use that for two things: one is to avoid bothering Cairo 
and another is to avoid doing some unecessary computations in your own 
application too.


 What does the cairo_rectangle actually do? And how does the 
 set_cairo_surface restrict to drawing only to the exposed area, or 
 does cairo handle the drawing for the exposed area only even if I draw 
 the whole surface?

The cairo_rectangle serves as a container for the fill of the cached 
surface you have.
When you use cairo_clip() (and you should do) Cairo knows what to 
draw and what not and will never draw outside the clipping path that you 
defined with cairo_clip().


 I'm not quite sure how to copy a small part of previously stored 
 surface to current surface at the same position, or if I do scrolling 
 I just copy most of the stored surface to slightly different position 
 and draw the new information.

It depends on your performance needs.
You can do things smart (and more complex) by getting the contents 
of the drawable and slide it according to the scroll size and then draw 
only the remaining part; or you can do things more easily: just draw 
everything again with the new offsets or different translation in your 
transformation matrix.


 What happens, no matter what size the exposed event area is, if I draw 
 the whole wiget area? Does cairo ignore the draw commands that affect 
 outside the exposed area? Does this give bad performace?

If you use cairo_clip(), then Cairo will not draw outside of the 
clipping path.
You may cache different parts of your drawing to speed things up. In 
my application for example, there is a background image that I 
translate, rotate, scale, sheer, change brightness and contrast, and 
that is all slow, so I just cache the result of that and I regenerate it 
only when the user changes the Zoom level.


 It needs some logic to decide what to draw and where, if I'm supposed 
 to draw only the exposed 

Re: using cairo surfaces

2006-10-18 Thread Tommi Sakari Uimonen
   You are welcome! I also get some help from people here so its nice to give 
 something in return :).

It does give that warm fuzzy feeling, doesn't it :)

   Are you sure you need a container and various child widgets?

No I'm not sure. To me it also felt very strange, as I just need place to 
draw with the cairo, but I don't know whether I can pass the expose events 
to other widgets that are not child widgets.

   Can you instead use only a GtkDrawingArea?

I'll look into that.

 Let's imagine the surfaces as two identical playing cards. If small area on 
 the center of the card needs to be redrawn, I just place the new card on 
 top of the old one and draw the needed area from the new card, while other 
 areas in the old card remain untouched. If I put nonzero values to 
 startPosH/V the cards are no longer aligned and yields to incorrect result.
 
   You are right.
   Though, I don't understand: the new card and the old card are two cards or 
 are the same card but you just want to modify a portion of it?

I was a bit unclear. If some part of the first card gets dirty, I just 
copy the same part from the 'clean' card and patch it over the first one, 
instead of placing the whole card on top of the dirty one.

   You can tell Cairo what to draw and what to skip with:
 gdk_cairo_region( myCairo_t, myGdkEventExpose-region );
 cairo_clip( myCairo_t );
   That speeds things up because Cairo doesn't draw things that it doesn't 
 need, though AFAIK Cairo needs to be more smart about it and optimize things 
 more, but at least it already do some things and likely it will just improve 
 with time :). You can help it though: there are gdk_cairo_* functions to find 
 out if a point is inside the region or not, you can use that for two things: 
 one is to avoid bothering Cairo and another is to avoid doing some unecessary 
 computations in your own application too.

Ok, sounds good. I kind of already know how to decide what needs to be 
done when some area gets dirty.

 I'm not quite sure how to copy a small part of previously stored surface to 
 current surface at the same position, or if I do scrolling I just copy most 
 of the stored surface to slightly different position and draw the new 
 information.
 
   It depends on your performance needs.
   You can do things smart (and more complex) by getting the contents of the 
 drawable and slide it according to the scroll size and then draw only the 
 remaining part; or you can do things more easily: just draw everything again 
 with the new offsets or different translation in your transformation matrix.

Well, I have most of the contents already stored in the cached surface, so 
the former would be the way to go.

   I suggest to follow the examples, there is a Clock Widget done using Cairo 
 (http://www.gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28)
  
 and is a good example for a lot of things and a good start, though instead of 
 using the cairo_rectangle for clipping just use the gdk_cairo_region for 
 clipping, that gives better performance, thats the only thing that I would 
 change to that tutorial.

:) This is exactly the one I have been following. I even created my 
current test widgets just by modifying the example (and I still have the 
same function names haunting me all over the code, never bothered to 
rename them)


   Hope this helps.
   Happy coding! :)

Thanks!

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


GtkTreeRowReferences and ¿signal 155?

2006-10-18 Thread Matias Torres
Hi all,

I'm building an app with a TreeView with the selection mode set to 
multiple. When i have to delete data from the tree view, i get a list of 
selection with gtk_tree_selection_get_selected them i transform this 
list into another list with GtkTreeRowReferences in it.

The deletion of the data works, but just after delete some element i get 
this error message:

GLib-GObject-WARNING **: gsignal.c:2133: signal id `155' is invalid for 
instance `0x8072eb8'

Does anybody knows what is this? I didn't connect any signal to the 
RowReference. Here's goes part of the code:
  
   /* act is a GList of GtkTreeRowReferences */
while (act != NULL)
{
if (gtk_tree_row_reference_valid ((GtkTreeRowReference*) 
act-data))
{
path = gtk_tree_row_reference_get_path 
((GtkTreeRowReference*) act-data);
gtk_tree_row_reference_free ((GtkTreeRowReference*) 
act-data); /* Without this the error keep appearing */
if (path != NULL)
{
gtk_tree_model_get_iter (model, iter, path);
gtk_tree_model_get (model, iter, BRAND_ID_COLUMN, 
brandid, -1);
   /* Updates DB */
res = db_brand_delete (brandid);
if (res == SQLITE_DONE)
{
/* Updates model */
gtk_list_store_remove (GTK_LIST_STORE (model), 
iter);
}
}
}
act = g_list_next (act);
}

I'm using Gtk+-2.10.6 and Glib 2.12.4.

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: advice on implementing elastic tabstops for GTK+ 2.x?

2006-10-18 Thread Nick Gravgaard
On 15/10/06, Owen Taylor [EMAIL PROTECTED] wrote:
 On Sun, 2006-10-15 at 18:07 +0200, Nick Gravgaard wrote:
  Hi all,
 
  I would like to implement an idea I call elastic tabstops (see
  nickgravgaard.com/elastictabstops/) for GTK+ 2.x. Could someone advise
  me on whether support for this should be added to an exisiting widget
  (GtkTextView?), or if another approach should be used?

 Because the effect is non-local - the contents of one paragraph effect
 the drawing (and line wrapping?) of previous/following paragraphs, you'd
 certainly have to change the GtkTextView code to make GtkTextView show
 that effect. A GtkTextView uses a PangoLayout per paragraph.

 (Nobody uses GtkTextView for editing source code directly, but the
 GtkSourceView subclass is used for that extensively. That's a separate
 project from GTK+.)

 If you also wanted to get the effect for multi-line GtkLabels then you'd
 have to also implement support for it inside Pango, since a GtkLabel
 uses a single PangoLayout with multiple paragraphs in it.

 GtkTextView and GtkLabel are the only GTK+ widgets that show multiple
 lines of text.

 For both GtkTextView and PangoLayout I think you'd find the job a bit
 challenging. (Think days or weeks, not hours.) There is a lot of
 existing complexity in both of them you'd have to integrate with. But
 possible? I don't see why not.

Thanks for the reply.

Ideally I'd like to write the code in a modular way so that it can be
easily added to any GTK multi-line text widget, but I'm still at the
exploratory stage so I don't know if such an approach is possible. It
would be great if I could write something that could be used by
GtkTextView, GtkSourceView and whatever widget Vim uses...
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


GdkPixbuf and Xrender scales

2006-10-18 Thread Carlos Eduardo Rodrigues Diógenes
Hi,

GdkPixbuf will start to use cairo/xrender or other library to do it's
scale operations? If the answear is no, what are the reasons, since use
cairo will enable hardware accelarating when glitz be finished.

Thanks,
Carlos.



___ 
Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. 
Registre seu aparelho agora! 
http://br.mobile.yahoo.com/mailalertas/ 
 

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


Re: GdkPixbuf and Xrender scales

2006-10-18 Thread Federico Mena Quintero
On Wed, 2006-10-18 at 15:48 -0200, Carlos Eduardo Rodrigues Diógenes
wrote:

 GdkPixbuf will start to use cairo/xrender or other library to do it's
 scale operations? If the answear is no, what are the reasons, since use
 cairo will enable hardware accelarating when glitz be finished.

The answer is wrong question :)

GdkPixbuf is a representation for images in your process's memory.  When
you scale a pixbuf, you get another pixbuf in your process's memory.
So, it is like this:

  pixbuf-in-process - scale operation - pixbuf-in-process

When you use acceleration in a video card to do scaling, you do this:

  image-in-process - scale operation - display memory

I.e. the scaled image goes to a completely different place.  You don't
get that image back in your process.

Every application paints things differently.  Some create temporary
images in memory, draw stuff to them (including scaled images), and
finally paint the final image to the screen.  Others create temporary
pixmaps in the video card, draw everything there, and then paint the
pixmap to the screen.  It is this second kind of applications that would
benefit from hardware acceleration in video cards.

  Federico

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