[Mono-dev] GTK# Window Display Issue Outside of Main.cs

Johnnie Odom jodom at escambia.k12.fl.us
Tue Nov 6 21:55:37 UTC 2012


Hello Everyone, 


This is my first day on the mailing list, and as it is I have a question regarding some odd behavior I am encountering. I have also posted this message to the GTK# list as I am not sure which is the more appropriate venue. 


I am writing an application on OS X 10.8 using C#, Mono 2.10.9 and MonoDevelop 3.0.4 (including the Designer views) that makes some simple changes to LDAP. As part of it, I decided to get fancy with GTK#. All is going well, except for one behavior. 


I have created a window class to display a progress bar and stop button. I have further created a function in this class to update the progress bar with a fraction and text message. In my code, I create a new instance of this window class when real work is happening in another class, and then populate it after every ten iterations of a foreach loop. 


My problem is that when the window is created FROM THE CLASS DOING REAL WORK, it displays neither the progress bar widget, nor the button. It displays only the window title and then white space below. Only this window displays this behavior -- several other windows that I create over the course of the application all display appropriately. 


If I instead create the progress bar window in Main.cs and call Show(), it will display just fine. I can even call the function to set its status from Main.cs and it will display correctly. 


I have tried creating the window in Main.cs and passing it to the class that does the real work later. I have tried creating it in other classes besides the one that does the work. In all cases the behavior is the same -- if the window is created and used solely in Main.cs it will display fine, but if it it ever invoked or created from anywhere else (whether or not it is created in another class or in Main.cs) it will display incorrectly.  


I have taken to using the debugger and break points to isolate the behavior. If I set a breakpoint immediately after the window is created, it is still blank -- that is, I do not think it is a case that the window is just not keeping pace with any updates I am sending. I have also compared the various values of the window objects and attributes when it is displayed (created and used solely in Main.cs) and when it is not (displayed in any other class) and they seem to be identical. 


So, I am at a loss, and I would appreciate any advice you might give. 


I can send any code you think would prove useful, but for now I am sending you the class where I am trying to call the window, and the contents of the window's code-behind. 


Thank you for any guidance you can give. 


Johnnie Odom 
Network Services 
School District of Escambia County 


**************** 

The function from the calling class:


public string radiazerMain(string radiazerGroup, string radiazerProfile){ 
Progression MarathonBar = new Progression(); 
MarathonBar.Show(); 
string monologger = ""; 
string lastLine = "Radiazer completed current run." + Environment.NewLine; 
Array usersToModify = getGroupMembers(radiazerGroup); 
string[] radiusAttribs = new string[]{"dialupAccess","radiusArapFeatures","radiusArapSecurity","radiusArapZoneAccess","radiusAuthType","radiusCallbackId","radiusCallbackNumber","radiusCalledStationId","radiusCallingStationId","radiusCheckItem","radiusClass","radiusClientIPAddress","radiusExpiration","radiusFilterId","radiusFramedAppleTalkLink","radiusFramedAppleTalkNetwork","radiusFramedAppleTalkZone","radiusFramedCompression","radiusFramedIPAddress","radiusFramedIPNetmask","radiusFramedIPXNetwork","radiusFramedMTU","radiusFramedProtocol","radiusFramedRoute","radiusFramedRouting","radiusGroupName","radiusHint","radiusHuntgroupName","radiusIdleTimeout","radiusLoginIPHost","radiusLoginLATGroup","radiusLoginLATNode","radiusLoginLATPort","radiusLoginLATService","radiusLoginService","radiusLoginTCPPort","radiusLoginTime","radiusPasswordRetry","radiusPortLimit","radiusProfileDn","radiusPrompt","radiusProxyToRealm","radiusRealm","radiusReplicateToRealm","radiusReplyItem","radiusServiceType","radiusSessionTimeout","radiusSimultaneousUse","radiusStripUserName","radiusTerminationAction","radiusTunnelAssignmentId","radiusTunnelClientEndpoint","radiusTunnelMediumType","radiusTunnelPassword","radiusTunnelPreference","radiusTunnelPrivateGroupId","radiusTunnelServerEndpoint","radiusTunnelType","radiusUserCategory","radiusVSA"}; 
LdapAttributeSet profileTemplate = LdapAttributeSetFiltered(radiazerProfile, radiusAttribs); 
profileTemplate.Add(new LdapAttribute("radiusProfileDn", radiazerProfile)); 


int totalUsersCount = usersToModify.Length; 
int currentUserCount = 0; 
int errorCount = 0; 
MarathonBar.Show(); 


foreach(string userToModify in usersToModify){ 
currentUserCount++; 
try{ 
monologger = monologger + radiazeModifyUser(userToModify, profileTemplate); 
} 
catch(LdapException LdapFailure){ 
monologger = monologger + "User " + userToModify + " failed. Error is " + LdapFailure.ToString() + Environment.NewLine; 
errorCount++; 
} 
if(((currentUserCount % 10) == 0) || ((totalUsersCount - currentUserCount) < 10)){ 
MarathonBar.setProgress(((double)currentUserCount / totalUsersCount), totalUsersCount , currentUserCount, errorCount, userToModify); 
} 
if(MarathonBar.cancelFromUser){ 
lastLine = "Radiazer cancelled by user." + Environment.NewLine; 
break; 
} 
} 


MarathonBar.Destroy(); 
monologger = monologger + lastLine; 
return monologger; 
} 


************* 


The Code-Behind: 


using System; 


namespace Radiazer2 
{ 
public partial class Progression : Gtk.Window 
{ 


public bool cancelFromUser = false; 


public Progression () :  
base(Gtk.WindowType.Toplevel) 
{ 
this.Build (); 
} 


public void setProgress(double fractionOfProgress, int totalUnits, int finishedUnits, int errorUnits, string finishedUser){ 
this.progressIndicator.Fraction = fractionOfProgress; 
this.progressIndicator.Text = "Completed " + finishedUnits + " of " + totalUnits + " with " + errorUnits + " errors. Current user is " + finishedUser + "."; 
} 


protected void OnStopUserClicked (object sender, EventArgs e) 
{ 
cancelFromUser = true; 
} 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20121106/38896fba/attachment-0001.html>


More information about the Mono-devel-list mailing list