Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread Lars Wirzenius
ke, 2009-10-14 kello 18:52 -0700, Daniel B. Thurman kirjoitti:
 I have a FileViewer application that I am working on
 and so far I have not been able to force expanders
 on TreeView when there are only top-level
 directories/files populated in the TreeStore.

As I understand it, the expander will only be shown for tree rows that
have children. You want to show them always, so that you don't have to
scan an entire directory tree to figure out which have children and
which don't.

Would one of the following approaches work for you?

a) Add dummy items to nodes. When a node is expanded, and it has a dummy
node, scan for subdirectories and replace the dummy node with real ones.
This means even nodes without subdirectories will have an expander,
which might be awkward for the user.

b) Initially, add top level items and their immediate subdirectories.
When a node is expanded the first time, scan its subdirectories'
subdirectories and add those. That was confusing, let me show an
example. Initially, have this ( means closed expander, v means open):

 aaa
 bbb
  ccc

Here, you've scanned aaa and bbb and ccc for subdirectories. You know
ccc doesn't have any, so it gets no children and no expander. aaa and
bbb have children, so they get them and expanders.

When aaa is expanded the first time, you scan aaa/* for subdirectories,
and add them to their parent nodes (i.e., to children of aaa), before
letting the aaa node be expanded on screen. In other words:

v aaa
aaa-1
   aaa-2
aaa-3
 bbb
  ccc

Here, you scanned aaa-1, aaa-2, and aaa-3 for children, and found that
aaa-2 has them.

You can use a hidden column to keep track of which nodes have been
expanded (= scanned).

c) Do the scan in the background, modifying the tree when you find
things. You can either let the scan go through the entire filesystem
this way, or scan directories that are shown (a bit like in option b,
but scanning is done in the background, not just when the node is about
to be expanded).


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


The difference of mapping between toplevel window and popup window

2009-10-15 Thread eric_zhang
Hello,

I'm new to GTK+ programming.I encountered a problem in my program.

There is a window which contain more widgets in my program, the widgets
were mapped with more pictures(via gtkrc file ).

The problem is: if the window is a toplevel window,you would saw flicker
phenomenon; if the window is a popup window,you wouldn't saw flicker
phenomenon,and mapped normally(no flikcer phenomenon).

The flicker phenomenon not serious,but you could saw it with eyes.and
popup window mapped normally( Why ?).

The version of gtk is gtk+ - 2.12.9 (the OS is ubuntu 8.04 ), and it
already set double buffer mechanism. 

How could I do to avoid flicker phenomenon ?

Thanks,

Eric

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


Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread Daniel B. Thurman
On 10/14/2009 11:56 PM, Lars Wirzenius wrote:
 ke, 2009-10-14 kello 18:52 -0700, Daniel B. Thurman kirjoitti:
   
 I have a FileViewer application that I am working on
 and so far I have not been able to force expanders
 on TreeView when there are only top-level
 directories/files populated in the TreeStore.
 
 As I understand it, the expander will only be shown for tree rows that
 have children. You want to show them always, so that you don't have to
 scan an entire directory tree to figure out which have children and
 which don't.

 Would one of the following approaches work for you?

 a) Add dummy items to nodes. When a node is expanded, and it has a dummy
 node, scan for subdirectories and replace the dummy node with real ones.
 This means even nodes without subdirectories will have an expander,
 which might be awkward for the user.

 b) Initially, add top level items and their immediate subdirectories.
 When a node is expanded the first time, scan its subdirectories'
 subdirectories and add those. That was confusing, let me show an
 example. Initially, have this ( means closed expander, v means open):

  aaa
  bbb
   ccc

 Here, you've scanned aaa and bbb and ccc for subdirectories. You know
 ccc doesn't have any, so it gets no children and no expander. aaa and
 bbb have children, so they get them and expanders.

 When aaa is expanded the first time, you scan aaa/* for subdirectories,
 and add them to their parent nodes (i.e., to children of aaa), before
 letting the aaa node be expanded on screen. In other words:

 v aaa
 aaa-1
aaa-2
 aaa-3
  bbb
   ccc
 
 Here, you scanned aaa-1, aaa-2, and aaa-3 for children, and found that
 aaa-2 has them.

 You can use a hidden column to keep track of which nodes have been
 expanded (= scanned).

 c) Do the scan in the background, modifying the tree when you find
 things. You can either let the scan go through the entire filesystem
 this way, or scan directories that are shown (a bit like in option b,
 but scanning is done in the background, not just when the node is about
 to be expanded).


 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
   
Yes,  I have already implemented (b) as you suggested.

In reading the documentation, it was not clear at first, that
setting the boolean=True does not make expanders appear
when there are no children.  This makes sense.

I still have some other issues to deal with:

(1) I am trying to find the expander-open event for the
  connect method. I think it is something like:

  self.treeview.connect('expander-open', self.on_expander_open)

  Do you know of a link/reference listing GTK events for the
  connect() method so that I can look them up?

(2) I note that for some reason when I open an expander, the
 the icon/text next gets right justified.

 The expected behavior is:

v aaa
aaa-1
   aaa-2
  bbb-1
 bbb-2
aaa-3
 bbb
  ccc

   But I get:

v aaa
  aaa-1
 aaa-2
  bbb-1
 bbb-2
  aaa-3
 bbb
  ccc

  So, every time one opens a sub-expander, the icon/text
  cell keeps shifting further to the right. So how can I
  correct this?

Thank you for replying,
and kind regards!

Dan


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


Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread Lars Wirzenius
to, 2009-10-15 kello 07:44 -0700, Daniel B. Thurman kirjoitti:
 (1) I am trying to find the expander-open event for the
   connect method. I think it is something like:

http://library.gnome.org/devel/gtk/stable/ has a list of all widgets,
and lists for each widgets the signals they support. The page for each
widget only lists the signals native to it, not the ones it inherits
from its parent. I have not tried this, but this seems relevant to you:

http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView-expand-collapse-cursor-row

 (2) I note that for some reason when I open an expander, the
  the icon/text next gets right justified.

I am not sure what would happen to that, but my first guess is that you
have one column for the expander, but no value to put in its cell, and
another column for the folder name. If you remove the first column and
mark the folder name column as the expander column (see link below), it
might fix things.

http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-set-expander-column



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


Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread David Nečas
On Thu, Oct 15, 2009 at 07:44:56AM -0700, Daniel B. Thurman wrote:
 On 10/14/2009 11:56 PM, Lars Wirzenius wrote:
 (1) I am trying to find the expander-open event for the
   connect method. I think it is something like:
 
   self.treeview.connect('expander-open', self.on_expander_open)
 
   Do you know of a link/reference listing GTK events for the
   connect() method so that I can look them up?

The signal is called row-expanded.

 (2) I note that for some reason when I open an expander, the
  the icon/text next gets right justified.
 
  The expected behavior is:
 
 v aaa
 aaa-1
aaa-2
   bbb-1
  bbb-2
 aaa-3
  bbb
   ccc
 
But I get:
 
 v aaa
   aaa-1
  aaa-2
   bbb-1
  bbb-2
   aaa-3
  bbb
   ccc
 
   So, every time one opens a sub-expander, the icon/text
   cell keeps shifting further to the right. So how can I
   correct this?

You have the text in another column instead of directly in the expander
column?

Yeti

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


Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread Shaun McCance
On Wed, 2009-10-14 at 18:52 -0700, Daniel B. Thurman wrote:
 I have a FileViewer application that I am working on
 and so far I have not been able to force expanders
 on TreeView when there are only top-level
 directories/files populated in the TreeStore.
 
 You would think that doing something simple as:
 [...]
 self.treestore = gtk.TreeStore(str, gtk.gdk.Pixbuf, str)
 self.treeview = gtk.TreeView(self.treestore)
 self.treeview.set_show_expanders(True)
 self.path = os.path.expanduser('~')
 self.populate_treestore(path=self.path, recurse=0)
 [...]
 
 Would force the TreeView to show the expanders,
 but I have not been able to get this to work.  I need
 the expanders so that when I expand the directory
 in question, I would then trigger a call to add more
 children, and so on.

If you want to populate data on-demand like this,
you're probably going to have to write your own
GtkTreeModel.

--
Shaun


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


Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread Daniel B. Thurman
On 10/15/2009 07:53 AM, Lars Wirzenius wrote:
 to, 2009-10-15 kello 07:44 -0700, Daniel B. Thurman kirjoitti:
   
 (1) I am trying to find the expander-open event for the
   connect method. I think it is something like:
 
 http://library.gnome.org/devel/gtk/stable/ has a list of all widgets,
 and lists for each widgets the signals they support. The page for each
 widget only lists the signals native to it, not the ones it inherits
 from its parent. I have not tried this, but this seems relevant to you:

 http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView-expand-collapse-cursor-row

   
 (2) I note that for some reason when I open an expander, the
  the icon/text next gets right justified.
 
 I am not sure what would happen to that, but my first guess is that you
 have one column for the expander, but no value to put in its cell, and
 another column for the folder name. If you remove the first column and
 mark the folder name column as the expander column (see link below), it
 might fix things.

 http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-set-expander-column



 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
   
Focusing only on (1) above, it appears that the signal I am seeking
for is: row-has-child-toggled, but I get an error saying:

self.treeview.connect('row-has-child-toggled', self.on_row_child_toggled)
TypeError: gtk.TreeView object at 0xb7b9ab6c (GtkTreeView at
0x8df5080): unknown signal name: row-has-child-toggled

It's documented, but is it functional, or is it the correct signal I am
seeking?


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


Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread Daniel B. Thurman
On 10/14/2009 06:52 PM, Daniel B. Thurman wrote:
[snip!]

Apologies.  It appears that there is something wrong
with email-deliveries and I am not getting every
posting, so I will have to reply to certain individuals
that I have not received directly into my mailbox.
(I am looking directly at the archives for those I have missed)


David Nec(as yeti physics muni cz
(1) The signal is called row-expanded.

[Dan] Thank you!  But how did you find this signal?

(2)  You have the text in another column instead of directly in the
expander column?

[Dan] I have posted the experimental code  hopefully the post is accepted.


Shaun McCance shaunm gnome org
(1)  If you want to populate data on-demand like this,
  you're probably going to have to write your own GtkTreeModel.

[Dan] Ugh.  I will try to use the stock and see if I can get this to
work first!


Holger Berndt bern...@gmx.de (sent directly to me)

The way I do that is to add a single dummy child (with a text like
Loading...). That makes the top level entry expandable. When
the user expands the item, he gets feedback right away by seeing the
Loading... entry, while the code populates the model on the fly, and
finally removes the dummy entry.

Others (e.g. Nautilus list view) seem to do it similarly.

[Dan- All below]

The problem I have is: how do I capture the signal when the
row is expanded?  I posted a follow up on this and it seems
that the key is row-has-child-toggled, but this does not
seem to work:

self.treeview.connect('row-has-child-toggled', self.on_row_activated)
TypeError: gtk.TreeView object at 0xb7b9ab6c (GtkTreeView at
0x8df5080): unknown signal name: row-has-child-toggled

I have, however tried:
self.treeview.connect('row-activated', self.on_row_activated)

and this works, except that the row has to be mouse
double-clicked, which is not what I want.

I sure wish there is a Python-GTK code somewhere
that I could peruse to resolve my many issues!

Since the code I have is experimental, I include it
in the following, so that it is open to critique and
may be of benefit to others following the same
pathway:

==
[code]
#!/usr/bin/env python

import os, stat, sys, time
import pygtk
pygtk.require('2.0')
import gtk

DEBUG=True
RECURSE=1
SEP='  '

DEFAULT_PATH='~/Desktop/'

class FileLister:

#column_names = ['Files', 'Size', 'Mode', 'Last Changed', 'Path']
column_names = ['Files']

# Close the window and quit
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False

def __init__(self, path=None):
   
cell_data_funcs = (
None,
self.file_size,
self.file_mode,
self.file_last_changed,
self.file_path)
   
# Create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title(FileLister)
self.window.set_size_request(600, 400)
self.window.connect(delete_event, self.delete_event)

# TreeView
self.treestore = gtk.TreeStore(str, gtk.gdk.Pixbuf, int, bool, str)
self.treeview = gtk.TreeView(self.treestore)

# TreeView Options
self.treeview.set_level_indentation(0)
self.treeview.set_show_expanders(True)
#self.treeview.set_hover_expand(True)
#self.treeview.set_search_column(0)
#self.treeview.set_reorderable(True)

# TreeViewColumns
self.tvcolumn = [None] * len(self.column_names)
cellpb = gtk.CellRendererPixbuf()
self.tvcolumn[0] = gtk.TreeViewColumn(self.column_names[0], cellpb)
self.tvcolumn[0].set_cell_data_func(cellpb, self.file_pixbuf)
cell = gtk.CellRendererText()
self.tvcolumn[0].pack_start(cell, False)
self.tvcolumn[0].set_cell_data_func(cell, self.file_name)
self.treeview.append_column(self.tvcolumn[0])
# Append more TreeView columns, if available   
for n in range(1, len(self.column_names)):
cell = gtk.CellRendererText()
self.tvcolumn[n] = gtk.TreeViewColumn(self.column_names[n],
cell)
if n == 1:
cell.set_property('xalign', 0.0)
self.tvcolumn[n].set_cell_data_func(cell, cell_data_funcs[n])
self.treeview.append_column(self.tvcolumn[n])

# Signals
#self.treeview.connect('row-activated', self.on_row_activated)
''' FOLLOWING DOES NOT WORK '''
self.treeview.connect('row-has-child-toggled',
self.on_row_activated)
   
# Populate TreeView with initial files
self.path = os.path.expanduser(DEFAULT_PATH)
self.dir_walk(path=self.path, recurse=RECURSE)

# Add scrolled Window
self.scrolledwindow = gtk.ScrolledWindow()
self.scrolledwindow.add(self.treeview)
self.window.add(self.scrolledwindow)

   

Pango problems

2009-10-15 Thread geoff . jay

Out of no where my program decided to starthaving problems with Pango 
rendering. The GUI now shows text as thestandard no character boxes and all of 
the icons that were there havebeen replaced by the red x file icon.

When I run the program I get a lot of errors like:



(xpath_test:11200): Gtk-WARNING **: Error loading theme icon'gtk-media-record' 
for stock: Unable to load image-loading 
module:/usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-png.so:/usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-png.so:
 ELF loadcommand alignment not page-aligned

(xpath_test:11200): Pango-WARNING 
**:/usr/lib/pango/1.6.0/modules/pango-basic-fc.so: ELF load commandalignment 
not page-aligned



All of the code used was pretty much cut and pasted from anotherapplication 
that still displays fonts and icons correctly so I'm notsure what happened to 
this one. I can provide source code if anyone requires it.

Build system
-
Linux 2.6.24-24-generic #1 SMP Fri Sep 18 16:49:39 UTC 2009 i686 GNU/Linux
GLib: 2.16.6
GTK+: 2.12.9
GCC: 4.2.4
Pango: 1.20.5

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

Re: Has anyone been able to force TreeView expander with no children?

2009-10-15 Thread David Nečas
On Thu, Oct 15, 2009 at 10:25:23AM -0700, Daniel B. Thurman wrote:
 (1) The signal is called row-expanded.
 
 [Dan] Thank you!  But how did you find this signal?

I know about it.  However, if I didn't I would go to

http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView.signals

or the same in devhelp assuming I have the API docs installed, or to the
gtk.TreeView docs for Python.  They all list all the signals.

Yeti


P.S.: Please don't cross-post though at this moment it is too late to
stop it in this thread...
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list