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-30 Thread Kristian Rietveld
On Sat, Sep 29, 2007 at 01:14:56PM -0300, Mat??as Alejandro Torres wrote:
> 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.
> 
> /* 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)

You want to wrap the GtkTreeModelFilter you create here in a
GtkTreeModelSort.  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.
___
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 Kristian Rietveld
On Fri, Sep 28, 2007 at 11:49:50PM -0300, Mat??as Alejandro Torres wrote:
> Is someone implementing this interface in the GtkTreeModelFilter? I've 
> checked in Gtk 2.12 docs and I THINK this isn't implemented yet. If 
> somemone can confirm this, I would appreciate it.

The GtkTreeModelFilter is not supposed to have the GtkTreeSortable
interface implemented, it is just there to do filtering not to do
sorting.  Sorting is handled by GtkTreeModelSort.  Wrapping a
GtkTreeModelFilter in a GtkTreeModelSort as has been suggested on the
list already is the preferred and a common solution.

[Theoretically it is possible to have GtkTreeModelFilter implement the
GtkTreeSortable interface, but this would both render GtkTreeModelSort
(which is pretty lean compared to GtkTreeModelFilter) obsolete and make
GtkTreeModelFilter even more obscure and harder to maintain and use.]


regards,

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


Re: Treeview column width changed signal

2007-09-30 Thread Kristian Rietveld
On Tue, Sep 25, 2007 at 05:45:51PM -0600, Jeffrey Barish wrote:
> Is there a way to be notified when the width of a column in a treeview
> changes?  I would like to record the new column widths so that I can set
> them to the same values the next time the window opens.  The only signal in
> TreeViewColumn is clicked, which doesn't seem to do what I need.

If just saving the column widths of the tree view when the tree view is
destroyed is not enough, the easiest way to do this is probably to
connect to the "notify::width" signal on each column.  Remember to keep
the callback fast (do not write to files, etc) as your callback will be
called a lot, especially when the user is resizing columns with the
mouse.


regards,

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


Re: Spontaneous background colors in treeview

2007-09-30 Thread Kristian Rietveld
On Sun, Sep 30, 2007 at 11:08:05AM -0600, Jeffrey Barish wrote:
> After making some changes to my program (not directly related to the GUI), I
> find that one treeview has a background of alternating light and dark
> bands, but only for certain data sets.  I never set the background in my
> code, so I expect it to be white for every data set.  The program has this

Note that the theme controls the background color of the tree view; the
background color in the default theme happens to be white.

> behavior only under Ubuntu.  On another platform, I do get a white
> background for all data sets (with the same code).  Does anyone have a clue
> what might be causing this bizarre behavior?  If I wanted to set the
> background of the treeview to alternating light and dark bands, how would I
> do that?  I find that modify_bg on the treeview does nothing (although

To get the alternating colors you would set the "rules-hint" property on
GtkTreeView to TRUE (the default is FALSE).  If you do not set this
property to TRUE, the background should always be a solid color.  Also
note that "rules-hint" is only a hint to the theme engine; if the theme
engine sets the "allow-rules" style property to FALSE (the default is
TRUE) the colors will not be alternating.

The application always has the final call about showing alternating
colors, if the application sets rules-hint to FALSE and the theme still
shows alternating colors, the theme is broken and needs to be fixed.


regards,

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


Re: 16 bits grayscale images

2007-09-30 Thread Michael L Torrie
alex wrote:
> Actually I am porting a Windows .NET software to GTK.
> So some procedure I use (as false color convertion) is written. I will
> use it as is because it's not depending on GTK or else...

Are you porting it to GTK# and C# then?

> 
> Anyway...
> First I create a color structure wich define 256 different color from
> cold to hot.
> Then I convert my 16 bits image to a 8 bit and for each pixels value I
> replace with the corresponding color.
> It's help a lot for understanding a picture. I also add a conversion
> scale (for example to convert only values between from 100 to 256)
> 
> I can post the code used, but _for the moment_ it still use .NET and
> FreeImage library, but algorythm remains the same
> 
> 
> ___
> 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


Re: GtkNotebookPage

2007-09-30 Thread James Scott Jr
On Sun, 2007-09-30 at 10:07 -0400, dhk wrote:

> I have a notebook with a treeview on each page.  I'm trying to reference
> a treeview on a notebook tab when it is clicked and compare it to
> another treeview on another tab; I'm using the "switch-page" signal.
> The treeviews are in vbox's in the tabs and I can't seem to get to the
> one on the tab that was clicked.  The callback is like this . . .
> 
> void
> on_ipm_notebook1_switch_page  (GtkNotebook *notebook,
> GtkNotebookPage *page,
> guintpage_num,
> gpointer user_data)
> {
>   GtkWidget *tv=(GtkWidget *)user_data;
>   /* the treeview is in c_page */
>   GtkWidget *c_page=gtk_notebook_get_nth_page(notebook, page_num);
> 
> }
> 


