Re: gtk question from a gtk lamer



I'm back!

I've done everything that I can think to do on the same-gnome preview
project.  From my careful cribbing from the imlib sources and the other
place in same-gnome where themes are loaded, my belief is that the
enclosed patch should work.

Can someone please enlighten me as to why, when the following patch is
applied to gnome-games/same-gnome/same-gnome.c, it does not have the
desired effect, i.e., that a frame is plucked from the .png file and
thrown into the chooser widget as a preview?

When you select a theme, there is a significant pause which indicates,
to me, that the theme is being parsed internally, a supposition which
my now-removed debugging code also verified.

1) /opt/gnome is hardcoded; search for FIXME
2) I chose "STONE_SIZE * 3" as the 4th and 5th args to gdk_draw_pixmap
	as a mildly-informed guess.  Caveat.

I'm sure that it's an obvious mistake on my part, so apologies in
advance for wasting people's time.  I'm not a very good programmer,
but I do want previews in same-gnome, so here you go.

TIA for any tips people can give.

--
Todd Graham Lewis            3249'N,8336'W          (800) 719-4664, x2804
******Linux******         MindSpring Enterprises      tlewis@mindspring.net
--- same-gnome.c.orig	Mon Nov  9 04:28:22 1998
+++ same-gnome.c	Mon Nov  9 04:31:39 1998
@@ -52,6 +52,8 @@
 	int frame;
 } field [STONE_COLS][STONE_LINES];
 
+static GtkWidget *pv;
+
 static int nstones;
 static int ncolors;
 static int sync_stones = 0;
@@ -429,8 +431,28 @@
 }
 
 static void
+set_selection_preview (char *name)
+{
+	char *foo;
+	static GdkImlibImage *pvimage;
+	GdkPixmap *pvp;
+
+	/* FIXME: hardcoded */
+	foo=g_copy_strings("/opt/gnome/share/pixmaps/same-gnome/", name, NULL);
+	pvimage=gdk_imlib_load_image(foo);
+	gdk_imlib_render(pvimage,STONE_SIZE,STONE_SIZE);
+	pvp=gdk_imlib_move_image(pvimage);
+	gdk_draw_pixmap(pv->window, \
+		pv->style->black_gc, \
+		pvp, STONE_SIZE * 3, STONE_SIZE * 3, STONE_SIZE, \
+		STONE_SIZE, STONE_SIZE, STONE_SIZE);
+}
+
+static void
 set_selection (GtkWidget *widget, void *data)
 {
+	/* printf("New selection is %s.\n", data); */
+	set_selection_preview(data);
 	selected_scenario.scenario = data;
 }
 
@@ -577,6 +599,10 @@
 	gtk_box_pack_start_defaults (GTK_BOX(hb), l);
 	gtk_box_pack_start_defaults (GTK_BOX(hb), omenu);
 
+	pv = gtk_drawing_area_new();
+	gtk_drawing_area_size (GTK_DRAWING_AREA (pv), STONE_SIZE, STONE_SIZE);
+	gtk_widget_show(pv);
+
 	cb = gtk_check_button_new_with_label ( _("Make it the default scenario") );
 	gtk_signal_connect (GTK_OBJECT(cb), "clicked", (GtkSignalFunc)set_selection_def, NULL);
 	gtk_widget_show (cb);
@@ -585,6 +611,7 @@
 	gtk_container_border_width (GTK_CONTAINER (fv), 5);
 	gtk_widget_show (fv);
 	
+	gtk_box_pack_start_defaults (GTK_BOX(fv), pv);
 	gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
 	gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
 	gtk_box_pack_start_defaults (GTK_BOX(d->vbox), f);
@@ -605,6 +632,7 @@
         gtk_widget_show(button);
 
         gtk_widget_show (pref_dialog);
+	set_selection_preview("stones.png");
 }
 
 static int


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]