Exemplo n.º 1
0
/*
 * Callback for the timer
 *
 * This is the callback that the timer is calling in order to check if messages are there.
 *
 */
gboolean
_tray_change_icon(gpointer data)
{
    if (shutting_down) {
        return FALSE;
    }

    unread_messages = wins_get_total_unread();

    if (unread_messages) {
        if (!prof_tray) {
            prof_tray = gtk_status_icon_new_from_file(icon_msg_filename->str);
        } else {
            gtk_status_icon_set_from_file(prof_tray, icon_msg_filename->str);
        }
    } else {
        if (prefs_get_boolean(PREF_TRAY_READ)) {
            if (!prof_tray) {
                prof_tray = gtk_status_icon_new_from_file(icon_filename->str);
            } else {
                gtk_status_icon_set_from_file(prof_tray, icon_filename->str);
            }
        } else {
            g_clear_object(&prof_tray);
            prof_tray = NULL;
        }
    }

    return TRUE;
}
Exemplo n.º 2
0
void TrayItemGtk::SetIcon(std::string& iconPath)
{
    if (active) {
        if (iconPath.empty()) {
            gtk_status_icon_set_from_file(this->item, NULL);
        } else {
            gtk_status_icon_set_from_file(this->item, iconPath.c_str());
        }
    }
}
Exemplo n.º 3
0
Arquivo: eject.c Projeto: pzanoni/tray
void update_status()
{
#if 0
	if (count) {
		gtk_widget_show(sep);
		gtk_widget_set_sensitive(item, TRUE);
		gtk_status_icon_set_from_file(icon, ICON_PATH "dev1.png");
	} else {
		gtk_widget_hide(sep);
		gtk_widget_set_sensitive(item, FALSE);
		gtk_status_icon_set_from_file(icon, ICON_PATH "dev0.png");
	}
#endif

	gtk_status_icon_set_visible(icon, !!count);
}
Exemplo n.º 4
0
int main(int argc, char *argv[]) {
    GtkStatusIcon *tray_icon = NULL;
    GtkMenu *menu = NULL;
    gchar *tray_icon_file = "/usr/share/pixmaps/gnome-tigert.png";

    gtk_init(&argc, &argv);

    /* builds the menus */
    menu = make_menu();

    tray_icon = gtk_status_icon_new();

    g_signal_connect(G_OBJECT(tray_icon), "activate",
                     G_CALLBACK(left_click), menu);

    g_signal_connect(G_OBJECT(tray_icon), "popup-menu",
                     G_CALLBACK(right_click), menu);

    gtk_status_icon_set_from_file(tray_icon, tray_icon_file);
    gtk_status_icon_set_visible(tray_icon, TRUE);

    gtk_main();

    return 0;
}
Exemplo n.º 5
0
/*
 Battery levels:
 0 .. 10		empty
 10 .. 20	0
 20 .. 40	1
 40 .. 60	2
 60 .. 80	3
 80 .. 100	4
 100			5
 */
void update_status_icon(int level, BATT_STATUS status)
{
	gchar *icon;
	static int old_level=-1;
	static BATT_STATUS old_status=BATT_NORMAL;

	if(level==old_level && status==old_status)
		return;

	old_level=level;
	old_status=status;

	if(level<10 && status==BATT_NORMAL){
		icon=g_strdup("_empty");
	}else if(level==100){
		icon=g_strdup("_5");
	}else if(status==BATT_CHARGING){
		icon=g_strdup_printf("_ch_%d",level/20);
	}else{
		icon=g_strdup_printf("_%d",level/20);
	}

	gchar *path=g_strdup_printf("%sbatt%s.png",ICONS_PATH,icon);
	if(!status_icon_batt_meter)
		status_icon_batt_meter=gtk_status_icon_new_from_file(ICONS_PATH "network-strength-none.png");
	else
		gtk_status_icon_set_from_file(status_icon_batt_meter,path);

	gchar *tip=g_strdup_printf("%d%%",level);
	gtk_status_icon_set_tooltip_text(status_icon_batt_meter,tip);

	g_free(tip);
	g_free(path);
	g_free(icon);
}
Exemplo n.º 6
0
gboolean cc_manager_applet_setup_widget(CCManagerApplet * applet)
{
    g_return_val_if_fail(CC_IS_MANAGERAPPLET(applet), FALSE);

    applet->status_icon = gtk_status_icon_new();
    if (!applet->status_icon)
	return FALSE;
    gtk_status_icon_set_from_file(applet->status_icon, STATUS_ICON);


    g_signal_connect(applet->status_icon, "activate",
		     G_CALLBACK(status_icon_activate_cb), applet);

//setting CCLogingWin
    applet->loging_win = cc_loging_win_new();
    g_message("dddddddddddddddddddddddddddddd");
    cc_loging_win_initialize(applet->loging_win);
    cc_loging_win_setup(applet->loging_win);
    g_message("win setuped in cc_manager_applet_setup_widget");
//    cc_loging_ovirt_get_domain_r(applet->loging_win->ovirt);
//    cc_loging_switch2win(applet->loging_win);
//    g_message("pppppppppppppppppppppppp%x ",applet->loging_win->info);
    cc_loging_info_print(applet->loging_win->info);

//    g_message("pppppppppppppppppppppppp");
//    g_print("     loging_win [%x]\n",applet->loging_win);
//    g_message("before switch2win  applet setup");
//    g_message("after switch2win  applet setup");
//    cc_loging_win_setup(applet->loging_win);


    return TRUE;
}
Exemplo n.º 7
0
gboolean update(struct Icon_data *data)
{
  if( pread(data-> fd,data-> text_buff, data-> len_to_read, data-> offset) <= 0) { /* Try to read from the file. */
      /* Error enter. */
      fprintf(stderr, "*** Filemon first reading error, try to reopen ***\n");

      /* If pread return error, try to open it again(Due to suspend and so on). */
      if((data-> fd = open((const char*)data-> saved_file, O_RDONLY)) <= 0) {
          fprintf(stderr, "Cant reopen the file, exit.\n");
          file2mon_exit(data);
      } else if( pread(data-> fd,data-> text_buff, data-> len_to_read, data-> offset) <= 0) { /* Try to read from the file again. */
          /* Second reading was fail too. */
          fprintf(stderr, "Filemon Reading error, exit.\n");
          file2mon_exit(data);
      }
  }

#ifdef DEBUG
  fprintf(stdout, "TEXT: [%s]\n", data-> text_buff);	        /* Debug. */
  fprintf(stdout, "TMP: [%s]\n", data-> tmp_buff);		/* Debug. */
#endif

  /* If current buffer is the same like previous (tmp_buffer), do nothign.
   * Or if it's different, create new icon and reset the icon.
   * Also copy current text to temporary buffer for future comparisons.
   */
  if(strcmp( (const char*)data-> text_buff, (const char*)data-> tmp_buff) != 0) {
      create_icon(data);						/* Create new icon. 			*/
      gtk_status_icon_set_from_file(data-> icon, data-> path_to_file);	/* Reset the icon.  			*/
      strcpy( (char*)data-> tmp_buff, (const char*)data-> text_buff);	/* Copy new lalue to temporary buffer. 	*/
  }

  return TRUE;	/* Keeep running. */
}
Exemplo n.º 8
0
/*
 * Callback for the timer
 *
 * This is the callback that the timer is calling in order to check if messages are there.
 *
 */
