/[antiright]/antiright/lib/window.c
ViewVC logotype

Diff of /antiright/lib/window.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by jefbed, Mon Nov 1 21:52:41 2004 UTC revision 1.8 by jefbed, Fri Jan 21 22:36:30 2005 UTC
# Line 1  Line 1 
1  /*  /*
2    AntiRight    AntiRight
3    (c) 2002-2004 Jeffrey Bedard    (c) 2002-2005 Jeffrey Bedard
4    jefbed@e-list.net    jefbed@e-list.net
5    
6    This file is part of AntiRight.    This file is part of AntiRight.
# Line 38  antiright_set_title(const char* name) Line 38  antiright_set_title(const char* name)
38    antiright_set_widget_title(antiright.parent_widget, name);    antiright_set_widget_title(antiright.parent_widget, name);
39  }  }
40    
 Pixmap  
 antiright_file_to_bitmap(char *filename)  
 {  
   Pixmap bitmap;  
   int width, height, x_hot, y_hot;  
   XReadBitmapFile(antiright.display, antiright.root_window, filename,  
                   &width, &height, &bitmap, &x_hot, &y_hot);  
   return(bitmap);  
 }  
   
 char *  
 antiright_get_file_extension(char *filename)  
 {  
   char *extension=(char*)xmalloc(4);  
   unsigned int filename_length=strlen(filename);  
   unsigned int counter=filename_length-3;  
   unsigned int extension_counter=0;  
   
     
   while(counter < filename_length)  
     {  
       extension[extension_counter]=filename[counter];  
       counter++;  
       extension_counter++;  
     }  
   extension[extension_counter]='\0';  
   return(extension);  
 }  
   
 XpmColorSymbol *  
 antiright_setup_color_symbol(Widget widget)  
 {  
   Pixel background;  
   XpmColorSymbol *symbol=xmalloc(sizeof(XpmColorSymbol));  
   XtVaGetValues(widget, XmNbackground, &background, NULL);  
   symbol->name=NULL;  
   symbol->value="none";  
   symbol->pixel=background;  
   return(symbol);  
 }  
   
   
 XpmAttributes  
 antiright_setup_pixmap_attributes_for_widget(Widget widget)  
 {  
   XpmAttributes attributes;  
   
   attributes.colorsymbols=antiright_setup_color_symbol(widget);  
   attributes.numsymbols=1;  
   attributes.valuemask=XpmColorSymbols;  
   
   return(attributes);  
 }  
 void  
 antiright_free_pixmap_attributes(XpmAttributes *attributes)  
 {  
   free(attributes->colorsymbols);  
 }  
   
 void  
 antiright_set_widget_pixmaps(Widget label, Pixmap bitmap)  
 {  
   XtVaSetValues(label,  
                 XmNlabelType, XmPIXMAP,  
                 XmNlabelPixmap, bitmap,  
                 XmNiconPixmap, bitmap,  
                 NULL);  
 #ifdef XmNpixmap  
   XtVaSetValues(label, XmNpixmap, bitmap, NULL);  
 #endif /* XmNpixmap  */  
 }  
 void  
 antiright_set_pixmap_from_data(Widget widget, char **data)  
 {  
   Pixmap bitmap;  
   XpmAttributes attributes;  
   attributes=antiright_setup_pixmap_attributes_for_widget(widget);  
   XpmCreatePixmapFromData(antiright.display, antiright.root_window,  
                           data, &bitmap, NULL, &attributes);  
   antiright_free_pixmap_attributes(&attributes);  
   antiright_set_widget_pixmaps(widget, bitmap);  
 }  
   
 void  
 antiright_set_bitmap_from_file(Widget label, char* filename)  
 {  
   Pixmap bitmap;  
   char *extension=antiright_get_file_extension(filename);  
   
   if(!strncmp(extension, "xpm", 3)) /* File is a pixmap.  */  
     {  
       XpmAttributes attributes;  
       attributes=antiright_setup_pixmap_attributes_for_widget(label);  
       XpmReadFileToPixmap(antiright.display, antiright.root_window,  
                           filename, &bitmap, NULL, &attributes);  
       antiright_free_pixmap_attributes(&attributes);  
     }  
   else /* File is a bitmap.  */  
     {  
       bitmap=antiright_file_to_bitmap(filename);  
     }  
   free(extension);  
   antiright_set_widget_pixmaps(label, bitmap);  
 }  
   
 void  
 antiright_print_license_and_description()  
 {  
   puts( "AntiRight Desktop Environment");  
   puts("Copyright 2002-2004, Jeffrey Bedard");    
   puts("AntiRight is a lightweight dekstop environment.");  
   puts("It is distributed under the GNU General Public License.");  
   puts("There is NO WARRANTY.  Please see COPYING for details.");  
 }  
   
 void  
 antiright_print_command_line_options()  
 {  
   puts("Command Line Options:");  
   puts("\t[-display display]");  
   puts("\t[-geometry geometry]");  
   puts("\t[-bg color], [-background color]");  
   puts("\t[-fg color], [-foreground color]");  
   puts("\t[-iconic]");  
   puts("\t[-synchronous]");  
   puts("\t[-title string]");  
   puts("\t[-xrm string]");  
 }  
   
   
 void  
 antiright_standard_usage(char *name_string)  
 {  
   antiright_print_license_and_description();  
   printf("Usage:  %s [OPTION]\n", name_string);  
   fflush(stdout);  
   antiright_print_command_line_options();  
 }  
 void  
 antiright_report_bugs_message()  
 {  
   puts("Report bugs to <jefbed@e-list.net>");  
 }  
   
 void  
 antiright_setup_xt(int* argc, char **argv)  
 {  
   /* Set up Xt.  */  
   antiright.parent_widget=XtVaAppInitialize(&antiright.app_context,  
                                             "AntiRight",  
                                             NULL, 0, argc, argv, NULL, NULL);  
 }  
   
 void  
 antiright_initialize_antiright_data()  
 {  
   antiright.display=XtDisplay(antiright.parent_widget);  
   antiright.screen=DefaultScreen(antiright.display);  
   antiright.root_window=RootWindow(antiright.display, antiright.screen);  
 }  
   
 /* Handle arguments and set up parent_widget.  The character string  
    name contains the string to which the icon and window title will be  
    set.  The array bits contains the icon data for the application  
    icon.  */  
 void  
 antiright_initialize_application(int* argc,  
                                  char** argv,  
                                  const char* name)  
 {  
   antiright_setup_xt(argc, argv);  
   antiright_initialize_antiright_data();  
   antiright_set_title(name);  
   antiright_system("ACE -c &");  
 }  
   

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26