remove GTK1 specific font handling

svn path=/trunk/; revision=24842
This commit is contained in:
Ulf Lamping 2008-04-08 04:47:32 +00:00
parent 578c25b88f
commit df724f83cd
6 changed files with 30 additions and 60 deletions

View File

@ -1100,16 +1100,7 @@ init_prefs(void) {
prefs.filter_toolbar_show_in_statusbar = FALSE;
prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
#ifdef _WIN32
/* XXX - not sure, if it must be "Lucida Console" or "lucida console"
* for gui_font_name1. Maybe it's dependant on the windows version running?!
* verified on XP: "Lucida Console"
* unknown for other windows versions.
*
* Problem: if we have no preferences file, and the default font name is unknown,
* we cannot save Preferences as an error dialog pops up "You have not selected a font".
*/
prefs.gui_font_name1 = g_strdup("-*-Lucida Console-medium-r-*-*-*-100-*-*-*-*-*-*");
prefs.gui_font_name2 = g_strdup("Lucida Console 10");
prefs.gui_font_name = g_strdup("Lucida Console 10");
#else
/*
* XXX - for now, we make the initial font name a pattern that matches
@ -1156,9 +1147,9 @@ init_prefs(void) {
* protocol-tree, and hex-dump windows involves a lot more than, say,
* just using font sets rather than fonts.
*/
prefs.gui_font_name1 = g_strdup("-misc-fixed-medium-r-semicondensed-*-*-100-*-*-*-*-iso8859-1");
/* XXX - the above comment was about the GTK1 font stuff, just remove this comment now */
/* XXX- is this the correct default font name for GTK2 none win32? */
prefs.gui_font_name2 = g_strdup("Monospace 10");
prefs.gui_font_name = g_strdup("Monospace 10");
#endif
prefs.gui_marked_fg.pixel = 65535;
prefs.gui_marked_fg.red = 65535;
@ -1219,10 +1210,8 @@ prefs_reset(void)
if (prefs.pr_cmd)
g_free(prefs.pr_cmd);
free_col_info(&prefs);
if (prefs.gui_font_name1)
g_free(prefs.gui_font_name1);
if (prefs.gui_font_name2)
g_free(prefs.gui_font_name2);
if (prefs.gui_font_name)
g_free(prefs.gui_font_name);
if (prefs.gui_colorized_fg)
g_free(prefs.gui_colorized_fg);
if (prefs.gui_colorized_bg)
@ -1923,13 +1912,11 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
find_index_from_string_array(value, gui_toolbar_style_text,
TB_STYLE_ICONS);
} else if (strcmp(pref_name, PRS_GUI_FONT_NAME_1) == 0) {
if (prefs.gui_font_name1 != NULL)
g_free(prefs.gui_font_name1);
prefs.gui_font_name1 = g_strdup(value);
/* GTK1 font name obsolete */
} else if (strcmp(pref_name, PRS_GUI_FONT_NAME_2) == 0) {
if (prefs.gui_font_name2 != NULL)
g_free(prefs.gui_font_name2);
prefs.gui_font_name2 = g_strdup(value);
if (prefs.gui_font_name != NULL)
g_free(prefs.gui_font_name);
prefs.gui_font_name = g_strdup(value);
} else if (strcmp(pref_name, PRS_GUI_MARKED_FG) == 0) {
cval = strtoul(value, NULL, 16);
prefs.gui_marked_fg.pixel = 0;
@ -2724,11 +2711,8 @@ write_prefs(char **pf_path_return)
fprintf (pf, "\n######## User Interface: Font ########\n");
fprintf(pf, "\n# Font name for packet list, protocol tree, and hex dump panes (GTK version 1).\n");
fprintf(pf, PRS_GUI_FONT_NAME_1 ": %s\n", prefs.gui_font_name1);
fprintf(pf, "\n# Font name for packet list, protocol tree, and hex dump panes (GTK version 2).\n");
fprintf(pf, PRS_GUI_FONT_NAME_2 ": %s\n", prefs.gui_font_name2);
fprintf(pf, "\n# Font name for packet list, protocol tree, and hex dump panes.\n");
fprintf(pf, PRS_GUI_FONT_NAME_2 ": %s\n", prefs.gui_font_name);
fprintf (pf, "\n######## User Interface: Colors ########\n");
@ -2923,8 +2907,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
dest->gui_layout_content_1 = src->gui_layout_content_1;
dest->gui_layout_content_2 = src->gui_layout_content_2;
dest->gui_layout_content_3 = src->gui_layout_content_3;
dest->gui_font_name1 = g_strdup(src->gui_font_name1);
dest->gui_font_name2 = g_strdup(src->gui_font_name2);
dest->gui_font_name = g_strdup(src->gui_font_name);
dest->gui_marked_fg = src->gui_marked_fg;
dest->gui_marked_bg = src->gui_marked_bg;
dest->gui_geometry_save_position = src->gui_geometry_save_position;
@ -2959,13 +2942,9 @@ free_prefs(e_prefs *pr)
pr->pr_cmd = NULL;
}
free_col_info(pr);
if (pr->gui_font_name1 != NULL) {
g_free(pr->gui_font_name1);
pr->gui_font_name1 = NULL;
}
if (pr->gui_font_name2 != NULL) {
g_free(pr->gui_font_name2);
pr->gui_font_name2 = NULL;
if (pr->gui_font_name != NULL) {
g_free(pr->gui_font_name);
pr->gui_font_name = NULL;
}
if (pr->gui_fileopen_dir != NULL) {
g_free(pr->gui_fileopen_dir);

View File

@ -41,14 +41,6 @@
#define RTP_PLAYER_DEFAULT_VISIBLE 4
/* only GTK1 *or* GTK2 font_name should be used */
/* (we need to keep both in the preferences file but will only use the one suitable for the programs GTK version used) */
#if GTK_MAJOR_VERSION < 2
#define PREFS_GUI_FONT_NAME gui_font_name1
#else
#define PREFS_GUI_FONT_NAME gui_font_name2
#endif
/*
* Convert a string listing name resolution types to a bitmask of
* those types.
@ -122,8 +114,7 @@ typedef struct _e_prefs {
gint gui_ptree_expander_style;
gboolean gui_hex_dump_highlight_style;
gint gui_toolbar_main_style;
gchar *gui_font_name1;
gchar *gui_font_name2;
gchar *gui_font_name;
color_t gui_marked_fg;
color_t gui_marked_bg;
gchar *gui_colorized_fg;

View File

@ -245,7 +245,7 @@ user_font_apply(void) {
FONT_TYPE *old_r_font = NULL, *old_b_font = NULL;
/* convert font name to reflect the zoom level */
gui_font_name = font_zoom(prefs.PREFS_GUI_FONT_NAME);
gui_font_name = font_zoom(prefs.gui_font_name);
if (gui_font_name == NULL) {
/*
* This means the font name isn't an XLFD font name.
@ -400,20 +400,20 @@ void font_init(void)
#endif
/* Try to load the regular and boldface fixed-width fonts */
m_r_font = pango_font_description_from_string(prefs.gui_font_name2);
m_r_font = pango_font_description_from_string(prefs.gui_font_name);
m_b_font = pango_font_description_copy(m_r_font);
pango_font_description_set_weight(m_b_font, PANGO_WEIGHT_BOLD);
if (m_r_font == NULL || m_b_font == NULL) {
/* XXX - pop this up as a dialog box? no */
if (m_r_font == NULL) {
fprintf(stderr, "wireshark: Warning: font %s not found - defaulting to Monospace 9\n",
prefs.gui_font_name2);
prefs.gui_font_name);
} else {
pango_font_description_free(m_r_font);
}
if (m_b_font == NULL) {
fprintf(stderr, "wireshark: Warning: bold font %s not found - defaulting"
" to Monospace 9\n", prefs.gui_font_name2);
" to Monospace 9\n", prefs.gui_font_name);
} else {
pango_font_description_free(m_b_font);
}
@ -426,9 +426,9 @@ void font_init(void)
fprintf(stderr, "wireshark: Error: font Monospace 9 bold not found\n");
exit(1);
}
g_free(prefs.gui_font_name2);
g_free(prefs.gui_font_name);
pango_font_description_set_weight(m_b_font, PANGO_WEIGHT_BOLD);
prefs.gui_font_name2 = g_strdup("Monospace 9");
prefs.gui_font_name = g_strdup("Monospace 9");
}
/* Call this for the side-effects that set_fonts() produces */

