本文整理汇总了C#中Gtk.ComboBox.SetCellDataFunc方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.SetCellDataFunc方法的具体用法?C# ComboBox.SetCellDataFunc怎么用?C# ComboBox.SetCellDataFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ComboBox
的用法示例。
在下文中一共展示了ComboBox.SetCellDataFunc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComboBoxHelper
public ComboBoxHelper(ComboBox comboBox, object id, string selectSql)
{
CellRendererText cellRendererText = new CellRendererText ();
comboBox.PackStart (cellRendererText, false);
comboBox.SetCellDataFunc (cellRendererText, new CellLayoutDataFunc (delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
cellRendererText.Text = ((object[])tree_model.GetValue(iter, 0))[1].ToString();
}));
ListStore listStore = new ListStore (typeof(object));
object[] initial = new object[] { null, "<sin asignar>" };
TreeIter initialTreeIter = listStore.AppendValues ((object)initial);
IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand ();
dbCommand.CommandText = selectSql;
IDataReader dataReader = dbCommand.ExecuteReader ();
while (dataReader.Read()) {
object currentId = dataReader [0];
object currentName = dataReader [1];
object[] values = new object[] { currentId, currentName };
TreeIter treeIter = listStore.AppendValues ((object)values);
if (currentId.Equals (id))
initialTreeIter = treeIter;
}
dataReader.Close ();
comboBox.Model = listStore;
comboBox.SetActiveIter (initialTreeIter);
}
示例2: Fill
public static void Fill(ComboBox comboBox, QueryResult queryResult)
{
CellRendererText cellRenderText = new CellRendererText ();
comboBox.PackStart (cellRenderText, false);
comboBox.SetCellDataFunc(cellRenderText,
delegate(CellLayout Cell_layout, CellRenderer CellView, TreeModel tree_model, TreeIter iter) {
IList row = (IList)tree_model.GetValue(iter, 0);
cellRenderText.Text = row[1].ToString();
//Vamos a ver el uso de los parámetros para acceder a SQL
});
ListStore listStore = new ListStore (typeof(IList));
//TODO localización de "Sin Asignar".
IList first = new object[] { null, "<sin asignar>" };
TreeIter treeIterFirst = listStore.AppendValues (first);
//TreeIter treeIterFirst = ListStore.AppendValues(first);
foreach (IList row in queryResult.Rows)
listStore.AppendValues (row);
comboBox.Model = listStore;
//Por defecto vale -1 (para el indice de categoría)
comboBox.Active = 0;
comboBox.SetActiveIter(treeIterFirst);
}
示例3: ColourDropDownView
/// <summary>Constructor</summary>
public ColourDropDownView(ViewBase owner)
: base(owner)
{
combobox1 = new ComboBox(comboModel);
_mainWidget = combobox1;
combobox1.PackStart(comboRender, true);
combobox1.AddAttribute(comboRender, "text", 0);
combobox1.SetCellDataFunc(comboRender, OnDrawColourCombo);
combobox1.Changed += OnChanged;
_mainWidget.Destroyed += _mainWidget_Destroyed;
}
示例4: CreateComboBox
protected override ComboBox CreateComboBox ()
{
var box = new ComboBox ();
cell_renderer = new CellRendererText ();
box.PackStart (cell_renderer, false);
box.AddAttribute (cell_renderer, "text", 0);
box.SetCellDataFunc (cell_renderer, new CellLayoutDataFunc (RenderFont));
return box;
}
示例5: ConfigurationWidget
public override Widget ConfigurationWidget () {
VBox vbox = new VBox ();
Label info = new Label (Catalog.GetString ("Select the area that needs cropping."));
constraints_combo = new ComboBox ();
CellRendererText constraint_name_cell = new CellRendererText ();
CellRendererPixbuf constraint_pix_cell = new CellRendererPixbuf ();
constraints_combo.PackStart (constraint_name_cell, true);
constraints_combo.PackStart (constraint_pix_cell, false);
constraints_combo.SetCellDataFunc (constraint_name_cell, new CellLayoutDataFunc (ConstraintNameCellFunc));
constraints_combo.SetCellDataFunc (constraint_pix_cell, new CellLayoutDataFunc (ConstraintPixCellFunc));
constraints_combo.Changed += HandleConstraintsComboChanged;
// FIXME: need tooltip Catalog.GetString ("Constrain the aspect ratio of the selection")
LoadPreference (Preferences.CUSTOM_CROP_RATIOS);
vbox.Add (info);
vbox.Add (constraints_combo);
return vbox;
}
示例6: Fill
public static void Fill(ComboBox combobox, QueryResult queryResult)
{
CellRendererText cellRendererText = new CellRendererText ();
combobox.PackStart (cellRendererText, false);
combobox.SetCellDataFunc (cellRendererText,
delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
IList row = (IList)tree_model.GetValue (iter, 0);
cellRendererText.Text = row [1].ToString ();
});
ListStore listStore = new ListStore (typeof(IList));
foreach (IList row in queryResult.Rows)
listStore.AppendValues (row);
combobox.Model = listStore;
}
示例7: Fill
public static void Fill(ComboBox comboBox, QueryResult queryResult, object id)
{
CellRendererText cellRendererText = new CellRendererText ();
comboBox.PackStart (cellRendererText, false);
comboBox.SetCellDataFunc (cellRendererText,
delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
IList row = (IList)tree_model.GetValue(iter, 0);
cellRendererText.Text = row[1].ToString();
});
ListStore listStore = new ListStore (typeof(IList));
//TODO localización de "sin asignar"
IList first = new object[]{null, "<sin asignar>"};
TreeIter treeIterFirst = listStore.AppendValues (first);
foreach (IList row in queryResult.Rows)
listStore.AppendValues (row);
comboBox.Model = listStore;
//comboBox.Active = 0;
comboBox.SetActiveIter (treeIterFirst);
}
示例8: Fill
public static void Fill(ComboBox comboBox,QueryResult queryResult, object id)
{
CellRendererText cellRendererText = new CellRendererText ();
comboBox.PackStart (cellRendererText, false);
comboBox.SetCellDataFunc (cellRendererText, delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) { //ESTA Y LA ANTERIOR CREAN LA CAJA PARA DIBUJAR
IList row =(IList)tree_model.GetValue(iter,0);
cellRendererText.Text = /*row[0] +" - "+*/ row[1].ToString(); // Id - Categoria
});
ListStore listStore = new ListStore (typeof(IList));
IList first = new object[] {null, "<sin asignar>"};
TreeIter treeIterAsignado =listStore.AppendValues (first); // lo guardo en un treeIter Para utilizarlo como activo en el comboiBox
foreach (IList row in queryResult.Rows) {
TreeIter treeIter = listStore.AppendValues (row);
if (row[0].Equals(id))
treeIterAsignado = treeIter;
}
comboBox.Model = listStore;
comboBox.SetActiveIter(treeIterAsignado);
}
示例9: Fill
public static void Fill(ComboBox combobox1, QueryResult queryresult, object id)
{
CellRendererText cellRendererText = new CellRendererText ();
combobox1.PackStart (cellRendererText, false);
combobox1.SetCellDataFunc (cellRendererText,
delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
IList row = (IList)tree_model.GetValue (iter, 0);
cellRendererText.Text = row[1].ToString();
});
ListStore listStore = new ListStore (typeof(IList));
IList first=new object[]{null,"<sin asignar>"};
TreeIter treeiterId=listStore.AppendValues (first);
foreach (IList row in queryresult.Rows) {
TreeIter treeiter=listStore.AppendValues (row);
if (row[0].Equals(id))
treeiterId = treeiter;
}
combobox1.Model = listStore;
//combobox1.Active = 0;
combobox1.SetActiveIter (treeiterId);
}
示例10: MainToolbar
public MainToolbar ()
{
executionTargetsChanged = DispatchService.GuiDispatch (new EventHandler (HandleExecutionTargetsChanged));
IdeApp.Workspace.ActiveConfigurationChanged += (sender, e) => UpdateCombos ();
IdeApp.Workspace.ConfigurationsChanged += (sender, e) => UpdateCombos ();
IdeApp.Workspace.SolutionLoaded += (sender, e) => UpdateCombos ();
IdeApp.Workspace.SolutionUnloaded += (sender, e) => UpdateCombos ();
IdeApp.ProjectOperations.CurrentSelectedSolutionChanged += HandleCurrentSelectedSolutionChanged;
WidgetFlags |= Gtk.WidgetFlags.AppPaintable;
AddWidget (button);
AddSpace (8);
configurationCombo = new Gtk.ComboBox ();
configurationCombo.Model = configurationStore;
var ctx = new Gtk.CellRendererText ();
configurationCombo.PackStart (ctx, true);
configurationCombo.AddAttribute (ctx, "text", 0);
configurationCombosBox = new HBox (false, 8);
var configurationComboVBox = new VBox ();
configurationComboVBox.PackStart (configurationCombo, true, false, 0);
configurationCombosBox.PackStart (configurationComboVBox, false, false, 0);
runtimeCombo = new Gtk.ComboBox ();
runtimeCombo.Model = runtimeStore;
ctx = new Gtk.CellRendererText ();
runtimeCombo.PackStart (ctx, true);
runtimeCombo.SetCellDataFunc (ctx, RuntimeRenderCell);
runtimeCombo.RowSeparatorFunc = RuntimeIsSeparator;
var runtimeComboVBox = new VBox ();
runtimeComboVBox.PackStart (runtimeCombo, true, false, 0);
configurationCombosBox.PackStart (runtimeComboVBox, false, false, 0);
AddWidget (configurationCombosBox);
buttonBarBox = new Alignment (0.5f, 0.5f, 0, 0);
buttonBarBox.LeftPadding = (uint) 7;
buttonBarBox.Add (buttonBar);
buttonBarBox.NoShowAll = true;
AddWidget (buttonBarBox);
AddSpace (24);
statusArea = new StatusArea ();
statusArea.ShowMessage (BrandingService.ApplicationName);
var statusAreaAlign = new Alignment (0, 0, 1, 1);
statusAreaAlign.Add (statusArea);
contentBox.PackStart (statusAreaAlign, true, true, 0);
AddSpace (24);
statusAreaAlign.SizeAllocated += (object o, SizeAllocatedArgs args) => {
Gtk.Widget toplevel = this.Toplevel;
if (toplevel == null)
return;
int windowWidth = toplevel.Allocation.Width;
int center = windowWidth / 2;
int left = Math.Max (center - 300, args.Allocation.Left);
int right = Math.Min (left + 600, args.Allocation.Right);
uint left_padding = (uint) (left - args.Allocation.Left);
uint right_padding = (uint) (args.Allocation.Right - right);
if (left_padding != statusAreaAlign.LeftPadding || right_padding != statusAreaAlign.RightPadding)
statusAreaAlign.SetPadding (0, 0, (uint) left_padding, (uint) right_padding);
};
matchEntry = new SearchEntry ();
var searchFiles = this.matchEntry.AddMenuItem (GettextCatalog.GetString ("Search Files"));
searchFiles.Activated += delegate {
SetSearchCategory ("files");
};
var searchTypes = this.matchEntry.AddMenuItem (GettextCatalog.GetString ("Search Types"));
searchTypes.Activated += delegate {
SetSearchCategory ("type");
};
var searchMembers = this.matchEntry.AddMenuItem (GettextCatalog.GetString ("Search Members"));
searchMembers.Activated += delegate {
SetSearchCategory ("member");
};
matchEntry.ForceFilterButtonVisible = true;
matchEntry.Entry.FocusOutEvent += delegate {
matchEntry.Entry.Text = "";
};
var cmd = IdeApp.CommandService.GetCommand (Commands.NavigateTo);
cmd.KeyBindingChanged += delegate {
UpdateSearchEntryLabel ();
};
UpdateSearchEntryLabel ();
matchEntry.Ready = true;
matchEntry.Visible = true;
matchEntry.IsCheckMenu = true;
//.........这里部分代码省略.........
示例11: FilterWidgetRow
public FilterWidgetRow(FileSearchFilter filter)
: base(0, 0, 1, 1)
{
TreeIter iter;
CellRendererText textCell;
ListStore store;
this.filter = filter;
matchTypeStore = new ListStore(typeof(string), typeof(FileSearchFilterComparison));
textCell = new CellRendererText();
matchTypeComboBox = new ComboBox();
matchTypeComboBox.Model = matchTypeStore;
matchTypeComboBox.PackStart(textCell, true);
matchTypeComboBox.AddAttribute(textCell, "text", 0);
matchTypeComboBox.RowSeparatorFunc = ComboSeparatorFunc;
matchTypeComboBox.Changed += MatchTypeChanged;
textCell = new CellRendererText();
store = new ListStore(typeof(string), typeof(FilterEntryMode), typeof(FileSearchFilterField));
filterTextEntry = new FilterEntry(filter);
filterTextEntry.Changed += FilterTextChanged;
fieldComboBox = new ComboBox();
fieldComboBox.PackStart(textCell, true);
fieldComboBox.AddAttribute(textCell, "text", 0);
fieldComboBox.SetCellDataFunc(textCell, FieldComboDataFunc);
store.AppendValues("File Name", FilterEntryMode.String, FileSearchFilterField.FileName);
store.AppendValues("Size", FilterEntryMode.Size, FileSearchFilterField.Size);
store.AppendValues("-");
store.AppendValues("(Audio)", null);
store.AppendValues("Artist", FilterEntryMode.String, FileSearchFilterField.Artist);
store.AppendValues("Album", FilterEntryMode.String, FileSearchFilterField.Album);
store.AppendValues("Bitrate", FilterEntryMode.Speed, FileSearchFilterField.Bitrate);
store.AppendValues("-");
store.AppendValues("(Video)", null);
store.AppendValues("Resolution", FilterEntryMode.Dimentions, FileSearchFilterField.Resolution);
store.AppendValues("-");
store.AppendValues("(Images)", null);
store.AppendValues("Dimentions", FilterEntryMode.Dimentions, FileSearchFilterField.Dimentions);
fieldComboBox.Model = store;
fieldComboBox.RowSeparatorFunc = ComboSeparatorFunc;
fieldComboBox.Changed += FieldChanged;
/*
if (fieldComboBox.Model.GetIterFirst(out iter)) {
fieldComboBox.SetActiveIter(iter);
}
*/
addButton = new Button();
addButton.Relief = ReliefStyle.None;
addButton.Image = new Image(Gui.LoadIcon(16, "list-add"));
addButton.Clicked += AddButtonClicked;
removeButton = new Button();
removeButton.Relief = ReliefStyle.None;
removeButton.Image = new Image(Gui.LoadIcon(16, "list-remove"));
removeButton.Clicked += RemoveButtonClicked;
box = new HBox();
box.PackStart(fieldComboBox, false, false, 0);
box.PackStart(matchTypeComboBox, false, false, 3);
box.PackStart(filterTextEntry, true, true, 0);
box.PackStart(removeButton, false, false, 0);
box.PackStart(addButton, false, false, 0);
this.TopPadding = 3;
this.BottomPadding = 3;
this.Add(box);
fieldComboBox.Model.GetIterFirst(out iter);
do {
FileSearchFilterField field = (FileSearchFilterField)fieldComboBox.Model.GetValue(iter, 2);
if (field == filter.Field) {
fieldComboBox.SetActiveIter(iter);
break;
}
} while (fieldComboBox.Model.IterNext(ref iter));
matchTypeComboBox.Model.GetIterFirst(out iter);
do {
FileSearchFilterComparison comp = (FileSearchFilterComparison)matchTypeComboBox.Model.GetValue(iter, 1);
if (comp == filter.Comparison) {
matchTypeComboBox.SetActiveIter(iter);
break;
}
} while (matchTypeComboBox.Model.IterNext(ref iter));
filterTextEntry.Text = filter.Text;
}
示例12: MainToolbar
public MainToolbar ()
{
WidgetFlags |= Gtk.WidgetFlags.AppPaintable;
AddWidget (button);
AddSpace (8);
configurationCombo = new Gtk.ComboBox ();
configurationCombo.Model = configurationStore;
var ctx = new Gtk.CellRendererText ();
configurationCombo.PackStart (ctx, true);
configurationCombo.AddAttribute (ctx, "text", 0);
configurationCombosBox = new HBox (false, 8);
var configurationComboVBox = new VBox ();
configurationComboVBox.PackStart (configurationCombo, true, false, 0);
configurationCombosBox.PackStart (configurationComboVBox, false, false, 0);
// bold attributes for running runtime targets / (emulators)
boldAttributes.Insert (new Pango.AttrWeight (Pango.Weight.Bold));
runtimeCombo = new Gtk.ComboBox ();
runtimeCombo.Model = runtimeStore;
ctx = new Gtk.CellRendererText ();
if (Platform.IsWindows)
ctx.Ellipsize = Pango.EllipsizeMode.Middle;
runtimeCombo.PackStart (ctx, true);
runtimeCombo.SetCellDataFunc (ctx, RuntimeRenderCell);
runtimeCombo.RowSeparatorFunc = RuntimeIsSeparator;
var runtimeComboVBox = new VBox ();
runtimeComboVBox.PackStart (runtimeCombo, true, false, 0);
configurationCombosBox.PackStart (runtimeComboVBox, false, false, 0);
AddWidget (configurationCombosBox);
buttonBarBox = new Alignment (0.5f, 0.5f, 0, 0);
buttonBarBox.LeftPadding = (uint) 7;
buttonBarBox.Add (buttonBar);
buttonBarBox.NoShowAll = true;
AddWidget (buttonBarBox);
AddSpace (24);
statusArea = new StatusArea ();
statusArea.ShowMessage (BrandingService.ApplicationName);
var statusAreaAlign = new Alignment (0, 0, 1, 1);
statusAreaAlign.Add (statusArea);
contentBox.PackStart (statusAreaAlign, true, true, 0);
AddSpace (24);
statusAreaAlign.SizeAllocated += (object o, SizeAllocatedArgs args) => {
Gtk.Widget toplevel = this.Toplevel;
if (toplevel == null)
return;
int windowWidth = toplevel.Allocation.Width;
int center = windowWidth / 2;
int left = Math.Max (center - 300, args.Allocation.Left);
int right = Math.Min (left + 600, args.Allocation.Right);
uint left_padding = (uint) (left - args.Allocation.Left);
uint right_padding = (uint) (args.Allocation.Right - right);
if (left_padding != statusAreaAlign.LeftPadding || right_padding != statusAreaAlign.RightPadding)
statusAreaAlign.SetPadding (0, 0, (uint) left_padding, (uint) right_padding);
};
matchEntry = new SearchEntry ();
matchEntry.ForceFilterButtonVisible = true;
matchEntry.Entry.FocusOutEvent += (o, e) => {
if (SearchEntryLostFocus != null)
SearchEntryLostFocus (o, e);
};
matchEntry.Ready = true;
matchEntry.Visible = true;
matchEntry.IsCheckMenu = true;
matchEntry.WidthRequest = 240;
if (!Platform.IsMac && !Platform.IsWindows)
matchEntry.Entry.ModifyFont (Pango.FontDescription.FromString ("Sans 9")); // TODO: VV: "Segoe UI 9"
matchEntry.RoundedShape = true;
matchEntry.Entry.Changed += HandleSearchEntryChanged;
matchEntry.Activated += HandleSearchEntryActivated;
matchEntry.Entry.KeyPressEvent += HandleSearchEntryKeyPressed;
SizeAllocated += (o, e) => {
if (SearchEntryResized != null)
SearchEntryResized (o, e);
};
contentBox.PackStart (matchEntry, false, false, 0);
var align = new Gtk.Alignment (0, 0, 1f, 1f);
align.Show ();
align.TopPadding = (uint) 5;
align.LeftPadding = (uint) 9;
align.RightPadding = (uint) 18;
align.BottomPadding = (uint) 10;
align.Add (contentBox);
//.........这里部分代码省略.........
示例13: OnAddWallpapersClicked
// Add more wallpapers
private void OnAddWallpapersClicked(object sender, EventArgs args)
{
FileChooserDialog fc = new FileChooserDialog(Catalog.GetString("Add wallpaper"), winPref, FileChooserAction.Open);
// Settings
fc.LocalOnly = true; // Only local files
fc.SelectMultiple = true; // Users can select multiple images at a time
fc.Filter = new FileFilter(); // Filter
fc.Filter.AddPixbufFormats(); // Add pixmaps
// Add buttons
fc.AddButton(Stock.Cancel, ResponseType.Cancel);
fc.AddButton(Stock.Open , ResponseType.Ok);
// Try to goto the monitor dir if monitoring is enabled, else goto documents
if (DrapesApp.Cfg.MonitorEnabled == true)
fc.SetUri(DrapesApp.Cfg.MonitorDirectory);
else
fc.SetUri(Environment.GetEnvironmentVariable("HOME") + "/Documents");
ListStore FileOptions = new ListStore(typeof(string), typeof(string));
FileOptions.AppendValues(Catalog.GetString("Images"), Stock.File);
FileOptions.AppendValues(Catalog.GetString("Directory"), Stock.Directory);
ComboBox ChooserType = new ComboBox(FileOptions);
ChooserType.Active = 0;
CellRendererPixbuf fTypeImage = new CellRendererPixbuf();
CellRendererText fTypeText = new CellRendererText();
ChooserType.PackStart(fTypeImage, false);
ChooserType.PackStart(fTypeText, true);
CellLayoutDataFunc renderer = delegate (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter)
{
if (cell == fTypeText) {
(cell as CellRendererText).Text = (string) model.GetValue(iter, 0);
} else if (cell == fTypeImage) {
if (model.GetValue(iter, 1) != null) {
(cell as CellRendererPixbuf).StockId = (string) model.GetValue(iter, 1);
} else
(cell as CellRendererPixbuf).StockId = null;
}
};
ChooserType.SetCellDataFunc(fTypeText, renderer);
ChooserType.SetCellDataFunc(fTypeImage, renderer);
// changed event is just going to be anonymous method
ChooserType.Changed += delegate (object dSender, EventArgs dArgs)
{
ComboBox cb = (ComboBox) dSender;
if (cb.Active == 0) {
fc.SelectMultiple = true;
fc.Action = FileChooserAction.Open;
} else {
fc.SelectMultiple = false;
fc.Action = FileChooserAction.SelectFolder;
}
};
fc.ExtraWidget = new HBox(false, 10);
(fc.ExtraWidget as HBox).PackEnd(ChooserType, false, false, 0);
(fc.ExtraWidget as HBox).PackEnd(new Label(Catalog.GetString("Import type:")), false, false, 0);
fc.ExtraWidget.ShowAll();
// Show the dialog
int r = fc.Run();
if ((ResponseType) r == ResponseType.Ok) {
if (fc.Action == FileChooserAction.SelectFolder)
DrapesApp.WpList.AddDirectory(fc.Filename);
else
DrapesApp.WpList.AddFiles(fc.Filenames);
}
// Get rid of the window
fc.Destroy();
}
示例14: SetupWidgets
private void SetupWidgets()
{
histogram_expander = new Expander (Catalog.GetString ("Histogram"));
histogram_expander.Activated += delegate(object sender, EventArgs e) {
ContextSwitchStrategy.SetHistogramVisible (Context, histogram_expander.Expanded);
UpdateHistogram ();
};
histogram_expander.StyleSet += delegate(object sender, StyleSetArgs args) {
Gdk.Color c = this.Toplevel.Style.Backgrounds[(int)Gtk.StateType.Active];
histogram.RedColorHint = (byte)(c.Red / 0xff);
histogram.GreenColorHint = (byte)(c.Green / 0xff);
histogram.BlueColorHint = (byte)(c.Blue / 0xff);
histogram.BackgroundColorHint = 0xff;
UpdateHistogram ();
};
histogram_image = new Gtk.Image ();
histogram = new Histogram ();
histogram_expander.Add (histogram_image);
Add (histogram_expander);
info_expander = new Expander (Catalog.GetString ("Image Information"));
info_expander.Activated += (sender, e) => {
ContextSwitchStrategy.SetInfoBoxVisible (Context, info_expander.Expanded);
};
info_table = new Table (head_rows, 2, false) { BorderWidth = 0 };
AddLabelEntry (null, null, null, null,
photos => { return String.Format (Catalog.GetString ("{0} Photos"), photos.Length); });
AddLabelEntry (null, Catalog.GetString ("Name"), null,
(photo, file) => { return photo.Name ?? String.Empty; }, null);
version_list = new ListStore (typeof(IPhotoVersion), typeof(string), typeof(bool));
version_combo = new ComboBox ();
CellRendererText version_name_cell = new CellRendererText ();
version_name_cell.Ellipsize = Pango.EllipsizeMode.End;
version_combo.PackStart (version_name_cell, true);
version_combo.SetCellDataFunc (version_name_cell, new CellLayoutDataFunc (VersionNameCellFunc));
version_combo.Model = version_list;
version_combo.Changed += OnVersionComboChanged;
AddEntry (null, Catalog.GetString ("Version"), null, version_combo, 0.5f,
(widget, photo, file) => {
version_list.Clear ();
version_combo.Changed -= OnVersionComboChanged;
int count = 0;
foreach (IPhotoVersion version in photo.Versions) {
version_list.AppendValues (version, version.Name, true);
if (version == photo.DefaultVersion)
version_combo.Active = count;
count++;
}
if (count <= 1) {
version_combo.Sensitive = false;
version_combo.TooltipText = Catalog.GetString ("(No Edits)");
} else {
version_combo.Sensitive = true;
version_combo.TooltipText =
String.Format (Catalog.GetPluralString ("(One Edit)", "({0} Edits)", count - 1),
count - 1);
}
version_combo.Changed += OnVersionComboChanged;
}, null);
AddLabelEntry ("date", Catalog.GetString ("Date"), Catalog.GetString ("Show Date"),
(photo, file) => {
return String.Format ("{0}{2}{1}",
photo.Time.ToShortDateString (),
photo.Time.ToShortTimeString (),
Environment.NewLine); },
photos => {
IPhoto first = photos[photos.Length - 1];
IPhoto last = photos[0];
if (first.Time.Date == last.Time.Date) {
//Note for translators: {0} is a date, {1} and {2} are times.
return String.Format (Catalog.GetString ("On {0} between \n{1} and {2}"),
first.Time.ToShortDateString (),
first.Time.ToShortTimeString (),
last.Time.ToShortTimeString ());
} else {
return String.Format (Catalog.GetString ("Between {0} \nand {1}"),
first.Time.ToShortDateString (),
last.Time.ToShortDateString ());
}
});
AddLabelEntry ("size", Catalog.GetString ("Size"), Catalog.GetString ("Show Size"),
(photo, metadata) => {
int width = metadata.Properties.PhotoWidth;
int height = metadata.Properties.PhotoHeight;
if (width != 0 && height != 0)
return String.Format ("{0}x{1}", width, height);
else
return Catalog.GetString ("(Unknown)");
}, null);
//.........这里部分代码省略.........
示例15: InitWindow
void InitWindow()
{
int height;
int width;
this.Icon = Utilities.GetIcon ("tasque-48", 48);
// Update the window title
Title = string.Format ("Tasque");
width = GtkApplication.Instance.Preferences.GetInt("MainWindowWidth");
height = GtkApplication.Instance.Preferences.GetInt("MainWindowHeight");
if(width == -1)
width = 600;
if(height == -1)
height = 600;
this.DefaultSize = new Gdk.Size( width, height);
accelGroup = new AccelGroup ();
AddAccelGroup (accelGroup);
globalKeys = new GlobalKeybinder (accelGroup);
VBox mainVBox = new VBox();
mainVBox.BorderWidth = 0;
mainVBox.Show ();
this.Add (mainVBox);
HBox topHBox = new HBox (false, 0);
topHBox.BorderWidth = 4;
categoryComboBox = new ComboBox ();
categoryComboBox.Accessible.Description = "Category Selection";
categoryComboBox.WidthRequest = 150;
categoryComboBox.WrapWidth = 1;
categoryComboBox.Sensitive = false;
CellRendererText comboBoxRenderer = new Gtk.CellRendererText ();
comboBoxRenderer.WidthChars = 20;
comboBoxRenderer.Ellipsize = Pango.EllipsizeMode.End;
categoryComboBox.PackStart (comboBoxRenderer, true);
categoryComboBox.SetCellDataFunc (comboBoxRenderer,
new Gtk.CellLayoutDataFunc (CategoryComboBoxDataFunc));
categoryComboBox.Show ();
topHBox.PackStart (categoryComboBox, false, false, 0);
// Space the addTaskButton and the categoryComboBox
// far apart by using a blank label that expands
Label spacer = new Label (string.Empty);
spacer.Show ();
topHBox.PackStart (spacer, true, true, 0);
// The new task entry widget
addTaskEntry = new Entry (Catalog.GetString ("New task..."));
addTaskEntry.Sensitive = false;
addTaskEntry.Focused += OnAddTaskEntryFocused;
addTaskEntry.Changed += OnAddTaskEntryChanged;
addTaskEntry.Activated += OnAddTaskEntryActivated;
addTaskEntry.FocusInEvent += OnAddTaskEntryFocused;
addTaskEntry.FocusOutEvent += OnAddTaskEntryUnfocused;
addTaskEntry.DragDataReceived += OnAddTaskEntryDragDataReceived;
addTaskEntry.Show ();
topHBox.PackStart (addTaskEntry, true, true, 0);
// Use a small add icon so the button isn't mammoth-sized
HBox buttonHBox = new HBox (false, 6);
Gtk.Image addImage = new Gtk.Image (Gtk.Stock.Add, IconSize.Menu);
addImage.Show ();
buttonHBox.PackStart (addImage, false, false, 0);
Label l = new Label (Catalog.GetString ("_Add"));
l.Show ();
buttonHBox.PackStart (l, true, true, 0);
buttonHBox.Show ();
addTaskButton =
new MenuToolButton (buttonHBox, Catalog.GetString ("_Add Task"));
addTaskButton.UseUnderline = true;
// Disactivate the button until the backend is initialized
addTaskButton.Sensitive = false;
Gtk.Menu addTaskMenu = new Gtk.Menu ();
addTaskButton.Menu = addTaskMenu;
addTaskButton.Clicked += OnAddTask;
addTaskButton.Show ();
topHBox.PackStart (addTaskButton, false, false, 0);
globalKeys.AddAccelerator (OnGrabEntryFocus,
(uint) Gdk.Key.n,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
globalKeys.AddAccelerator (delegate (object sender, EventArgs e) {
GtkApplication.Instance.Quit (); },
(uint) Gdk.Key.q,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
this.KeyPressEvent += KeyPressed;
topHBox.Show ();
mainVBox.PackStart (topHBox, false, false, 0);
//.........这里部分代码省略.........