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); }
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); }
public PreferencesDialog(ITranslations translations, PlayerHistory history) : base(translations, "PreferencesDialog.ui", "preferences") { this.history = history; prefspinbutton.Value = Preferences.Get <int> (Preferences.MemQuestionTimeKey); prefcheckbutton.Active = Preferences.Get <bool> (Preferences.MemQuestionWarnKey); maxstoredspinbutton.Value = Preferences.Get <int> (Preferences.MaxStoredGamesKey); minplayedspinbutton.Value = Preferences.Get <int> (Preferences.MinPlayedGamesKey); colorblindcheckbutton.Active = Preferences.Get <bool> (Preferences.ColorBlindKey); englishcheckbutton.Active = Preferences.Get <bool> (Preferences.EnglishKey); loadextensionscheckbutton.Active = Preferences.Get <bool> (Preferences.LoadPlugginsKey); usesoundscheckbutton.Active = Preferences.Get <bool> (Preferences.SoundsKey); switch ((GameDifficulty)Preferences.Get <int> (Preferences.DifficultyKey)) { case GameDifficulty.Easy: rb_easy.Active = rb_easy.HasFocus = true; break; case GameDifficulty.Medium: rb_medium.Active = rb_medium.HasFocus = true; break; case GameDifficulty.Master: rb_master.Active = rb_master.HasFocus = true; break; } ListStore store = new ListStore(typeof(string), typeof(Theme)); // DisplayName, theme reference CellRenderer layout_cell = new CellRendererText(); themes_combobox.Model = store; themes_combobox.PackStart(layout_cell, true); themes_combobox.SetCellDataFunc(layout_cell, ComboBoxCellFunc); foreach (Theme theme in ThemeManager.Themes) { store.AppendValues(Catalog.GetString(theme.LocalizedName), theme); } // Default value TreeIter iter; bool more = store.GetIterFirst(out iter); while (more) { Theme theme = (Theme)store.GetValue(iter, COLUMN_VALUE); if (String.Compare(theme.Name, Preferences.Get <string> (Preferences.ThemeKey), true) == 0) { themes_combobox.SetActiveIter(iter); break; } more = store.IterNext(ref iter); } #if !MONO_ADDINS loadextensionscheckbutton.Visible = false; #endif }
/// <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; }
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; }
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; }
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; }
public SmugMugAddAlbum(SmugMugExport export, SmugMugApi smugmug) : base("smugmug_add_album_dialog") { this.export = export; this.smugmug = smugmug; this.category_store = new ListStore(typeof(int), typeof(string)); CellRendererText display_cell = new CellRendererText(); category_combo.PackStart(display_cell, true); category_combo.SetCellDataFunc(display_cell, new CellLayoutDataFunc(CategoryDataFunc)); this.category_combo.Model = category_store; PopulateCategoryCombo(); Dialog.Response += HandleAddResponse; title_entry.Changed += HandleChanged; HandleChanged(null, null); }
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); }
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); }
public SmugMugAddAlbum(SmugMugExport export, SmugMugApi smugmug) { xml = new Glade.XML(null, "SmugMugExport.glade", dialog_name, "f-spot"); xml.Autoconnect(this); this.export = export; this.smugmug = smugmug; this.category_store = new ListStore(typeof(int), typeof(string)); CellRendererText display_cell = new CellRendererText(); category_combo.PackStart(display_cell, true); category_combo.SetCellDataFunc(display_cell, new CellLayoutDataFunc(CategoryDataFunc)); this.category_combo.Model = category_store; PopulateCategoryCombo(); Dialog.Response += HandleAddResponse; title_entry.Changed += HandleChanged; HandleChanged(null, null); }
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); }
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; matchEntry.Entry.ModifyBase (StateType.Normal, Style.White); matchEntry.WidthRequest = 240; matchEntry.RoundedShape = true; matchEntry.Entry.Changed += HandleSearchEntryChanged; matchEntry.Activated += (sender, e) => { var pattern = SearchPopupSearchPattern.ParsePattern (matchEntry.Entry.Text); if (pattern.Pattern == null && pattern.LineNumber > 0) { popup.Destroy (); var doc = IdeApp.Workbench.ActiveDocument; if (doc != null && doc != null) { doc.Select (); doc.Editor.Caret.Location = new Mono.TextEditor.DocumentLocation (pattern.LineNumber, pattern.Column > 0 ? pattern.Column : 1); doc.Editor.CenterToCaret (); doc.Editor.Parent.StartCaretPulseAnimation (); } return; } if (popup != null) popup.OpenFile (); }; matchEntry.Entry.KeyPressEvent += (o, args) => { if (args.Event.Key == Gdk.Key.Escape) { var doc = IdeApp.Workbench.ActiveDocument; if (doc != null) { if (popup != null) popup.Destroy (); doc.Select (); } return; } if (popup != null) { args.RetVal = popup.ProcessKey (args.Event.Key, args.Event.State); } }; IdeApp.Workbench.RootWindow.WidgetEvent += delegate(object o, WidgetEventArgs args) { if (args.Event is Gdk.EventConfigure) PositionPopup (); }; BuildToolbar (); IdeApp.CommandService.RegisterCommandBar (buttonBar); AddinManager.ExtensionChanged += delegate(object sender, ExtensionEventArgs args) { if (args.PathChanged (ToolbarExtensionPath)) BuildToolbar (); }; 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); Add (align); SetDefaultSizes (-1, 21); UpdateCombos (); button.Clicked += HandleStartButtonClicked; IdeApp.CommandService.RegisterCommandBar (this); IdeApp.CommandService.ActiveWidgetChanged += (sender, e) => { lastCommandTarget = e.OldActiveWidget; }; this.ShowAll (); this.statusArea.statusIconBox.HideAll (); }
public PdfExportDialog(GameManager manager, ITranslations translations) : base(translations, "PdfExportDialog.ui", "pdfexportbox") { pdfExporter = new PdfExporter(translations); this.manager = manager; games_spinbutton.Value = 10; checkbox_logic.Active = checkbox_calculation.Active = checkbox_verbal.Active = true; // Use defaults from Preferences switch ((GameDifficulty)Preferences.Get <int> (Preferences.DifficultyKey)) { case GameDifficulty.Easy: rb_easy.Active = rb_easy.HasFocus = true; break; case GameDifficulty.Medium: rb_medium.Active = rb_medium.HasFocus = true; break; case GameDifficulty.Master: rb_master.Active = rb_master.HasFocus = true; break; } // File selection string def_file; def_file = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), // Translators: default file name used when exporting PDF files (keep the pdf extension please) Catalog.GetString("games.pdf")); file = new BrowseFile(hbox_file, def_file, true); FileFilter[] filters = new FileFilter [2]; filters[0] = new FileFilter(); filters[0].AddPattern("*.pdf"); filters[0].Name = Catalog.GetString("PDF files"); filters[1] = new FileFilter(); filters[1].AddPattern("*.*"); filters[1].Name = Catalog.GetString("All files"); file.Filters = filters; ListStore layout_store = new ListStore(typeof(string), typeof(int)); // DisplayName, index to array CellRenderer layout_cell = new CellRendererText(); layout_combo.Model = layout_store; layout_combo.PackStart(layout_cell, true); layout_combo.SetCellDataFunc(layout_cell, ComboBoxCellFunc); int [] per_side = pdfExporter.PagesPerSide; for (int i = 0; i < per_side.Length; i++) { layout_store.AppendValues(per_side[i].ToString(), per_side[i]); } // Default value TreeIter iter; bool more = layout_store.GetIterFirst(out iter); while (more) { if ((int)layout_store.GetValue(iter, COLUMN_VALUE) == DEF_SIDEVALUE) { layout_combo.SetActiveIter(iter); break; } more = layout_store.IterNext(ref iter); } }
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); scrolledWindow = new ScrolledWindow (); scrolledWindow.VscrollbarPolicy = PolicyType.Automatic; scrolledWindow.HscrollbarPolicy = PolicyType.Never; scrolledWindow.BorderWidth = 0; scrolledWindow.CanFocus = true; scrolledWindow.Show (); mainVBox.PackStart (scrolledWindow, true, true, 0); innerEb = new EventBox(); innerEb.BorderWidth = 0; Gdk.Color backgroundColor = GetBackgroundColor (); innerEb.ModifyBg (StateType.Normal, backgroundColor); innerEb.ModifyBase (StateType.Normal, backgroundColor); targetVBox = new VBox(); targetVBox.BorderWidth = 5; targetVBox.Show (); innerEb.Add(targetVBox); scrolledWindow.AddWithViewport(innerEb); statusbar = new Gtk.Statusbar (); statusbar.HasResizeGrip = true; statusbar.Show (); mainVBox.PackEnd (statusbar, false, false, 0); // // Delay adding in the TaskGroups until the backend is initialized // Shown += OnWindowShown; DeleteEvent += WindowDeleted; backend.BackendInitialized += OnBackendInitialized; backend.BackendSyncStarted += OnBackendSyncStarted; backend.BackendSyncFinished += OnBackendSyncFinished; // if the backend is already initialized, go ahead... initialize if(backend.Initialized) { OnBackendInitialized(null, null); } GtkApplication.Instance.Preferences.SettingChanged += OnSettingChanged; }
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; }
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); Add (align); SetDefaultSizes (-1, 21); configurationCombo.Changed += (o, e) => { if (ConfigurationChanged != null) ConfigurationChanged (o, e); }; runtimeCombo.Changed += (o, e) => { var ea = new HandledEventArgs (); if (RuntimeChanged != null) RuntimeChanged (o, ea); TreeIter it; if (runtimeCombo.GetActiveIter (out it)) { if (ea.Handled) { runtimeCombo.SetActiveIter (lastSelection); return; } lastSelection = it; } }; button.Clicked += HandleStartButtonClicked; IdeApp.CommandService.ActiveWidgetChanged += (sender, e) => { lastCommandTarget = new WeakReference (e.OldActiveWidget); }; this.ShowAll (); this.statusArea.statusIconBox.HideAll (); }
// 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(); }
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); AddLabelEntry ("exposure", Catalog.GetString ("Exposure"), Catalog.GetString ("Show Exposure"), (photo, metadata) => { var fnumber = metadata.ImageTag.FNumber; var exposure_time = metadata.ImageTag.ExposureTime; var iso_speed = metadata.ImageTag.ISOSpeedRatings; string info = String.Empty; if (fnumber.HasValue && fnumber.Value != 0.0) { info += String.Format ("f/{0:.0} ", fnumber.Value); } if (exposure_time.HasValue) { if (Math.Abs (exposure_time.Value) >= 1.0) { info += String.Format ("{0} sec ", exposure_time.Value); } else { info += String.Format ("1/{0} sec ", (int)(1 / exposure_time.Value)); } } if (iso_speed.HasValue) { info += String.Format ("{0}ISO {1}", Environment.NewLine, iso_speed.Value); } var exif = metadata.ImageTag.Exif; if (exif != null) { var flash = exif.ExifIFD.GetLongValue (0, (ushort)TagLib.IFD.Tags.ExifEntryTag.Flash); if (flash.HasValue) { if ((flash.Value & 0x01) == 0x01) info += String.Format (", {0}", Catalog.GetString ("flash fired")); else info += String.Format (", {0}", Catalog.GetString ("flash didn't fire")); } } if (info == String.Empty) return Catalog.GetString ("(None)"); return info; }, null); AddLabelEntry ("focal_length", Catalog.GetString ("Focal Length"), Catalog.GetString ("Show Focal Length"), false, (photo, metadata) => { var focal_length = metadata.ImageTag.FocalLength; if (focal_length == null) return Catalog.GetString ("(Unknown)"); else return String.Format ("{0} mm", focal_length.Value); }, null); AddLabelEntry ("camera", Catalog.GetString ("Camera"), Catalog.GetString ("Show Camera"), false, (photo, metadata) => { return metadata.ImageTag.Model ?? Catalog.GetString ("(Unknown)"); }, null); AddLabelEntry ("creator", Catalog.GetString ("Creator"), Catalog.GetString ("Show Creator"), (photo, metadata) => { return metadata.ImageTag.Creator ?? Catalog.GetString ("(Unknown)"); }, null); AddLabelEntry ("file_size", Catalog.GetString ("File Size"), Catalog.GetString ("Show File Size"), false, (photo, metadata) => { try { GFile file = FileFactory.NewForUri (photo.DefaultVersion.Uri); GFileInfo file_info = file.QueryInfo ("standard::size", FileQueryInfoFlags.None, null); return Format.SizeForDisplay (file_info.Size); } catch (GLib.GException e) { Hyena.Log.DebugException (e); return Catalog.GetString ("(File read error)"); } }, null); var rating_entry = new RatingEntry { HasFrame = false, AlwaysShowEmptyStars = true }; rating_entry.Changed += HandleRatingChanged; var rating_align = new Gtk.Alignment (0, 0, 0, 0); rating_align.Add (rating_entry); AddEntry ("rating", Catalog.GetString ("Rating"), Catalog.GetString ("Show Rating"), rating_align, false, (widget, photo, metadata) => { ((widget as Alignment).Child as RatingEntry).Value = (int) photo.Rating; }, null); AddEntry ("tag", null, Catalog.GetString ("Show Tags"), new TagView (), false, (widget, photo, metadata) => { (widget as TagView).Current = photo; }, null); UpdateTable (); EventBox eb = new EventBox (); eb.Add (info_table); info_expander.Add (eb); eb.ButtonPressEvent += HandleButtonPressEvent; Add (info_expander); }
public DateEdit(System.DateTime time, DateEditFlags flags) { datetime = new DateTimeZone(time); datetime.Changed += HandleDateTimeZoneChanged; this.flags = flags; date_entry = new Gtk.Entry(); date_entry.WidthChars = 10; date_entry.Changed += HandleDateEntryChanged; PackStart(date_entry, true, true, 0); Gtk.HBox b_box = new Gtk.HBox(); b_box.PackStart(new Gtk.Label(Catalog.GetString("Calendar")), true, true, 0); b_box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), true, false, 0); date_button = new Gtk.Button(b_box); date_button.Clicked += HandleCalendarButtonClicked; PackStart(date_button, false, false, 0); calendar = new Gtk.Calendar(); calendar.DaySelected += HandleCalendarDaySelected; Gtk.Frame frame = new Gtk.Frame(); frame.Add(calendar); cal_popup = new Gtk.Window(Gtk.WindowType.Popup); cal_popup.DestroyWithParent = true; cal_popup.Add(frame); cal_popup.Shown += HandleCalendarPopupShown; cal_popup.GrabNotify += HandlePopupGrabNotify; frame.Show(); calendar.Show(); time_entry = new Gtk.Entry(); time_entry.WidthChars = 8; time_entry.Changed += HandleTimeEntryChanged; PackStart(time_entry, true, true, 0); Gtk.CellRendererText timecell = new Gtk.CellRendererText(); time_combo = new Gtk.ComboBox(); time_store = new Gtk.TreeStore(typeof(string), typeof(int), typeof(int)); time_combo.Model = time_store; time_combo.PackStart(timecell, true); time_combo.SetCellDataFunc(timecell, new CellLayoutDataFunc(TimeCellFunc)); time_combo.Realized += FillTimeCombo; time_combo.Changed += HandleTimeComboChanged; PackStart(time_combo, false, false, 0); zone_entry = new Gtk.Entry(); zone_entry.IsEditable = false; zone_entry.MaxLength = 6; zone_entry.WidthChars = 6; PackStart(zone_entry, true, true, 0); Gtk.CellRendererText offsetcell = new Gtk.CellRendererText(); offset_combo = new Gtk.ComboBox(); offset_combo.Model = new Gtk.TreeStore(typeof(string), typeof(int)); offset_combo.PackStart(offsetcell, true); offset_combo.SetCellDataFunc(offsetcell, new CellLayoutDataFunc(OffsetCellFunc)); FillOffsetCombo(); offset_combo.Changed += HandleOffsetComboChanged; PackStart(offset_combo, false, false, 0); Update(); ShowAll(); }
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 += delegate (object sender, EventArgs e) { ContextSwitchStrategy.SetInfoBoxVisible (Context, info_expander.Expanded); }; Table info_table = new Table (10, 2, false); info_table.BorderWidth = 0; string name_pre = "<b>"; string name_post = "</b>"; name_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Name") + name_post); info_table.Attach (name_label, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); version_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Version") + name_post); info_table.Attach (version_label, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); date_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Date") + name_post + Environment.NewLine); info_table.Attach (date_label, 0, 1, 2, 3, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); size_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Size") + name_post); info_table.Attach (size_label, 0, 1, 3, 4, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); default_exposure_string = name_pre + Catalog.GetString ("Exposure") + name_post; exposure_label = CreateRightAlignedLabel (default_exposure_string); info_table.Attach (exposure_label, 0, 1, 4, 5, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); focal_length_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Focal Length") + name_post); info_table.Attach (focal_length_label, 0, 1, 5, 6, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); camera_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Camera") + name_post); info_table.Attach (camera_label, 0, 1, 6, 7, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); file_size_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("File Size") + name_post); info_table.Attach (file_size_label, 0, 1, 7, 8, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); rating_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Rating") + name_post); info_table.Attach (rating_label, 0, 1, 8, 9, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); rating_label.Visible = false; name_value_label = new Label (); name_value_label.Ellipsize = Pango.EllipsizeMode.Middle; name_value_label.Justify = Gtk.Justification.Left; name_value_label.Selectable = true; name_value_label.Xalign = 0; name_value_label.PopulatePopup += HandlePopulatePopup; info_table.Attach (name_value_label, 1, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 3, 0); date_value_label = AttachLabel (info_table, 2, name_value_label); size_value_label = AttachLabel (info_table, 3, name_value_label); exposure_value_label = AttachLabel (info_table, 4, name_value_label); version_list = new ListStore (typeof (uint), 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; info_table.Attach (version_combo, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); date_value_label.Text = Environment.NewLine; exposure_value_label.Text = Environment.NewLine; focal_length_value_label = AttachLabel (info_table, 5, name_value_label); camera_value_label = AttachLabel (info_table, 6, name_value_label); file_size_value_label = AttachLabel (info_table, 7, name_value_label); Gtk.Alignment rating_align = new Gtk.Alignment( 0, 0, 0, 0); info_table.Attach (rating_align, 1, 2, 8, 9, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); rating_view = new RatingSmall (); rating_view.Visible = false; rating_view.Changed += HandleRatingChanged; rating_align.Add (rating_view); tag_view = new TagView (MainWindow.ToolTips); info_table.Attach (tag_view, 0, 2, 9, 10, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING); info_table.ShowAll (); EventBox eb = new EventBox (); eb.Add (info_table); info_expander.Add (eb); eb.ButtonPressEvent += HandleButtonPressEvent; Add (info_expander); rating_label.Visible = show_rating; rating_view.Visible = show_rating; }
public DateEdit (System.DateTime time, DateEditFlags flags) { datetime = new DateTimeZone (time); datetime.Changed += HandleDateTimeZoneChanged; this.flags = flags; date_entry = new Gtk.Entry (); date_entry.WidthChars = 10; date_entry.Changed += HandleDateEntryChanged; PackStart (date_entry, true, true, 0); Gtk.HBox b_box = new Gtk.HBox (); b_box.PackStart (new Gtk.Label (Catalog.GetString ("Calendar")), true, true, 0); b_box.PackStart (new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), true, false, 0); date_button = new Gtk.Button (b_box); date_button.Clicked += HandleCalendarButtonClicked; PackStart (date_button, false, false, 0); calendar = new Gtk.Calendar (); calendar.DaySelected += HandleCalendarDaySelected; Gtk.Frame frame = new Gtk.Frame (); frame.Add (calendar); cal_popup = new Gtk.Window (Gtk.WindowType.Popup); cal_popup.DestroyWithParent = true; cal_popup.Add (frame); cal_popup.Shown += HandleCalendarPopupShown; cal_popup.GrabNotify += HandlePopupGrabNotify; frame.Show (); calendar.Show (); time_entry = new Gtk.Entry (); time_entry.WidthChars = 8; time_entry.Changed += HandleTimeEntryChanged; PackStart (time_entry, true, true, 0); Gtk.CellRendererText timecell = new Gtk.CellRendererText (); time_combo = new Gtk.ComboBox (); time_store = new Gtk.TreeStore (typeof (string), typeof (int), typeof (int)); time_combo.Model = time_store; time_combo.PackStart (timecell, true); time_combo.SetCellDataFunc (timecell, new CellLayoutDataFunc (TimeCellFunc)); time_combo.Realized += FillTimeCombo; time_combo.Changed += HandleTimeComboChanged; PackStart (time_combo, false, false, 0); zone_entry = new Gtk.Entry (); zone_entry.IsEditable = false; zone_entry.MaxLength = 6; zone_entry.WidthChars = 6; PackStart (zone_entry, true, true, 0); Gtk.CellRendererText offsetcell = new Gtk.CellRendererText (); offset_combo = new Gtk.ComboBox (); offset_combo.Model = new Gtk.TreeStore (typeof (string), typeof (int)); offset_combo.PackStart (offsetcell, true); offset_combo.SetCellDataFunc (offsetcell, new CellLayoutDataFunc (OffsetCellFunc)); FillOffsetCombo (); offset_combo.Changed += HandleOffsetComboChanged; PackStart (offset_combo, false, false, 0); Update (); ShowAll (); }
public Gtk.Widget MakeSyncPane () { Gtk.VBox vbox = new Gtk.VBox (false, 0); vbox.Spacing = 4; vbox.BorderWidth = 8; Gtk.HBox hbox = new Gtk.HBox (false, 4); Gtk.Label label = new Gtk.Label (Catalog.GetString ("Ser_vice:")); label.Xalign = 0; label.Show (); hbox.PackStart (label, false, false, 0); // Populate the store with all the available SyncServiceAddins syncAddinStore = new Gtk.ListStore (typeof (SyncServiceAddin)); syncAddinIters = new Dictionary<string,Gtk.TreeIter> (); SyncServiceAddin [] addins = Tomboy.DefaultNoteManager.AddinManager.GetSyncServiceAddins (); Array.Sort (addins, CompareSyncAddinsByName); foreach (SyncServiceAddin addin in addins) { Gtk.TreeIter iter = syncAddinStore.Append (); syncAddinStore.SetValue (iter, 0, addin); syncAddinIters [addin.Id] = iter; } syncAddinCombo = new Gtk.ComboBox (syncAddinStore); label.MnemonicWidget = syncAddinCombo; Gtk.CellRendererText crt = new Gtk.CellRendererText (); syncAddinCombo.PackStart (crt, true); syncAddinCombo.SetCellDataFunc (crt, new Gtk.CellLayoutDataFunc (ComboBoxTextDataFunc)); // Read from Preferences which service is configured and select it // by default. Otherwise, just select the first one in the list. string addin_id = Preferences.Get ( Preferences.SYNC_SELECTED_SERVICE_ADDIN) as String; Gtk.TreeIter active_iter; if (addin_id != null && syncAddinIters.ContainsKey (addin_id)) { active_iter = syncAddinIters [addin_id]; syncAddinCombo.SetActiveIter (active_iter); } else { if (syncAddinStore.GetIterFirst (out active_iter) == true) { syncAddinCombo.SetActiveIter (active_iter); } } syncAddinCombo.Changed += OnSyncAddinComboChanged; syncAddinCombo.Show (); hbox.PackStart (syncAddinCombo, true, true, 0); hbox.Show (); vbox.PackStart (hbox, false, false, 0); // Get the preferences GUI for the Sync Addin if (active_iter.Stamp != Gtk.TreeIter.Zero.Stamp) selectedSyncAddin = syncAddinStore.GetValue (active_iter, 0) as SyncServiceAddin; if (selectedSyncAddin != null) syncAddinPrefsWidget = selectedSyncAddin.CreatePreferencesControl (OnSyncAddinPrefsChanged); if (syncAddinPrefsWidget == null) { Gtk.Label l = new Gtk.Label (Catalog.GetString ("Not configurable")); l.Yalign = 0.5f; l.Yalign = 0.5f; syncAddinPrefsWidget = l; } if (syncAddinPrefsWidget != null && addin_id != null && syncAddinIters.ContainsKey (addin_id) && selectedSyncAddin.IsConfigured) syncAddinPrefsWidget.Sensitive = false; syncAddinPrefsWidget.Show (); syncAddinPrefsContainer = new Gtk.VBox (false, 0); syncAddinPrefsContainer.PackStart (syncAddinPrefsWidget, false, false, 0); syncAddinPrefsContainer.Show (); vbox.PackStart (syncAddinPrefsContainer, true, true, 10); // Autosync preference int timeout = (int) Preferences.Get (Preferences.SYNC_AUTOSYNC_TIMEOUT); if (timeout > 0 && timeout < 5) { timeout = 5; Preferences.Set (Preferences.SYNC_AUTOSYNC_TIMEOUT, 5); } Gtk.HBox autosyncBox = new Gtk.HBox (false, 5); // Translators: This is and the next string go together. // Together they look like "Automatically Sync in Background Every [_] Minutes", // where "[_]" is a GtkSpinButton. autosyncCheck = new Gtk.CheckButton (Catalog.GetString ("Automaticall_y Sync in Background Every")); autosyncSpinner = new Gtk.SpinButton (5, 1000, 1); autosyncSpinner.Value = timeout >= 5 ? timeout : 10; Gtk.Label autosyncExtraText = // Translators: See above comment for details on // this string. new Gtk.Label (Catalog.GetString ("Minutes")); autosyncCheck.Active = autosyncSpinner.Sensitive = timeout >= 5; EventHandler updateTimeoutPref = (o, e) => { Preferences.Set (Preferences.SYNC_AUTOSYNC_TIMEOUT, autosyncCheck.Active ? (int) autosyncSpinner.Value : -1); }; autosyncCheck.Toggled += (o, e) => { autosyncSpinner.Sensitive = autosyncCheck.Active; updateTimeoutPref (o, e); }; autosyncSpinner.ValueChanged += updateTimeoutPref; autosyncBox.PackStart (autosyncCheck); autosyncBox.PackStart (autosyncSpinner); autosyncBox.PackStart (autosyncExtraText); vbox.PackStart (autosyncBox, false, true, 0); Gtk.HButtonBox bbox = new Gtk.HButtonBox (); bbox.Spacing = 4; bbox.LayoutStyle = Gtk.ButtonBoxStyle.End; // "Advanced..." button to bring up extra sync config dialog Gtk.Button advancedConfigButton = new Gtk.Button (Catalog.GetString ("_Advanced...")); advancedConfigButton.Clicked += OnAdvancedSyncConfigButton; advancedConfigButton.Show (); bbox.PackStart (advancedConfigButton, false, false, 0); bbox.SetChildSecondary (advancedConfigButton, true); resetSyncAddinButton = new Gtk.Button (Gtk.Stock.Clear); resetSyncAddinButton.Clicked += OnResetSyncAddinButton; resetSyncAddinButton.Sensitive = (selectedSyncAddin != null && addin_id == selectedSyncAddin.Id && selectedSyncAddin.IsConfigured); resetSyncAddinButton.Show (); bbox.PackStart (resetSyncAddinButton, false, false, 0); // TODO: Tabbing should go directly from sync prefs widget to here // TODO: Consider connecting to "Enter" pressed in sync prefs widget saveSyncAddinButton = new Gtk.Button (Gtk.Stock.Save); saveSyncAddinButton.Clicked += OnSaveSyncAddinButton; saveSyncAddinButton.Sensitive = (selectedSyncAddin != null && (addin_id != selectedSyncAddin.Id || !selectedSyncAddin.IsConfigured)); saveSyncAddinButton.Show (); bbox.PackStart (saveSyncAddinButton, false, false, 0); syncAddinCombo.Sensitive = (selectedSyncAddin == null || addin_id != selectedSyncAddin.Id || !selectedSyncAddin.IsConfigured); bbox.Show (); vbox.PackStart (bbox, false, false, 0); vbox.ShowAll (); return vbox; }