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 */ } }
static void status_icon_update_tooltip (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); if (priv->event) { gchar *tooltip = NULL; if (priv->event->message != NULL) tooltip = g_markup_printf_escaped ("<i>%s</i>\n%s", priv->event->header, priv->event->message); else tooltip = g_markup_printf_escaped ("<i>%s</i>", priv->event->header); gtk_status_icon_set_tooltip_markup (priv->icon, tooltip); g_free (tooltip); } else { TpConnectionPresenceType type; gchar *msg; type = tp_account_manager_get_most_available_presence ( priv->account_manager, NULL, &msg); if (!EMP_STR_EMPTY (msg)) { gtk_status_icon_set_tooltip_text (priv->icon, msg); } else { gtk_status_icon_set_tooltip_text (priv->icon, empathy_presence_get_default_message (type)); } g_free (msg); } }
gint yad_notification_run () { GIOChannel *channel = NULL; status_icon = gtk_status_icon_new (); g_signal_connect (status_icon, "size-changed", G_CALLBACK (icon_size_changed_cb), NULL); if (options.data.dialog_text) { if (!options.data.no_markup) gtk_status_icon_set_tooltip_markup (status_icon, options.data.dialog_text); else gtk_status_icon_set_tooltip_text (status_icon, options.data.dialog_text); } else gtk_status_icon_set_tooltip_text (status_icon, _("Yad notification")); if (options.data.dialog_image) icon = g_strdup (options.data.dialog_image); if (options.common_data.command) action = g_strdup (options.common_data.command); set_icon (); g_signal_connect (status_icon, "activate", G_CALLBACK (activate_cb), NULL); g_signal_connect (status_icon, "popup_menu", G_CALLBACK (popup_menu_cb), NULL); if (options.notification_data.menu) parse_menu_str (options.notification_data.menu); /* quit on middle click (like press Esc) */ if (options.notification_data.middle) g_signal_connect (status_icon, "button-press-event", G_CALLBACK (middle_quit_cb), NULL); if (options.common_data.listen) { channel = g_io_channel_unix_new (0); if (channel) { g_io_channel_set_encoding (channel, NULL, NULL); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN | G_IO_HUP, handle_stdin, NULL); } } /* Show icon and wait */ gtk_status_icon_set_visible (status_icon, !options.notification_data.hidden); if (options.data.timeout > 0) g_timeout_add_seconds (options.data.timeout, (GSourceFunc) timeout_cb, NULL); gtk_main (); return exit_code; }
void on_tt_markup_set_clicked(GtkWidget *widget, gpointer data) { GtkEntry *entry = data; const char *markup; markup = gtk_entry_get_text(entry); if (*markup != '\0') gtk_status_icon_set_tooltip_markup(status_icon, markup); }
void set_icon(gboolean enabled) { const char *name = (enabled ? "bluetooth-active" : "bluetooth-disabled"); const char *_tooltip = enabled ? _("Bluetooth: Enabled") : _("Bluetooth: Disabled"); if (statusicon == NULL) { g_free (icon_name); g_free (tooltip); icon_name = g_strdup (name); tooltip = g_strdup (_tooltip); } else { gtk_status_icon_set_from_icon_name (statusicon, name); gtk_status_icon_set_tooltip_markup(statusicon, _tooltip); } }
GtkStatusIcon *init_notification(void) { notify_init("bluetooth-manager"); statusicon = gtk_status_icon_new_from_icon_name(icon_name); gtk_status_icon_set_title (GTK_STATUS_ICON (statusicon), _("Bluetooth")); gtk_status_icon_set_tooltip_markup(statusicon, tooltip); /* XXX: Make sure the status icon is actually shown */ gtk_status_icon_set_visible(statusicon, FALSE); gtk_status_icon_set_visible(statusicon, TRUE); return statusicon; }
static void xmr_tray_icon_init(XmrTrayIcon *tray) { XmrTrayIconPrivate *priv; tray->priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, XMR_TYPE_TRAY_ICON, XmrTrayIconPrivate); priv = tray->priv; priv->popup_menu = NULL; priv->main_window = NULL; gtk_status_icon_set_tooltip_markup(GTK_STATUS_ICON(tray), "<b>xmradio</b>"); g_signal_connect(tray, "popup-menu", G_CALLBACK(on_tray_popup_menu), NULL); g_signal_connect(tray, "activate", G_CALLBACK(on_tray_activate), NULL); }
static gboolean init_timeout (void) { guint num_processes; gfloat cpu, memory, swap; guint64 swap_free, swap_total; gchar tooltip[1024]; xtm_task_manager_get_system_info (task_manager, &num_processes, &cpu, &memory, &swap); xtm_process_window_set_system_info (XTM_PROCESS_WINDOW (window), num_processes, cpu, memory, swap); xtm_task_manager_get_swap_usage (task_manager, &swap_free, &swap_total); xtm_process_window_show_swap_usage (XTM_PROCESS_WINDOW (window), (swap_total > 0)); if (gtk_status_icon_get_visible (status_icon)) { #if GTK_CHECK_VERSION (2,16,0) g_snprintf (tooltip, 1024, _("<b>Processes:</b> %u\n" "<b>CPU:</b> %.0f%%\n" "<b>Memory:</b> %.0f%%\n" "<b>Swap:</b> %.0f%%"), num_processes, cpu, memory, swap); gtk_status_icon_set_tooltip_markup (GTK_STATUS_ICON (status_icon), tooltip); #else g_snprintf (tooltip, 1024, _("Processes: %u\n" "CPU: %.0f%%\n" "Memory: %.0f%%\n" "Swap: %.0f%%"), num_processes, cpu, memory, swap); gtk_status_icon_set_tooltip (GTK_STATUS_ICON (status_icon), tooltip); #endif } xtm_task_manager_update_model (task_manager); if (timeout == 0) { guint refresh_rate; g_object_get (settings, "refresh-rate", &refresh_rate, NULL); timeout = g_timeout_add (refresh_rate, (GSourceFunc)init_timeout, NULL); } return TRUE; }
GtkStatusIcon *init_notification(void) { notify_init("bluetooth-manager"); icon_enabled = g_themed_icon_new_with_default_fallbacks (ACTIVE_ICON_NAME"-symbolic"); icon_disabled = g_themed_icon_new_with_default_fallbacks (DISABLE_ICON_NAME"-symbolic"); statusicon = gtk_status_icon_new_from_gicon(bt_enabled ? icon_enabled : icon_disabled); gtk_status_icon_set_title (GTK_STATUS_ICON (statusicon), _("Bluetooth")); gtk_status_icon_set_tooltip_markup(statusicon, tooltip); /* XXX: Make sure the status icon is actually shown */ gtk_status_icon_set_visible(statusicon, FALSE); gtk_status_icon_set_visible(statusicon, TRUE); return statusicon; }
static int gtkDialogSetTrayTipAttrib(Ihandle *ih, const char *value) { GtkStatusIcon* status_icon = gtkDialogGetStatusIcon(ih); #if GTK_CHECK_VERSION(2, 16, 0) if (value) { gtk_status_icon_set_has_tooltip(status_icon, TRUE); if (iupAttribGetBoolean(ih, "TIPMARKUP")) gtk_status_icon_set_tooltip_markup(status_icon, value); else gtk_status_icon_set_tooltip_text(status_icon, value); } else gtk_status_icon_set_has_tooltip(status_icon, FALSE); #else gtk_status_icon_set_tooltip(status_icon, value); #endif return 1; }
static void status_icon_update_tooltip (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); gchar *tooltip = NULL; if (priv->event) { if (priv->event->message != NULL) tooltip = g_strdup_printf ("<i>%s</i>\n%s", priv->event->header, priv->event->message); else tooltip = g_strdup_printf ("<i>%s</i>", priv->event->header); gtk_status_icon_set_tooltip_markup (priv->icon, tooltip); } else { tooltip = g_strdup (empathy_idle_get_status (priv->idle)); gtk_status_icon_set_tooltip_text (priv->icon, tooltip); } g_free (tooltip); }
static void tooltip_set() { gchar *argv[] = { LIBEXECDIR "/fbxkb/options.sh", NULL }; gchar *text; gint standard_output; gsize len; GIOChannel *gio; ENTER; if (!g_spawn_async_with_pipes(NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &standard_output, NULL, NULL)) RET(); gio = g_io_channel_unix_new (standard_output); if (g_io_channel_read_to_end(gio, &text, &len, NULL) == G_IO_STATUS_NORMAL) { g_strchomp(text); gtk_status_icon_set_tooltip_markup(icon, text); } g_io_channel_shutdown(gio, FALSE, NULL); g_free(text); RET(); }
static gboolean handle_stdin (GIOChannel * channel, GIOCondition condition, gpointer data) { if ((condition & G_IO_IN) != 0) { GString *string; GError *err = NULL; string = g_string_new (NULL); while (channel->is_readable == FALSE); do { gint status; gchar *command = NULL, *value = NULL, **args; do { status = g_io_channel_read_line_string (channel, string, NULL, &err); while (gdk_events_pending ()) gtk_main_iteration (); } while (status == G_IO_STATUS_AGAIN); if (status != G_IO_STATUS_NORMAL) { if (err) { g_printerr ("yad_notification_handle_stdin(): %s\n", err->message); g_error_free (err); err = NULL; } /* stop handling but not exit */ g_io_channel_shutdown (channel, TRUE, NULL); return FALSE; } strip_new_line (string->str); if (!string->str[0]) continue; args = g_strsplit (string->str, ":", 2); command = g_strdup (args[0]); if (args[1]) value = g_strdup (args[1]); g_strfreev (args); if (value) g_strstrip (value); if (!g_ascii_strcasecmp (command, "icon") && value) { g_free (icon); icon = g_strdup (value); if (gtk_status_icon_get_visible (status_icon) && gtk_status_icon_is_embedded (status_icon)) set_icon (); } else if (!g_ascii_strcasecmp (command, "tooltip")) { if (g_utf8_validate (value, -1, NULL)) { gchar *message = g_strcompress (value); if (!options.data.no_markup) gtk_status_icon_set_tooltip_markup (status_icon, message); else gtk_status_icon_set_tooltip_text (status_icon, message); g_free (message); } else g_printerr (_("Invalid UTF-8 in tooltip!\n")); } else if (!g_ascii_strcasecmp (command, "visible")) { #if !GTK_CHECK_VERSION(2,22,0) if (!g_ascii_strcasecmp (value, "blink")) { gboolean state = gtk_status_icon_get_blinking (status_icon); gtk_status_icon_set_blinking (status_icon, !state); } else #endif if (!g_ascii_strcasecmp (value, "false")) { gtk_status_icon_set_visible (status_icon, FALSE); #if !GTK_CHECK_VERSION(2,22,0) gtk_status_icon_set_blinking (status_icon, FALSE); #endif } else { gtk_status_icon_set_visible (status_icon, TRUE); #if !GTK_CHECK_VERSION(2,22,0) gtk_status_icon_set_blinking (status_icon, FALSE); #endif } } else if (!g_ascii_strcasecmp (command, "action")) { g_free (action); if (value) action = g_strdup (value); } else if (!g_ascii_strcasecmp (command, "quit")) { exit_code = YAD_RESPONSE_OK; gtk_main_quit (); } else if (!g_ascii_strcasecmp (command, "menu")) { if (value) parse_menu_str (value); } else g_printerr (_("Unknown command '%s'\n"), command); g_free (command); g_free (value); } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); g_string_free (string, TRUE); } if ((condition & G_IO_HUP) != 0) { g_io_channel_shutdown (channel, TRUE, NULL); gtk_main_quit (); return FALSE; } return TRUE; }
static void qq_tray_init(QQTray *tray) { gtk_status_icon_set_tooltip_markup(GTK_STATUS_ICON(tray), "<b>GtkQQ</b>"); QQTrayPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, qq_tray_get_type() , QQTrayPriv); priv -> blinking_queue = g_queue_new(); priv -> tmp_queue = g_queue_new(); priv -> popupmenu = gtk_menu_new(); GtkWidget *menuitem; menuitem = gtk_check_menu_item_new_with_label("Mute"); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); GtkWidget *img; GdkPixbuf *pb; #define STATUS_ITEM(x,y) \ menuitem = gtk_image_menu_item_new();\ gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem);\ pb = gdk_pixbuf_new_from_file_at_size(IMGDIR"/status/"x".png"\ , 12, 12, NULL);\ img = gtk_image_new_from_pixbuf(pb);\ g_object_unref(pb);\ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), img);\ gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), y);\ g_signal_connect(G_OBJECT(menuitem), "activate"\ , G_CALLBACK(qq_tray_status_menu_item_activate), x); STATUS_ITEM("online", "Online"); STATUS_ITEM("hidden", "Hidden"); STATUS_ITEM("away", "Away"); STATUS_ITEM("busy", "Busy"); STATUS_ITEM("callme", "Call Me"); STATUS_ITEM("silent", "Silent"); #undef STATUS_ITEM menuitem = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_menu_item_new_with_label("Personal Setting"); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_personal_setting_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_menu_item_new_with_label("System Setting"); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_system_setting_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_about_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), "About GtkQQ"); menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_quit_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), "Quit"); gtk_widget_show_all(priv -> popupmenu); g_signal_connect(G_OBJECT(tray), "popup-menu" , G_CALLBACK(qq_tray_popup_menu), tray); g_signal_connect(G_OBJECT(tray), "button-press-event" , G_CALLBACK(qq_tray_button_press), tray); g_signal_connect(G_OBJECT(tray), "query-tooltip" , G_CALLBACK(qq_tray_on_show_tooltip), tray); }
void xmr_tray_icon_set_tooltips(XmrTrayIcon *tray, const gchar *text) { g_return_if_fail(tray != NULL && text != NULL); gtk_status_icon_set_tooltip_markup(GTK_STATUS_ICON(tray), text); }