gint destroy(GtkWidget *widget,gpointer gdata) {
   gdk_rgb_cmap_free(V_CPU.cmap);
   close(V_CPU.synth2app);
   close(V_CPU.app2synth);
   //
   DEBUG_TRACE("(F) before gtk_main_quit\n");
   gtk_main_quit();
   return(FALSE);
}
Esempio n. 2
0
/* draw a part of a pixmap info to the window */
void draw_pinfo(GdkWindow *w, GdkGC *gc,struct pixmap_info *p_info,
		int srcx,int srcy, int destx, int desty,
		int width, int height)
{
  guchar *bitbuf=p_info->row_pointers[srcy]+srcx*p_info->bit_depth/8;
  if (p_info->num_palette) {
    GdkRgbCmap* cmap=gdk_rgb_cmap_new(p_info->gdk_palette,
				      p_info->num_palette);
    
    /* printf("drawing %x:(%d,%d) to (%d,%d) w:%d h=%d\n",(int)p_info,
       srcx,srcy,destx,desty,width,height); */
    gdk_draw_indexed_image(w,gc,destx,desty,width,height,
			   GDK_RGB_DITHER_NONE,
			   bitbuf,p_info->row_len,
			   cmap);
    gdk_rgb_cmap_free(cmap);
  } else {
    gdk_draw_rgb_image(w,gc,destx,desty,width,height,
		       GDK_RGB_DITHER_NONE,bitbuf,
		       p_info->row_len);
	     
  }
  
}
Esempio n. 3
0
/* EDITOR: PALETTE SWITCHER
 * ========================
 * TODO: This somehow affects the main engine despite us using our own GdkColmap... 
 */
gint VID_EditorLoadPalette(gpointer data)
{
	int i;
	GtkWidget *dialog;
	GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
	gint res;
	loadedfile_t *palfile;
	unsigned int colors[256];

	dialog = gtk_file_chooser_dialog_new ("NGUNIXEd - Open Palette (.lmp) File",
                                      NULL,
                                      action,
                                      ("_Cancel"),
                                      GTK_RESPONSE_CANCEL,
                                      ("_Open"),
                                      GTK_RESPONSE_ACCEPT,
                                      NULL);

	// Set the dialog and the default path (current directory)
	GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
	char path[MAX_OSPATH];
	sprintf(path, "file://%s", get_current_dir_name());
	gtk_file_chooser_set_current_folder_uri(chooser, path);

	// Add the filter for .lmp files
	GtkFileFilter *filter = gtk_file_filter_new ();
	gtk_file_filter_add_pattern (filter, "*.lmp");
	gtk_file_chooser_set_filter (chooser, filter);

	res = gtk_dialog_run (GTK_DIALOG (dialog));
	if (res == GTK_RESPONSE_ACCEPT)
  	{
    		char *filename;
    		filename = gtk_file_chooser_get_filename (chooser);

		palfile = COM_LoadFile (filename, 2);
		
		if(palfile)
		{
			Con_Printf("[EDITOR] Switching palette to %s\n", filename);

			for(i=0; i < 16*16*3; i++)
				ed_palette[i] = palfile->data[i];

    			if (ed_cmap) 
				gdk_rgb_cmap_free(ed_cmap);

    			for (i = 0; i < 256; i++) 
			{
				unsigned char r, g, b;
				r = *ed_palette++;
				g = *ed_palette++;
				b = *ed_palette++;
				colors[i] = r << 16 | g << 8 | b;
    			}

    			ed_cmap = gdk_rgb_cmap_new(colors, 256);
		}
    		g_free (filename);
  	}

	gtk_widget_destroy (dialog);
	return 0;
}