View File

@ -397,11 +397,11 @@ gui_prefs_fetch(GtkWidget *w)
* places where there *can* be a bad preference value.
*/
if (font_fetch()) {
if (strcmp(new_font_name, prefs.PREFS_GUI_FONT_NAME) != 0) {
if (strcmp(new_font_name, prefs.gui_font_name) != 0) {
font_changed = TRUE;
if (prefs.PREFS_GUI_FONT_NAME != NULL)
g_free(prefs.PREFS_GUI_FONT_NAME);
prefs.PREFS_GUI_FONT_NAME = g_strdup(new_font_name);
if (prefs.gui_font_name != NULL)
g_free(prefs.gui_font_name);
prefs.gui_font_name = g_strdup(new_font_name);
}
}
}

View File

@ -2674,9 +2674,9 @@ main(int argc, char *argv[])
#endif
break;
case 'm': /* Fixed-width font for the display */
if (prefs->PREFS_GUI_FONT_NAME != NULL)
g_free(prefs->PREFS_GUI_FONT_NAME);
prefs->PREFS_GUI_FONT_NAME = g_strdup(optarg);
if (prefs->gui_font_name != NULL)
g_free(prefs->gui_font_name);
prefs->gui_font_name = g_strdup(optarg);
break;
case 'n': /* No name resolution */
g_resolv_flags = RESOLV_NONE;

View File

@ -546,7 +546,7 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
a fix; hopefully, it'll show up in 1.2.9 if, as, and when
they put out a 1.2.9 release. */
gtk_font_selection_set_font_name(
GTK_FONT_SELECTION(gui_font_pg), prefs.PREFS_GUI_FONT_NAME);
GTK_FONT_SELECTION(gui_font_pg), prefs.gui_font_name);
/* GUI Colors prefs */
g_strlcpy(label_str, "Colors", MAX_TREE_NODE_NAME_LEN);