Ejemplo n.º 1
0
static void
load_scenario (char *fname)
{
	char *tmp, *fn;
        GdkColor bgcolor;
        GdkImage *tmpimage;
    
	tmp = g_strconcat ( "same-gnome/", fname, NULL);

	fn = gnome_unconditional_pixmap_file ( tmp );
	g_free( tmp );

	if (!g_file_exists (fn)) {
		printf (_("Could not find the \'%s\' theme for SameGnome\n"), fn);
		exit (1);
	}

	if (scenario)
		g_free (scenario);

	scenario = g_strdup(fname);

	configure_sync (fname);

	if (image)
		gdk_imlib_destroy_image (image);

	image = gdk_imlib_load_image (fn);
	gdk_imlib_render (image, image->rgb_width, image->rgb_height);

	stones = gdk_imlib_move_image (image);
	mask = gdk_imlib_move_mask (image);

        tmpimage = gdk_image_get(stones, 0, 0, 1, 1);
        bgcolor.pixel = gdk_image_get_pixel(tmpimage, 0, 0);
        gdk_window_set_background (draw_area->window, &bgcolor);
        gdk_image_destroy(tmpimage);
  
	g_free( fn );

	nstones = image->rgb_width / STONE_SIZE;
/*	ncolors = image->rgb_height / STONE_SIZE; */
	ncolors = 3;


	gtk_widget_draw (draw_area, NULL);
}
Ejemplo n.º 2
0
void eplay_load_image()
{

	if (im) {
		gdk_imlib_kill_image(im);
		im = NULL;
	}

	if(!p[image_idx]) {
		im = gdk_imlib_load_image(image_names[image_idx]);
	}


	if (first) {
		w = org_w = im->rgb_width;
		h = org_h = im->rgb_height;
		win_x = (screen_x - w) / 2;
		win_y = (screen_y - h) / 2;
		attr.window_type = GDK_WINDOW_TEMP;
		attr.wclass = GDK_INPUT_OUTPUT;
		attr.event_mask = GDK_ALL_EVENTS_MASK;
		attr.x = attr.y = 0;
		attr.width = screen_x;
		attr.height = screen_y;
		parent = NULL;
		win = gdk_window_new(parent, &attr, ATTRIBUTES_MASK);
		gdk_window_show(win);
		gc = gdk_gc_new(win);
		first = 0;
		gdk_window_set_background(win, &color_bg);
		gdk_keyboard_grab(win, FALSE, CurrentTime);
		gdk_pointer_grab(win, FALSE, event_mask, NULL, cursor, CurrentTime);
		gdk_window_set_hints(win, win_x, win_y, w, h, w, h, GDK_HINT_MIN_SIZE |
							 GDK_HINT_MAX_SIZE | GDK_HINT_POS);
	}
/*	gdk_imlib_free_pixmap(p[image_idx]);  */  /* killing old pixmap */
	if(!p[image_idx]) {
		gdk_imlib_render(im, w, h);     /* Imlib render ... */
		p[image_idx] = gdk_imlib_move_image(im);    /* creating new */
	}

	gdk_draw_pixmap(win, gc, p[image_idx], 0, 0, win_x, win_y, w, h);
	gdk_window_show(win);       /* display image */
}
Ejemplo n.º 3
0
void Skin (void)
{
  if ((ifilestuff == 0) && ((biscomputer == 0) || (wiscomputer == 0))
    && (iyesno == 0))
  {
    if ((skindir = opendir (PKGDATADIR"skins/")) == NULL)
    {
      Message ("Error loading skins.", 1, 0);
    }
    else
    {
      skinswindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_title (GTK_WINDOW (skinswindow), "load skin");
      gtk_signal_connect (GTK_OBJECT (skinswindow), "delete_event",
        GTK_SIGNAL_FUNC (DestroyFiles), NULL);
      gtk_window_set_policy (GTK_WINDOW (skinswindow), 0, 0, 1);
      gtk_container_border_width (GTK_CONTAINER (skinswindow), 10);
      gtk_widget_realize (skinswindow);
      skintable = gtk_table_new (100, 3, FALSE);
      gtk_widget_show (skintable);
      gtk_container_add (GTK_CONTAINER (skinswindow), skintable);
      inrskins = 0;
      while ((dir = readdir (skindir)) != NULL)
      {
        if ((strcmp (dir->d_name, ".") != 0) && (strcmp (dir->d_name, "..")
          != 0))
        {
          sprintf (skinnames[inrskins], "%s", dir->d_name);
          inrskins++;
        }
      }
      closedir (skindir);

      for (isskinnames = 0; isskinnames < inrskins; isskinnames++)
      {
        sprintf (skinpix, PKGDATADIR"skins/%s/mmb.png",
          skinnames[isskinnames]);
        skinpixim = gdk_imlib_load_image (skinpix);
        skinpixw = skinpixim->rgb_width;
        skinpixh = skinpixim->rgb_height;
        gdk_imlib_render (skinpixim, skinpixw, skinpixh);
        skinpixmap = gdk_imlib_move_image (skinpixim);
        skinpixmapwid = gtk_pixmap_new (skinpixmap, NULL);
        gtk_table_attach (GTK_TABLE (skintable), skinpixmapwid,
          0, 1, isskinnames, isskinnames + 1, GTK_FILL, GTK_FILL, 0, 0);
        gtk_widget_show (skinpixmapwid);
        gdk_flush ();

        skinbuttons[isskinnames] = gtk_button_new_with_label
          (skinnames[isskinnames]);
        gtk_widget_set_usize (GTK_WIDGET (skinbuttons[isskinnames]), 200, 30);
        gtk_table_attach (GTK_TABLE (skintable), skinbuttons[isskinnames],
          1, 2, isskinnames, isskinnames + 1, GTK_FILL | GTK_EXPAND, GTK_FILL
          | GTK_EXPAND, 4, 2);
        gtk_signal_connect (GTK_OBJECT (skinbuttons[isskinnames]), "clicked",
          GTK_SIGNAL_FUNC (ChangeSkin), (gpointer) skinnames[isskinnames]);
        gtk_widget_show (skinbuttons[isskinnames]);

        sprintf (skinpix, PKGDATADIR"skins/%s/mmw.png",
          skinnames[isskinnames]);
        skinpixim = gdk_imlib_load_image (skinpix);
        skinpixw = skinpixim->rgb_width;
        skinpixh = skinpixim->rgb_height;
        gdk_imlib_render (skinpixim, skinpixw, skinpixh);
        skinpixmap = gdk_imlib_move_image (skinpixim);
        skinpixmapwid = gtk_pixmap_new (skinpixmap, NULL);
        gtk_table_attach (GTK_TABLE (skintable), skinpixmapwid,
          2, 3, isskinnames, isskinnames + 1, GTK_FILL, GTK_FILL, 0, 0);
        gtk_widget_show (skinpixmapwid);
        gdk_flush ();
      }
      gtk_widget_show (skinswindow);
      ifilestuff = 1;
      if (ichangestuff == 0)
      {
        Play ("open.mp3", 0);
      }
    }
  }
  else
  {
    if (ichangestuff == 0)
    {
      Play ("click.mp3", 0);
    }
  }
}
Ejemplo n.º 4
0
void ReallyReStart (GtkWidget *rrw, GtkFileSelection *rrfs)
{
  gfloat pvalue = 0;
  if ((ihistory > 0) && (isave == 1))
  {
    JudgeBoard ('w');
    Save ();
  }
  if (isavemes == 1)
  {
    Message (ssavemes, 2, 1);
  }

  x = 0;
  y = 0;
  iCapturedW = 0;
  iCapturedB = 0;
  ilimit = 0;
  ijustundo = 0;
  ifilestuff = 0;
  iduh = 0;
  iother = 0;
  isave = 1;
  iquit = 0;
  isavemes = 0;
  iiamblack = 0;
  ihistory = 0;
  imoves = 0;
  ilastmoveb = 1000;
  ilastmovew = 1000;
  StatusBar ();

  for (iPlace = 1; iPlace <= 361; iPlace++)
  {
    sprintf (Board[iPlace], "%s", "mme");
  }
  sprintf (Board[1], "%s", "lte");
  for (iPlace = 2; iPlace <= 18; iPlace++)
  {
    sprintf (Board[iPlace], "%s", "mte");
  }
  sprintf (Board[19], "%s", "rte");
  sprintf (Board[20], "%s", "lme");
  sprintf (Board[38], "%s", "rme");
  sprintf (Board[39], "%s", "lme");
  sprintf (Board[57], "%s", "rme");
  sprintf (Board[58], "%s", "lme");
  sprintf (Board[61], "%s", "mms");
  sprintf (Board[67], "%s", "mms");
  sprintf (Board[73], "%s", "mms");
  sprintf (Board[76], "%s", "rme");
  sprintf (Board[77], "%s", "lme");
  sprintf (Board[95], "%s", "rme");
  sprintf (Board[96], "%s", "lme");
  sprintf (Board[114], "%s", "rme");
  sprintf (Board[115], "%s", "lme");
  sprintf (Board[133], "%s", "rme");
  sprintf (Board[134], "%s", "lme");
  sprintf (Board[152], "%s", "rme");
  sprintf (Board[153], "%s", "lme");
  sprintf (Board[171], "%s", "rme");
  sprintf (Board[172], "%s", "lme");
  sprintf (Board[175], "%s", "mms");
  sprintf (Board[181], "%s", "mms");
  sprintf (Board[187], "%s", "mms");
  sprintf (Board[190], "%s", "rme");
  sprintf (Board[191], "%s", "lme");
  sprintf (Board[209], "%s", "rme");
  sprintf (Board[210], "%s", "lme");
  sprintf (Board[228], "%s", "rme");
  sprintf (Board[229], "%s", "lme");
  sprintf (Board[247], "%s", "rme");
  sprintf (Board[248], "%s", "lme");
  sprintf (Board[266], "%s", "rme");
  sprintf (Board[267], "%s", "lme");
  sprintf (Board[285], "%s", "rme");
  sprintf (Board[286], "%s", "lme");
  sprintf (Board[289], "%s", "mms");
  sprintf (Board[295], "%s", "mms");
  sprintf (Board[301], "%s", "mms");
  sprintf (Board[304], "%s", "rme");
  sprintf (Board[305], "%s", "lme");
  sprintf (Board[323], "%s", "rme");
  sprintf (Board[324], "%s", "lme");
  sprintf (Board[342], "%s", "rme");
  sprintf (Board[343], "%s", "lue");
  for (iPlace = 344; iPlace <= 360; iPlace++)
  {
    sprintf (Board[iPlace], "%s", "mue");
  }
  sprintf (Board[361], "%s", "rue");

  DoHandicap ();

  for (ibuttonrr = 1; ibuttonrr <= 361; ibuttonrr++)
  {
    sprintf (History[ihistory][ibuttonrr], "%s", Board[ibuttonrr]);
  }
  gtk_widget_hide (window1);

  loadingw = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_position (GTK_WINDOW (loadingw), GTK_WIN_POS_CENTER);
  gtk_window_set_title (GTK_WINDOW (loadingw), "loading...");
  gtk_signal_connect (GTK_OBJECT (loadingw), "delete_event",
    GTK_SIGNAL_FUNC (Quit), NULL);
  gtk_window_set_policy (GTK_WINDOW (loadingw), 0, 0, 1);
  gtk_container_border_width (GTK_CONTAINER (loadingw), 0);
  gtk_widget_realize (loadingw);

  lbox1 = gtk_vbox_new (FALSE, 0);
  gtk_container_border_width (GTK_CONTAINER (lbox1), 0);
  gtk_container_add (GTK_CONTAINER (loadingw), lbox1);
  gtk_widget_show (lbox1);
  lbox2 = gtk_hbox_new (FALSE, 0);
  gtk_container_border_width (GTK_CONTAINER (lbox2), 0);
  gtk_box_pack_start (GTK_BOX (lbox1), lbox2, FALSE, FALSE, 0);
  gtk_widget_show (lbox2);
  ltable1 = gtk_table_new (1, 2, FALSE);
  gtk_box_pack_start (GTK_BOX (lbox2), ltable1, TRUE, TRUE, 0);
  gtk_widget_show (ltable1);

#ifdef USE_GNOME
  im9 = gdk_imlib_load_image (PKGDATADIR"pix/gologog.png");
#else
  im9 = gdk_imlib_load_image (PKGDATADIR"pix/gologo.png");
#endif
  w9 = im9->rgb_width;
  h9 = im9->rgb_height;
  gdk_imlib_render (im9, w9, h9);
  lpixmap = gdk_imlib_move_image (im9);
  lpixmapwid = gtk_pixmap_new (lpixmap, NULL);
  gtk_table_attach (GTK_TABLE (ltable1), lpixmapwid, 0, 1, 0, 1,
    GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (lpixmapwid);
  gdk_flush ();

  lbar = gtk_progress_bar_new ();
  gtk_table_attach (GTK_TABLE (ltable1), lbar, 0, 1, 1, 2,
    GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (lbar);

  gtk_widget_show (loadingw);
  while (gtk_events_pending ())
  {
    gtk_main_iteration ();
  }

  for (ibuttonrr = 1; ibuttonrr <= 361; ibuttonrr++)
  {
    PixmapOnButton (ibuttonrr);
    pvalue = lprogress (pvalue);
  }
  gtk_widget_destroy (loadingw);
  if (itooltips == 0)
  {
    itooltips = 1;
    Tooltips ();
  }
  gtk_widget_show (window1);
}
Ejemplo n.º 5
0
void 
ghack_menu_window_add_menu( GtkWidget *menuWin, gpointer menu_item,
			    gpointer data)
{
    GHackMenuItem*  item;
    GtkWidget	    *clist;
    gchar buf[BUFSZ]="", accelBuf[BUFSZ]="";
    gchar *pbuf;
    char *text[4] = { buf, NULL, NULL, NULL };
    gint nCurrentRow = -1, numItems = -1;
    MenuWinType isMenu;
    GtkStyle *bigStyle = NULL;
    gboolean item_selectable;
    GdkImlibImage* image;
    static gboolean special;

    g_assert (menu_item != NULL);
    item = (GHackMenuItem*) menu_item;
    item_selectable = ( item->identifier->a_int == 0)? FALSE : TRUE;
    isMenu = (MenuWinType) GPOINTER_TO_INT
    	(gtk_object_get_data (GTK_OBJECT (menuWin), "isMenu"));

    clist = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (menuWin), "clist"));
    g_assert (clist != NULL);
    /* This is a special kludge to make the special hidden help menu item work as designed */ 
    if ( special==TRUE ) {
	special=FALSE;
	item_selectable=TRUE;
    }
    if ( ! strcmp( item->str, "The NetHack license.")) {
	special=TRUE;
    }
    
    if (item->str) {

	/* First, make a new blank entry in the clist */
	nCurrentRow = gtk_clist_append (GTK_CLIST (clist), text);

	if (item->glyph != NO_GLYPH) {
	    image = ghack_image_from_glyph( item->glyph, FALSE);
	    if (image==NULL || image->pixmap==NULL) {
		g_warning("Bummer -- having to force rendering for glyph %d!", item->glyph);
		/* wierd -- pixmap is NULL so retry rendering it */
		image = ghack_image_from_glyph( item->glyph, TRUE);
	    }
	    if (image==NULL || image->pixmap==NULL) {
		    g_error("Aiiee! glyph is still NULL for item\n\"%s\"", 
			    item->str);
	    }
	    else 
		gtk_clist_set_pixmap (GTK_CLIST (clist), 
			nCurrentRow, 1, 
			gdk_imlib_move_image( image), 
			gdk_imlib_move_mask( image));
	}
	if (item->accelerator) {
	    /* FIXME: handle accelerator, */
	    g_snprintf(accelBuf, sizeof(accelBuf), "%c ", item->accelerator);
	    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 0, accelBuf);
	    g_snprintf(buf, sizeof(buf), "%s", item->str);
	    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 2, buf);
	} else {
	    if (item->group_accel) {
		/* FIXME: maybe some day I should try to handle 
		 * group accelerators... */
	    }
	    if (( (item->attr == 0) && (item->identifier->a_int != 0)) || (special ==TRUE) ) {
		numItems = GPOINTER_TO_INT( gtk_object_get_data(
			    GTK_OBJECT(clist), "numItems") )+1;

		/* Ok, now invent a unique accelerator */
		if (  ('a'+numItems) <= 'z' ) {
		    g_snprintf(accelBuf, sizeof(accelBuf), "%c ", 'a'+numItems);
		    gtk_clist_set_text(GTK_CLIST(clist), nCurrentRow, 0, accelBuf);
		}
		else if ( ('A'+numItems-26)<='Z') {
		    g_snprintf(accelBuf, sizeof(accelBuf), "%c ", 'A'+numItems-26); 
		    gtk_clist_set_text(GTK_CLIST(clist), nCurrentRow, 0, accelBuf);
		} else {
		    accelBuf[0] = buf[0] = 0;
		}
		g_snprintf(buf, sizeof(buf), "%s", item->str);
		gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 2, buf);
		gtk_object_set_data (GTK_OBJECT (clist), "numItems",
					GINT_TO_POINTER (numItems));

		/* This junk is to specially handle the options menu */
		pbuf = strstr( buf, " [");
		if (pbuf == NULL) {
		    pbuf = strstr( buf, "\t[");
		}
		if (pbuf != NULL) {
		    *pbuf=0;
		    pbuf++;
		    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 3, pbuf);
		}
	    }
	    /* FIXME: handle more than 26*2 accelerators (but how?
	     * since I only have so many keys to work with???)
	    else
	    {
		foo();
	    }
	    */
	    else {
		g_snprintf(buf, sizeof(buf), "%s", item->str);
		pbuf = strstr( buf, " [");
		if (pbuf == NULL) {
		    pbuf = strstr( buf, "\t[");
		}
		if (pbuf != NULL) {
		    *pbuf=0;
		    pbuf++;
		    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 3, pbuf);
		}
		gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 2, buf);
		
	    }
	}

	if (item->attr) {
	    switch(item->attr) {
		case ATR_ULINE:
		case ATR_BOLD:
		case ATR_BLINK:
		case ATR_INVERSE:
		    bigStyle = gtk_style_copy (GTK_WIDGET (clist)->style);
		    g_assert (bigStyle != NULL);
		    gdk_font_unref (bigStyle->font);
		    bigStyle->font = gdk_font_load (
				"-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
		    bigStyle->fg[GTK_STATE_NORMAL] = color_blue;
		    gtk_clist_set_cell_style (GTK_CLIST (clist), 
			    nCurrentRow, 2, bigStyle);
		    item_selectable = FALSE;
	    }
	}


	g_assert (nCurrentRow >= 0);
	gtk_clist_set_selectable (GTK_CLIST (clist), nCurrentRow,
			      item_selectable);

	if ( item_selectable==TRUE && item->presel== TRUE) {
	    /* pre-select this item */
	    gtk_clist_select_row( GTK_CLIST (clist), nCurrentRow, 0);
	}
	
	gtk_object_set_data (GTK_OBJECT (clist), "numRows",
		                GINT_TO_POINTER (nCurrentRow));
        
	/* We have to allocate memory here, since the menu_item currently
	 * lives on the stack, and will otherwise go to the great bit bucket 
	 * in the sky as soon as this function exits, which would leave a 
	 * pointer to crap in the row_data.  Use g_memdup to make a private, 
	 * persistant copy of the item identifier.
	 *
	 * We need to arrange to blow away this memory somewhere (like 
	 * ghack_menu_destroy and ghack_menu_window_clear for example).
	 *
	 *  -Erik
	 */
	{
	    menuItem newItem;
	    menuItem *pNewItem;
	    
	    newItem.identifier = *item->identifier;
	    newItem.itemNumber=nCurrentRow;
	    newItem.selected=FALSE;
	    newItem.accelerator[0]=0;
	    /* only copy 1 char, since accel keys are by definition 1 char */
	    if (accelBuf[0]) {
		strncpy(newItem.accelerator, accelBuf, 1);
	    }
	    newItem.accelerator[1]=0;

	    pNewItem = g_memdup(&newItem, sizeof( menuItem));
	    gtk_clist_set_row_data (GTK_CLIST (clist), nCurrentRow,
				    (gpointer) pNewItem);
	}
    }
    /* Now adjust the column widths to match the contents */
    gtk_clist_columns_autosize (GTK_CLIST (clist));
}
Ejemplo n.º 6
0
void OptionsX (void)
{
  if (ixdone == 1)
  {
    ixdone = 0;
    if (ioptionsx == 0)
    {
      ioptionsx = 1;
    }
    else
    {
      ioptionsx = 0;
    }

    gtk_container_remove (GTK_CONTAINER (changebutton), cbpixmapwid);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/1x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/1.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap = gdk_imlib_move_image (im3);
    cbpixmapwid = gtk_pixmap_new (cbpixmap, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton), cbpixmapwid);
    gtk_widget_show (cbpixmapwid);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton2), cbpixmapwid2);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/2x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/2.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap2 = gdk_imlib_move_image (im3);
    cbpixmapwid2 = gtk_pixmap_new (cbpixmap2, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton2), cbpixmapwid2);
    gtk_widget_show (cbpixmapwid2);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton3), cbpixmapwid3);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/3x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/3.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap3 = gdk_imlib_move_image (im3);
    cbpixmapwid3 = gtk_pixmap_new (cbpixmap3, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton3), cbpixmapwid3);
    gtk_widget_show (cbpixmapwid3);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton4), cbpixmapwid4);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/4x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/4.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap4 = gdk_imlib_move_image (im3);
    cbpixmapwid4 = gtk_pixmap_new (cbpixmap4, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton4), cbpixmapwid4);
    gtk_widget_show (cbpixmapwid4);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton5), cbpixmapwid5);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/5x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/5.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap5 = gdk_imlib_move_image (im3);
    cbpixmapwid5 = gtk_pixmap_new (cbpixmap5, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton5), cbpixmapwid5);
    gtk_widget_show (cbpixmapwid5);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebuttonx), cbpixmapwidx);
    if (ioptionsx == 1)
    {
    im3 = gdk_imlib_load_image (PKGDATADIR"pix/5bx.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/5b.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmapx = gdk_imlib_move_image (im3);
    cbpixmapwidx = gtk_pixmap_new (cbpixmapx, NULL);
    gtk_container_add (GTK_CONTAINER (changebuttonx), cbpixmapwidx);
    gtk_widget_show (cbpixmapwidx);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton6), cbpixmapwid6);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/6x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/6.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap6 = gdk_imlib_move_image (im3);
    cbpixmapwid6 = gtk_pixmap_new (cbpixmap6, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton6), cbpixmapwid6);
    gtk_widget_show (cbpixmapwid6);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton7), cbpixmapwid7);
    if ((ioptionsx == 1) && (itooltips == 1))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/6onx.png");
    }
    if ((ioptionsx == 1) && (itooltips == 0))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/6offx.png");
    }
    if ((ioptionsx == 0) && (itooltips == 1))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/6on.png");
    }
    if ((ioptionsx == 0) && (itooltips == 0))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/6off.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap7 = gdk_imlib_move_image (im3);
    cbpixmapwid7 = gtk_pixmap_new (cbpixmap7, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton7), cbpixmapwid7);
    gtk_widget_show (cbpixmapwid7);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton8), cbpixmapwid8);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/7x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/7.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap8 = gdk_imlib_move_image (im3);
    cbpixmapwid8 = gtk_pixmap_new (cbpixmap8, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton8), cbpixmapwid8);
    gtk_widget_show (cbpixmapwid8);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton9), cbpixmapwid9);
    if ((ioptionsx == 1) && (ishowlast == 1))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/7onx.png");
    }
    if ((ioptionsx == 1) && (ishowlast == 0))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/7offx.png");
    }
    if ((ioptionsx == 0) && (ishowlast == 1))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/7on.png");
    }
    if ((ioptionsx == 0) && (ishowlast == 0))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/7off.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap9 = gdk_imlib_move_image (im3);
    cbpixmapwid9 = gtk_pixmap_new (cbpixmap9, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton9), cbpixmapwid9);
    gtk_widget_show (cbpixmapwid9);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton10), cbpixmapwid10);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/8x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/8.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap10 = gdk_imlib_move_image (im3);
    cbpixmapwid10 = gtk_pixmap_new (cbpixmap10, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton10), cbpixmapwid10);
    gtk_widget_show (cbpixmapwid10);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton11), cbpixmapwid11);
    if ((ioptionsx == 1) && (isound == 1))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/8onx.png");
    }
    if ((ioptionsx == 1) && (isound == 0))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/8offx.png");
    }
    if ((ioptionsx == 0) && (isound == 1))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/8on.png");
    }
    if ((ioptionsx == 0) && (isound == 0))
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/8off.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap11 = gdk_imlib_move_image (im3);
    cbpixmapwid11 = gtk_pixmap_new (cbpixmap11, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton11), cbpixmapwid11);
    gtk_widget_show (cbpixmapwid11);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton12), cbpixmapwid12);
    if (ioptionsx == 1)
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/9x.png");
    }
    else
    {
      im3 = gdk_imlib_load_image (PKGDATADIR"pix/9.png");
    }
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap12 = gdk_imlib_move_image (im3);
    cbpixmapwid12 = gtk_pixmap_new (cbpixmap12, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton12), cbpixmapwid12);
    gtk_widget_show (cbpixmapwid12);
    gdk_flush ();

    gtk_container_remove (GTK_CONTAINER (changebutton13), cbpixmapwid13);
    if (ioptionsx == 1)
    {
      sprintf (cThePng3, PKGDATADIR"pix/9%ix.png", ihandicap);
    }
    else
    {
      sprintf (cThePng3, PKGDATADIR"pix/9%i.png", ihandicap);
    }
    im3 = gdk_imlib_load_image (cThePng3);
    w3 = im3->rgb_width;
    h3 = im3->rgb_height;
    gdk_imlib_render (im3, w3, h3);
    cbpixmap13 = gdk_imlib_move_image (im3);
    cbpixmapwid13 = gtk_pixmap_new (cbpixmap13, NULL);
    gtk_container_add (GTK_CONTAINER (changebutton13), cbpixmapwid13);
    gtk_widget_show (cbpixmapwid13);
    gdk_flush ();
    while (gtk_events_pending ())
    {
      gtk_main_iteration ();
    }
    ixdone = 1;
  }
}
Ejemplo n.º 7
0
/* load a map file or get it from the cache */
static struct pixmap_info *load_image_mtime(char *name,time_t *mtime  /*GdkWindow *win*/)
{
  GList *cached;
  struct cache_entry ce_search;
  struct cache_entry *ce;
  struct stat st;
  char filename[512];
#ifdef USE_IMLIB
  GdkPixmap *p;
  GdkImlibImage *im;
#else
  struct pixmap_info *p;
#endif

