MCPcopy Create free account
hub / github.com/NetHack/NetHack / ghack_menu_window_add_menu

Function ghack_menu_window_add_menu

outdated/win/gnome/gnmenu.c:267–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267void
268ghack_menu_window_add_menu(GtkWidget *menuWin, gpointer menu_item,
269 gpointer data)
270{
271 GHackMenuItem *item;
272 GtkWidget *clist;
273 gchar buf[BUFSZ] = "", accelBuf[BUFSZ] = "";
274 gchar *pbuf;
275 char *text[4] = { buf, NULL, NULL, NULL };
276 gint nCurrentRow = -1, numItems = -1;
277 MenuWinType isMenu;
278 GtkStyle *bigStyle = NULL;
279 gboolean item_selectable;
280 GdkImlibImage *image;
281 static gboolean special;
282
283 g_assert(menu_item != NULL);
284 item = (GHackMenuItem *) menu_item;
285 item_selectable = (item->identifier->a_int == 0) ? FALSE : TRUE;
286 isMenu = (MenuWinType) GPOINTER_TO_INT(
287 gtk_object_get_data(GTK_OBJECT(menuWin), "isMenu"));
288
289 clist = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(menuWin), "clist"));
290 g_assert(clist != NULL);
291 /* This is a special kludge to make the special hidden help menu item work
292 * as designed */
293 if (special == TRUE) {
294 special = FALSE;
295 item_selectable = TRUE;
296 }
297 if (!strcmp(item->str, "The NetHack license.")) {
298 special = TRUE;
299 }
300
301 if (item->str) {
302 /* First, make a new blank entry in the clist */
303 nCurrentRow = gtk_clist_append(GTK_CLIST(clist), text);
304
305 if (item->glyph != NO_GLYPH) {
306 image = ghack_image_from_glyph(item->glyph, FALSE);
307 if (image == NULL || image->pixmap == NULL) {
308 g_warning("Bummer -- having to force rendering for glyph %d!",
309 item->glyph);
310 /* wierd -- pixmap is NULL so retry rendering it */
311 image = ghack_image_from_glyph(item->glyph, TRUE);
312 }
313 if (image == NULL || image->pixmap == NULL) {
314 g_error("Aiiee! glyph is still NULL for item\n\"%s\"",
315 item->str);
316 } else
317 gtk_clist_set_pixmap(GTK_CLIST(clist), nCurrentRow, 1,
318 gdk_imlib_move_image(image),
319 gdk_imlib_move_mask(image));
320 }
321 if (item->accelerator) {
322 /* FIXME: handle accelerator, */
323 g_snprintf(accelBuf, sizeof(accelBuf), "%c ", item->accelerator);
324 gtk_clist_set_text(GTK_CLIST(clist), nCurrentRow, 0, accelBuf);

Callers

nothing calls this directly

Calls 1

ghack_image_from_glyphFunction · 0.85

Tested by

no test coverage detected