gboolean _tray_change_icon(gpointer data)
{
    if (shutting_down) {
        return false;
    }

    unread_messages = wins_get_total_unread();

    if (unread_messages) {
        gtk_status_icon_set_from_file(prof_tray, icon_msg_filename->str);
    } else {
        gtk_status_icon_set_from_file(prof_tray, icon_filename->str);
    }

    return true;
}
Exemplo n.º 9
0
GtkStatusIcon* ui_statusicon()
{
    GObject* status_icon = gtk_builder_get_object(builder, "statusicon");

#ifdef DEBUG
    GError* error = NULL;
    gchar* exe_path = g_file_read_link("/proc/self/exe", &error);
    if(error)
    {
        g_message("g_file_read_link() failed (%s)", error->message);
        g_error_free(error);
        g_free(exe_path);
        return GTK_STATUS_ICON(status_icon);
    }

    gchar* dirname = g_path_get_dirname(exe_path);
    g_free(exe_path);

    gchar* icon_file = g_build_path("/", dirname, "../data/pasystray.svg", NULL);
    g_free(dirname);

    if(g_file_test(icon_file, G_FILE_TEST_EXISTS))
    {
        gtk_status_icon_set_from_file(GTK_STATUS_ICON(status_icon), icon_file);
        g_message("using icon: %s", icon_file);
    }
    g_free(icon_file);
#endif

    return GTK_STATUS_ICON(status_icon);
}
Exemplo n.º 10
0
void NotifyUpdate() {
	if (Connected==1 && icon_s!=1) {
		icon_s=1;
		gtk_status_icon_set_from_file (Notify, icon_c);
	}
	if (Connected==0 && icon_s!=2) {
		icon_s=2;
		gtk_status_icon_set_from_file (Notify, icon_d);
	}
	if (Connected==2 && icon_s!=0) {
		icon_s=0;
		gtk_status_icon_set_from_file (Notify, icon_n);
	}
	
	if (Connected==0) gtk_status_icon_set_tooltip (Notify, "GVPN - Disconnected");
	if (Connected==1) gtk_status_icon_set_tooltip (Notify, "GVPN - Connected");	
	if (Connected==2) gtk_status_icon_set_tooltip (Notify, "GVPN - Connecting...");	
}
Exemplo n.º 11
0
void set_icon(const char *iconName)
{
  if (tray_icon != NULL) {
    gtk_status_icon_set_from_file(tray_icon, iconName);
  }
  if (indicator != NULL && appindicator_handle != NULL) {
    dl_app_indicator_set_icon(indicator, iconName);
  }
}
Exemplo n.º 12
0
Arquivo: main.c Projeto: anovmari/main
static gboolean do_timer(gpointer data)
{
	gboolean new_status = isTennisFree();
	gtk_image_set_from_file((GtkImage*)image, "video.jpg");
	if(new_status != cur_status)
	{
		if(new_status == TRUE)
		{
			gtk_status_icon_set_from_file(icon, "img/pingpong_green.png");
		}
		else
		{
			gtk_status_icon_set_from_file(icon, "img/pingpong_red.png");
		}
		cur_status = new_status;
	}
	return TRUE;
}
Exemplo n.º 13
0
void fx_head_set_state_image(FxMain* fxmain , StateType type)
{
	FxHead *fxhead = fxmain->headPanel;
	GdkPixbuf *pixbuf;
	gchar *statename = fx_util_get_state_name(type);
	gint use_status_icon = USE_STATUS_ICON(fxmain->user->config);

	gtk_label_set_markup(GTK_LABEL(fxhead->state_label) , statename);
	switch(type)
	{
		case P_ONLINE :
			pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"online.svg" , 20 , 20 , NULL);
			if(use_status_icon)
				gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"online.svg");
			break;
		case P_BUSY :
			pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"busy.svg" , 20 , 20 , NULL);
			if(use_status_icon)
				gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"busy.svg");
			break;
		case P_HIDDEN :
			pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"invisible.svg" , 20 , 20 , NULL);
			if(use_status_icon)
				gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"invisible.svg");
			break;
		case P_OFFLINE :
			pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"offline.svg" , 20 , 20 , NULL);
			if(use_status_icon)
				gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"offline.svg");
			gtk_widget_set_sensitive(fxhead->portrait, FALSE);
			break;
		default :
			pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"away.svg" , 20 , 20 , NULL);
			if(use_status_icon)
				gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"away.svg");
			break;
	}
	gtk_image_set_from_pixbuf(GTK_IMAGE(fxhead->state_img) , pixbuf);
	g_object_unref(pixbuf);
	free(statename);
}
Exemplo n.º 14
0
static void shoes_native_systray_old(char *title, char *message, char *path) {
    if (stsicon == NULL) {
        stsicon = gtk_status_icon_new_from_file(path);
        stspath = path;
    }
    // detect change of icon
    if (strcmp(path, stspath)) {
        stspath = path;
        gtk_status_icon_set_from_file (stsicon, stspath);
    }
    gtk_status_icon_set_title(stsicon, title);
    gtk_status_icon_set_tooltip_text(stsicon, message);
}
Exemplo n.º 15
0
Arquivo: ftmenu.c Projeto: taq/ftmenu
static void create_tray(void){
	GtkStatusIcon *icon;
	char menu_file[PATH_MAX];
	char icon_f[PATH_MAX];

	icon = create_icon();
	g_signal_connect(G_OBJECT(icon),"button-press-event",G_CALLBACK(menu_popup),NULL);

	create_menu(menu_file);
	if(icon_file(menu_file,icon_f)!=NULL && access(icon_f,R_OK)==0){
		g_print("Setting Fluxbox Tray Menu icon to %s\n",icon_f);
		gtk_status_icon_set_from_file(icon,icon_f);
	}
}
Exemplo n.º 16
0
static GtkStatusIcon *create_tray_icon() 
{
  GtkStatusIcon *tray_icon;
  gchar* filename;
  tray_icon = gtk_status_icon_new();
      
  g_signal_connect(G_OBJECT(tray_icon), "popup-menu", 
                         G_CALLBACK(tray_icon_on_click), NULL);
  g_signal_connect(G_OBJECT(tray_icon), "activate",
                         G_CALLBACK(tray_icon_on_click), NULL);
		
  filename = g_build_filename (g_get_current_dir(), "moo.png", NULL);
  printf("PATH for sysIcon: %s\n",filename);		
  gtk_status_icon_set_from_file(tray_icon, filename);
        
  gtk_status_icon_set_tooltip(tray_icon, "Click to Hide/Show GtkMoo\n \302\251 Rohit Yadav, 2008-10");
  gtk_status_icon_set_visible(tray_icon, TRUE);
  return tray_icon;
}
Exemplo n.º 17
0
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);

        /* GdkPixbuf *default_icon = gdk_pixbuf_new_from_xpm_data(firefox_xpm); */

        /* gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(tray_icon), */
        /*                                 GDK_PIXBUF(default_icon)); */
        const gchar *default_icon_filename = "firefox32.png";
        gtk_status_icon_set_from_file(tray_icon,
                                      default_icon_filename);
        gtk_status_icon_set_tooltip(tray_icon, 
                                    "Example Tray Icon");
        gtk_status_icon_set_visible(tray_icon, TRUE);

        return tray_icon;
}
Exemplo n.º 18
0
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 ();
}
Exemplo n.º 19
0
bool loop(int argc, char** argv) {

	char home[256]; //NEED TO MAKE THIS DYNAMIC
	strcpy(home, getenv("HOME"));

	//parse the config file
	settings.parse_config(strcat(home, config_file));
	//load the controls into list
	ElementList list(settings.card);
	list_ptr = &list;
	//reorder the controls to the order specified in the config file
	settings.reorder_list(&list);

	//set the scale
	list.set_scale((Element::scale_t)settings.scaling);
	//set the auto_mute
	list.set_auto_mute(settings.auto_mute);
	
	//initialize gtk
	gtk_init(&argc, &argv);

	//set up the tray_slider that goes in the tray
	if (settings.enable_tray_icon){
		GtkWidget *tray_frame;
		tray_frame = gtk_alignment_new(0.5,0.0,0,0);
		settings.tray_slider = new retro_slider;
		settings.set_tray_slider(&list);
		settings.apply_to_tray_slider(settings.tray_slider);
		if (list.num_elems > 0){
			settings.tray_slider->init(tray_frame, (void*)settings.tray_control, &Element::get_callback, &Element::set_callback, (settings.tray_control->values > 1));
		} else {
			settings.tray_control = NULL;
		}

		//set up the small window that holds the tray_slider
		settings.slider_window = gtk_window_new (GTK_WINDOW_POPUP);
		gtk_window_set_resizable(GTK_WINDOW(settings.slider_window), false);
		gtk_window_set_decorated(GTK_WINDOW(settings.slider_window), false);
		gtk_window_set_skip_taskbar_hint(GTK_WINDOW(settings.slider_window), true);
		gtk_window_set_skip_pager_hint(GTK_WINDOW(settings.slider_window), true);
		gtk_widget_set_usize(settings.slider_window, settings.tray_slider->width, settings.tray_slider->height);
		//don't want accidental closure of the slider window to destroy the window
		g_signal_connect(settings.slider_window, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
		//want the widow to go away when it loses focus
		g_signal_connect(settings.slider_window, "focus-out-event", G_CALLBACK (gtk_widget_hide), NULL);
		gtk_container_add( GTK_CONTAINER(settings.slider_window), tray_frame );
		//we want it hidden by default, but it must be shown at least once or else scrolling over the icon will cause a hang
		gtk_widget_show_all(settings.slider_window);
		gtk_widget_hide_all(settings.slider_window);
		
			
		//set up tray icon
#if GTK_CHECK_VERSION(2,16,0)
		settings.tray_icon = gtk_status_icon_new();
		gtk_status_icon_set_from_file(settings.tray_icon, VOL_MUTED_IMAGE);
#else
		settings.tray_icon = GTK_WIDGET(egg_tray_icon_new("Retrovol Tray Icon"));
		//set the background color
		bool enable_tray_icon_background_color = settings.enable_tray_icon_background_color; 
		GdkColor bg_color;
		char bg_color_str[8];
		if (cmdline_enable_bg_color){
			enable_tray_icon_background_color = true;
			strcpy(bg_color_str, cmdline_bg_color);
		} else if (settings.enable_tray_icon_background_color){
			settings.nftoh(settings.tray_icon_background_color, bg_color_str);
		}
		if (enable_tray_icon_background_color){
			if (gdk_color_parse(bg_color_str, &bg_color)){
				GtkStyle *style = gtk_style_copy(gtk_widget_get_style(settings.tray_icon));
				style->bg[GTK_STATE_NORMAL] = bg_color;
				gtk_widget_set_style(settings.tray_icon, style);
			} else {
				fprintf(stderr, _("Error:  Failed to set background color to %s\n"), bg_color_str);
			}
		}
		//set up the images
		settings.tray_icon_image = gtk_image_new();
		gtk_container_add( GTK_CONTAINER(settings.tray_icon), settings.tray_icon_image );
		gtk_image_set_from_file(GTK_IMAGE(settings.tray_icon_image), VOL_MEDIUM_IMAGE);
		//set the event mask
		gtk_widget_set_events (settings.tray_icon, GDK_BUTTON_PRESS_MASK | GDK_SCROLL_MASK);
#endif

		//signals
		g_signal_connect(G_OBJECT(settings.tray_icon), "button_press_event", G_CALLBACK (&tray_button_press_event_callback), settings.slider_window);
		if (settings.tray_control){
			g_signal_connect(G_OBJECT(settings.tray_icon), "scroll_event", G_CALLBACK (&retro_slider::scroll_event_callback), settings.tray_slider);
		}

#if GTK_CHECK_VERSION(2,16,0)
		//make icon visible
		gtk_status_icon_set_visible(settings.tray_icon, true);
#else
		//handle situations where the icon's window dies, such as due to the tray itself exiting
		g_signal_connect(G_OBJECT(settings.tray_icon), "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);

		//make icon visible
		gtk_widget_show_all(settings.tray_icon);
#endif

		//set up the popup menu (the function checks if it should actually do anything)
		set_menu();

	}
	


	//set up the window
	settings.main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	//gtk_window_set_position(GTK_WINDOW(settings.main_window), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(settings.main_window), settings.window_width, settings.window_height);
	gtk_window_set_title(GTK_WINDOW(settings.main_window), "Retrovol");
	restore_posdim();
	g_signal_connect(settings.main_window, "configure-event", G_CALLBACK (save_posdim), NULL);
	
	//if the tray icon is enabled, we want the window to hide rather than closing
	if (settings.enable_tray_icon){
		g_signal_connect(settings.main_window, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
	}

	//make the over_box, which will hold stuff like the menu, status bar, and the actual content in the middle
	GtkWidget *over_box;
	over_box = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(settings.main_window), over_box);

	//define the menu
	GtkItemFactoryEntry menu_items_1[] = {
		{ (gchar*)_("/_File"),           NULL,              NULL,                      0, (gchar*)"<Branch>" },
		{ (gchar*)_("/File/_Configure"), (gchar*)"<CTRL>C", G_CALLBACK(configure),     0, (gchar*)"<StockItem>", GTK_STOCK_EXECUTE },
		{ (gchar*)_("/File/_Quit"),      (gchar*)"<CTRL>Q", G_CALLBACK(close_window),  0, (gchar*)"<StockItem>", GTK_STOCK_QUIT },
	};
	gint nmenu_items_1 = sizeof (menu_items_1) / sizeof (menu_items_1[0]);
	
	GtkItemFactoryEntry menu_items_2[] = {
		{ (gchar*)_("/_File"),           NULL,              NULL,                      0, (gchar*)"<Branch>" },
		{ (gchar*)_("/File/_Configure"), (gchar*)"<CTRL>C", G_CALLBACK(configure),     0, (gchar*)"<StockItem>", GTK_STOCK_EXECUTE },
		{ (gchar*)_("/File/_Exit completely"),      (gchar*)"<CTRL>E", G_CALLBACK(gtk_main_quit),  0, (gchar*)"<StockItem>", GTK_STOCK_QUIT },
		{ (gchar*)_("/File/_Quit"),      (gchar*)"<CTRL>Q", G_CALLBACK(close_window),  0, (gchar*)"<StockItem>", GTK_STOCK_QUIT },
	};
	gint nmenu_items_2 = sizeof (menu_items_2) / sizeof (menu_items_2[0]);

	GtkItemFactoryEntry *menu_items;
	gint nmenu_items;
	//if the tray menu is enabled, don't have the "Exit" entry in the main menu
	if (settings.enable_tray_menu){
		menu_items = menu_items_1;
		nmenu_items = nmenu_items_1;
	} else {
		menu_items = menu_items_2;
		nmenu_items = nmenu_items_2;
	}

	//build the menu
	GtkWidget *menubar;
	menubar = get_menubar_menu(settings.main_window, menu_items, nmenu_items, "<RetrovolMain>");
	gtk_box_pack_start(GTK_BOX(over_box), menubar, FALSE, TRUE, 0);


	//use a scrolled window
	GtkWidget *scrolled_window;
	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(over_box), scrolled_window);
	
	//put the stuff into a viewport manually, so we can specify that it should have no shadow
	GtkWidget *viewport;
	viewport = gtk_viewport_new(NULL, NULL);
	gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
	gtk_container_add(GTK_CONTAINER(scrolled_window), viewport);
	
			
	//and create an Hbox to hold all the stuff
	GtkWidget *hbox;
	if (settings.vertical){
		hbox = gtk_hbox_new(TRUE, 2);
		gtk_container_add(GTK_CONTAINER(viewport), hbox);
	} else {
		hbox = gtk_vbox_new(TRUE, 2);
		gtk_container_add(GTK_CONTAINER(viewport), hbox);
	}
			
	//add the sliders
	retro_slider *sliders = new retro_slider[list.num_items];
	
	for(int i=0; i<list.num_items; i++){
		//use a vbox w/ slider on top and label on bottom
		GtkWidget *vbox;
		if (settings.vertical){
			vbox = gtk_vbox_new(FALSE, 2);
		} else {
			vbox = gtk_hbox_new(FALSE, 2);
		}
		gtk_box_pack_start(GTK_BOX(hbox), vbox, false, false, 0);
		
		if (strcmp(list.items[i]->type, "INTEGER") == 0){
			//integers need sliders
			//the rslider pseudo-widget likes to be inside a container, lets use a GtkAlignment
			GtkWidget *frame;
			if (settings.vertical){
				frame = gtk_alignment_new(0.5,0.0,0,0);
				gtk_box_pack_start(GTK_BOX(vbox), frame, false, false, 0);
			} else {
				frame = gtk_alignment_new(0.0,0.5,0,0);
				gtk_box_pack_end(GTK_BOX(vbox), frame, false, false, 0);
			}
			//make the slider and associate with a control
			settings.apply_to_slider(&sliders[i]);
			sliders[i].init(frame, (void*)list.items[i], &Element::get_callback, &Element::set_callback, (list.items[i]->values > 1));
		
		} else if (strcmp(list.items[i]->type, "BOOLEAN") == 0){
			//booleans need checkboxes
			GtkWidget *alignment;
			if (settings.vertical){
				alignment = gtk_alignment_new(0.5,1.0,0,0);
				gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0);
			} else {
				alignment = gtk_alignment_new(1.0,0.5,0,0);
				gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0);
			}
			GtkWidget *chkbx;
			chkbx = gtk_check_button_new();
			//set it to the current state
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbx), (bool)list.items[i]->get());
			//bind to the toggle_checkbox function
			Element* ptr = list.items[i];
			g_signal_connect(GTK_TOGGLE_BUTTON(chkbx), "toggled", G_CALLBACK (toggle_checkbox), ptr);
			g_signal_connect_after(GTK_TOGGLE_BUTTON(chkbx), "expose-event", G_CALLBACK (refresh_checkbox), ptr);
			gtk_container_add(GTK_CONTAINER(alignment), chkbx);
		} else if (strcmp(list.items[i]->type, "ENUMERATED") == 0){
			GtkWidget *alignment;
			if (settings.vertical){
				alignment = gtk_alignment_new(0.5,0.5,0,0);
				gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0);
			} else {
				alignment = gtk_alignment_new(1.0,0.5,0,0);
				gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0);
			}
			//insert a combobox with the different options
			GtkWidget *combo_box;
			combo_box=gtk_combo_box_new_text();
			for(unsigned int n=0; n<list.items[i]->number_of_enums; n++){
				gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), list.items[i]->enums[n]);
			}
			gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), list.items[i]->get());
			//bind to the change_combo_box function
			g_signal_connect(GTK_COMBO_BOX(combo_box), "changed", G_CALLBACK (change_combo_box), list.items[i]);
			gtk_container_add(GTK_CONTAINER(alignment), combo_box);
		}
		
		//add a checkbox for sliders that are muteable
		if (list.items[i]->switch_id >= 0){
			GtkWidget *alignment;
			if (settings.vertical){
				alignment = gtk_alignment_new(0.5,1.0,0,0);
				gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0);
			} else {
				alignment = gtk_alignment_new(1.0,0.5,0,0);
				gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0);
			}
			GtkWidget *chkbx;
			chkbx = gtk_check_button_new();
			//set it to the current state
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbx), (bool)list.elems[list.items[i]->switch_id].get());
			//bind to the toggle_checkbox function
			g_signal_connect(GTK_TOGGLE_BUTTON(chkbx), "toggled", G_CALLBACK (toggle_checkbox), &(list.elems[list.items[i]->switch_id]));
			g_signal_connect_after(GTK_TOGGLE_BUTTON(chkbx), "expose-event", G_CALLBACK (refresh_checkbox), &(list.elems[list.items[i]->switch_id]));
			
			gtk_container_add(GTK_CONTAINER(alignment), chkbx);
		}
		
		//display the name of the control
		GtkWidget *alignment;
		char wrapped[256];
		if (settings.vertical){
			alignment = gtk_alignment_new(0.5,1.0,0,0);
			gtk_box_pack_end(GTK_BOX(vbox), alignment, false, false, 0);
			word_wrap(wrapped, list.items[i]->short_name);
		} else {
			alignment = gtk_alignment_new(1.0,0.5,0,0);
			gtk_box_pack_start(GTK_BOX(vbox), alignment, false, false, 0);
			strcpy(wrapped, list.items[i]->short_name);
		}
		GtkWidget *label;
		label = gtk_label_new(wrapped);
		gtk_container_add(GTK_CONTAINER(alignment), label);
	}
	
	//finish the window stuff
	if (!start_hidden){ gtk_widget_show_all(settings.main_window); }
	g_signal_connect(settings.main_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
	

	//add some periodic refreshment to keep the icon and window up-to-date
	#if GTK_CHECK_VERSION(2,14,0)
		int timeout = g_timeout_add_seconds(1, update, NULL);
	#else
		//this is less efficient than g_timeout_add_seconds()
		int timeout = g_timeout_add(1000, update, NULL);
	#endif
	
	//finished with gtk setup
	gtk_main();

	//stop the timeout
	g_source_remove(timeout);
	
	//have the window shown again if it was open before we restarted
	if (settings.resume_main){
		settings.resume_main = false;
		start_hidden = false;
	} else {
		start_hidden = true;
	}

	return(settings.restart);
}
Exemplo n.º 20
0
//update the tray-icon and refresh the window
gboolean update(gpointer data){
	bool state = true;
	if (settings.enable_tray_icon){
		if (settings.tray_control){
			int val = settings.tray_control->get();
			char tooltiptext[32];
			if (settings.tray_control->switch_id >= 0){
				state = (bool)list_ptr->elems[settings.tray_control->switch_id].get();
			}
			if (state){
				int image = 2+3*val/100;
				if (image > 4){
					image=4;
				} else if (image < 0){
					image=0;
				} else if (val == 0){
					image=1;
				}
				sprintf(tooltiptext, _("Volume: %d%%"), val);
#if GTK_CHECK_VERSION(2,16,0)
				gtk_status_icon_set_from_file(settings.tray_icon, settings.icon_file_names[image]);
#else
				gtk_image_set_from_file(GTK_IMAGE(settings.tray_icon_image), settings.icon_file_names[image]);
#endif
			} else {
				sprintf(tooltiptext, _("Volume: Muted"));
#if GTK_CHECK_VERSION(2,16,0)
				gtk_status_icon_set_from_file(settings.tray_icon, settings.icon_file_names[0]);
#else
				gtk_image_set_from_file(GTK_IMAGE(settings.tray_icon_image), settings.icon_file_names[0]);
#endif
			}
#if GTK_CHECK_VERSION(2,16,0)
				gtk_status_icon_set_tooltip_text(settings.tray_icon, tooltiptext);
#elif GTK_CHECK_VERSION(2,12,0)
				gtk_widget_set_tooltip_text(settings.tray_icon_image, tooltiptext);
#else
				static GtkTooltips *tooltips = gtk_tooltips_new();
				gtk_tooltips_set_tip(tooltips, settings.tray_icon_image, tooltiptext, NULL);
#endif
			//if the tray was moved, update the menu
			GdkScreen *screen = gdk_screen_get_default();
			int icon_x,icon_y;
#if GTK_CHECK_VERSION(2,16,0)
			GdkScreen *screen_from_tray;
			GdkRectangle area;
			GtkOrientation orientation;
			if (gtk_status_icon_get_geometry(settings.tray_icon, &screen_from_tray, &area, &orientation)){
				icon_x = area.x;
				icon_y = area.y;
			} else {
				icon_x = gdk_screen_get_width(screen);
				icon_y = gdk_screen_get_height(screen);
			}
#else
			gtk_window_get_position(GTK_WINDOW(settings.tray_icon), &icon_x, &icon_y);
#endif
			if ((bool)(icon_y > gdk_screen_get_height(screen)/2) ^ tray_at_bottom){
				//the current status does not match the previous status, so update the menu
				set_menu();
			}
			//in case the icon was hidden due to the tray exiting, try reshowing it again
#if GTK_CHECK_VERSION(2,16,0)
			gtk_status_icon_set_visible(settings.tray_icon, true);
#else
			gtk_widget_show_all(settings.tray_icon);
#endif
		}
	}
	if (GTK_WIDGET_VISIBLE(settings.main_window)){
		gtk_widget_queue_draw(settings.main_window);
	}
	if (GTK_WIDGET_VISIBLE(settings.slider_window)){
		gtk_widget_queue_draw(settings.slider_window);
	}
	
	return(true);
}
Exemplo n.º 21
0
Arquivo: mixer.c Projeto: pzanoni/tray
static void update_icon(struct channel *c)
{
	if (c->playback)
		gtk_status_icon_set_from_file(icon, c->muteval ?
				ICON_PATH "speaker.png" : ICON_PATH "mute.png");
}
Exemplo n.º 22
0
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 ();
}
Exemplo n.º 23
0
void load_tray_icon_win32()
{
  dbg("load_tray_icon_win32\n");
#if WIN32
  // when login, creating icon too early may cause block in gtk_status_icon_new_from_file
  if (win32_tray_disabled  /* || !gcin_status_tray */)
    return;
#endif

//  dbg("load_tray_icon_win32\n");
#if UNIX
  char *tip;
  tip="";
#else
  wchar_t *tip;
  tip=L"";
#endif

  char *iconame="en-tsin.png";
  char tt[32];
  strcpy(tt, iconame);

  if (!current_CS || current_CS->im_state == GCIN_STATE_DISABLED||current_CS->im_state == GCIN_STATE_ENG_FULL) {
    iconame=capslock_on?"en-gcin-A.png":GCIN_TRAY_PNG;
  } else {
    iconame=inmd[current_CS->in_method].icon;
  }

//  dbg("caps %d %s\n", capslock_on, iconame);

//  dbg("tsin_pho_mode() %d\n", tsin_pho_mode());

  gboolean is_tsin = current_method_type()==method_type_TSIN;

  if (current_CS && current_CS->im_state == GCIN_STATE_CHINESE && !tsin_pho_mode()) {
    if ((is_tsin || current_method_type()==method_type_MODULE)) {
      strcpy(tt, "en-");
      strcat(tt, iconame);
      if (capslock_on && is_tsin)
        strcpy(tt, "en-tsin-A.png");
    } else {
      if (current_method_type()==method_type_GTAB) {
        strcpy(tt, capslock_on?"en-gtab-A.png":"en-gtab.png");
       }
    }

    iconame = tt;
  }

  dbg("iconame %s\n", iconame);
  char fname[128];
  fname[0]=0;
  if (iconame)
    get_icon_path(iconame, fname);


  char *icon_st=NULL;
  char fname_state[128];

//  dbg("%d %d\n",current_CS->im_state,current_CS->b_half_full_char);

  if (current_CS && (current_CS->im_state == GCIN_STATE_ENG_FULL ||
      current_CS->im_state != GCIN_STATE_DISABLED && current_CS->b_half_full_char ||
      current_method_type()==method_type_TSIN && tss.tsin_half_full)) {
      if (gb_output) {
        icon_st="full-simp.png";
        tip = _L("全形/簡體輸出");
      }
      else {
        icon_st="full-trad.png";
        tip = _L("全形/正體輸出");
      }
  } else {
    if (gb_output) {
      icon_st="half-simp.png";
      tip= _L("半形/簡體輸出");
    } else {
      icon_st="half-trad.png";
      tip = _L("半形/正體輸出");
    }
  }

  get_icon_path(icon_st, fname_state);
//  dbg("wwwwwwww %s\n", fname_state);

  if (gcin_status_win)
    disp_win_screen_status(fname, fname_state);

  if (!gcin_status_tray)
    return;

#if UNIX
  if (gcin_win32_icon==GCIN_TRAY_UNIX)
    return;
#endif

  if (icon_main) {
//    dbg("set %s %s\n", fname, fname_state);
    gtk_status_icon_set_from_file(icon_main, fname);
    gtk_status_icon_set_from_file(icon_state, fname_state);
  }
  else {
//    dbg("gtk_status_icon_new_from_file a\n");
    icon_main = gtk_status_icon_new_from_file(fname);
    g_signal_connect(G_OBJECT(icon_main),"activate", G_CALLBACK (cb_activate), NULL);
    g_signal_connect(G_OBJECT(icon_main),"popup-menu", G_CALLBACK (cb_popup), NULL);

//	dbg("gtk_status_icon_new_from_file %s b\n", fname_state);
    icon_state = gtk_status_icon_new_from_file(fname_state);
    g_signal_connect(G_OBJECT(icon_state),"activate", G_CALLBACK (cb_activate_state), NULL);
    g_signal_connect(G_OBJECT(icon_state),"popup-menu", G_CALLBACK (cb_popup_state), NULL);

//	dbg("icon %s %s\n", fname, fname_state);
  }

#if GTK_CHECK_VERSION(2,16,0)
  if (icon_state)
    gtk_status_icon_set_tooltip_text(icon_state, _(tip));
#endif

  if (icon_main) {
    char tt[64];
    if (current_CS && inmd[current_CS->in_method].cname && inmd[current_CS->in_method].cname[0]) {
      dbg("cname %s\n", inmd[current_CS->in_method].cname);
      strcpy(tt, inmd[current_CS->in_method].cname);
    }

    if (!iconame || !strcmp(iconame, GCIN_TRAY_PNG) || !tsin_pho_mode())
      strcpy(tt, "English");
#if GTK_CHECK_VERSION(2,16,0)
    gtk_status_icon_set_tooltip_text(icon_main, tt);
#endif
  }

  return;
}
Exemplo n.º 24
0
void load_tray_icon_double()
{
  if (!hime_status_tray)
    return;
  if (hime_tray_display != HIME_TRAY_DISPLAY_DOUBLE)
    return;

#if WIN32
  // when login, creating icon too early may cause block in gtk_status_icon_new_from_file
  if (win32_tray_disabled)
    return;
#endif

  destroy_other_tray();

//  dbg("load_tray_icon_win32\n");
#if UNIX
  char *tip;
  tip="";
#else
  wchar_t *tip;
  tip=L"";
#endif

  char *iconame;
  if (!current_CS || current_CS->im_state == HIME_STATE_DISABLED||current_CS->im_state == HIME_STATE_ENG_FULL) {
    iconame=HIME_TRAY_PNG;
  } else {
    iconame=inmd[current_CS->in_method].icon;
  }

//  dbg("tsin_pho_mode() %d\n", tsin_pho_mode());

  char tt[32];
  if (current_CS && current_CS->im_state == HIME_STATE_CHINESE && !tsin_pho_mode()) {
    if ((current_method_type()==method_type_TSIN || current_method_type()==method_type_MODULE)) {
      strcpy(tt, "en-");
      strcat(tt, iconame);
    } else {
      strcpy(tt, "en-tsin.png");
    }

    iconame = tt;
  }

//  dbg("iconame %s\n", iconame);
  char fname[128];
  fname[0]=0;
  if (iconame)
    get_icon_path(iconame, fname);


  char *icon_st=NULL;
  char fname_state[128];

//  dbg("%d %d\n",current_CS->im_state,current_CS->b_half_full_char);

  if (current_CS && (current_CS->im_state == HIME_STATE_ENG_FULL ||
      (current_CS->im_state != HIME_STATE_DISABLED && current_CS->b_half_full_char) ||
      (current_method_type()==method_type_TSIN && tss.tsin_half_full))) {
      if (gb_output) {
        icon_st="full-simp.png";
        tip = _("全形/簡體輸出");
      }
      else {
        icon_st="full-trad.png";
        tip = _("全形/正體輸出");
      }
  } else {
    if (gb_output) {
      icon_st="half-simp.png";
      tip= _("半形/簡體輸出");
    } else {
      icon_st="half-trad.png";
      tip = _("半形/正體輸出");
    }
  }

  get_icon_path(icon_st, fname_state);
//  dbg("wwwwwwww %s\n", fname_state);


  if (icon_main) {
//    dbg("set %s %s\n", fname, fname_state);
    gtk_status_icon_set_from_file(icon_main, fname);
    gtk_status_icon_set_from_file(icon_state, fname_state);
  }
  else {
//    dbg("gtk_status_icon_new_from_file a\n");
    icon_main = gtk_status_icon_new_from_file(fname);
    g_signal_connect(G_OBJECT(icon_main),"activate", G_CALLBACK (cb_activate), NULL);
    g_signal_connect(G_OBJECT(icon_main),"popup-menu", G_CALLBACK (cb_popup), NULL);

//	dbg("gtk_status_icon_new_from_file %s b\n", fname_state);
    icon_state = gtk_status_icon_new_from_file(fname_state);
    g_signal_connect(G_OBJECT(icon_state),"activate", G_CALLBACK (cb_activate_state), NULL);
    g_signal_connect(G_OBJECT(icon_state),"popup-menu", G_CALLBACK (cb_popup_state), NULL);

//	dbg("icon %s %s\n", fname, fname_state);
  }

#if GTK_CHECK_VERSION(2,16,0)
  if (icon_state)
    gtk_status_icon_set_tooltip_text(icon_state, _(tip));
#endif

  if (icon_main) {
    char tt[64];
    if (current_CS && inmd[current_CS->in_method].cname[0])
      strcpy(tt, inmd[current_CS->in_method].cname);

    if (!iconame || !strcmp(iconame, HIME_TRAY_PNG) || !tsin_pho_mode())
      strcpy(tt, "English");
#if GTK_CHECK_VERSION(2,16,0)
    gtk_status_icon_set_tooltip_text(icon_main, tt);
#endif
  }

  return;
}