Exemplo n.º 1
0
static void
local_icon_toggle_cb (GtkWidget *widget, gpointer data)
{
    AppIndicator * ci = APP_INDICATOR(data);

    if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
        app_indicator_set_icon_full(ci, LOCAL_ICON, "Local Icon");
    } else {
        app_indicator_set_icon_full(ci, "indicator-messages", "System Icon");
    }

    return;
}
Exemplo n.º 2
0
/* FIXME: name 대신에 DasomEngineInfo 또는 id 를 받아올 필요가 있습니다.
 * 미래에 중국어 엔진을 추가할 때 그때 변경을 고려해 봅시다.
 */
static void on_engine_changed (DasomAgent   *agent,
                               gchar        *name,
                               AppIndicator *indicator)
{
  g_debug (G_STRLOC ": %s: name: %s", G_STRFUNC, name);

  if (g_strcmp0 (name, "en") == 0 || g_strcmp0 (name, "EN") == 0)
    app_indicator_set_icon_full (indicator, "dasom-indicator-en", "english");
  else if (g_strcmp0 (name, "정") == 0)
    app_indicator_set_icon_full (indicator, "dasom-indicator-ko", "korean");
  else
    app_indicator_set_icon_full (indicator, "dasom-indicator", "Dasom");
}
Exemplo n.º 3
0
void set_icon(gboolean enabled)
{
	const char *_tooltip = enabled ? _("Bluetooth: On") : _("Bluetooth: Off");

	bt_enabled = enabled;

#ifdef HAVE_APP_INDICATOR
	if (indicator == NULL) {
#else
	if (statusicon == NULL) {
#endif /* HAVE_APP_INDICATOR */
		g_free (tooltip);
		tooltip = g_strdup (_tooltip);
	} else {
#ifdef HAVE_APP_INDICATOR
		app_indicator_set_icon_full(indicator,
		                            bt_enabled ? ACTIVE_ICON_NAME
		                                       : DISABLE_ICON_NAME,
		                            _tooltip);
#else
		gtk_status_icon_set_from_gicon (statusicon, enabled ? icon_enabled : icon_disabled);
		gtk_status_icon_set_tooltip_markup(statusicon, _tooltip);
#endif /* HAVE_APP_INDICATOR */
	}
}
Exemplo n.º 4
0
void QAppIndicator::onIconNameChanged(QString _iconName)
{
    m_iconName = _iconName;
    app_indicator_set_icon_full(m_appIndicator,
                                m_iconName.toLocal8Bit().data(),
                                m_iconName.toLocal8Bit().data());
}
Exemplo n.º 5
0
static void on_disconnected (DasomAgent   *agent,
                             AppIndicator *indicator)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  app_indicator_set_icon_full (indicator,
                               "dasom-indicator-warning", "disconnected");
}
Exemplo n.º 6
0
/* FIXME: need NimfEngineInfo or id instead of name */
static void on_engine_changed (NimfAgent    *agent,
                               gchar        *name,
                               AppIndicator *indicator)
{
  g_debug (G_STRLOC ": %s: name: %s", G_STRFUNC, name);

  gchar *icon_name;

  if (g_strcmp0 (name, "focus-out") == 0)
    icon_name = g_strdup ("nimf-indicator");
  else
    icon_name = g_strdup_printf ("nimf-indicator-%s", name);

  app_indicator_set_icon_full (indicator, icon_name, name);

  g_free (icon_name);
}
Exemplo n.º 7
0
void update_tray(void)
{
  GtkMenuItem *menu_cal;
  gchar *icon_name, *today_text;
  
  menu_cal = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu_cal"));
  icon_name = g_strdup_printf("acal-%s-%d", 
	      g_settings_get_boolean(settings, "dark-icon") ? "dark" : "light",
              today.tm_mday);
  
  /* set tray icon */
  app_indicator_set_icon_full(indicator, icon_name, icon_name);
  g_free(icon_name);
  
  /* set menu_cal text */
  today_text = g_strdup_printf("%s %s %s %s", gettext(day[today.tm_wday]),
                               persian_digit(today.tm_mday),
                               gettext(mon[today.tm_mon]),
                               persian_digit(today.tm_year));
  gtk_menu_item_set_label(menu_cal, today_text);
  g_free(today_text);
}
Exemplo n.º 8
0
static void tray_appindicator_update_icon()
{
  if (!current_CS || current_CS->im_state == HIME_STATE_DISABLED||current_CS->im_state == HIME_STATE_ENG_FULL) {
    strcpy(iconfile, HIME_TRAY_PNG);
  } else {
    strcpy(iconfile, inmd[current_CS->in_method].icon);
  }

  if (current_CS && current_CS->im_state == HIME_STATE_CHINESE && !tsin_pho_mode()) {
    char s[64];
    strcpy(s, "en-");
    strcat(s, iconfile);
    strcpy(iconfile, s);
    if (!tray_appindicator_load_icon("en-tsin.png", iconfile, iconame, icondir))
      return;
  } else {
    if (!tray_appindicator_load_icon(HIME_TRAY_PNG, iconfile, iconame, icondir))
      return;
  }
  
  app_indicator_set_icon_theme_path(tray_appindicator, icondir);
  app_indicator_set_icon_full(tray_appindicator, iconame, "");
}
Exemplo n.º 9
0
void setIcon(char* icon_path) {
	app_indicator_set_icon_full(global_app_indicator, icon_path, "");
	app_indicator_set_attention_icon_full(global_app_indicator, icon_path, "");
	free(icon_path);
}
Exemplo n.º 10
0
int
main (int argc, char **argv)
{
  GError         *error     = NULL;
  gboolean        no_daemon = FALSE;
  gboolean        debug     = FALSE;
  GOptionContext *context;
  GOptionEntry    entries[] = {
    {"no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Do not daemonize"), NULL},
    {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Log debugging message"), NULL},
    {NULL}
  };

  context = g_option_context_new ("- dasom daemon");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_parse (context, &argc, &argv, &error);
  g_option_context_free (context);

  if (error != NULL)
  {
    g_warning ("%s", error->message);
    g_error_free (error);
    return EXIT_FAILURE;
  }

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, DASOM_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  if (no_daemon == FALSE)
  {
    openlog (g_get_prgname (), LOG_PID | LOG_PERROR, LOG_DAEMON);
    syslog_initialized = TRUE;
    g_log_set_default_handler ((GLogFunc) dasom_log_default_handler, &debug);

    if (daemon (0, 0) != 0)
    {
      g_critical ("Couldn't daemonize.");
      return EXIT_FAILURE;
    }
  }

  gtk_init (&argc, &argv);

  AppIndicator *indicator;
  GtkWidget    *menu_shell;
  GtkWidget    *about_menu;
  GtkWidget    *exit_menu;
  DasomAgent   *agent;

  menu_shell = gtk_menu_new ();
  about_menu = gtk_menu_item_new_with_label (_("About"));
  exit_menu  = gtk_menu_item_new_with_label (_("Exit"));

  gtk_widget_show_all (about_menu);
  gtk_widget_show_all (exit_menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), about_menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), exit_menu);

  gtk_widget_show_all (menu_shell);

  indicator = app_indicator_new ("dasom-indicator", "input-keyboard",
                                 APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
  app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE);
  app_indicator_set_icon_full (indicator, "dasom-indicator", "Dasom");
  app_indicator_set_menu (indicator, GTK_MENU (menu_shell));

  agent = dasom_agent_new ();
  g_signal_connect (agent, "engine-changed",
                    G_CALLBACK (on_engine_changed), indicator);
  g_signal_connect (agent, "disconnected",
                    G_CALLBACK (on_disconnected), indicator);
  g_signal_connect (about_menu, "activate",  G_CALLBACK (on_about_menu), indicator);
  g_signal_connect (exit_menu,  "activate",  G_CALLBACK (on_exit_menu),  indicator);

  gtk_main ();

  g_object_unref (agent);
  g_object_unref (indicator);
  g_object_unref (menu_shell);

  if (syslog_initialized)
    closelog ();

  return EXIT_SUCCESS;
}
Exemplo n.º 11
0
static void
update_sensor_menu_item_label(IsIndicator *self,
                              IsSensor *sensor,
                              GtkMenuItem *menu_item)
{
  gchar *text;

  text = g_strdup_printf("%s %2.*f%s",
                         is_sensor_get_label(sensor),
                         is_sensor_get_digits(sensor),
                         is_sensor_get_value(sensor),
                         is_sensor_get_units(sensor));
  gtk_menu_item_set_label(menu_item, text);
  g_free(text);
  text = NULL;

#if HAVE_APPINDICATOR
  if (sensor == self->priv->primary)
  {
    IsIndicatorPrivate *priv = self->priv;
    gboolean connected;

    g_object_get(self, "connected", &connected, NULL);
    /* using fallback so just set icon */
    if (!connected)
    {
      app_indicator_set_icon_full(APP_INDICATOR(self), PACKAGE,
                                  is_sensor_get_label(sensor));
      return;
    }

    if (priv->display_flags & IS_INDICATOR_DISPLAY_VALUE)
    {
      text = g_strdup_printf("%2.*f%s",
                             is_sensor_get_digits(sensor),
                             is_sensor_get_value(sensor),
                             is_sensor_get_units(sensor));
    }
    if (priv->display_flags & IS_INDICATOR_DISPLAY_LABEL)
    {
      /* join label to existing text - if text is NULL this
         will just show label */
      text = g_strjoin(" ",
                       is_sensor_get_label(sensor),
                       text, NULL);
    }
    if (priv->display_flags & IS_INDICATOR_DISPLAY_ICON)
    {
      app_indicator_set_icon_full(APP_INDICATOR(self),
                                  is_sensor_get_icon_path(sensor),
                                  is_sensor_get_label(sensor));
    }
    else
    {
      /* set to a 1x1 transparent icon for no icon */
      app_indicator_set_icon_full(APP_INDICATOR(self), "indicator-sensors-no-icon",
                                  is_sensor_get_label(sensor));

    }
    app_indicator_set_label(APP_INDICATOR(self), text, text);
    g_free(text);
    app_indicator_set_status(APP_INDICATOR(self),
                             is_sensor_get_alarmed(sensor) ?
                             APP_INDICATOR_STATUS_ATTENTION :
                             APP_INDICATOR_STATUS_ACTIVE);
  }
#else
  gtk_status_icon_set_from_icon_name(GTK_STATUS_ICON(self), PACKAGE);
#endif

}
Exemplo n.º 12
0
int
main (int argc, char **argv)
{
  GError         *error        = NULL;
  gboolean        is_no_daemon = FALSE;
  gboolean        is_debug     = FALSE;
  gboolean        is_version   = FALSE;
  GOptionContext *context;
  GOptionEntry    entries[] = {
    {"no-daemon", 0, 0, G_OPTION_ARG_NONE, &is_no_daemon, N_("Do not daemonize"), NULL},
    {"debug", 0, 0, G_OPTION_ARG_NONE, &is_debug, N_("Log debugging message"), NULL},
    {"version", 0, 0, G_OPTION_ARG_NONE, &is_version, N_("Version"), NULL},
    {NULL}
  };

  context = g_option_context_new ("- indicator for Nimf");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_parse (context, &argc, &argv, &error);
  g_option_context_free (context);

  if (error != NULL)
  {
    g_warning ("%s", error->message);
    g_error_free (error);
    return EXIT_FAILURE;
  }

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, NIMF_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  if (is_debug)
    g_setenv ("G_MESSAGES_DEBUG", "nimf", TRUE);

  if (is_version)
  {
    g_print ("%s %s\n", argv[0], VERSION);
    exit (EXIT_SUCCESS);
  }

  if (is_no_daemon == FALSE)
  {
    openlog (g_get_prgname (), LOG_PID | LOG_PERROR, LOG_DAEMON);
    syslog_initialized = TRUE;
    g_log_set_default_handler ((GLogFunc) nimf_log_default_handler, &is_debug);

    if (daemon (0, 0) != 0)
    {
      g_critical ("Couldn't daemonize.");
      return EXIT_FAILURE;
    }
  }

  gtk_init (&argc, &argv);

  AppIndicator *indicator;
  GtkWidget    *menu_shell;
  GtkWidget    *about_menu;
  GtkWidget    *exit_menu;

  menu_shell = gtk_menu_new ();
  indicator = app_indicator_new ("nimf-indicator", "input-keyboard",
                                 APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
  app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE);
  app_indicator_set_icon_full (indicator, "nimf-indicator", "Nimf");
  app_indicator_set_menu (indicator, GTK_MENU (menu_shell));

  agent = nimf_agent_new ();

  g_signal_connect (agent, "engine-changed",
                    G_CALLBACK (on_engine_changed), indicator);
  g_signal_connect (agent, "disconnected",
                    G_CALLBACK (on_disconnected), indicator);

  /* menu */
  gchar         **engine_ids = nimf_agent_get_loaded_engine_ids (agent);
  GtkWidget      *engine_menu;
  NimfEngineInfo *info;

  guint i;

  for (i = 0; i < g_strv_length (engine_ids); i++)
  {
    info = nimf_engine_get_info_by_id (engine_ids[i]);
    engine_menu = gtk_menu_item_new_with_label (_(info->engine_name));
    gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), engine_menu);
    g_signal_connect (engine_menu, "activate",
                      G_CALLBACK (on_engine_menu), engine_ids[i]);
    g_slice_free (NimfEngineInfo, info);
  }

  about_menu = gtk_menu_item_new_with_label (_("About"));
  exit_menu  = gtk_menu_item_new_with_label (_("Exit"));

  g_signal_connect (about_menu, "activate",
                    G_CALLBACK (on_about_menu), NULL);
  g_signal_connect (exit_menu,  "activate",
                    G_CALLBACK (on_exit_menu),  NULL);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), about_menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), exit_menu);

  gtk_widget_show_all (menu_shell);

  gtk_main ();

  g_object_unref (agent);
  g_object_unref (indicator);
  g_strfreev (engine_ids);

  if (syslog_initialized)
    closelog ();

  return EXIT_SUCCESS;
}
Exemplo n.º 13
0
void UnityIndicator::setIcon(const QString &icon)
{
    app_indicator_set_icon_full(m_indicator, qPrintable(icon), "icon");
}