static void tray_menu_cb(GtkWidget *widget, guint button, guint time, gpointer userdata) { GtkWidget *menu; GtkWidget *submenu; menu = gtk_menu_new (); /*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/ if (tray_get_window_status() == WS_HIDDEN) tray_make_item (menu, _("_Restore"), tray_menu_restore_cb, NULL); else tray_make_item (menu, _("_Hide"), tray_menu_restore_cb, NULL); tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); submenu = mg_submenu (menu, _("_Blink on")); blink_item (&prefs.input_tray_chans, submenu, _("Channel Message")); blink_item (&prefs.input_tray_priv, submenu, _("Private Message")); blink_item (&prefs.input_tray_hilight, submenu, _("Highlighted Message")); /*blink_item (BIT_FILEOFFER, submenu, _("File Offer"));*/ tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL); menu_add_plugin_items (menu, "\x5$TRAY", NULL); g_object_ref (menu); g_object_ref_sink (menu); g_object_unref (menu); g_signal_connect (G_OBJECT (menu), "selection-done", G_CALLBACK (tray_menu_destroy), NULL); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, userdata, button, time); }
void fe_tray_set_balloon(const char *title, const char *text) { #ifndef _WIN32 char *stext; WinStatus ws; NotifyNotification *n; /* no balloons if the window is focused */ ws = tray_get_window_status(); if (ws == WS_FOCUSED) return; /* bit 1 of flags means "no balloons unless hidden/iconified" */ if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2)) return; /* FIXME: this should close the current balloon */ if (!text) return; stext = strip_color(text, -1, STRIP_ALL); n = notify_notification_new(title, stext, NULL); notify_notification_set_icon_from_pixbuf(n, ICON_NORMAL); notify_notification_set_timeout(n, 20000); notify_notification_show(n, NULL); free(stext); g_object_unref(G_OBJECT(n)); #endif }
void fe_tray_set_balloon (const char *title, const char *text) { #ifndef WIN32 const char *argv[8]; const char *path; char time[16]; WinStatus ws; /* no balloons if the window is focused */ ws = tray_get_window_status (); if (ws == WS_FOCUSED) return; /* bit 1 of flags means "no balloons unless hidden/iconified" */ if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2)) return; /* FIXME: this should close the current balloon */ if (!text) return; #ifdef LIBNOTIFY /* try it via libnotify.so */ if (libnotify_notify_new (title, text, sticon)) return; /* success */ #endif /* try it the crude way */ path = g_find_program_in_path ("notify-send"); if (path) { sprintf(time, "%d000",prefs.input_balloon_time); argv[0] = path; argv[1] = "-i"; argv[2] = "gtk-dialog-info"; if (access (XCHATSHAREDIR"/pixmaps/xchat.png", R_OK) == 0) argv[2] = XCHATSHAREDIR"/pixmaps/xchat.png"; argv[3] = "-t"; argv[4] = time; argv[5] = title; text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP); argv[6] = text; argv[7] = NULL; xchat_execv (argv); g_free ((char *)path); g_free ((char *)text); } else { /* show this error only once */ static unsigned char said_it = FALSE; if (!said_it) { said_it = TRUE; fe_message (_("Cannot find 'notify-send' to open balloon alerts.\nPlease install libnotify."), FE_MSG_ERROR); } } #endif }
static void tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) { GtkWidget *menu; GtkWidget *submenu; GtkWidget *item; int away_status; /* ph may have an invalid context now */ xchat_set_context (ph, xchat_find_context (ph, NULL, NULL)); menu = gtk_menu_new (); /*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/ if (tray_get_window_status () == WS_HIDDEN) tray_make_item (menu, _("_Restore Window"), tray_menu_restore_cb, NULL); else tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL); tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); #ifndef WIN32 /* somehow this is broken on win32 */ submenu = mg_submenu (menu, _("_Blink on")); blink_item (&prefs.input_tray_chans, submenu, _("Channel Message")); blink_item (&prefs.input_tray_priv, submenu, _("Private Message")); blink_item (&prefs.input_tray_hilight, submenu, _("Highlighted Message")); /*blink_item (BIT_FILEOFFER, submenu, _("File Offer"));*/ submenu = mg_submenu (menu, _("_Change status")); away_status = tray_find_away_status (); item = tray_make_item (submenu, _("_Away"), tray_foreach_server, "away"); if (away_status == 1) gtk_widget_set_sensitive (item, FALSE); item = tray_make_item (submenu, _("_Back"), tray_foreach_server, "back"); if (away_status == 2) gtk_widget_set_sensitive (item, FALSE); tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); #endif mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL); menu_add_plugin_items (menu, "\x5$TRAY", NULL); g_object_ref (menu); g_object_ref_sink (menu); g_object_unref (menu); g_signal_connect (G_OBJECT (menu), "selection-done", G_CALLBACK (tray_menu_destroy), NULL); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, userdata, button, time); }
void fe_tray_set_balloon (const char *title, const char *text) { #ifndef WIN32 #if 0 const char *argv[8]; const char *path; char time[16]; #endif WinStatus ws; /* no balloons if the window is focused */ ws = tray_get_window_status (); if ((prefs.hex_away_omit_alerts && hexchat_get_info(ph, "away")) || (prefs.hex_gui_focus_omitalerts && ws == WS_FOCUSED)) return; /* bit 1 of flags means "no balloons unless hidden/iconified" */ if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet) return; /* FIXME: this should close the current balloon */ if (!text) return; #ifdef USE_LIBNOTIFY NotifyNotification *notification; char *notify_text, *notify_title; if (!notify_is_initted()) notify_init(PACKAGE_NAME); notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP); notify_title = strip_color (title, -1, STRIP_ALL); notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/icons/hicolor/scalable/apps/hexchat.svg", NULL); #if NOTIFY_CHECK_VERSION(0,7,0) notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("hexchat")); #endif g_free ((char *)notify_title); g_free ((char *)notify_text); notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000); notify_notification_show (notification, NULL); g_object_unref (notification); #endif #endif }
static void tray_set_flash(TrayIcon icon) { /* don't ever flash the window if it's focused, that's just dumb. --nenolod */ if (tray_get_window_status() == WS_FOCUSED) return; if (!sticon) return; /* already flashing the same icon */ if (flash_tag && gtk_status_icon_get_pixbuf (sticon) == icon) return; /* no flashing if window is focused */ if (tray_get_window_status() == WS_FOCUSED) return; tray_stop_flash(); gtk_status_icon_set_from_pixbuf (sticon, icon); flash_tag = g_timeout_add (TIMEOUT, (GSourceFunc) tray_timeout_cb, icon); }
void fe_tray_set_balloon (const char *title, const char *text) { #ifndef WIN32 #if 0 const char *argv[8]; const char *path; char time[16]; #endif WinStatus ws; /* no balloons if the window is focused */ ws = tray_get_window_status (); if (ws == WS_FOCUSED) return; /* bit 1 of flags means "no balloons unless hidden/iconified" */ if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet) return; /* FIXME: this should close the current balloon */ if (!text) return; #ifdef USE_LIBNOTIFY NotifyNotification *notification; char *notify_text, *notify_title; if (!notify_is_initted()) notify_init(PACKAGE_NAME); notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP); notify_title = strip_color (title, -1, STRIP_ALL); notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/pixmaps/hexchat.png", NULL); g_free ((char *)notify_title); g_free ((char *)notify_text); notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000); notify_notification_show (notification, NULL); g_object_unref (notification); #endif #endif }
static void tray_set_flash (TrayIcon icon) { if (!sticon) return; /* already flashing the same icon */ if (flash_tag && gtk_status_icon_get_pixbuf (sticon) == icon) return; /* no flashing if window is focused */ if (tray_get_window_status () == WS_FOCUSED) return; tray_stop_flash (); gtk_status_icon_set_from_pixbuf (sticon, icon); if (prefs.hex_gui_tray_blink) flash_tag = g_timeout_add (TIMEOUT, (GSourceFunc) tray_timeout_cb, icon); }
static void tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) { static GtkWidget *menu; GtkWidget *submenu; GtkWidget *item; int away_status; /* ph may have an invalid context now */ hexchat_set_context (ph, hexchat_find_context (ph, NULL, NULL)); /* close any old menu */ if (G_IS_OBJECT (menu)) { tray_menu_destroy (menu, NULL); } menu = gtk_menu_new (); /*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/ if (tray_get_window_status () == WS_HIDDEN) tray_make_item (menu, _("_Restore Window"), tray_menu_restore_cb, NULL); else tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL); tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); #ifndef WIN32 /* submenus are buggy on win32 */ submenu = mg_submenu (menu, _("_Blink on")); blink_item (&prefs.hex_input_tray_chans, submenu, _("Channel Message")); blink_item (&prefs.hex_input_tray_priv, submenu, _("Private Message")); blink_item (&prefs.hex_input_tray_hilight, submenu, _("Highlighted Message")); /*blink_item (BIT_FILEOFFER, submenu, _("File Offer"));*/ submenu = mg_submenu (menu, _("_Change status")); #else /* so show away/back in main tray menu */ submenu = menu; #endif away_status = tray_find_away_status (); item = tray_make_item (submenu, _("_Away"), tray_foreach_server, "away"); if (away_status == 1) gtk_widget_set_sensitive (item, FALSE); item = tray_make_item (submenu, _("_Back"), tray_foreach_server, "back"); if (away_status == 2) gtk_widget_set_sensitive (item, FALSE); menu_add_plugin_items (menu, "\x5$TRAY", NULL); #ifdef WIN32 tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); mg_create_icon_item (_("_Preferences"), GTK_STOCK_PREFERENCES, menu, tray_menu_settings, NULL); #endif tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL); g_object_ref (menu); g_object_ref_sink (menu); g_object_unref (menu); g_signal_connect (G_OBJECT (menu), "selection-done", G_CALLBACK (tray_menu_destroy), NULL); #ifdef WIN32 g_signal_connect (G_OBJECT (menu), "leave-notify-event", G_CALLBACK (tray_menu_left_cb), NULL); g_signal_connect (G_OBJECT (menu), "enter-notify-event", G_CALLBACK (tray_menu_enter_cb), NULL); tray_menu_timer = g_timeout_add(500, (GSourceFunc) tray_check_hide, menu); #endif gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, userdata, button, time); }