ScrolledWindow e IconView
Juan Carlos Ferrández <[email protected]> Thu, 5 May 2011 00:17:04 -0700 (PDT)
| Newsgroups | gmane.comp.gnome.mono.hispano |
|---|---|
| Message-ID | <[email protected]> |
Buenas. Tengo una ventana más ancha que alta (alargada de izquierda a
derecha, pero nada alta), con un ScrolledWindow y dentro de esta, un
IconView. El caso es que ScrolledWindow, por mucho que yo le diga, no
consigo que haga scroll de izquierda a derecha, en lugar de arriba a abajo.
Necesito hacer un scroll de imágenes de izquierda a derecha, pero parece que
el iconview sólo me deja de arriba a abajo. Alguna idea?
El código es el siguiente:
using System;
using System.IO;
using Gtk;
public partial class MainWindow : Gtk.Window
{
const int COL_DISPLAY_NAME = 1;
const int COL_PIXBUF = 2;
DirectoryInfo parent = new DirectoryInfo ("/home/bio/Imágenes");
ListStore store;
public MainWindow () : base(Gtk.WindowType.Toplevel)
{
VBox vbox = new VBox (false, 0);
Add (vbox);
ScrolledWindow sw = new ScrolledWindow();
sw.ShadowType = ShadowType.EtchedIn;
sw.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
vbox.PackStart (sw, true, true, 0);
// Create the store and fill it with the contents of '/'
store = CreateStore ();
FillStore ();
IconView iconView = new IconView (store);
iconView.SelectionMode = SelectionMode.Single;
iconView.TextColumn = COL_DISPLAY_NAME;
iconView.PixbufColumn = COL_PIXBUF;
iconView.ItemActivated += new ItemActivatedHandler
(OnItemActivated);
sw.Add (iconView);
//vbox.PackStart(iconView, true, true, 0);
iconView.GrabFocus ();
Build ();
ShowAll();
}
Gdk.Pixbuf GetIcon (string name)
{
return Gtk.IconTheme.Default.LoadIcon (name, 48,
(IconLookupFlags) 0);
}
ListStore CreateStore ()
{
// path, name, pixbuf, is_dir
ListStore store = new ListStore (typeof (string), typeof
(string), typeof (Gdk.Pixbuf), typeof (bool));
store.SetSortColumnId (COL_DISPLAY_NAME,
SortType.Ascending);
return store;
}
void FillStore ()
{
// first clear the store
store.Clear ();
// Now go through the directory and extract all the file
information
if (!parent.Exists)
return;
foreach (FileInfo file in parent.GetFiles ())
{
if (!file.Name.StartsWith (".") && file.Extension ==
".jpg")
store.AppendValues (file.FullName, "", new
Gdk.Pixbuf(file.FullName), false);
}
}
void OnItemActivated (object sender, ItemActivatedArgs a)
{
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
}
Un Saludo
JC
--
View this message in context: http://monohispano.2299865.n2.nabble.com/ScrolledWindow-e-IconView-tp6333393p6333393.html
Sent from the MonoHispano mailing list archive at Nabble.com.