statuicon에 매우 이상한 문제가 있습니다.Gtk # statusicon 사라짐
테이블에 데이터를 저장하고 표시하는 간단한 프로젝트에서 사용자가 데이터를 삽입 한 다음 주 창 (SumWindow)이있는 다른 창이있는 주 창 (MainWindow)이 있습니다. 또한 Gtk.StatusIcon을 서브 클래스 화하여 생성 한 상태 아이콘이 있습니다. 문제는 응용 프로그램을 시작하고 데이터를 표시해야하는 창 (모든 것이 작동 함)을 표시 한 다음 창을 닫을 때 (아무리 상관없이) statusIcon이 패널에서 사라질 때입니다.
또한 SumList 클래스의 생성자가 길이라는 것을 알아 냈습니다. 거기에서 몇 줄을 지우면 (무작위 순서) statusicon이 정상적으로 작동합니다.
이 이상한 동작을 어떻게 해결할 수 있습니까?
EDIT # 1 대신 StatusIcon을 하위 클래스로 만들지 말고 대신 MainClass의 정적 멤버로 선언 했으므로 이상하게 작동합니다. 어쨌든 statusIcon이 정적으로 선언되지 않은 경우 질문이 작동하지 않는 이유는 무엇입니까?
MainClass (StatusIcon)
class MainClass : StatusIcon
{
MainWindow window;
private MainClass()
{
window = new MainWindow();
window.Show();
Stock = Gtk.Stock.Home;
PopupMenu += rightClick;
Activate += leftClick;
}
private void rightClick (object sender, Gtk.PopupMenuArgs evt){
window.Hide();
}
private void leftClick (object sender, EventArgs e){
window.Show();
}
public static void Main (string[] args)
{
Application.Init();
new MainClass();
Application.Run();
}
}
SumList 클래스
public partial class SumList : Gtk.Window
{
public SumList() : base(Gtk.WindowType.Toplevel)
{
this.Build();
// create the "title" column ------------ //
TreeViewColumn title = new TreeViewColumn();
CellRendererText titleR = new CellRendererText();
title.PackStart(titleR, true);
title.AddAttribute(titleR, "text", 0);
// create the "detial" column ----------- //
TreeViewColumn detail = new TreeViewColumn();
CellRendererText detailR = new CellRendererText();
detail.PackStart(detailR, true);
detail.AddAttribute(detailR, "text", 1);
// create the "price" column ------------ //
TreeViewColumn price = new TreeViewColumn();
CellRendererText priceR = new CellRendererText();
price.PackStart(priceR, true);
price.AddAttribute(priceR, "text", 2);
// create the "date" column ------------- //
TreeViewColumn date = new TreeViewColumn();
CellRendererText dateR = new CellRendererText();
date.PackStart(dateR, true);
date.AddAttribute(dateR, "text", 3);
// set the columns names
title.Title = "Title";
detail.Title = "Detail";
price.Title = "Price";
date.Title = "Date";
// append columns to the treeview
this.treeview.AppendColumn(title);
this.treeview.AppendColumn(detail);
this.treeview.AppendColumn(price);
this.treeview.AppendColumn(date);
// set the model
this.treeview.Model = Singleton.Model.Instance.Data;
}
}
MainWindow를 클래스
public partial class MainWindow: Gtk.Window{
public MainWindow(): base (Gtk.WindowType.Toplevel){
Build();
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a){
Application.Quit();
a.RetVal = true;
}
protected void OnButtonOKClicked (object sender, System.EventArgs e){
SumList list = new SumList();
list.Show();
}
protected void onButtonHideClicked (object sender, System.EventArgs e){
entrySum.Text = "";
entryTitle.Text = "";
this.Hide();
}
}
시도해 보았습니다 MainClass main = new MainClass(); 하지만 여전히 동일합니다. 작동하는 유일한 방법은 statusicon이 정적 인 경우입니다. – Jan