/*
* Copyright (C) 2006 Eskil Bylund
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
using System;
using Gtk;
using Mono.Unix;
using DCSharp.Backend.Objects;
namespace DCSharp.GUI{
public class SearchFileTypeComboBox : ComboBox
{
#region Constructors
public SearchFileTypeComboBox() : base()
{
ListStore store = new ListStore(typeof(Gdk.Pixbuf), typeof(string));
foreach (SearchFileType type in
Enum.GetValues(typeof(SearchFileType)))
{
// Simply using Catalog.GetString(type.ToString()) does not seem to work.
store.AppendValues(Util.GetFileTypeIcon(type),
GetTranslatedString(type));
}
CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf();
CellRendererText textRenderer = new CellRendererText();
textRenderer.Xpad = 3;
PackStart(pixbufRenderer, false);
PackStart(textRenderer, true);
AddAttribute(pixbufRenderer, "pixbuf", 0);
AddAttribute(textRenderer, "text", 1);
Model = store;
Active = 0;
}
#endregion
#region Properties
public SearchFileType ActiveType
{
get
{
return (SearchFileType)(Active + 1);
}
}
#endregion
#region Methods
protected static string GetTranslatedString(SearchFileType type)
{
switch (type)
{
case SearchFileType.Any:
return Catalog.GetString("Any");
case SearchFileType.Audio:
return Catalog.GetString("Audio");
case SearchFileType.Directory:
return Catalog.GetString("Directory");
case SearchFileType.Document:
return Catalog.GetString("Document");
case SearchFileType.Executable:
return Catalog.GetString("Executable");
case SearchFileType.Image:
return Catalog.GetString("Image");
case SearchFileType.Package:
return Catalog.GetString("Package");
case SearchFileType.Video:
return Catalog.GetString("Video");
default:
return String.Empty;
}
}
#endregion
}
}
|