  cache_count++;
  ce_search.name=name;
  p=NULL;
 
  cached=g_list_find_custom(cache_list,
			    &ce_search,find_cache);
  if (cached)
    {
      ce=(struct cache_entry *)cached->data;
      if (ce) {
	ce->count=cache_count;
	if (mtime)
	  *mtime=ce->mtime;
	return ce->p;
      }
    }
  if (g_list_length(cache_list)>=MAX_CACHE)
    {
      GList *rem;
      cache_list=g_list_sort(cache_list,compare_cache);
      ce=(struct cache_entry *)g_list_nth_data(cache_list,0);
      if (ce->p)
#ifdef USE_IMLIB
	gdk_imlib_free_pixmap(ce->p);
#else
      free_pinfo(ce->p);
#endif
      /* printf("entferne %s\n",ce->name); */
      g_free(ce->name);
      g_free(ce);
      rem=g_list_first(cache_list);
      cache_list=g_list_remove_link(cache_list,rem);
      g_list_free(rem);
      
    }
  
    snprintf(filename,sizeof(filename),"%s.str", name);
    read_str_file(filename,name);
    snprintf(filename,sizeof(filename),"%s.png", name);
#ifndef USE_IMLIB
    p=load_gfxfile(filename);
    if (!p) {
      if (!stat(filename,&st)) {
	if (mtime)
	  *mtime=st.st_mtime;
	return NULL;
      }
      snprintf(filename,sizeof(filename),"%s.jpg", name);
      p=load_gfxfile(filename);
    }
#endif
#ifdef USE_IMLIB
    im=gdk_imlib_load_image(filename);
    if (im)
      break;
    snprintf(filename,sizeof(filename),"%s/%s.bmp",kartenpfad[i],
	     name);
    im=gdk_imlib_load_image(filename);
    if (im)
      break;
#endif
#ifdef USE_IMLIB
  if (!im)
    return NULL;
  w=im->rgb_width; h=im->rgb_height;
  if (!gdk_imlib_render(im,w,h)) {
    gdk_imlib_destroy_image(im);
    return NULL;
  }
  p=gdk_imlib_move_image(im);
  gdk_imlib_destroy_image(im);
#endif
  if (p) {
    struct stat st;
    ce=g_malloc(sizeof(struct cache_entry));
    ce->p=p;
    ce->name=g_strdup(name);
    ce->count=cache_count;
    cache_list=g_list_append(cache_list,ce);
    stat(filename,&st);
    ce->mtime=st.st_mtime;
    if (mtime)
	*mtime=ce->mtime;
  } else {
    if (!stat(filename,&st)) {
      if (mtime)
	*mtime=st.st_mtime;
      return NULL;
    }
      
  }
  
  return p;  
}