gboolean tray_button_press_event_cb (GtkStatusIcon *status_icon, GdkEventButton * event, gpointer userdata) { switch (event->button) { case 1: if (event->state & GDK_SHIFT_MASK) inmd_switch_popup_handler(NULL, (GdkEvent *)event); else toggle_im_enabled(); break; case 2: #if 0 inmd_switch_popup_handler(NULL, (GdkEvent *)event); #else kbm_toggle(); dbg("win_kbm_on %d\n", win_kbm_on); update_item_active_all(); #endif break; case 3: if (!tray_menu) tray_menu = create_tray_menu(mitems); gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, gtk_status_icon_position_menu, tray_icon, event->button, event->time); break; } return TRUE; }
gboolean tray_appindicator_create(gpointer data) { if (is_exist_tray_appindicator()) return FALSE; if (tray_appindicator) { if (app_indicator_get_status (tray_appindicator) != APP_INDICATOR_STATUS_ACTIVE) { app_indicator_set_status (tray_appindicator, APP_INDICATOR_STATUS_ACTIVE); destroy_other_tray(); } } else { destroy_other_tray(); if (!tray_appindicator_load_icon(HIME_TRAY_PNG, HIME_TRAY_PNG, iconame, icondir)) return FALSE; tray_appindicator = app_indicator_new_with_path ("hime", iconame, APP_INDICATOR_CATEGORY_APPLICATION_STATUS, icondir); if(tray_appindicator == NULL) return TRUE; app_indicator_set_status (tray_appindicator, APP_INDICATOR_STATUS_ACTIVE); GtkWidget *menu = NULL; menu = create_tray_menu(mitems); app_indicator_set_secondary_activate_target(tray_appindicator, mitems[0].item); app_indicator_set_menu (tray_appindicator, GTK_MENU (menu)); } load_tray_appindicator(); return FALSE; }
static void cb_popup(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data) { // dbg("cb_popup\n"); switch (button) { #if UNIX case 1: toggle_im_enabled(); break; case 2: kbm_toggle(); break; #endif case 3: // dbg("tray_menu %x\n", tray_menu); if (!tray_menu) tray_menu = create_tray_menu(mitems_main); #if 0 gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, gtk_status_icon_position_menu, status_icon, button, activate_time); #else gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, NULL, NULL, button, activate_time); #endif break; } }
void create_app_indicator(gint create) { /* Create the menu */ indicator_menu = create_tray_menu(indicator_menu, 2); /* check if we need to create the indicator or just refresh the menu */ if(create == 1) { indicator = app_indicator_new("clipit", "clipit-trayicon", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon (indicator, "clipit-trayicon"); } app_indicator_set_menu (indicator, GTK_MENU (indicator_menu)); }
/* Called when status icon is clicked */ static void show_clipit_menu(int menu_type) { /* If the menu is visible, we don't do anything, so that it gets hidden */ if((statusicon_menu != NULL) && gtk_widget_get_visible((GtkWidget *)statusicon_menu)) return; if(status_menu_lock) return; status_menu_lock = TRUE; /* Create the menu */ statusicon_menu = create_tray_menu(statusicon_menu, menu_type); g_signal_connect((GObject*)statusicon_menu, "selection-done", (GCallback)gtk_widget_destroy, NULL); /* GENERATE THE MENU*/ gtk_widget_set_visible(statusicon_menu, TRUE); gtk_menu_popup((GtkMenu*)statusicon_menu, NULL, NULL, gtk_status_icon_position_menu, status_icon, 1, gtk_get_current_event_time()); gtk_menu_shell_select_first((GtkMenuShell*)statusicon_menu, TRUE); status_menu_lock = FALSE; }
static void cb_popup_state(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data) { switch (button) { case 1: #if UNIX toggle_im_enabled(); break; case 2: #endif kbm_toggle(); break; case 3: { char bak[512], cur[512]; get_gcin_conf_fstr(PHONETIC_KEYBOARD, cur, ""); get_gcin_conf_fstr(PHONETIC_KEYBOARD_BAK, bak, ""); if (bak[0] && strcmp(bak, cur)) { char kbm[512]; strcpy(kbm, bak); char *p=strchr(kbm, ' '); if (p) { *(p++)=0; int i; for(i=0;kbm_sel[i].name;i++) if (!strcmp(kbm_sel[i].kbm, kbm)) { break; } if (kbm_sel[i].kbm) { unich_t tt[128]; if (mitems_state[0].name) free(mitems_state[0].name); #if UNIX sprintf(tt, "注音換 %s %s", kbm_sel[i].name, p); mitems_state[0].name = strdup(tt); #else swprintf(tt, L"注音換 %s %S", kbm_sel[i].name, p); mitems_state[0].name = wcsdup(tt); #endif } } // dbg("hhhhhhhhhhhh %x\n", tray_menu_state); if (tray_menu_state) { gtk_widget_destroy(tray_menu_state); tray_menu_state = NULL; } } if (!tray_menu_state) tray_menu_state = create_tray_menu(mitems_state); gtk_menu_popup(GTK_MENU(tray_menu_state), NULL, NULL, NULL, NULL, button, activate_time); break; } } // dbg("zzzzzzzzzzzzz\n"); }