static void set_icon (void) { GdkPixbuf *pixbuf; GError *err = NULL; if (icon == NULL) { gtk_status_icon_set_from_icon_name (status_icon, "yad"); return; } if (g_file_test (icon, G_FILE_TEST_EXISTS)) { pixbuf = gdk_pixbuf_new_from_file_at_scale (icon, icon_size, icon_size, TRUE, &err); if (err) { g_printerr (_("Could not load notification icon '%s': %s\n"), icon, err->message); g_clear_error (&err); } if (pixbuf) { gtk_status_icon_set_from_pixbuf (status_icon, pixbuf); g_object_unref (pixbuf); } else gtk_status_icon_set_from_icon_name (status_icon, "yad"); } else gtk_status_icon_set_from_icon_name (status_icon, icon); }
/* Creates a new trayicon instance */ struct trayicon *trayicon_new(struct view *view, GCallback quit_cb) { START_FUNC struct trayicon *trayicon; trayicon=g_malloc(sizeof(struct trayicon)); memset(trayicon, 0, sizeof(struct trayicon)); trayicon->trayicon_quit=quit_cb; trayicon->tray_icon=gtk_status_icon_new(); trayicon->view=view; g_signal_connect(G_OBJECT(trayicon->tray_icon), "activate", G_CALLBACK(trayicon_on_click), (gpointer)trayicon); g_signal_connect(G_OBJECT(trayicon->tray_icon), "popup-menu", G_CALLBACK(trayicon_on_menu), (gpointer)trayicon); gtk_status_icon_set_from_icon_name(trayicon->tray_icon, "florence"); gtk_status_icon_set_tooltip_text(trayicon->tray_icon, _("Florence Virtual Keyboard")); gtk_status_icon_set_visible(trayicon->tray_icon, TRUE); #ifdef ENABLE_NOTIFICATION if (settings_get_bool(SETTINGS_STARTUP_NOTIFICATION)) g_timeout_add(2000, trayicon_notification_start, (gpointer)trayicon); #endif END_FUNC return trayicon; }
static void update_icon (void) { GSList *l; gchar *icon_name; gchar *tooltip; if (status == TEST_STATUS_INFO) { icon_name = "dialog-information"; tooltip = "Some Information ..."; } else { icon_name = "dialog-question"; tooltip = "Some Question ..."; } for (l = icons; l; l = l->next) { GtkStatusIcon *status_icon = l->data; gtk_status_icon_set_from_icon_name (status_icon, icon_name); gtk_status_icon_set_tooltip_text (status_icon, tooltip); } }
static void status_icon_update_icon (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); const gchar *icon_name; if (priv->event && priv->showing_event_icon) { icon_name = priv->event->icon_name; } else { TpConnectionPresenceType state; state = tp_account_manager_get_most_available_presence ( priv->account_manager, NULL, NULL); /* An unset presence type here doesn't make sense. Force it * to be offline. */ if (state == TP_CONNECTION_PRESENCE_TYPE_UNSET) { state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE; } icon_name = empathy_icon_name_for_presence (state); } if (icon_name != NULL) gtk_status_icon_set_from_icon_name (priv->icon, icon_name); }
static GtkStatusIcon *create_icon() { GtkStatusIcon *icon; icon = gtk_status_icon_new(); gtk_status_icon_set_from_icon_name(icon,GTK_STOCK_INDEX); gtk_status_icon_set_visible(icon,TRUE); gtk_status_icon_set_tooltip(icon,"Click here for the Fluxbox menu"); return icon; }
static void statusicon_set_status (StatusIcon *statusicon, const std::string & presence) { g_return_if_fail (statusicon != NULL); /* Update the status icon */ if (presence == "away") gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "user-away"); else if (presence == "busy") gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "user-busy"); else if (presence == "offline") gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "user-offline"); else gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "user-available"); statusicon->priv->status = presence; }
NS_IMETHODIMP Icon::Init(nsIDOMWindow *aWindow, const nsString& aTitle) { nsresult rv; nsCOMPtr<nsIBaseWindow> baseWindow; rv = GetBaseWindow(aWindow, getter_AddRefs(baseWindow)); NS_ENSURE_SUCCESS(rv, rv); nativeWindow native = 0; rv = baseWindow->GetParentNativeWindow(&native); NS_ENSURE_SUCCESS(rv, rv); // Get the window mGdkWindow = gdk_window_get_toplevel(reinterpret_cast<GdkWindow*>(native)); if (!mGdkWindow) { return NS_ERROR_UNEXPECTED; } // Get the widget and gtk window GtkWidget *widget; gdk_window_get_user_data(mGdkWindow, reinterpret_cast<gpointer*>(&widget)); widget = gtk_widget_get_toplevel(widget); mGtkWindow = reinterpret_cast<GtkWindow*>(widget); // Set up tray icon mStatusIcon = gtk_status_icon_new(); // Get the window icon and set it GdkPixbuf *buf = gtk_window_get_icon(mGtkWindow); if (buf) { gtk_status_icon_set_from_pixbuf(mStatusIcon, buf); } else { const gchar *iconname = gtk_window_get_icon_name(mGtkWindow); if (iconname) gtk_status_icon_set_from_icon_name(mStatusIcon, iconname); } // Get and set the title if (aTitle.IsEmpty()) { gtk_status_icon_set_tooltip_text(mStatusIcon, gtk_window_get_title(mGtkWindow)); gtk_widget_add_events(widget, GDK_PROPERTY_CHANGE_MASK); propertyEventId = g_signal_connect(mGtkWindow, "property-notify-event", G_CALLBACK(gtkPropertyEvent), this); } else { NS_ConvertUTF16toUTF8 titleUTF8(aTitle); gtk_status_icon_set_tooltip_text(mStatusIcon, reinterpret_cast<const char*>(titleUTF8.get())); propertyEventId = 0; } // Add signals g_signal_connect(G_OBJECT(mStatusIcon), "button-press-event", G_CALLBACK(gtkButtonEvent), this); g_signal_connect(G_OBJECT(mStatusIcon), "button-release-event", G_CALLBACK(gtkButtonEvent), this); // Make visible gtk_status_icon_set_visible(mStatusIcon, 1); return NS_OK; }
static void update_online(DHCPCD_CONNECTION *con, bool showif) { bool ison, iscarrier; char *msg, *msgs, *tmp; DHCPCD_IF *ifs, *i; ison = iscarrier = false; msgs = NULL; ifs = dhcpcd_interfaces(con); for (i = ifs; i; i = i->next) { if (g_strcmp0(i->type, "link") == 0) { if (i->up) iscarrier = true; } else { if (i->up) ison = true; } msg = dhcpcd_if_message(i, NULL); if (msg) { if (showif) g_message("%s", msg); if (msgs) { tmp = g_strconcat(msgs, "\n", msg, NULL); g_free(msgs); g_free(msg); msgs = tmp; } else msgs = msg; } else if (showif) g_message("%s: %s", i->ifname, i->reason); } if (online != ison || carrier != iscarrier) { online = ison; carrier = iscarrier; if (ani_timer != 0) { g_source_remove(ani_timer); ani_timer = 0; ani_counter = 0; } if (ison) { animate_online(NULL); ani_timer = g_timeout_add(300, animate_online, NULL); } else if (iscarrier) { animate_carrier(NULL); ani_timer = g_timeout_add(500, animate_carrier, NULL); } else { gtk_status_icon_set_from_icon_name(status_icon, "network-offline"); } } gtk_status_icon_set_tooltip_text(status_icon, msgs); g_free(msgs); }
static void statusicon_set_inacall (StatusIcon *statusicon, bool inacall) { g_return_if_fail (statusicon != NULL); /* Update the status icon */ if (inacall) gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "user-inacall"); else statusicon_set_status (statusicon, statusicon->priv->status); }
static GtkStatusIcon *create_tray_icon() { GtkStatusIcon *tray_icon; tray_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL); g_signal_connect(G_OBJECT(tray_icon), "popup-menu",G_CALLBACK(tray_icon_on_menu), NULL); gtk_status_icon_set_from_icon_name(tray_icon, GTK_STOCK_REFRESH); gtk_status_icon_set_tooltip(tray_icon, "Fan control"); gtk_status_icon_set_visible(tray_icon, TRUE); return tray_icon; }
void update_icon(void){ E_RETURN is_wall_active; is_wall_active = torwall_client_status(); if (is_wall_active == STATUS_RUNNING) { gtk_status_icon_set_from_icon_name(tray_icon, "torwallActive"); update_notify(TOOL_ACTIVE, "torwallActive"); gtk_status_icon_set_tooltip(tray_icon, TOOL_ACTIVE); g_signal_handler_block(ch_toggle, ch_toggle_handler_id); gtk_check_menu_item_set_active(ch_toggle, 1); gtk_widget_set_sensitive((GtkWidget*)i_currentnode, 1); g_signal_handler_unblock(ch_toggle, ch_toggle_handler_id); } else { gtk_status_icon_set_from_icon_name(tray_icon, "torwallInactive"); update_notify(TOOL_INACTIVE, "torwallInactive"); gtk_status_icon_set_tooltip(tray_icon, TOOL_INACTIVE); g_signal_handler_block(ch_toggle, ch_toggle_handler_id); gtk_check_menu_item_set_active(ch_toggle, 0); gtk_widget_set_sensitive((GtkWidget*)i_currentnode, 0); g_signal_handler_unblock(ch_toggle, ch_toggle_handler_id); } }
static GtkStatusIcon *create_tray_icon() { GtkStatusIcon *tray_icon; tray_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL); g_signal_connect(G_OBJECT(tray_icon), "popup-menu", G_CALLBACK(tray_icon_on_menu), NULL); gtk_status_icon_set_from_icon_name(tray_icon, "stock_appointment-reminder"); gtk_status_icon_set_title(tray_icon, "Eyerest"); gtk_status_icon_set_visible(tray_icon, TRUE); return tray_icon; }
void create_tray_icon(){ E_RETURN is_wall_active; is_wall_active = torwall_client_status(); tray_icon = gtk_status_icon_new(); create_menu(is_wall_active); g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(on_click), NULL); g_signal_connect(G_OBJECT(tray_icon), "popup-menu", G_CALLBACK(on_menu), NULL); gtk_status_icon_set_from_icon_name(tray_icon, GTK_STOCK_MEDIA_STOP); create_notify(tray_icon, TOOL_INACTIVE); if (is_wall_active == STATUS_RUNNING) { gtk_status_icon_set_tooltip(tray_icon, TOOL_ACTIVE); gtk_status_icon_set_from_icon_name(tray_icon, "torwallActive"); } else { gtk_status_icon_set_tooltip(tray_icon, TOOL_INACTIVE); gtk_status_icon_set_from_icon_name(tray_icon, "torwallInactive"); } gtk_status_icon_set_visible(tray_icon, TRUE); }
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); } }
static gboolean statusicon_blink_cb (gpointer data) { StatusIcon *statusicon = STATUSICON (data); g_return_val_if_fail (data != NULL, false); if (statusicon->priv->blinking) gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "im-message"); else statusicon_set_status (statusicon, statusicon->priv->status); statusicon->priv->blinking = !statusicon->priv->blinking; return true; }
void lassi_tray_update(LassiTrayInfo *i, int n_connected) { char *t; g_assert(i); gtk_status_icon_set_from_icon_name(i->status_icon, n_connected > 0 ? ICON_BUSY : ICON_IDLE); if (n_connected == 0) t = g_strdup("No desktops connected."); else if (n_connected == 1) t = g_strdup("1 desktop connected."); else t = g_strdup_printf("%i desktops connected.", n_connected); gtk_status_icon_set_tooltip_text(i->status_icon, t); g_free(t); }
static void status_icon_update_icon (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); const gchar *icon_name; if (priv->event && priv->showing_event_icon) { icon_name = priv->event->icon_name; } else { McPresence state; state = empathy_idle_get_state (priv->idle); icon_name = empathy_icon_name_for_presence (state); } gtk_status_icon_set_from_icon_name (priv->icon, icon_name); }
static void progress_ui_handler_update_status_icon (NemoProgressUIHandler *self) { gchar *tooltip; progress_ui_handler_ensure_status_icon (self); tooltip = g_strdup_printf (ngettext ("%'d file operation active. %d%% complete.", "%'d file operations active. %d%% complete.", self->priv->active_infos), self->priv->active_infos, self->priv->active_percent); gtk_status_icon_set_tooltip_text (self->priv->status_icon, tooltip); gchar *name = get_icon_name_from_percent (self->priv->active_percent); gtk_status_icon_set_from_icon_name (self->priv->status_icon, name); g_free (name); g_free (tooltip); gtk_status_icon_set_visible (self->priv->status_icon, self->priv->should_show_status_icon); }
static void dhcpcd_status_cb(DHCPCD_CONNECTION *con, const char *status, _unused void *data) { static char *last = NULL; const char *msg; bool refresh; WI_SCAN *w; g_message("Status changed to %s", status); if (g_strcmp0(status, "down") == 0) { msg = N_(last ? "Connection to dhcpcd lost" : "dhcpcd not running"); if (ani_timer != 0) { g_source_remove(ani_timer); ani_timer = 0; ani_counter = 0; } online = carrier = false; gtk_status_icon_set_from_icon_name(status_icon, "network-offline"); gtk_status_icon_set_tooltip_text(status_icon, msg); dhcpcd_prefs_abort(); while (wi_scans) { w = wi_scans->next; dhcpcd_wi_scans_free(wi_scans->scans); g_free(wi_scans); wi_scans = w; } dhcpcd_unwatch(-1, con); g_timeout_add(DHCPCD_RETRYOPEN, dhcpcd_try_open, con); } else { if ((last == NULL || g_strcmp0(last, "down") == 0)) { g_message(_("Connected to %s-%s"), "dhcpcd", dhcpcd_version(con)); refresh = true; } else refresh = g_strcmp0(last, "opened") ? false : true; update_online(con, refresh); } g_free(last); last = g_strdup(status); }
static gboolean animate_online(_unused gpointer data) { const char *icon; if (ani_timer == 0) return false; if (ani_counter++ > 6) { ani_timer = 0; ani_counter = 0; return false; } if (ani_counter % 2 == 0) icon = "network-idle"; else icon = "network-transmit-receive"; gtk_status_icon_set_from_icon_name(status_icon, icon); return true; }
void update_tray_icon(void) { // Yes, we've been updated once now updated_once = TRUE; // Get the new tray icon name and tooltip text format audio_status *as = shared_audio_status(); gchar *icon_name, *tooltip_text_format; if (as->muted) { icon_name = "audio-volume-muted"; tooltip_text_format = "Volume: %d%% (muted)"; } else { if (as->volume < 100.0 / 3) icon_name = "audio-volume-low"; else if (as->volume < 100.0 / 3 * 2) icon_name = "audio-volume-medium"; else icon_name = "audio-volume-high"; tooltip_text_format = "Volume: %d%%"; } // Update the icon name gtk_status_icon_set_from_icon_name(tray_icon, icon_name); // Update the tooltip gsize buffer_size = (strlen(tooltip_text_format) + 5) * sizeof(gchar); gchar *tooltip_text = g_malloc0(buffer_size); if (tooltip_text) { g_snprintf(tooltip_text, buffer_size, tooltip_text_format, (int)(as->volume)); gtk_status_icon_set_tooltip_text(tray_icon, tooltip_text); g_free(tooltip_text); } // Update the volume scale or the popup menu if needed if (is_volume_scale_visible()) update_volume_scale(); else if (is_popup_menu_visible()) update_popup_menu(); }
static gboolean animate_carrier(_unused gpointer data) { const char *icon; if (ani_timer == 0) return false; switch(ani_counter++) { case 0: icon = "network-transmit"; break; case 1: icon = "network-receive"; break; default: icon = "network-idle"; ani_counter = 0; break; } gtk_status_icon_set_from_icon_name(status_icon, icon); return true; }
void ui_update_statusicon(menu_info_item_t* mii) { #ifdef DEBUG g_message("pulseaudio_update_status_icon(%s)", mii->name); #endif pa_volume_t volume = pa_cvolume_avg(mii->volume); g_message("volume:%u%s", volume, mii->mute ? " muted" : ""); const char* icon_name = NULL; if(volume == PA_VOLUME_MUTED || mii->mute) icon_name = "stock_volume-mute"; else if(volume < (PA_VOLUME_NORM / 3)) icon_name = "stock_volume-min"; else if(volume < (PA_VOLUME_NORM / 3 * 2)) icon_name = "stock_volume-med"; else icon_name = "stock_volume-max"; menu_infos_t* mis = mii->menu_info->menu_infos; gtk_status_icon_set_from_icon_name(mis->icon, icon_name); }
static void update_tray_icon_status (GtkStatusIcon *tray_icon) { gboolean battery_present = FALSE; gboolean ac_online = FALSE; gint battery_status = -1; static gint old_battery_status = -1; static gboolean battery_low = FALSE; static gboolean battery_critical = FALSE; static gboolean spawn_command_critical = FALSE; gint percentage, time; gchar *battery_string, *time_string; GError *error = NULL; #ifdef WITH_NOTIFY NotifyNotification *notification = NULL; #endif g_return_if_fail (tray_icon != NULL); /* update tray icon for AC only */ if (battery_path == NULL) { static gboolean ac_notified = FALSE; if (ac_notified == FALSE) { ac_notified = TRUE; NOTIFY_MESSAGE (¬ification, _("AC only, no battery!"), NULL, NOTIFY_EXPIRES_NEVER, NOTIFY_URGENCY_NORMAL); } gtk_status_icon_set_tooltip_text (tray_icon, _("AC only, no battery!")); gtk_status_icon_set_from_icon_name (tray_icon, "ac-adapter"); return; } /* update tray icon for battery */ if (get_battery_present (&battery_present) == FALSE) { return; } if (battery_present == FALSE) { battery_status = MISSING; } else { if (get_battery_status (&battery_status) == FALSE) { return; } /* workaround for limited/bugged batteries/drivers */ /* that unduly return unknown status */ if (battery_status == UNKNOWN && get_ac_online (&ac_online) == TRUE) { if (ac_online == TRUE) { battery_status = CHARGING; if (get_battery_charge (FALSE, &percentage, NULL) == TRUE && percentage >= 99) { battery_status = CHARGED; } } else { battery_status = DISCHARGING; } } } #define HANDLE_BATTERY_STATUS(PCT,TIM,EXP,URG) \ \ percentage = PCT; \ \ battery_string = get_battery_string (battery_status, percentage); \ time_string = get_time_string (TIM); \ \ if (old_battery_status != battery_status) { \ old_battery_status = battery_status; \ NOTIFY_MESSAGE (¬ification, battery_string, time_string, EXP, URG); \ } \ \ gtk_status_icon_set_tooltip_text (tray_icon, get_tooltip_string (battery_string, time_string)); \ gtk_status_icon_set_from_icon_name (tray_icon, get_icon_name (battery_status, percentage)); switch (battery_status) { case MISSING: HANDLE_BATTERY_STATUS (0, -1, NOTIFY_EXPIRES_NEVER, NOTIFY_URGENCY_NORMAL) break; case UNKNOWN: HANDLE_BATTERY_STATUS (0, -1, NOTIFY_EXPIRES_DEFAULT, NOTIFY_URGENCY_NORMAL) break; case CHARGED: HANDLE_BATTERY_STATUS (100, -1, NOTIFY_EXPIRES_DEFAULT, NOTIFY_URGENCY_NORMAL) break; case CHARGING: if (old_battery_status != CHARGING && estimation_needed == TRUE) { reset_battery_time_estimation (); } if (get_battery_charge (FALSE, &percentage, &time) == FALSE) { return; } HANDLE_BATTERY_STATUS (percentage, time, NOTIFY_EXPIRES_DEFAULT, NOTIFY_URGENCY_NORMAL) break; case DISCHARGING: case NOT_CHARGING: if (old_battery_status != DISCHARGING && estimation_needed == TRUE) { reset_battery_time_estimation (); } if (get_battery_charge (TRUE, &percentage, &time) == FALSE) { return; } battery_string = get_battery_string (battery_status, percentage); time_string = get_time_string (time); if (old_battery_status != DISCHARGING) { old_battery_status = DISCHARGING; NOTIFY_MESSAGE (¬ification, battery_string, time_string, NOTIFY_EXPIRES_DEFAULT, NOTIFY_URGENCY_NORMAL); battery_low = FALSE; battery_critical = FALSE; spawn_command_critical = FALSE; } if (battery_low == FALSE && percentage <= configuration.low_level) { battery_low = TRUE; battery_string = get_battery_string (LOW_LEVEL, percentage); NOTIFY_MESSAGE (¬ification, battery_string, time_string, NOTIFY_EXPIRES_NEVER, NOTIFY_URGENCY_NORMAL); } if (battery_critical == FALSE && percentage <= configuration.critical_level) { battery_critical = TRUE; battery_string = get_battery_string (CRITICAL_LEVEL, percentage); NOTIFY_MESSAGE (¬ification, battery_string, time_string, NOTIFY_EXPIRES_NEVER, NOTIFY_URGENCY_CRITICAL); spawn_command_critical = TRUE; } gtk_status_icon_set_tooltip_text (tray_icon, get_tooltip_string (battery_string, time_string)); gtk_status_icon_set_from_icon_name (tray_icon, get_icon_name (battery_status, percentage)); if (spawn_command_critical == TRUE) { spawn_command_critical = FALSE; if (configuration.command_critical_level != NULL) { syslog (LOG_CRIT, _("Spawning critical battery level command in 30 seconds: %s"), configuration.command_critical_level); g_usleep (G_USEC_PER_SEC * 30); if (g_spawn_command_line_async (configuration.command_critical_level, &error) == FALSE) { syslog (LOG_CRIT, _("Cannot spawn critical battery level command: %s"), error->message); g_error_free (error); error = NULL; NOTIFY_MESSAGE (¬ification, _("Cannot spawn critical battery level command!"), configuration.command_critical_level, NOTIFY_EXPIRES_NEVER, NOTIFY_URGENCY_CRITICAL); } } } break; } }
void finestra(struttura *str) { GtkWidget *frame, *winbox, *box,*table;//nuovo x lista GtkWidget **buttonArray; int i, x, y; char s_i[3]; /*Definiamo vettore che contiene gli indici delle posizioni possibili dell'interfaccia*/ char s[NUM_OF_BUTTONS][10]={"1","2 abc","3 def","4 ghi","5 jkl","6 mno","7 pqrs","8 tuv","9 wxyz","⇧ shift","0 +","PT","del","space","↵","sf","tab","ins","→","↓","."}; /* GDK_GRAVITY_SOUTH_WEST is the reference point corresponding at the lower left corner -> position 1 GDK_GRAVITY_SOUTH is the reference point corresponding at the middle of the lower edge -> position 2 GDK_GRAVITY_SOUTH_EAST is the reference point corresponding at the lower right corner -> position 3 */ str->window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_default_size (GTK_WINDOW(str->window), WINDOW_WIDTH, WINDOW_HEIGHT); winbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (str->window), winbox); gtk_widget_show (winbox); /* Crea una Frame */ frame = gtk_frame_new(NULL); gtk_container_add(GTK_CONTAINER(winbox), frame); /* Setta l'etichetta della frame */ gtk_frame_set_label( GTK_FRAME(frame), "Keyboard" ); gtk_widget_show (frame); box = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (frame), box); gtk_widget_show (box); buttonArray = (GtkWidget**)g_malloc((NUM_OF_BUTTONS)*sizeof(GtkButton**)); table = gtk_table_new(NUM_OF_ROWS, NUM_OF_COLUMNS, TRUE); gtk_table_set_row_spacings(GTK_TABLE(table), 1); gtk_table_set_col_spacings(GTK_TABLE(table), 1); x=y=0; for(i=1; i<=NUM_OF_BUTTONS;i++) { buttonArray[i] = gtk_button_new_with_label(s[i-1]); gtk_widget_set_size_request(buttonArray[i],60,40); gtk_table_attach_defaults(GTK_TABLE(table), buttonArray[i], x, x+1, y, y+1); supportoButtonTable(s_i,i); gtk_widget_set_name(buttonArray[i],s_i); g_signal_connect(G_OBJECT(buttonArray[i]), "clicked", G_CALLBACK(button_clicked),str); if(++x==NUM_OF_COLUMNS) { x=0; y++; } } gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 0); /* Crea una Label per i tasti Shift e Ctrl */ str->mylabel = gtk_label_new ("Shift off"); gtk_widget_set_usize(str->mylabel, 0, 1); gtk_container_add(GTK_CONTAINER(box), str->mylabel); gtk_widget_show (str->mylabel); /* Crea una Lista per il T9 */ str->tp.gtklist=gtk_list_new(); gtk_list_set_selection_mode((GtkList *)str->tp.gtklist, GTK_SELECTION_SINGLE); str->tp.scrolled_window=gtk_scrolled_window_new(NULL,NULL); gtk_widget_set_usize(str->tp.scrolled_window, 0,S_W_MAIN);//75// gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (str->tp.scrolled_window),GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(str->tp.scrolled_window),str->tp.gtklist); gtk_container_add(GTK_CONTAINER(box),str->tp.scrolled_window); gtk_widget_show(str->tp.scrolled_window); gtk_widget_show(str->tp.gtklist); gtk_signal_connect(GTK_OBJECT(str->tp.gtklist),"selection_changed",GTK_SIGNAL_FUNC(sigh_print_selection),str);//nuovo x lista /* Crea una Label per il T9 */ str->mylabel2 = gtk_label_new ("PT off"); gtk_widget_set_usize(str->mylabel2,0, 1); gtk_container_add(GTK_CONTAINER(box),str->mylabel2); gtk_widget_show (str->mylabel2); /* Crea uno status icon per la minimizzazione */ str->tray_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(str->tray_icon), "activate",G_CALLBACK(tray_icon_on_click), str); gtk_status_icon_set_from_icon_name(str->tray_icon,GTK_STOCK_MEDIA_STOP); gtk_status_icon_set_from_file(str->tray_icon,PATH_IMG); gtk_status_icon_set_tooltip(str->tray_icon,"Keyboard Tray Icon"); gtk_status_icon_set_visible(str->tray_icon, FALSE); gtk_widget_show_all(str->window); /*salviamo le dim massime dello schermo corrente*/ getMaxScreen(str); ins(str); // gtk_main (); }
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 }
void create_tray_icon (void) { dpy = XOpenDisplay(NULL); gxneur_config_read_str("show_in_the_tray", &show_in_the_tray); gxneur_config_read_str("rendering_engine", &rendering_engine); gxneur_config_add_notify("show_in_the_tray", show_in_the_tray_callback, NULL); gxneur_config_add_notify("rendering_engine", rendering_engine_callback, NULL); if (arg_show_in_the_tray) g_free(show_in_the_tray), show_in_the_tray = g_strdup(arg_show_in_the_tray); if (arg_rendering_engine) g_free(rendering_engine), rendering_engine = g_strdup(arg_rendering_engine); if (!show_in_the_tray) show_in_the_tray = g_strdup(DEFAULT_SHOW_IN_THE_TRAY); if (!rendering_engine) rendering_engine = g_strdup(DEFAULT_RENDERING_ENGINE); tray = g_new0(struct _tray_icon, 1); #ifdef HAVE_APP_INDICATOR tray->app_indicator = NULL; #endif tray->status_icon = NULL; tray->tray_icon = NULL; // Init pixbuf array for (int i = 0; i < MAX_LAYOUTS; i++) { tray->images[i] = NULL; } // Load images names for (int i = 0; i < xconfig->handle->total_languages; i++) { char *layout_name = strdup(xconfig->handle->languages[i].dir); tray->images[i] = g_strdup_printf("%s-%s", PACKAGE, layout_name); free(layout_name); } tray->menu = create_menu(tray, xconfig->manual_mode); int tray_icon_created = 0; int tray_icon_failed = 0; if (strcasecmp(rendering_engine, "AppIndicator") == 0) { #ifdef HAVE_APP_INDICATOR // App indicator tray->app_indicator = app_indicator_new ("X Neural Switcher", PACKAGE, APP_INDICATOR_CATEGORY_APPLICATION_STATUS); if (tray->app_indicator) { app_indicator_set_status (tray->app_indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_menu (tray->app_indicator, tray->menu); tray_icon_created = 1; tray_icon_failed = 0; } else { tray_icon_failed = 1; } #else tray_icon_failed = 1; #endif } gint kbd_gr = get_active_kbd_group(dpy); // Tray icon if (strcasecmp(rendering_engine, "Built-in") == 0 /*|| tray_icon_failed*/) { tray->tray_icon = _gtk_tray_icon_new(_("X Neural Switcher")); if (tray->tray_icon) { g_signal_connect(G_OBJECT(tray->tray_icon), "button_press_event", G_CALLBACK(tray_icon_press), NULL); tray->evbox = gtk_event_box_new(); gtk_event_box_set_visible_window(GTK_EVENT_BOX(tray->evbox), 0); if (strcasecmp(show_in_the_tray, "Text") == 0) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].dir); for (unsigned int i=0; i < strlen(layout_name); i++) layout_name[i] = toupper(layout_name[i]); tray->image = gtk_label_new ((const gchar *)layout_name); gtk_label_set_justify (GTK_LABEL(tray->image), GTK_JUSTIFY_CENTER); free(layout_name); } else { tray->image = gtk_image_new_from_icon_name(tray->images[kbd_gr], GTK_ICON_SIZE_LARGE_TOOLBAR); } gtk_container_add(GTK_CONTAINER(tray->evbox), tray->image); gtk_container_add(GTK_CONTAINER(tray->tray_icon), tray->evbox); gtk_widget_show_all(GTK_WIDGET(tray->tray_icon)); tray_icon_created = 1; tray_icon_failed = 0; } else { tray_icon_failed = 1; } } // Status Icon if (tray_icon_failed || !tray_icon_created || strcasecmp(rendering_engine, "StatusIcon") == 0 ) { tray->status_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(tray->status_icon), "activate", G_CALLBACK(status_icon_on_click), NULL); g_signal_connect(G_OBJECT(tray->status_icon), "popup-menu", G_CALLBACK(status_icon_on_menu), NULL); gtk_status_icon_set_from_icon_name(tray->status_icon, PACKAGE); gtk_status_icon_set_tooltip_text(tray->status_icon, "X Neural Switcher"); gtk_status_icon_set_visible(tray->status_icon, TRUE); if (strcasecmp(show_in_the_tray, "Text") == 0) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].dir); for (unsigned int i=0; i < strlen(layout_name); i++) layout_name[i] = toupper(layout_name[i]); GdkPixbuf *pb = text_to_gtk_pixbuf (layout_name); free(layout_name); pb = gdk_pixbuf_add_alpha(pb, TRUE, 255, 255, 255); gtk_status_icon_set_from_pixbuf(tray->status_icon, pb); g_object_unref(pb); } else { gtk_status_icon_set_from_icon_name(tray->status_icon, tray->images[kbd_gr]); } } force_update = TRUE; g_timeout_add(1000, clock_check, 0); }
gboolean clock_check(gpointer dummy) { if (dummy) {}; int xneur_pid = -1; char *ps_command = (char *) malloc(1024 * sizeof(char)); if (xneur_old_pid == -1) xneur_old_pid = 1; snprintf(ps_command, 1024, "ps -p %d | grep xneur", xneur_old_pid); FILE *fp = popen(ps_command, "r"); free (ps_command); if (fp != NULL) { char buffer[NAME_MAX]; if (fgets(buffer, NAME_MAX, fp) != NULL) xneur_pid = xneur_old_pid; pclose(fp); } if (xneur_pid == -1) xneur_pid = xconfig->get_pid(xconfig); int xneur_state = xconfig->manual_mode; int xneur_group = get_active_kbd_group(dpy); if (get_kbd_group_count(dpy) != xconfig->handle->total_languages) { for (int i = 0; i < MAX_LAYOUTS; i++) { if (tray->images[i] != NULL) g_free(tray->images[i]); } gtk_widget_destroy(GTK_WIDGET(tray->menu)); tray->menu = NULL; g_spawn_command_line_async(PACKAGE, NULL); gtk_main_quit(); } if (xneur_pid == xneur_old_pid && xneur_state == xneur_old_state && xneur_group == xneur_old_group && force_update == FALSE) return TRUE; force_update = FALSE; xneur_old_pid = xneur_pid; xneur_old_state = xneur_state; xneur_old_group = xneur_group; int lang = get_active_kbd_group(dpy); gchar *hint; gchar *status_text; //float saturation = 1.0; if (xneur_pid != -1) { //saturation = 1.0; hint = g_strdup_printf("%s%s%s", _("X Neural Switcher running ("), xconfig->handle->languages[lang].dir, ")"); status_text = g_strdup_printf("%s", _("Stop daemon")); } else { //saturation = 0.25; hint = g_strdup_printf("%s%s%s", _("X Neural Switcher stopped ("), xconfig->handle->languages[lang].dir, ")"); status_text = g_strdup_printf("%s", _("Start daemon")); } gtk_menu_item_set_label(GTK_MENU_ITEM(tray->status), status_text); gint kbd_gr = get_active_kbd_group(dpy); const char *icon_name = get_tray_icon_name(tray->images[kbd_gr]); if (tray->tray_icon) { gtk_widget_hide_all(GTK_WIDGET(tray->tray_icon)); gtk_widget_destroy (tray->image); if (strcasecmp(show_in_the_tray, "Text") == 0) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].dir); for (unsigned int i=0; i < strlen(layout_name); i++) layout_name[i] = toupper(layout_name[i]); tray->image = gtk_label_new ((const gchar *)layout_name); gtk_label_set_justify (GTK_LABEL(tray->image), GTK_JUSTIFY_CENTER); free(layout_name); } else { tray->image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); } gtk_container_add(GTK_CONTAINER(tray->evbox), tray->image); gtk_widget_show_all(GTK_WIDGET(tray->tray_icon)); } else if (tray->status_icon) { if (gtk_status_icon_is_embedded(tray->status_icon)) { if (strcasecmp(show_in_the_tray, "Text") == 0) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].dir); for (unsigned int i=0; i < strlen(layout_name); i++) layout_name[i] = toupper(layout_name[i]); GdkPixbuf *pb = text_to_gtk_pixbuf (layout_name); free(layout_name); pb = gdk_pixbuf_add_alpha(pb, TRUE, 255, 255, 255); gtk_status_icon_set_from_pixbuf(tray->status_icon, pb); g_object_unref(pb); } else { gtk_status_icon_set_from_icon_name(tray->status_icon, icon_name); } gtk_status_icon_set_tooltip(tray->status_icon, hint); } } #ifdef HAVE_APP_INDICATOR else if (tray->app_indicator) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].name); if (strcasecmp(show_in_the_tray, "Text") == 0) { #ifdef HAVE_DEPREC_APP_INDICATOR app_indicator_set_icon (tray->app_indicator, icon_name); #else app_indicator_set_label (tray->app_indicator, layout_name, layout_name); app_indicator_set_icon (tray->app_indicator, ""); #endif } else { #ifdef HAVE_DEPREC_APP_INDICATOR app_indicator_set_icon (tray->app_indicator, icon_name); #else app_indicator_set_icon (tray->app_indicator, icon_name); app_indicator_set_label (tray->app_indicator,"", ""); #endif } free(layout_name); } #endif g_free (hint); g_free (status_text); return TRUE; }
void finestra(struttura *str) { GtkWidget *frame, *framet9, *winbox, *box,*cbox, *tbox, *table, *scrolled_window;//nuovo x lista GtkWidget **buttonArray; int i, x, y; char s_i[3]; char s[NUM_OF_BUTTONS][10]={"1","2 abc","3 def","4 ghi","5 jkl","6 mno","7 pqrs","8 tuv","9 wxyz","⇧ shift","0 +","alt gr","←","space","↵","txt pr","tab","←","→","."}; /*Definiamo vettore che contiene gli indici delle posizioni possibili dell'interfaccia GDK_GRAVITY_SOUTH_WEST is the reference point corresponding at the lower left corner -> position 1 GDK_GRAVITY_SOUTH is the reference point corresponding at the middle of the lower edge -> position 2 GDK_GRAVITY_SOUTH_EAST is the reference point corresponding at the lower right corner -> position 3 */ str->position=3; gtk_init (NULL,NULL); str->window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_default_size (GTK_WINDOW(str->window), NULL,NULL); winbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (str->window), winbox); gtk_widget_show (winbox); /* Crea una Frame */ frame = gtk_frame_new(NULL); gtk_container_add(GTK_CONTAINER(winbox), frame); /* Setta l'etichetta della frame */ gtk_frame_set_label( GTK_FRAME(frame), "Tastiera" ); gtk_widget_show (frame); box = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (frame), box); gtk_widget_show (box); buttonArray = (GtkWidget**)g_malloc(NUM_OF_BUTTONS*sizeof(GtkButton**)); table = gtk_table_new(NUM_OF_ROWS, NUM_OF_COLUMNS, TRUE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 2); x=y=0; for(i=0; i<NUM_OF_BUTTONS-3;i++) { buttonArray[i] = gtk_button_new_with_label(s[i]); gtk_widget_set_size_request(buttonArray[i],60,50); gtk_table_attach_defaults(GTK_TABLE(table), buttonArray[i], x, x+1, y, y+1); sprintf(s_i,"%i",i); gtk_widget_set_name(buttonArray[i],s_i); g_signal_connect(G_OBJECT(buttonArray[i]), "clicked", G_CALLBACK(button_clicked),str); x++; if(x==NUM_OF_COLUMNS) { x=0; y++; } } printf("questa è la i %d\n",i); //Inserisce un box per definire i pulsanti di spostamento cbox = gtk_hbox_new (FALSE, 0); gtk_table_attach_defaults(GTK_TABLE(table), cbox, x, x+1, y, y+1); gtk_widget_set_size_request(cbox,60,50); //gtk_widget_set_size_request(buttonArray[i],15,45); gtk_container_add(GTK_CONTAINER (cbox), buttonArray[i]); g_signal_connect(G_OBJECT(buttonArray[i]), "clicked", G_CALLBACK(movetoleft), str); buttonArray[i+1] = gtk_button_new_with_label(s[i+1]); //gtk_widget_set_name(buttonArray[i+1],s[i+1]); //gtk_widget_set_size_request(buttonArray[i+1],15,45); gtk_container_add(GTK_CONTAINER (cbox), buttonArray[i+1]); g_signal_connect(G_OBJECT(buttonArray[i+1]), "clicked", G_CALLBACK(movetoright), str); buttonArray[i+2] = gtk_button_new_with_label(s[i+2]); //gtk_widget_set_name(buttonArray[i+2],s[i+2]); //gtk_widget_set_size_request(buttonArray[i+2],15,45); gtk_container_add(GTK_CONTAINER (cbox), buttonArray[i+2]); g_signal_connect(G_OBJECT(buttonArray[i+2]), "clicked", G_CALLBACK(dockicon), str); gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 0); /* Crea una Label per i tasti Shift e Ctrl */ str->mylabel = gtk_label_new (NULL); gtk_container_add(GTK_CONTAINER(box), str->mylabel); gtk_widget_show (str->mylabel); /* Crea una FrameT9 */ framet9 = gtk_frame_new(NULL); gtk_container_add(GTK_CONTAINER(winbox), framet9); /* Setta l'etichetta della frame */ gtk_frame_set_label( GTK_FRAME(framet9), "txt prediction" ); gtk_widget_show (framet9); tbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (framet9), tbox); gtk_widget_show (tbox); /* Crea una Lista per il T9 */ str->tp.gtklist=gtk_list_new(); gtk_list_set_selection_mode((GtkList *)str->tp.gtklist, GTK_SELECTION_SINGLE); gtk_widget_set_usize(str->tp.gtklist, NULL, NULL); gtk_container_add(GTK_CONTAINER(tbox), str->tp.gtklist); gtk_widget_show(str->tp.gtklist); gtk_signal_connect(GTK_OBJECT(str->tp.gtklist),"selection_changed",GTK_SIGNAL_FUNC(sigh_print_selection),str);//nuovo x lista /* Crea una Label per il T9 */ str->mylabel2 = gtk_label_new (NULL); gtk_label_set_text (GTK_LABEL (str->mylabel2),"txt pr disattivato"); gtk_widget_set_usize(str->mylabel2, 0, 1); gtk_container_add(GTK_CONTAINER(tbox),str->mylabel2); gtk_widget_show (str->mylabel2); /* Crea uno status icon per la minimizzazione */ str->tray_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(str->tray_icon), "activate",G_CALLBACK(tray_icon_on_click), str); g_signal_connect(G_OBJECT(str->tray_icon),"popup-menu",G_CALLBACK(tray_icon_on_menu), str); gtk_status_icon_set_from_icon_name(str->tray_icon,GTK_STOCK_MEDIA_STOP); gtk_status_icon_set_from_file(str->tray_icon,"keyboard_icon.gif"); gtk_status_icon_set_tooltip(str->tray_icon,"Keyboard Tray Icon"); gtk_status_icon_set_visible(str->tray_icon, FALSE); gtk_widget_show_all(str->window); gtk_main (); }