protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); int descriptionWidth = 1; int totalHeight = yTitleBorder * 2 + yDescriptionBorder * 2 + 1; int width, height; titleLayout.SetText(TitleText); titleLayout.GetPixelSize(out width, out height); totalHeight += height; xSpacer = 0; int h2; int w2; descriptionLayout.GetPixelSize(out w2, out h2); totalHeight += h2; xSpacer = System.Math.Max(width, w2); xSpacer += xDescriptionBorder * 2 + 1; requisition.Width = triangleWidth + descriptionWidth + xSpacer; requisition.Height = totalHeight; }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); double y = verticalTextBorder * 2 - verticalTextSpace + (MonoDevelop.Core.Platform.IsWindows ? 10 : 2); using (var drawingLayout = new Pango.Layout(this.PangoContext)) { drawingLayout.FontDescription = cache.tooltipFontDescription; foreach (var msg in marker.Errors) { if (marker.Layouts.Count == 1) { drawingLayout.Width = maxTextWidth; } drawingLayout.SetText(msg.FullErrorMessage); int w; int h; drawingLayout.GetPixelSize(out w, out h); if (marker.Layouts.Count > 1) { w += (int)warningPixbuf.Width + iconTextSpacing; } requisition.Width = Math.Max(w + textBorder * 2, requisition.Width); y += h + verticalTextSpace - 3; } } requisition.Height = (int)y; }
static void GetMenuPosition(Gtk.Menu menu, out int x, out int y, out bool push_in) { if (menu.AttachWidget == null || menu.AttachWidget.GdkWindow == null) { // Prevent null exception in weird cases x = 0; y = 0; push_in = true; return; } menu.AttachWidget.GdkWindow.GetOrigin(out x, out y); x += menu.AttachWidget.Allocation.X; Gtk.Requisition menu_req = menu.SizeRequest(); if (y + menu_req.Height >= menu.AttachWidget.Screen.Height) { y -= menu_req.Height; } else { y += menu.AttachWidget.Allocation.Height; } push_in = true; }
//required by base class Gtk.Bin protected override void OnSizeRequested(ref Gtk.Requisition requisition) { if (this.Child != null) { requisition = this.Child.SizeRequest(); } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); double y = verticalTextBorder * 2 - verticalTextSpace; // one space get's added too much using (var drawingLayout = new Pango.Layout(this.PangoContext)) { drawingLayout.FontDescription = cache.tooltipFontDescription; foreach (var msg in marker.Errors) { if (marker.Layouts.Count == 1) { drawingLayout.Width = maxTextWidth; } drawingLayout.SetText(GetFirstLine(msg)); int w; int h; drawingLayout.GetPixelSize(out w, out h); if (marker.Layouts.Count > 1) { w += cache.warningPixbuf.Width + iconTextSpacing; } requisition.Width = Math.Max(w + textBorder * 2, requisition.Width); y += h + verticalTextSpace; } } requisition.Height = (int)y; }
public bool MenuOpensUpward() { bool open_upwards = false; int val = 0; Gdk.Screen screen = null; #if WIN32 || MAC int x; tray.TomboyTrayMenu.Screen.Display.GetPointer(out x, out val); screen = tray.TomboyTrayMenu.Screen; #else Gdk.Rectangle area; Gtk.Orientation orientation; GetGeometry(out screen, out area, out orientation); val = area.Y; #endif Gtk.Requisition menu_req = tray.TomboyTrayMenu.SizeRequest(); if (val + menu_req.Height >= screen.Height) { open_upwards = true; } return(open_upwards); }
public GtkSharpChoice(Widget shellobject, params object[] entries) : base(shellobject) { //note: this function is somewhat hacky to get stupid gtk combos to behave like we want //the question is if we can guarantee default width of combos are same evrywhere? int xborder; combobox = new Gtk.ComboBox(); //TODO: support adding objects GtkSharpDriver.InitWidget(combobox, shellobject); var c = combobox.Child; Gtk.Requisition req_r = c.SizeRequest(); Gtk.Requisition req_c = combobox.SizeRequest(); int btnwidth = req_c.Width - req_r.Width; xborder = req_c.Height - req_r.Height; c.SetSizeRequest(Guppy.DefaultEditWidth - xborder, -1); FitWidth(); combobox.Show(); }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); int descriptionWidth = 1; int totalHeight = yBorder * 2 + 1; int width, height; layout.SetText(TitleText); layout.GetPixelSize(out width, out height); totalHeight += height; xSpacer = 0; foreach (var pair in Items) { int w1, w2; layout.SetMarkup(pair.Key); layout.GetPixelSize(out w1, out height); layout.SetMarkup(pair.Value); layout.GetPixelSize(out w2, out height); descriptionWidth = System.Math.Max(descriptionWidth, w2); xSpacer = System.Math.Max(xSpacer, w1); totalHeight += height; } xSpacer += xBorder * 2 + 1; requisition.Width = descriptionWidth + xSpacer + xBorder * 2 + 1; requisition.Height = totalHeight; }
protected override void OnSizeAllocated(Gdk.Rectangle allocation) { foreach (var child in children) { Gtk.Requisition req = child.Widget.ChildRequisition; child.Widget.SizeAllocate(new Gdk.Rectangle(child.X, child.Y, req.Width, req.Height)); } if (IsRealized) { GdkWindow.MoveResize(allocation.X, allocation.Y, allocation.Width, allocation.Height); bin_window.Resize((int)Math.Max(width, allocation.Width), (int)Math.Max(height, allocation.Height)); } Hadjustment.PageSize = allocation.Width; Hadjustment.PageIncrement = Width * .9; Hadjustment.Lower = 0; Hadjustment.Upper = Math.Max(width, allocation.Width); Vadjustment.PageSize = allocation.Height; Vadjustment.PageIncrement = Height * .9; Vadjustment.Lower = 0; Vadjustment.Upper = Math.Max(height, allocation.Height); base.OnSizeAllocated(allocation); }
protected override bool OnExposeEvent(Gdk.EventExpose ev) { base.OnExposeEvent(ev); Gtk.Requisition req = SizeRequest(); Gtk.Style.PaintFlatBox(this.Style, this.GdkWindow, Gtk.StateType.Normal, Gtk.ShadowType.Out, Gdk.Rectangle.Zero, this, "tooltip", 0, 0, req.Width, req.Height); return(true); }
void UpdatePosition() { var bounds = view.CellBounds(Item); Gtk.Requisition requisition = SizeRequest(); Resize(requisition.Width, requisition.Height); view.GdkWindow.GetOrigin(out var x, out var y); // Acount for scrolling bounds.X -= (int)view.Hadjustment.Value; bounds.Y -= (int)view.Vadjustment.Value; // calculate the cell center x += bounds.X + (bounds.Width / 2); y += bounds.Y + (bounds.Height / 2); // find the window's x location limiting it to the screen x = Math.Max(0, x - requisition.Width / 2); x = Math.Min(x, Screen.Width - requisition.Width); // find the window's y location offset above or below depending on space y = Math.Max(0, y - requisition.Height / 2); y = Math.Min(y, Screen.Height - requisition.Height); Move(x, y); }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); IWidgetSurface ws = Frontend.Surface; int h, w; if (ws.SizeRequestMode == SizeRequestMode.HeightForWidth) { w = (int)ws.GetPreferredWidth().MinSize; h = (int)ws.GetPreferredHeightForWidth(w).MinSize; } else { h = (int)ws.GetPreferredHeight().MinSize; w = (int)ws.GetPreferredWidthForHeight(h).MinSize; } if (requisition.Width < w) { requisition.Width = w; } if (requisition.Height < h) { requisition.Height = h; } foreach (var cr in children) { cr.Key.SizeRequest(); } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { if (image != null) { requisition.Width = (int)(image.Width * IconScale); requisition.Height = (int)(image.Height * IconScale); } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { var size1 = Child1.SizeRequest(); var size2 = Child2.SizeRequest(); requisition.Height = Math.Max(size1.Height, size2.Height); requisition.Width = Handler.GetPreferredPanelSize(size1.Width, size2.Width); }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); foreach (var cr in children) { cr.Key.SizeRequest(); } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { int width, height; Layout.GetPixelSize(out width, out height); requisition.Width = width; requisition.Height = height; }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); foreach (var c in children.Keys.ToArray()) { c.SizeRequest(); } }
public static Gtk.Requisition ToGtkRequisition(this Size size) { var req = new Gtk.Requisition(); req.Height = (int)size.Height; req.Width = (int)size.Width; return(req); }
public bool GetSizeOfRow(Gtk.TreePath path, Gtk.Requisition requisition) { IntPtr native_requisition = GLib.Marshaller.StructureToPtrAlloc(requisition); bool raw_ret = gtk_cell_view_get_size_of_row(Handle, path == null ? IntPtr.Zero : path.Handle, native_requisition); bool ret = raw_ret; Marshal.FreeHGlobal(native_requisition); return(ret); }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { requisition.Width = requisition.Height = 0; foreach (var child in children) { child.Widget.SizeRequest(); } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { IWidgetSurface ws = Frontend; int w = (int)ws.GetPreferredWidth().MinSize; int h = (int)ws.GetPreferredHeight().MinSize; requisition.Width = w; requisition.Height = h; }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); if (!image.IsNull) { requisition.Width = (int)image.Size.Width; requisition.Height = (int)image.Size.Height; } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { // Always be X pixels tall, but maintain aspect ratio Size imagesize = PintaCore.Workspace.ImageSize; requisition.Height = 65; requisition.Width = (imagesize.Width * requisition.Height) / imagesize.Height; thumbnail = null; }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); // Ignore the size of top levels. They are supposed to fit the available space foreach (TopLevelChild tchild in topLevels) { tchild.Child.SizeRequest(); } }
protected override void OnSizeAllocated(Gdk.Rectangle allocation) { base.OnSizeAllocated(allocation); foreach (TopLevelChild child in topLevels) { Gtk.Requisition req = child.Child.SizeRequest(); child.Child.SizeAllocate(new Gdk.Rectangle(allocation.X + child.X, allocation.Y + child.Y, req.Width, req.Height)); } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { requisition.Width = Xpad * 2; requisition.Height = Ypad * 2; if (image != null) { requisition.Width += (int)(image.Width); requisition.Height += (int)(image.Height); } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); //if showing a border line, request a little more space if (showBorderLine) { requisition.Height += HScrollbar.Visible? 1 : 2; requisition.Width += VScrollbar.Visible? 1 : 2; } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); if (Child != null) { Child.SizeRequest(); } vScrollBar.SizeRequest(); hScrollBar.SizeRequest(); children.ForEach(child => child.Child.SizeRequest()); }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); if (PositionSet && Child1 != null) { var childreq = Child1.Requisition; if (childreq.Height > 0) { requisition.Height += Position - childreq.Height; } } }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { if (Child != null) { requisition = Child.SizeRequest(); } else { requisition.Width = 0; requisition.Height = 0; } }
protected override void OnSizeRequested (ref Gtk.Requisition req) { if (!inited) { CreateIcons (); inited = true; } base.OnSizeRequested (ref req); CalcSize (); Gtk.Requisition nr = new Gtk.Requisition (); nr.Width = xmax; nr.Height = ymax; req = nr; }
public MainWindow() : base("Smuxi") { // restore window size / position int width, heigth; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"] != null) { width = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"]; } else { width = 800; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"] != null) { heigth = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"]; } else { heigth = 600; } if (width < -1 || heigth < -1) { width = -1; heigth = -1; } if (width == -1 && heigth == -1) { SetDefaultSize(800, 600); Maximize(); } else if (width == 0 && heigth == 0) { // HACK: map 0/0 to default size as it crashes on Windows :/ SetDefaultSize(800, 600); } else { SetDefaultSize(width, heigth); } int x, y; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"] != null) { x = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"]; } else { x = 0; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"] != null) { y = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"]; } else { y = 0; } if (x < 0 || y < 0) { x = 0; y = 0; } if (x == 0 && y == 0) { SetPosition(Gtk.WindowPosition.Center); } else { Move(x, y); } DeleteEvent += OnDeleteEvent; FocusInEvent += OnFocusInEvent; FocusOutEvent += OnFocusOutEvent; WindowStateEvent += OnWindowStateEvent; Gtk.AccelGroup agrp = new Gtk.AccelGroup(); Gtk.AccelKey akey; AddAccelGroup(agrp); // Menu MenuBar = new Gtk.MenuBar(); Gtk.Menu menu; Gtk.MenuItem item; Gtk.ImageMenuItem image_item; // Menu - File menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_File")); item.Submenu = menu; MenuBar.Append(item); item = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, agrp); item.Activated += new EventHandler(_OnPreferencesButtonClicked); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Gtk.Stock.Quit, agrp); item.Activated += new EventHandler(_OnQuitButtonClicked); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); // Menu - Server menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Server")); item.Submenu = menu; MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(_("_Quick Connect")); image_item.Image = new Gtk.Image(Gtk.Stock.Connect, Gtk.IconSize.Menu); image_item.Activated += OnServerQuickConnectButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(Gtk.Stock.Add, agrp); image_item.Activated += OnServerAddButtonClicked; menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Manage")); image_item.Image = new Gtk.Image(Gtk.Stock.Edit, Gtk.IconSize.Menu); image_item.Activated += OnServerManageServersButtonClicked; menu.Append(image_item); // Menu - Chat menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Chat")); item.Submenu = menu; MenuBar.Append(item); _OpenChatMenuItem = new Gtk.ImageMenuItem(_("Open / Join Chat")); _OpenChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenChatMenuItem.Activated += OnOpenChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.L; _OpenChatMenuItem.AddAccelerator("activate", agrp, akey); _OpenChatMenuItem.AccelCanActivate += AccelCanActivateSensitive; menu.Append(_OpenChatMenuItem); _FindGroupChatMenuItem = new Gtk.ImageMenuItem(_("_Find Group Chat")); _FindGroupChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Find, Gtk.IconSize.Menu); _FindGroupChatMenuItem.Activated += OnChatFindGroupChatButtonClicked; _FindGroupChatMenuItem.Sensitive = false; menu.Append(_FindGroupChatMenuItem); image_item = new Gtk.ImageMenuItem(_("C_lear All Activity")); image_item.Image = new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu); image_item.Activated += OnChatClearAllActivityButtonClicked; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Next Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoForward, Gtk.IconSize.Menu); image_item.Activated += OnNextChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Down; image_item.AddAccelerator("activate", agrp, akey); image_item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Previous Chat")); image_item.Image = new Gtk.Image(Gtk.Stock.GoBack, Gtk.IconSize.Menu); image_item.Activated += OnPreviousChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.Page_Up; image_item.AddAccelerator("activate", agrp, akey); image_item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(image_item); menu.Append(new Gtk.SeparatorMenuItem()); /* // TODO: make a radio item for each chat hotkey Gtk.RadioMenuItem radio_item; radio_item = new Gtk.RadioMenuItem(); radio_item = new Gtk.RadioMenuItem(radio_item); radio_item = new Gtk.RadioMenuItem(radio_item); menu.Append(new Gtk.SeparatorMenuItem()); */ /* image_item = new Gtk.ImageMenuItem(Gtk.Stock.Find, agrp); image_item.Activated += OnFindChatMenuItemActivated; menu.Append(image_item); item = new Gtk.MenuItem(_("Find _Next")); item.Activated += OnFindNextChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask; akey.Key = Gdk.Key.G; item.AddAccelerator("activate", agrp, akey); menu.Append(item); item = new Gtk.MenuItem(_("Find _Previous")); item.Activated += OnFindPreviousChatMenuItemActivated; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.AccelMods = Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask; akey.Key = Gdk.Key.G; item.AddAccelerator("activate", agrp, akey); menu.Append(item); */ // ROFL: the empty code statement below is needed to keep stupid // gettext away from using all the commented code from above as // translator comment ; _OpenLogChatMenuItem = new Gtk.ImageMenuItem(_("Open Log")); _OpenLogChatMenuItem.Image = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Menu); _OpenLogChatMenuItem.Activated += OnOpenLogChatMenuItemActivated; _OpenLogChatMenuItem.Sensitive = false; _OpenLogChatMenuItem.NoShowAll = true; menu.Append(_OpenLogChatMenuItem); _CloseChatMenuItem = new Gtk.ImageMenuItem(Gtk.Stock.Close, agrp); _CloseChatMenuItem.Activated += OnCloseChatMenuItemActivated; _CloseChatMenuItem.AccelCanActivate += AccelCanActivateSensitive; menu.Append(_CloseChatMenuItem); // Menu - Engine menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Engine")); item.Submenu = menu; MenuBar.Append(item); item = new Gtk.MenuItem(_("_Use Local Engine")); item.Activated += new EventHandler(_OnUseLocalEngineButtonClicked); menu.Append(item); menu.Append(new Gtk.SeparatorMenuItem()); image_item = new Gtk.ImageMenuItem(_("_Add Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnAddRemoteEngineButtonClicked); menu.Append(image_item); image_item = new Gtk.ImageMenuItem(_("_Switch Remote Engine")); image_item.Image = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Menu); image_item.Activated += new EventHandler(_OnSwitchRemoteEngineButtonClicked); menu.Append(image_item); // Menu - View menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_View")); item.Submenu = menu; MenuBar.Append(item); item = new Gtk.CheckMenuItem(_("_Caret Mode")); item.Activated += new EventHandler(_OnCaretModeButtonClicked); akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F7; item.AddAccelerator("activate", agrp, akey); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); item = new Gtk.CheckMenuItem(_("_Browse Mode")); item.Activated += delegate { try { _Notebook.IsBrowseModeEnabled = !_Notebook.IsBrowseModeEnabled; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F8; item.AddAccelerator("activate", agrp, akey); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); ShowMenuBarMenuItem = new Gtk.CheckMenuItem(_("Show _Menubar")); ShowMenuBarMenuItem.Active = (bool) Frontend.FrontendConfig["ShowMenuBar"]; ShowMenuBarMenuItem.Activated += OnShowMenuBarMenuItemActivated; menu.Append(ShowMenuBarMenuItem); ShowStatusBarMenuItem = new Gtk.CheckMenuItem(_("Show _Status Bar")); ShowStatusBarMenuItem.Active = (bool) Frontend.FrontendConfig["ShowStatusBar"]; ShowStatusBarMenuItem.Activated += OnShowStatusBarMenuItemActivated; menu.Append(ShowStatusBarMenuItem); JoinWidget = new JoinWidget(); JoinWidget.NoShowAll = true; JoinWidget.Visible = (bool) Frontend.FrontendConfig["ShowQuickJoin"]; JoinWidget.Activated += OnJoinWidgetActivated; ShowQuickJoinMenuItem = new Gtk.CheckMenuItem(_("Show _Quick Join")); ShowQuickJoinMenuItem.Active = JoinWidget.Visible; ShowQuickJoinMenuItem.Activated += OnShowQuickJoinMenuItemActivated; menu.Append(ShowQuickJoinMenuItem); item = new Gtk.ImageMenuItem(Gtk.Stock.Fullscreen, agrp); item.Activated += delegate { try { IsFullscreen = !IsFullscreen; } catch (Exception ex) { Frontend.ShowException(this, ex); } }; akey = new Gtk.AccelKey(); akey.AccelFlags = Gtk.AccelFlags.Visible; akey.Key = Gdk.Key.F11; item.AddAccelerator("activate", agrp, akey); item.AccelCanActivate += AccelCanActivateSensitive; menu.Append(item); // Menu - Help menu = new Gtk.Menu(); item = new Gtk.MenuItem(_("_Help")); item.Submenu = menu; MenuBar.Append(item); image_item = new Gtk.ImageMenuItem(Gtk.Stock.About, agrp); image_item.Activated += new EventHandler(_OnAboutButtonClicked); menu.Append(image_item); MenuBar.ShowAll(); MenuBar.NoShowAll = true; MenuBar.Visible = ShowMenuBarMenuItem.Active; // TODO: network treeview _Notebook = new Notebook(); _Notebook.SwitchPage += OnNotebookSwitchPage; _Notebook.FocusInEvent += OnNotebookFocusInEvent; _ChatViewManager = new ChatViewManager(_Notebook, null); Assembly asm = Assembly.GetExecutingAssembly(); _ChatViewManager.Load(asm); _ChatViewManager.LoadAll(System.IO.Path.GetDirectoryName(asm.Location), "smuxi-frontend-gnome-*.dll"); _ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; _ChatViewManager.ChatSynced += OnChatViewManagerChatSynced; _ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; #if GTK_SHARP_2_10 _StatusIconManager = new StatusIconManager(this, _ChatViewManager); #endif #if INDICATE_SHARP _IndicateManager = new IndicateManager(this, _ChatViewManager); #endif #if NOTIFY_SHARP _NotifyManager = new NotifyManager(this, _ChatViewManager); #endif #if IPC_DBUS _NetworkManager = new NetworkManager(_ChatViewManager); #endif _UI = new GnomeUI(_ChatViewManager); // HACK: Frontend.FrontendConfig out of scope _EngineManager = new EngineManager(Frontend.FrontendConfig, _UI); _Entry = new Entry(_ChatViewManager); var entryScrolledWindow = new Gtk.ScrolledWindow(); entryScrolledWindow.ShadowType = Gtk.ShadowType.EtchedIn; entryScrolledWindow.HscrollbarPolicy = Gtk.PolicyType.Never; entryScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) { // predict and set useful heigth var layout = _Entry.CreatePangoLayout("Qp"); int lineWidth, lineHeigth; layout.GetPixelSize(out lineHeigth, out lineHeigth); var text = Entry.Text; var newLines = text.Count(f => f == '\n'); // cap to 1-3 lines if (text.Length > 0) { newLines++; newLines = Math.Max(newLines, 1); newLines = Math.Min(newLines, 3); } else { newLines = 1; } // use text heigth + a bit extra var bestSize = new Gtk.Requisition() { Height = (lineHeigth * newLines) + 5 }; args.Requisition = bestSize; }; entryScrolledWindow.Add(_Entry); _ProgressBar = new Gtk.ProgressBar(); _ProgressBar.BarStyle = Gtk.ProgressBarStyle.Continuous; MenuHBox = new Gtk.HBox(); MenuHBox.PackStart(MenuBar, false, false, 0); MenuHBox.PackEnd(JoinWidget, false, false, 0); Gtk.VBox vbox = new Gtk.VBox(); vbox.PackStart(MenuHBox, false, false, 0); vbox.PackStart(_Notebook, true, true, 0); vbox.PackStart(entryScrolledWindow, false, false, 0); _NetworkStatusbar = new Gtk.Statusbar(); _NetworkStatusbar.WidthRequest = 300; _NetworkStatusbar.HasResizeGrip = false; _Statusbar = new Gtk.Statusbar(); _Statusbar.HasResizeGrip = false; Gtk.HBox status_bar_hbox = new Gtk.HBox(); status_bar_hbox.Homogeneous = true; status_bar_hbox.PackStart(_NetworkStatusbar, false, true, 0); status_bar_hbox.PackStart(_Statusbar, true, true, 0); StatusHBox = new Gtk.HBox(); StatusHBox.PackStart(status_bar_hbox); StatusHBox.PackStart(_ProgressBar, false, false, 0); StatusHBox.ShowAll(); StatusHBox.NoShowAll = true; StatusHBox.Visible = ShowStatusBarMenuItem.Active; vbox.PackStart(StatusHBox, false, false, 0); Add(vbox); }
public MainWindow() : base("Smuxi") { // restore window size / position int width, heigth; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"] != null) { width = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"]; } else { width = 800; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"] != null) { heigth = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"]; } else { heigth = 600; } if (width < -1 || heigth < -1) { width = -1; heigth = -1; } if (width == -1 && heigth == -1) { SetDefaultSize(800, 600); Maximize(); } else if (width == 0 && heigth == 0) { // HACK: map 0/0 to default size as it crashes on Windows :/ SetDefaultSize(800, 600); } else { SetDefaultSize(width, heigth); } int x, y; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"] != null) { x = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"]; } else { x = 0; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"] != null) { y = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"]; } else { y = 0; } if (x < 0 || y < 0) { x = 0; y = 0; } if (x == 0 && y == 0) { SetPosition(Gtk.WindowPosition.Center); } else { Move(x, y); } DeleteEvent += OnDeleteEvent; FocusInEvent += OnFocusInEvent; FocusOutEvent += OnFocusOutEvent; WindowStateEvent += OnWindowStateEvent; // TODO: network treeview Notebook = new Notebook(); Notebook.SwitchPage += OnNotebookSwitchPage; Notebook.FocusInEvent += OnNotebookFocusInEvent; ChatViewManager = new ChatViewManager(Notebook, null); Assembly asm = Assembly.GetExecutingAssembly(); ChatViewManager.Load(asm); ChatViewManager.LoadAll(System.IO.Path.GetDirectoryName(asm.Location), "smuxi-frontend-gnome-*.dll"); ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; ChatViewManager.ChatSynced += OnChatViewManagerChatSynced; ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; #if GTK_SHARP_2_10 StatusIconManager = new StatusIconManager(this, ChatViewManager); #endif #if INDICATE_SHARP IndicateManager = new IndicateManager(this, ChatViewManager); #endif #if NOTIFY_SHARP NotifyManager = new NotifyManager(this, ChatViewManager); #endif #if IPC_DBUS NetworkManager = new NetworkManager(ChatViewManager); #endif UI = new GnomeUI(ChatViewManager); // HACK: Frontend.FrontendConfig out of scope EngineManager = new EngineManager(Frontend.FrontendConfig, UI); Entry = new Entry(ChatViewManager); var entryScrolledWindow = new Gtk.ScrolledWindow(); entryScrolledWindow.ShadowType = Gtk.ShadowType.EtchedIn; entryScrolledWindow.HscrollbarPolicy = Gtk.PolicyType.Never; entryScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) { // predict and set useful heigth var layout = Entry.CreatePangoLayout("Qp"); int lineWidth, lineHeigth; layout.GetPixelSize(out lineWidth, out lineHeigth); var text = Entry.Text; var newLines = text.Count(f => f == '\n'); // cap to 1-3 lines if (text.Length > 0) { newLines++; newLines = Math.Max(newLines, 1); newLines = Math.Min(newLines, 3); } else { newLines = 1; } // use text heigth + a bit extra var bestSize = new Gtk.Requisition() { Height = (lineHeigth * newLines) + 5 }; args.Requisition = bestSize; }; entryScrolledWindow.Add(Entry); ProgressBar = new Gtk.ProgressBar(); StatusHBox = new Gtk.HBox(); MenuWidget = new MenuWidget(this, ChatViewManager); Gtk.VBox vbox = new Gtk.VBox(); vbox.PackStart(MenuWidget, false, false, 0); vbox.PackStart(Notebook, true, true, 0); vbox.PackStart(entryScrolledWindow, false, false, 0); NetworkStatusbar = new Gtk.Statusbar(); NetworkStatusbar.WidthRequest = 300; NetworkStatusbar.HasResizeGrip = false; Statusbar = new Gtk.Statusbar(); Statusbar.HasResizeGrip = false; Gtk.HBox status_bar_hbox = new Gtk.HBox(); status_bar_hbox.Homogeneous = true; status_bar_hbox.PackStart(NetworkStatusbar, false, true, 0); status_bar_hbox.PackStart(Statusbar, true, true, 0); StatusHBox.PackStart(status_bar_hbox); StatusHBox.PackStart(ProgressBar, false, false, 0); StatusHBox.ShowAll(); StatusHBox.NoShowAll = true; StatusHBox.Visible = (bool) Frontend.FrontendConfig["ShowStatusBar"]; vbox.PackStart(StatusHBox, false, false, 0); Add(vbox); if (Frontend.IsMacOSX) { IgeMacMenu.GlobalKeyHandlerEnabled = true; IgeMacMenu.MenuBar = MenuWidget.MenuBar; ShowMenuBar = false; var appGroup = IgeMacMenu.AddAppMenuGroup(); appGroup.AddMenuItem( (Gtk.MenuItem) MenuWidget.PreferencesAction.CreateMenuItem(), _("Preferences") ); IgeMacMenu.QuitMenuItem = (Gtk.MenuItem) MenuWidget.QuitAction.CreateMenuItem(); } }
public MainWindow() : base("Smuxi") { // restore window size / position int width, heigth; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"] != null) { width = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Width"]; } else { width = 800; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"] != null) { heigth = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/Heigth"]; } else { heigth = 600; } if (width < -1 || heigth < -1) { width = -1; heigth = -1; } if (width == -1 && heigth == -1) { SetDefaultSize(800, 600); Maximize(); } else if (width == 0 && heigth == 0) { // HACK: map 0/0 to default size as it crashes on Windows :/ SetDefaultSize(800, 600); } else { SetDefaultSize(width, heigth); } int x, y; if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"] != null) { x = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/XPosition"]; } else { x = 0; } if (Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"] != null) { y = (int) Frontend.FrontendConfig[Frontend.UIName + "/Interface/YPosition"]; } else { y = 0; } if (x < 0 || y < 0) { x = 0; y = 0; } if (x == 0 && y == 0) { SetPosition(Gtk.WindowPosition.Center); } else { Move(x, y); } DeleteEvent += OnDeleteEvent; FocusInEvent += OnFocusInEvent; FocusOutEvent += OnFocusOutEvent; WindowStateEvent += OnWindowStateEvent; ChatTreeView = new ChatTreeView(); Notebook = new Notebook(); Notebook.SwitchPage += OnNotebookSwitchPage; Notebook.FocusInEvent += OnNotebookFocusInEvent; ChatViewManager = new ChatViewManager(Notebook, ChatTreeView); Assembly asm = Assembly.GetExecutingAssembly(); ChatViewManager.Load(asm); ChatViewManager.LoadAll(System.IO.Path.GetDirectoryName(asm.Location), "smuxi-frontend-gnome-*.dll"); ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; ChatViewManager.ChatSynced += OnChatViewManagerChatSynced; ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; #if GTK_SHARP_2_10 StatusIconManager = new StatusIconManager(this, ChatViewManager); #endif #if INDICATE_SHARP || MESSAGING_MENU_SHARP IndicateManager = new IndicateManager(this, ChatViewManager); #endif #if NOTIFY_SHARP NotifyManager = new NotifyManager(this, ChatViewManager); #endif #if IPC_DBUS NetworkManager = new NetworkManager(ChatViewManager); #endif UI = new GnomeUI(ChatViewManager); // HACK: Frontend.FrontendConfig out of scope EngineManager = new EngineManager(Frontend.FrontendConfig, UI); Entry = new Entry(ChatViewManager); var entryScrolledWindow = new Gtk.ScrolledWindow(); entryScrolledWindow.ShadowType = Gtk.ShadowType.EtchedIn; entryScrolledWindow.HscrollbarPolicy = Gtk.PolicyType.Never; entryScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) { // predict and set useful heigth int lineWidth, lineHeigth; using (var layout = Entry.CreatePangoLayout("Qp")) { layout.GetPixelSize(out lineHeigth, out lineHeigth); } var it = Entry.Buffer.StartIter; int newLines = 1; // move to end of next visual line while (Entry.ForwardDisplayLineEnd(ref it)) { newLines++; // calling ForwardDisplayLineEnd repeatedly stays on the same position // therefor we move one cursor position further it.ForwardCursorPosition(); } newLines = Math.Min(newLines, 3); // use text heigth + a bit extra var bestSize = new Gtk.Requisition() { Height = (lineHeigth * newLines) + 5 }; args.Requisition = bestSize; }; entryScrolledWindow.Add(Entry); ProgressBar = new Gtk.ProgressBar(); StatusHBox = new Gtk.HBox(); MenuWidget = new MenuWidget(this, ChatViewManager); var treeviewScrolledWindow = new Gtk.ScrolledWindow() { ShadowType = Gtk.ShadowType.EtchedIn, HscrollbarPolicy = Gtk.PolicyType.Never, VscrollbarPolicy = Gtk.PolicyType.Automatic }; treeviewScrolledWindow.Add(ChatTreeView); ChatViewManager.ChatAdded += (sender, e) => { treeviewScrolledWindow.CheckResize(); }; var notebookPaned = new Gtk.VPaned(); notebookPaned.Pack1(Notebook, true, false); notebookPaned.Pack2(entryScrolledWindow, false, false); var treeviewPaned = new Gtk.HPaned(); treeviewPaned.Pack1(treeviewScrolledWindow, false, false); treeviewPaned.Pack2(notebookPaned, true, false); TreeViewHPaned = treeviewPaned; var entryPaned = new Gtk.VPaned(); entryPaned.ButtonPressEvent += (sender, e) => { // reset entry size on double click if (e.Event.Type == Gdk.EventType.TwoButtonPress && e.Event.Button == 1) { GLib.Timeout.Add(100, delegate { entryPaned.Position = -1; return false; }); } }; entryPaned.Pack1(treeviewPaned, true, false); Gtk.VBox vbox = new Gtk.VBox(); vbox.PackStart(MenuWidget, false, false, 0); vbox.PackStart(entryPaned, true, true, 0); NetworkStatusbar = new Gtk.Statusbar(); NetworkStatusbar.WidthRequest = 300; NetworkStatusbar.HasResizeGrip = false; Statusbar = new Gtk.Statusbar(); Statusbar.HasResizeGrip = false; Gtk.HBox status_bar_hbox = new Gtk.HBox(); status_bar_hbox.Homogeneous = true; status_bar_hbox.PackStart(NetworkStatusbar, false, true, 0); status_bar_hbox.PackStart(Statusbar, true, true, 0); StatusHBox.PackStart(status_bar_hbox); StatusHBox.PackStart(ProgressBar, false, false, 0); StatusHBox.ShowAll(); StatusHBox.NoShowAll = true; StatusHBox.Visible = (bool) Frontend.FrontendConfig["ShowStatusBar"]; vbox.PackStart(StatusHBox, false, false, 0); Add(vbox); }
public GroupChatView(GroupChatModel groupChat) : base(groupChat) { Trace.Call(groupChat); _GroupChatModel = groupChat; // person list Participants = new List<PersonModel>(); _OutputHPaned = new Gtk.HPaned(); Gtk.TreeView tv = new Gtk.TreeView(); _PersonTreeView = tv; Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow(); PersonScrolledWindow = sw; sw.ShadowType = Gtk.ShadowType.None; sw.HscrollbarPolicy = Gtk.PolicyType.Never; //tv.CanFocus = false; tv.BorderWidth = 0; tv.Selection.Mode = Gtk.SelectionMode.Multiple; sw.Add(tv); Gtk.TreeViewColumn column; var cellr = new Gtk.CellRendererText() { Ellipsize = Pango.EllipsizeMode.End }; IdentityNameCellRenderer = cellr; column = new Gtk.TreeViewColumn(String.Empty, cellr); column.SortColumnId = 0; column.Spacing = 0; column.SortIndicator = false; column.Expand = true; column.Sizing = Gtk.TreeViewColumnSizing.Autosize; // FIXME: this callback leaks memory column.SetCellDataFunc(cellr, new Gtk.TreeCellDataFunc(RenderPersonIdentityName)); tv.AppendColumn(column); _IdentityNameColumn = column; Gtk.ListStore liststore = new Gtk.ListStore(typeof(PersonModel)); liststore.SetSortColumnId(0, Gtk.SortType.Ascending); liststore.SetSortFunc(0, new Gtk.TreeIterCompareFunc(SortPersonListStore)); _PersonListStore = liststore; tv.Model = liststore; tv.SearchColumn = 0; tv.SearchEqualFunc = (model, col, key, iter) => { var person = (PersonModel) model.GetValue(iter, col); // Ladies and gentlemen welcome to C // 0 means it matched but 0 as bool is false. So if it matches // we have to return false. Still not clear? true is false and // false is true, weirdo! If you think this is retarded, // yes it is. return !person.IdentityName.StartsWith(key, StringComparison.InvariantCultureIgnoreCase); }; tv.EnableSearch = true; tv.HeadersVisible = false; tv.RowActivated += new Gtk.RowActivatedHandler(OnPersonsRowActivated); tv.FocusOutEvent += OnPersonTreeViewFocusOutEvent; // popup menu _PersonMenu = new Gtk.Menu(); // don't loose the focus else we lose the selection too! // see OnPersonTreeViewFocusOutEvent() _PersonMenu.TakeFocus = false; _PersonMenu.Shown += OnPersonMenuShown; _PersonTreeView.ButtonPressEvent += _OnPersonTreeViewButtonPressEvent; _PersonTreeView.KeyPressEvent += OnPersonTreeViewKeyPressEvent; // frame needed for events when selecting something in the treeview _PersonTreeViewFrame = new Gtk.Frame() { ShadowType = Gtk.ShadowType.In }; _PersonTreeViewFrame.ButtonReleaseEvent += new Gtk.ButtonReleaseEventHandler(_OnUserListButtonReleaseEvent); _PersonTreeViewFrame.Add(sw); // topic // don't worry, ApplyConfig() will add us to the OutputVBox! _OutputVBox = new Gtk.VBox() { Spacing = 1 }; _TopicTextView = new MessageTextView(); _TopicTextView.Editable = false; _TopicTextView.WrapMode = Gtk.WrapMode.WordChar; _TopicScrolledWindow = new Gtk.ScrolledWindow(); _TopicScrolledWindow.ShadowType = Gtk.ShadowType.In; _TopicScrolledWindow.HscrollbarPolicy = Gtk.PolicyType.Never; _TopicScrolledWindow.Add(_TopicTextView); // make sure the topic is invisible and remains by default and // visible when a topic gets set _TopicScrolledWindow.ShowAll(); _TopicScrolledWindow.Visible = false; _TopicScrolledWindow.NoShowAll = true; _TopicScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) { // predict and set useful topic heigth int lineWidth, lineHeight; using (var layout = _TopicTextView.CreatePangoLayout("Test Topic")) { layout.GetPixelSize(out lineWidth, out lineHeight); } var lineSpacing = _TopicTextView.PixelsAboveLines + _TopicTextView.PixelsBelowLines; var it = _TopicTextView.Buffer.StartIter; int newLines = 1; // move to end of next visual line while (_TopicTextView.ForwardDisplayLineEnd(ref it)) { newLines++; // calling ForwardDisplayLineEnd repeatedly stays on the same position // therefor we move one cursor position further it.ForwardCursorPosition(); } newLines = Math.Min(newLines, 3); var bestSize = new Gtk.Requisition() { Height = ((lineHeight + lineSpacing) * newLines) + 4 }; args.Requisition = bestSize; }; Add(_OutputHPaned); //ApplyConfig(Frontend.UserConfig); ShowAll(); }
public static Gtk.Requisition ToGtkRequisition (this Size size) { var req = new Gtk.Requisition (); req.Height = (int)size.Height; req.Width = (int)size.Width; return req; }
public GroupChatView(GroupChatModel groupChat) : base(groupChat) { Trace.Call(groupChat); _GroupChatModel = groupChat; // person list _OutputHPaned = new Gtk.HPaned(); Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow(); _PersonScrolledWindow = sw; //sw.WidthRequest = 150; sw.HscrollbarPolicy = Gtk.PolicyType.Never; Gtk.TreeView tv = new Gtk.TreeView(); _PersonTreeView = tv; //tv.CanFocus = false; tv.BorderWidth = 0; tv.Selection.Mode = Gtk.SelectionMode.Multiple; sw.Add(tv); Gtk.TreeViewColumn column; Gtk.CellRendererText cellr = new Gtk.CellRendererText(); cellr.WidthChars = 12; column = new Gtk.TreeViewColumn(String.Empty, cellr); column.SortColumnId = 0; column.Spacing = 0; column.SortIndicator = false; column.Sizing = Gtk.TreeViewColumnSizing.Autosize; column.SetCellDataFunc(cellr, new Gtk.TreeCellDataFunc(RenderPersonIdentityName)); tv.AppendColumn(column); _IdentityNameColumn = column; Gtk.ListStore liststore = new Gtk.ListStore(typeof(PersonModel)); liststore.SetSortColumnId(0, Gtk.SortType.Ascending); liststore.SetSortFunc(0, new Gtk.TreeIterCompareFunc(SortPersonListStore)); _PersonListStore = liststore; tv.Model = liststore; tv.RowActivated += new Gtk.RowActivatedHandler(OnPersonsRowActivated); tv.FocusOutEvent += OnPersonTreeViewFocusOutEvent; // popup menu _PersonMenu = new Gtk.Menu(); // don't loose the focus else we lose the selection too! // see OnPersonTreeViewFocusOutEvent() _PersonMenu.TakeFocus = false; _PersonMenu.Shown += OnPersonMenuShown; _PersonTreeView.ButtonPressEvent += _OnPersonTreeViewButtonPressEvent; _PersonTreeView.KeyPressEvent += OnPersonTreeViewKeyPressEvent; // frame needed for events when selecting something in the treeview _PersonTreeViewFrame = new Gtk.Frame(); _PersonTreeViewFrame.ButtonReleaseEvent += new Gtk.ButtonReleaseEventHandler(_OnUserListButtonReleaseEvent); _PersonTreeViewFrame.Add(sw); // topic // don't worry, ApplyConfig() will add us to the OutputVBox! _OutputVBox = new Gtk.VBox(); _TopicTextView = new MessageTextView(); _TopicTextView.Editable = false; _TopicTextView.WrapMode = Gtk.WrapMode.WordChar; _TopicScrolledWindow = new Gtk.ScrolledWindow(); _TopicScrolledWindow.ShadowType = Gtk.ShadowType.In; // when using PolicyType.Never, it will try to grow but never shrinks! _TopicScrolledWindow.HscrollbarPolicy = Gtk.PolicyType.Automatic; _TopicScrolledWindow.VscrollbarPolicy = Gtk.PolicyType.Automatic; _TopicScrolledWindow.Add(_TopicTextView); // make sure the topic is invisible and remains by default and // visible when a topic gets set _TopicScrolledWindow.ShowAll(); _TopicScrolledWindow.Visible = false; _TopicScrolledWindow.NoShowAll = true; _TopicScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) { // predict and set useful topic heigth Pango.Layout layout = _TopicTextView.CreatePangoLayout("Test Topic"); int lineWidth, lineHeigth; layout.GetPixelSize(out lineWidth, out lineHeigth); var lineSpacing = _TopicTextView.PixelsAboveLines + _TopicTextView.PixelsBelowLines; var text = Topic != null ? Topic.ToString() : String.Empty; // hardcoded to 2 lines for now var newLines = text.Length > 0 ? 2 : 0; var bestSize = new Gtk.Requisition() { Height = ((lineHeigth + lineSpacing) * newLines) + 2 }; args.Requisition = bestSize; }; Add(_OutputHPaned); //ApplyConfig(Frontend.UserConfig); ShowAll(); }