/** menu_applet.c **/ #include #include #define APPLETNAME "menu-applet" #define VERSION "1.0" void changeCallback(AppletWidget *applet,GtkLabel *label); void aboutCallback(AppletWidget *applet,GtkLabel *label); int main(int argc,char *argv[]) { GtkWidget *applet; GtkWidget *label; applet_widget_init(APPLETNAME,VERSION, argc,argv, NULL,0,NULL); applet = applet_widget_new(APPLETNAME); label = gtk_label_new("Menu\nApplet"); gtk_widget_set_usize(label,48,48); applet_widget_add(APPLET_WIDGET(applet),label); gtk_widget_show_all(applet); applet_widget_register_callback( APPLET_WIDGET(applet), "change","Change", (AppletCallbackFunc)changeCallback,label); applet_widget_register_stock_callback( APPLET_WIDGET(applet), "about",GNOME_STOCK_MENU_ABOUT, "About...", (AppletCallbackFunc)aboutCallback,label); applet_widget_gtk_main(); exit(0); } void changeCallback(AppletWidget *applet,GtkLabel *label) { int i; static GtkStyle *oldStyle = NULL; static GtkStyle *newStyle = NULL; static int change = TRUE; if(oldStyle == NULL) { oldStyle = gtk_widget_get_style(GTK_WIDGET(label)); newStyle = gtk_style_copy(oldStyle); for(i=0; i<5; i++) { newStyle->fg[i] = oldStyle->light[i]; newStyle->fg_gc[i] = oldStyle->light_gc[i]; } } if(change) gtk_widget_set_style(GTK_WIDGET(label),newStyle); else gtk_widget_set_style(GTK_WIDGET(label),oldStyle); change = !change; } void aboutCallback(AppletWidget *applet,GtkLabel *label) { GtkWidget *aboutBox; const gchar *writtenBy[] = { "Arthur Griffith", "George Spelvin", NULL }; aboutBox = gnome_about_new("Menu Applet", "0.0", "(C) 1999 the Free Software Foundation", writtenBy, "This applet demonstrates the code " "necessary to add items to the menu. " "The added menu items can be simple text " "or it can be one of the stock items", NULL); gtk_widget_show(aboutBox); }