(Gnome, libappindicator) Indicator-application-service가 시작되면 AppIndicator가 사라집니다.

(Gnome, libappindicator) Indicator-application-service가 시작되면 AppIndicator가 사라집니다.

저는 다음 예제를 사용하고 있습니다:https://gist.github.com/davidboy/1045233Ubuntu 14.04 [Gnome Classic]에서. 시스템 트레이 아이콘이 표시됩니다. 하지만 인디케이터-애플리케이션-서비스가 시작되면 사라집니다. 표시기 응용 프로그램 서비스가 중지되면 아이콘이 다시 나타납니다.

"connection_changed" 신호를 사용하면 Indicator-application-service가 실행 중일 때 "connected" 속성이 true이고, 그렇지 않으면 false인 것 같습니다.

"연결됨"이 true인 동안 APP_INDICATOR_STATUS_PASSIVE를 설정해도 도움이 되지 않았습니다(다음에 따라).https://developer.ubuntu.com/api/devel/ubuntu-12.04/c/appindicator/libappindicator-app-indicator.html#AppIndicator--connected)

요구사항:

  1. libappindicator-dev
  2. 지표-응용

재현 단계:

  1. 표시기 응용 프로그램 서비스가 실행 중이면 중지하십시오.
  2. 예제 실행 -> 아이콘이 표시됩니다.
  3. 시작 표시기-응용 프로그램-서비스 -> 아이콘이 사라짐("연결 상태: 연결됨")
  4. 중지 표시기-응용 프로그램-서비스 -> 아이콘이 다시 표시됩니다("연결 상태: 연결 끊김")

코드(예제 + Connection_changed 신호 처리기):

// gcc -Wall app_indicator.c `pkg-config --libs --cflags gtk+-2.0 appindicator-0.1`
#include <gtk/gtk.h>
#include <libappindicator/app-indicator.h>

void connection_changed(AppIndicator* indicator, gboolean connected, gpointer user_data) {
    g_print ("Connection status: %s\n", connected ? "Connected" : "Disconnected");
}

int main (int argc, char **argv) {
  gtk_init(&argc, &argv);

  GtkWidget *menu;
  GtkWidget *menu_item;
  AppIndicator *indicator;

  menu = gtk_menu_new();

  menu_item = gtk_menu_item_new_with_label("Hello world!");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);

  indicator = app_indicator_new ("example-simple-client",
                                 "indicator-messages",
                                 APP_INDICATOR_CATEGORY_APPLICATION_STATUS);

  g_signal_connect(G_OBJECT(indicator), "connection_changed", G_CALLBACK(connection_changed), 0);

  app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE);
  app_indicator_set_attention_icon (indicator, "indicator-messages-new");

  app_indicator_set_menu (indicator, GTK_MENU (menu));

  gtk_widget_show_all(menu);

  gtk_main();
  return 0;
}

아마도 이것이 도움이 될 수 있습니다:

Indicator-application-service가 실행되고 있지 않으면 d-bus 로그(dbus-monitor)에 이 애플리케이션(example-simple-client)에 대한 정보가 없습니다.

Indicator-application-service가 실행 중일 때 d-bus 로그에는 다음이 포함됩니다.

signal sender=:1.84 -> dest=(null destination) serial=6 path=/org/ayatana/NotificationItem/example_simple_client/Menu; interface=com.canonical.dbusmenu; member=LayoutUpdated
   uint32 2
   int32 0
method call sender=:1.84 -> dest=org.freedesktop.DBus serial=7 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.kde.StatusNotifierWatcher"
method call sender=:1.84 -> dest=:1.39 serial=8 path=/StatusNotifierWatcher; interface=org.kde.StatusNotifierWatcher; member=RegisterStatusNotifierItem
   string "/org/ayatana/NotificationItem/example_simple_client"
method return sender=:1.39 -> dest=:1.84 reply_serial=8
method call sender=:1.37 -> dest=org.freedesktop.DBus serial=33 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender=':1.84',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/ayatana/NotificationItem/example_simple_client',arg0='org.kde.StatusNotifierItem'"
method call sender=:1.37 -> dest=org.freedesktop.DBus serial=34 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender=':1.84',interface='org.kde.StatusNotifierItem',path='/org/ayatana/NotificationItem/example_simple_client'"
method call sender=:1.37 -> dest=:1.84 serial=35 path=/org/ayatana/NotificationItem/example_simple_client; interface=org.freedesktop.DBus.Properties; member=GetAll
   string "org.kde.StatusNotifierItem"