When creating the notebook page and treeview.  set the treeview's
pointer into the vbox as userdata, then during the callback routine get
that userdata or pointer.  now you have the pointer to the treeview,
preform normal treeview operation.

During Create:
g_object_set_data (G_OBJECT(vbox), "TreeView-ptr", (gpointer)ptreeview);

During Callback:
treeview = (GtkTreeView *)g_object_get_data (G_OBJECT(page),
"TreeView-ptr");

Note: from the callback param list, '*page' is the value you supplied to
'gtk_notebook_append_page(p1, p2,p3)' as p2.  This would normally be
your vbox.

James,


> How would I get the treeview that's on the c_page?  Is there a way to
> send more than one object in with user_data?  user_data doesn't seem to
> like pointer-to-pointer (GtkWidget **tv) data.
> 
> Also, what can you do with the GtkNotebookPage object?  I don't see why
> this is passed in since there doesn't seem to be a way to use it.
> 
> Thanks in advance,
> 
> --dhk
> 
> ___
> 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


Re: Fast ways to draw brush outlines on a DrawingArea

2007-09-30 Thread Liam R E Quin
On Sun, 2007-09-30 at 10:56 +0100, Keith Feesh wrote:
> Hello, I have been developing a drawing application for quite some time now
Interesting, which one? :-)

[...]

> The way that I do things now includes redrawing the entire canvas every time
> the mouse is moved, in order to clear the old
> outline's drawing, and then to redraw the outline once again. 

A likely first optimization is to find the minimum bounding box of the
brush, remember where you last drew it, and redraw only that region.
You may also need to do this when the drawing window gets obscured
by another window and then exposed again, depending on platform and
hardware.

A second is that before you draw the brush, you save what's underneath,
on a hidden canvas, and copy that back afterwards.

I think someone also mentioned the problem with this approach -- it
would cause visible flicker as the brush outline was drawn, undrawn,
drawn again repeatedly -- so you end up with double buffering,
requiring an off-screen canvas large enough to hold as much of
the drawing as contains both the drawing under the old brush position
and the drawing under the new position.

If you are working on a CAD-style vector-based program it may seem
alien to store the rendered pixels, but it's what is generally
needed.

