//called every FIFO_TIMEOUT. Processes available commands in the fifo and returns gint timeout_callback( gpointer data ) { char command = 0; while(read(fifo_fd, &command, 1) >= 1) { switch(command) { case 'D': gtk_status_icon_set_from_pixbuf(status, pixbuf_normal); gtk_status_icon_set_blinking(status, FALSE); break; case 'R': gtk_status_icon_set_from_pixbuf(status, pixbuf_beeping); gtk_status_icon_set_blinking(status, FALSE); break; case 'B': gtk_status_icon_set_from_pixbuf(status, pixbuf_beeping); gtk_status_icon_set_blinking(status, TRUE); break; case 'v': gtk_status_icon_set_visible(status, FALSE); break; case 'V': gtk_status_icon_set_visible(status, TRUE); break; case 'Q': gtk_main_quit(); } } return TRUE; }
/* Read data and update tooltip */ gboolean temp_notifier_timeout_func (temp_notifier_s *core) { FILE *file; char string[50]; char temperature[6]; int i = 0, j = 0; /* Read CPU0's temperature */ file = fopen (core->thermal_file_cpu0, "r"); if (file != NULL) { fread (&string, sizeof (string), 1, file); snprintf (temperature, 3, "%c%c\0", string[25], string[26]); fclose (file); core->cpu0_temp = atoi (temperature); /* Check temperature */ i = temp_notifier_check_temp (core->cpu0_temp, core->critical_temp); } else core->cpu0_temp = -1; /* Read CPU0's temperature */ file = fopen (core->thermal_file_cpu1, "r"); if (file != NULL) { fread (&string, sizeof (string), 1, file); snprintf (temperature, 3, "%c%c\0", string[25], string[26]); fclose (file); core->cpu1_temp = atoi (temperature); /* Check temperature */ j = temp_notifier_check_temp (core->cpu1_temp, core->critical_temp); } else core->cpu1_temp = -1; /* Check GtkStatusIcon */ if ((i == -1) || (j == -1)) gtk_status_icon_set_blinking (GTK_STATUS_ICON(core->icon), TRUE); else gtk_status_icon_set_blinking (GTK_STATUS_ICON(core->icon), FALSE); /* Update GtkTooltip */ if ((core->cpu0_temp == -1) && (core->cpu1_temp == -1)) gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON(core->icon), g_strdup_printf ("- CPU1: ERROR\n- CPU2: ERROR")); else if (core->cpu0_temp == -1) gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON(core->icon), g_strdup_printf ("- CPU1: ERROR\n- CPU2: %d C", core->cpu1_temp)); else if (core->cpu1_temp == -1) gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON(core->icon), g_strdup_printf ("- CPU1: %d C\n- CPU2: ERROR", core->cpu0_temp)); else gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON(core->icon), g_strdup_printf ("- CPU1: %d C\n- CPU2: %d C", core->cpu0_temp, core->cpu1_temp)); return TRUE; }
static gboolean qq_tray_button_press(GtkStatusIcon *tray, GdkEvent *event , gpointer data) { GdkEventButton *buttonevent = (GdkEventButton*)event; /* Only handle left clicked. */ if(buttonevent -> button != 1 || buttonevent -> type != GDK_BUTTON_PRESS){ return FALSE; } QQTrayPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, qq_tray_get_type() , QQTrayPriv); gchar *uin = g_queue_pop_tail(priv -> blinking_queue); if(uin == NULL){ /* If there is no new msg, show or hide the main window. */ qq_mainwindow_show_hide(main_win); return FALSE; } GtkWidget *cw = gqq_config_lookup_ht(cfg, "chat_window_map", uin); if(cw != NULL){ gtk_widget_show(cw); } g_free(uin); if(g_queue_is_empty(priv -> blinking_queue)){ gtk_status_icon_set_blinking(tray, FALSE); GdkPixbuf *pb = gdk_pixbuf_new_from_file(IMGDIR"/webqq_icon.png" , NULL); gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(tray), pb); g_object_unref(pb); return FALSE; } qq_tray_blinking(QQ_TRAY(tray), g_queue_peek_tail(priv -> blinking_queue)); return FALSE; }
void trayIconActivated(GObject *trayIcon, gpointer window) { if(gtk_status_icon_get_blinking(GTK_STATUS_ICON (trayIcon))==FALSE){ gtk_widget_show(GTK_WIDGET(window)); gtk_window_deiconify(GTK_WINDOW(window)); } else{ printf("-------------------[click to create window start]----------------\n"); //if(Msghead != NULL) char ip[20]; strcpy(ip,Msghead->ip); printf("ip:%s\n",ip); char name[20]; strcpy(name,Msghead->name); printf("name:%s\n",name); char msg[1024]; bzero(msg,1024); getMsg(ip,msg); printf("msg:%s\n",msg); if(Msghead == NULL) gtk_status_icon_set_blinking (trayIcon,FALSE); createChatWindow(ip,name,msg); //showMessage(msg.message,p->textViewAll); printf("-------------------[click to create window end ]----------------\n"); } }
static void na_start_blinking(void) { gtk_status_icon_set_blinking(nall_globals.icon, TRUE); if (nall_globals.stop_blink_tag) g_source_remove(nall_globals.stop_blink_tag); nall_globals.stop_blink_tag = g_timeout_add_seconds(NA_BLINK_DURATION, na_stop_blinking, NULL); }
void stk_movement(StkWidget widgets) { int x, y, toward; /* check positon of move widget put in fixed container */ x = 0; y = 20; toward = 1; while(1) { gtk_status_icon_set_blinking(widgets.tray, TRUE); g_usleep(1000*250); gdk_threads_enter(); //gtk_fixed_move(GTK_FIXED(widgets.hfix),widgets.image, x, y); switch(toward) { case 1: x = x - 2; y = y - 2; toward = 2; break; case 2: x = x + 2; y = y + 2; toward = 3; break; case 3: x = x + 2; y = y - 2; toward = 4; break; case 4: x = x - 2; y = y + 2; toward = 1; } gdk_threads_leave(); } gtk_status_icon_set_blinking(widgets.tray, FALSE); //gtk_fixed_move(GTK_FIXED(widgets.hfix),widgets.image, 0, 20); }
static void ui_create_status_icon(KIM * im) { GtkStatusIcon *trayIcon; trayIcon = gtk_status_icon_new_from_file("/home/auv/right.png"); gtk_status_icon_set_visible(trayIcon, TRUE); gtk_status_icon_set_blinking(trayIcon, TRUE); gtk_status_icon_set_tooltip(trayIcon, "auv is a good v!"); g_signal_connect(trayIcon, "popup-menu", G_CALLBACK(status_icon_popup_menu_cb), NULL); }
void trayIconActivated(GObject *trayIcon, gpointer window) { if(gtk_status_icon_get_blinking(GTK_STATUS_ICON (trayIcon))==FALSE){ gtk_widget_show(GTK_WIDGET(window)); gtk_window_deiconify(GTK_WINDOW(window)); }else{ chatListForeach((chatFunc)doWindowShow,NULL); gtk_widget_show(GTK_WIDGET(window)); gtk_window_deiconify(GTK_WINDOW(window)); gtk_status_icon_set_blinking(GTK_STATUS_ICON(trayIcon),FALSE); } }
// // Blinking uin's face image // static void qq_tray_blinking(QQTray *tray, const gchar *uin) { gchar buf[500]; GdkPixbuf *pb; QQBuddy *bdy = qq_info_lookup_buddy_by_uin(info, uin); // blinking if(bdy == NULL){ g_snprintf(buf, 500, IMGDIR"/webqq_icon.png%s", ""); }else{ g_snprintf(buf, 500, CONFIGDIR"/faces/%s", bdy -> qqnumber -> str); } pb = gdk_pixbuf_new_from_file(buf, NULL); if(pb == NULL){ pb = gdk_pixbuf_new_from_file(IMGDIR"/webqq_icon.png", NULL); } gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(tray), pb); g_object_unref(pb); gtk_status_icon_set_blinking(GTK_STATUS_ICON(tray), TRUE); }
void qq_tray_stop_blinking_for(QQTray *tray, const gchar *uin) { if(tray == NULL || uin == NULL){ return; } QQTrayPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, qq_tray_get_type() , QQTrayPriv); gchar *tmpuin = NULL; g_queue_clear(priv -> tmp_queue); while(!g_queue_is_empty(priv -> blinking_queue)){ tmpuin = g_queue_pop_tail(priv -> blinking_queue); if(g_strcmp0(tmpuin, uin) == 0){ //remove it g_free(tmpuin); break; } g_queue_push_head(priv -> tmp_queue, tmpuin); } while(!g_queue_is_empty(priv -> tmp_queue)){ g_queue_push_tail(priv -> blinking_queue , g_queue_pop_head(priv -> tmp_queue)); } GdkPixbuf *pb; if(g_queue_is_empty(priv -> blinking_queue)){ // no more blinking gtk_status_icon_set_blinking(GTK_STATUS_ICON(tray), FALSE); pb = gdk_pixbuf_new_from_file(IMGDIR"/webqq_icon.png", NULL); gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(tray), pb); g_object_unref(pb); }else{ qq_tray_blinking(tray, g_queue_peek_tail(priv -> blinking_queue)); } }
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; }
void disable_blinking(void) { gtk_status_icon_set_blinking(statusicon, FALSE); }
void enable_blinking(void) { gtk_status_icon_set_blinking(statusicon, TRUE); }
static gboolean na_stop_blinking(gpointer data) { nall_globals.stop_blink_tag = 0; gtk_status_icon_set_blinking(nall_globals.icon, FALSE); return FALSE; }