Я создал новый индикатор:
indicator =
new ApplicationIndicator (
"sample-application", //id of the the indicator icon
"app-icon", //file name of the icon (will look for app-icon.png)
Category.ApplicationStatus,
ExecutableFolder //the folder where to look for app-icon.png
);
//Build Popup Menu for ApplicationIndicator
Menu popupMenu = new Menu ();
indicator.Label = "init label";
...
После обратного вызова таймера функция, которую я хочу обновить метку индикатора:
indicator.label = "new label";
Новое значение метки не применяется. к индикатору. Он по-прежнему показывает строку init label
.
я думаю он просто, что опечатка, Это должно быть indicator.Label = "new label";
с капиталом L
.
Вот моя полная рабочая витрина (Протестирована на Ubuntu 14.04):
indicator_demo.cs
using Gtk;
using AppIndicator;
public class IndicatorExample
{
static Window win;
static ApplicationIndicator indicator;
static int c;
public static void Main ()
{
Application.Init ();
win = new Window ("Test");
win.Resize (200, 200);
Label label = new Label ();
label.Text = "Hello, world!";
win.Add (label);
indicator = new ApplicationIndicator ("my-id",
"my-name",
Category.ApplicationStatus);
indicator.Status = Status.Attention;
Menu menu = new Menu ();
//menu.Append (new MenuItem ("Foo"));
//menu.Append (new MenuItem ("Bar"));
indicator.Menu = menu;
indicator.Menu.Show();
indicator.Label = "init label";
win.ShowAll ();
indicator.Label = "label2";
c = 0;
GLib.Timeout.Add (1000, new GLib.TimeoutHandler (update));
Application.Run ();
}
public static bool update()
{
c+=1;
indicator.Label = c.ToString();
return true;
}
}
Это было модификацией Ubuntu Wiki: Индикаторы приложения пример C#.
Компиляция & Выполненный для тестирования:
dmcs -pkg:gtk-sharp-2.0 -pkg:appindicator-sharp-0.1 indicator_demo.cs
mono indicator_demo.exe