Some CAD systems can also use a video overlay layer, if the video
card on the computer supports it, but then you're getting into
pretty arcane hardware stuff :(

Liam

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

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


Re: Spontaneous background colors in treeview

2007-09-30 Thread Yeti
On Sun, Sep 30, 2007 at 11:08:05AM -0600, Jeffrey Barish wrote:
> After making some changes to my program (not directly related to the GUI), I
> find that one treeview has a background of alternating light and dark
> bands, but only for certain data sets.  I never set the background in my
> code, so I expect it to be white for every data set.  The program has this
> behavior only under Ubuntu.  On another platform, I do get a white
> background for all data sets (with the same code).  Does anyone have a clue
> what might be causing this bizarre behavior?

Can it be

http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView--rules-hint
http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView--allow-rules

?

The alternating colors are controlled by the theme then.

Yeti

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


Spontaneous background colors in treeview

2007-09-30 Thread Jeffrey Barish
After making some changes to my program (not directly related to the GUI), I
find that one treeview has a background of alternating light and dark
bands, but only for certain data sets.  I never set the background in my
code, so I expect it to be white for every data set.  The program has this
behavior only under Ubuntu.  On another platform, I do get a white
background for all data sets (with the same code).  Does anyone have a clue
what might be causing this bizarre behavior?  If I wanted to set the
background of the treeview to alternating light and dark bands, how would I
do that?  I find that modify_bg on the treeview does nothing (although
modify_text works).
-- 
Jeffrey Barish

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


GtkNotebookPage

2007-09-30 Thread dhk

I have a notebook with a treeview on each page.  I'm trying to reference
a treeview on a notebook tab when it is clicked and compare it to
another treeview on another tab; I'm using the "switch-page" signal.
The treeviews are in vbox's in the tabs and I can't seem to get to the
one on the tab that was clicked.  The callback is like this . . .

void
on_ipm_notebook1_switch_page  (GtkNotebook *notebook,
GtkNotebookPage *page,
guintpage_num,
gpointer user_data)
{
  GtkWidget *tv=(GtkWidget *)user_data;
  /* the treeview is in c_page */
  GtkWidget *c_page=gtk_notebook_get_nth_page(notebook, page_num);

}

How would I get the treeview that's on the c_page?  Is there a way to
send more than one object in with user_data?  user_data doesn't seem to
like pointer-to-pointer (GtkWidget **tv) data.

Also, what can you do with the GtkNotebookPage object?  I don't see why
this is passed in since there doesn't seem to be a way to use it.

Thanks in advance,

--dhk

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


Re: Fast ways to draw brush outlines on a DrawingArea

2007-09-30 Thread jcupitt
On 9/30/07, Keith Feesh <[EMAIL PROTECTED]> wrote:
> The way that I do things now includes redrawing the entire canvas every time
> the mouse is moved, in order to clear the old
> outline's drawing, and then to redraw the outline once again. This brings my
> system to it's knees and I figure there must be
> a better method, just I can't think of any method. Any hints would be great.

I do something like this in my app:

  http://www.vips.ecs.soton.ac.uk

Load an image, doubleclick the thumbnail to get an image view window,
hold down CTRL and left-button drag down and right to mark a region.
Drag on the region label to move it around, drag on the edges to
resize.

The animation is done with gtk_widget_queue_draw_area().

  
http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-queue-draw-area

When I see a mouse movement, I queue a draw for the current position
and size of the region, I update the region to the new position, and
queue a draw at the new position.

When gtk is next in the idle loop, it will calculate the minimum
number of exposes to repaint the damaged area and ask my drawingarea
to repaint just those parts. Because I've moved my region model, this
will cause the old position to be undrawn and the new position to be
drawn.

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


Re: Fast ways to draw brush outlines on a DrawingArea

2007-09-30 Thread Jonathan Winterflood
Well actually it depends.

when you move the cursor you just blit the
buffer with no cursor to the topmost buffer, and repaint the cursor.
Bliting the buffer should be quite fast, so if your image is like lots of
shape objects you render every time this is many times faster.

If this is analogous to what you are already doing (ie your image renders
fast), you could do this (as you were thinking):
have a small buffer the size of the cursor
contain what is under the outline, and just blit that back and make a new
one in the right position before repainting the outline.

Another method is to paint the outline using the 'XOR' method instead of
'REPLACE', which means you just have to paint the cursor again in the same
place to erase it and return the picure to it's original state; and te paint
it in the new position.
just in case:
XOR is exclusive OR; 0xor0 = 0, 0xor1/1xor0 = 1; 1xor1 = 0
so b xor c xor c = b (paint c twice on b yields b : cool )

HTH,
Jonathan

On 9/30/07, Keith Feesh <[EMAIL PROTECTED]> wrote:
>
> Hmm, so no matter what you do, you end up redrawing the whole image again.
> I guess with some time you could make it only redraw the last place you were
> at instead of the whole image, but if that's the only method then luckily
> I've been doing it right. Cheers Jonathan.
>
> On 30/09/2007, Jonathan Winterflood <[EMAIL PROTECTED]>
> wrote:
> >
> > There is indeed a method.
> >
> > One would probably call it double buffering (anthough when you're done
> > with your program you might have moe like quad buffering...
> >
> > The idea is to render everything in layers:
> >
> > bottom layer = your image (data, etc)
> > above: rulers, marks, selection box, etc (semi-static stuff)
> > above: brush outline
> >
> > these are hopefully in the order of least to most often
> > changing, and what is painted on top of what.
> >
> > the data is held in a pixbuf
> > you paint that pixbuf and the selection etc into another pixbuf
> > you paint that pixbuf and the outline into the topmost buffer
> >
> > then that pixbuf is painted onto the screen.
> >
> > HTH,
> > Jonathan
> >
> > On 9/30/07, Keith Feesh < [EMAIL PROTECTED]> wrote:
> >
> > > Hello, I have been developing a drawing application for quite some
> > > time now
> > > and I have implemented an outline system
> > > which shows where your next drawing operation will go (just load up
> > > the
> > > gimp, go on the paintbrush tool and select a size 11
> > > brush if you don't quite get what I mean).
> > >
> > > The way that I do things now includes redrawing the entire canvas
> > > every time
> > > the mouse is moved, in order to clear the old
> > > outline's drawing, and then to redraw the outline once again. This
> > > brings my
> > > system to it's knees and I figure there must be
> > > a better method, just I can't think of any method. Any hints would be
> > > great.
> > > ___
> > > gtk-app-devel-list mailing list
> > > gtk-app-devel-list@gnome.org
> > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> > >
> >
> >
>


-- 
 linux, c'est une question de VI ou de MORE
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Fast ways to draw brush outlines on a DrawingArea

2007-09-30 Thread Jonathan Winterflood
There is indeed a method.

One would probably call it double buffering (anthough when you're done with
your program you might have moe like quad buffering...

The idea is to render everything in layers:

bottom layer = your image (data, etc)
above: rulers, marks, selection box, etc (semi-static stuff)
above: brush outline

these are hopefully in the order of least to most often
changing, and what is painted on top of what.

the data is held in a pixbuf
you paint that pixbuf and the selection etc into another pixbuf
you paint that pixbuf and the outline into the topmost buffer

then that pixbuf is painted onto the screen.

HTH,
Jonathan

On 9/30/07, Keith Feesh <[EMAIL PROTECTED]> wrote:
>
> Hello, I have been developing a drawing application for quite some time
> now
> and I have implemented an outline system
> which shows where your next drawing operation will go (just load up the
> gimp, go on the paintbrush tool and select a size 11
> brush if you don't quite get what I mean).
>
> The way that I do things now includes redrawing the entire canvas every
> time
> the mouse is moved, in order to clear the old
> outline's drawing, and then to redraw the outline once again. This brings
> my
> system to it's knees and I figure there must be
> a better method, just I can't think of any method. Any hints would be
> great.
> ___
> 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


Fast ways to draw brush outlines on a DrawingArea

2007-09-30 Thread Keith Feesh
Hello, I have been developing a drawing application for quite some time now
and I have implemented an outline system
which shows where your next drawing operation will go (just load up the
gimp, go on the paintbrush tool and select a size 11
brush if you don't quite get what I mean).

The way that I do things now includes redrawing the entire canvas every time
the mouse is moved, in order to clear the old
outline's drawing, and then to redraw the outline once again. This brings my
system to it's knees and I figure there must be
a better method, just I can't think of any method. Any hints would be great.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list