method return sender=:1.84 -> dest=:1.37 reply_serial=35
   array [
      dict entry(
         string "Id"
         variant             string "example-simple-client"
      )
      dict entry(
         string "Category"
         variant             string "ApplicationStatus"
      )
      dict entry(
         string "Status"
         variant             string "Active"
      )
      dict entry(
         string "IconName"
         variant             string "indicator-messages"
      )
      dict entry(
         string "IconAccessibleDesc"
         variant             string ""
      )
      dict entry(
         string "AttentionIconName"
         variant             string "indicator-messages-new"
      )
      dict entry(
         string "AttentionAccessibleDesc"
         variant             string ""
      )
      dict entry(
         string "Title"
         variant             string "a.out"
      )
      dict entry(
         string "IconThemePath"
         variant             string ""
      )
      dict entry(
         string "Menu"
         variant             object path "/org/ayatana/NotificationItem/example_simple_client/Menu"
      )
      dict entry(
         string "XAyatanaLabel"
         variant             string ""
      )
      dict entry(
         string "XAyatanaLabelGuide"
         variant             string ""
      )
      dict entry(
         string "XAyatanaOrderingIndex"
         variant             uint32 0
      )
   ]
method call sender=:1.37 -> dest=org.freedesktop.DBus serial=36 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',path='/org/freedesktop/DBus',arg0=':1.84'"
method call sender=:1.37 -> dest=org.freedesktop.DBus serial=37 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender=':1.84',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/ayatana/NotificationItem/example_simple_client',arg0='org.freedesktop.DBus.Properties'"
method call sender=:1.37 -> dest=org.freedesktop.DBus serial=38 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender=':1.84',interface='org.freedesktop.DBus.Properties',path='/org/ayatana/NotificationItem/example_simple_client'"
method call sender=:1.37 -> dest=:1.84 serial=39 path=/org/ayatana/NotificationItem/example_simple_client; interface=org.freedesktop.DBus.Properties; member=GetAll
   string "org.freedesktop.DBus.Properties"
error sender=:1.84 -> dest=:1.37 error_name=org.freedesktop.DBus.Error.InvalidArgs reply_serial=39
   string "Интерфейс отсутствует"
method call sender=:1.37 -> dest=:1.84 serial=40 path=/org/ayatana/NotificationItem/example_simple_client; interface=org.freedesktop.DBus.Properties; member=GetAll
   string "org.kde.StatusNotifierItem"
method return sender=:1.84 -> dest=:1.37 reply_serial=40
   array [
      dict entry(
         string "Id"
         variant             string "example-simple-client"
      )
      dict entry(
         string "Category"
         variant             string "ApplicationStatus"
      )
      dict entry(
         string "Status"
         variant             string "Active"
      )
      dict entry(
         string "IconName"
         variant             string "indicator-messages"
      )
      dict entry(
         string "IconAccessibleDesc"
         variant             string ""
      )
      dict entry(
         string "AttentionIconName"
         variant             string "indicator-messages-new"
      )
      dict entry(
         string "AttentionAccessibleDesc"
         variant             string ""
      )
      dict entry(
         string "Title"
         variant             string "a.out"
      )
      dict entry(
         string "IconThemePath"
         variant             string ""
      )
      dict entry(
         string "Menu"
         variant             object path "/org/ayatana/NotificationItem/example_simple_client/Menu"
      )
      dict entry(
         string "XAyatanaLabel"
         variant             string ""
      )
      dict entry(
         string "XAyatanaLabelGuide"
         variant             string ""
      )
      dict entry(
         string "XAyatanaOrderingIndex"
         variant             uint32 0
      )
   ]
signal sender=:1.37 -> dest=(null destination) serial=41 path=/com/canonical/indicator/application/service; interface=com.canonical.indicator.application.service; member=ApplicationAdded
   string "indicator-messages"
   int32 0
   string ":1.84"
   object path "/org/ayatana/NotificationItem/example_simple_client/Menu"
   string ""
   string ""
   string ""
   string ""
   string "example-simple-client"
   string "a.out"

관련 정보