Programming Tidbits
This page lists various things I got stuck with and needed an answer for. It is a both a place for me to save the information and a way to let others find it in their web searches.
How do I get the name of a GdkFont?
I've found the answer in the gabber package, in it there is an e-font.[hc] it has the following function in it:
/*
* Return newly allocated full name
*/
static gchar *
get_font_name (const GdkFont * font)
{
Atom font_atom, atom;
Bool status;
gint i;
g_print ("Extracting X font info\n");
font_atom = gdk_atom_intern ("FONT", FALSE);
if (font->type == GDK_FONT_FONTSET) {
XFontStruct **font_structs;
gint num_fonts;
gchar **font_names;
num_fonts = XFontsOfFontSet (GDK_FONT_XFONT (font), &font_structs, &font_names);
g_print ("Fonts of fontset:\n");
for (i = 0; i < num_fonts; i++) g_print (" %s\n", font_names[i]);
status = XGetFontProperty (font_structs[0], font_atom, &atom);
} else {
status = XGetFontProperty (GDK_FONT_XFONT (font), font_atom, &atom);
}
if (status) {
return gdk_atom_name (atom);
}
return NULL;
}
How to make the dialog modal?
In order to make the dialog modal you need to do (gtkmm):
dialog.set_modal(true); dialog.show(); Gtk::Main::run();
and put in the method that handles the ok and cancel buttons:
dialog.hide(); Gtk::Main::quit();
Don't worry, this will only quit the inner most loop and not the main application loop.
