/* gui_prefs.c
* Dialog box for GUI preferences
*
- * $Id: gui_prefs.c,v 1.59 2004/01/23 20:13:23 guy Exp $
+ * $Id: gui_prefs.c,v 1.60 2004/01/24 01:02:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include "packet_list.h"
#include "compat_macros.h"
#include "toolbar.h"
+#include "recent.h"
static gint fetch_enum_value(gpointer control, const enum_val_t *enumvals);
static gint fileopen_dir_changed_cb(GtkWidget *myentry _U_, GdkEvent *event, gpointer parent_w);
if (font_changed) {
/* This redraws the hex dump windows. */
- font_apply();
+ switch (font_apply()) {
+
+ case FA_SUCCESS:
+ break;
+
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "font_apply()" popped up an alert box. */
+ /* turn off zooming - font can't be resized */
+ recent.gui_zoom_level = 0;
+ break;
+
+ case FA_FONT_NOT_AVAILABLE:
+ /* We assume this means that the specified size
+ isn't available. */
+ simple_dialog(ESD_TYPE_CRIT, NULL,
+ "That font font isn't available at the specified zoom level;\n"
+ "turning zooming off.");
+ recent.gui_zoom_level = 0;
+ break;
+ }
} else {
/* Redraw the hex dump windows, in case the
highlight style changed.
/* main.c
*
- * $Id: main.c,v 1.371 2004/01/23 21:22:18 guy Exp $
+ * $Id: main.c,v 1.372 2004/01/24 01:02:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
void
view_zoom_in_cb(GtkWidget *w _U_, gpointer d _U_)
{
+ gint save_gui_zoom_level;
+ save_gui_zoom_level = recent.gui_zoom_level;
recent.gui_zoom_level++;
- font_apply();
+ switch (font_apply()) {
+
+ case FA_SUCCESS:
+ break;
+
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "font_apply()" popped up an alert box. */
+ recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
+ break;
+
+ case FA_FONT_NOT_AVAILABLE:
+ /* We assume this means that the specified size isn't available. */
+ simple_dialog(ESD_TYPE_CRIT, NULL,
+ "Your current font isn't available in the next larger size.\n");
+ recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
+ break;
+ }
}
void
view_zoom_out_cb(GtkWidget *w _U_, gpointer d _U_)
{
+ gint save_gui_zoom_level;
+ save_gui_zoom_level = recent.gui_zoom_level;
recent.gui_zoom_level--;
- font_apply();
+ switch (font_apply()) {
+
+ case FA_SUCCESS:
+ break;
+
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "font_apply()" popped up an alert box. */
+ recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
+ break;
+
+ case FA_FONT_NOT_AVAILABLE:
+ /* We assume this means that the specified size isn't available. */
+ simple_dialog(ESD_TYPE_CRIT, NULL,
+ "Your current font isn't available in the next smaller size.\n");
+ recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
+ break;
+ }
}
void
view_zoom_100_cb(GtkWidget *w _U_, gpointer d _U_)
{
+ gint save_gui_zoom_level;
+ save_gui_zoom_level = recent.gui_zoom_level;
recent.gui_zoom_level = 0;
- font_apply();
+ switch (font_apply()) {
+
+ case FA_SUCCESS:
+ break;
+
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "font_apply()" popped up an alert box. */
+ recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
+ break;
+
+ case FA_FONT_NOT_AVAILABLE:
+ /* We assume this means that the specified size isn't available.
+ XXX - this "shouldn't happen". */
+ simple_dialog(ESD_TYPE_CRIT, NULL,
+ "Your current font couldn't be reloaded at the size you selected.\n");
+ recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
+ break;
+ }
}
return g_strdup(new_font_name);
}
-void
+fa_ret_t
font_apply(void) {
char *gui_font_name;
#if GTK_MAJOR_VERSION < 2
* We just report that for now as a font not available in
* multiple sizes.
*/
- simple_dialog(ESD_TYPE_WARN, NULL,
- "Your current font isn't available in any other sizes.\n"
- "Please update your font setting in Edit->Preferences!");
- return;
+ simple_dialog(ESD_TYPE_CRIT, NULL,
+ "Your current font isn't available in any other sizes.\n");
+ return FA_FONT_NOT_RESIZEABLE;
}
#if GTK_MAJOR_VERSION < 2
pango_font_description_set_weight(new_b_font, PANGO_WEIGHT_BOLD);
#endif
if (new_r_font == NULL || new_b_font == NULL) {
- simple_dialog(ESD_TYPE_WARN, NULL,
- "Font name: \"%s\" invalid, cannot load font!",
- gui_font_name);
/* We're no longer using the new fonts; unreference them. */
#if GTK_MAJOR_VERSION < 2
if (new_r_font != NULL)
pango_font_description_free(new_b_font);
#endif
g_free(gui_font_name);
- return;
+
+ /* We let our caller pop up a dialog box, as the error message
+ depends on the context (did they zoom in or out, or did they
+ do something else? */
+ return FA_FONT_NOT_AVAILABLE;
}
/* the font(s) seem to be ok */
pango_font_description_free(old_b_font);
#endif
g_free(gui_font_name);
+ return FA_SUCCESS;
}
* Recent "preference" handling routines
* Copyright 2004, Ulf Lamping <ulf.lamping@web.de>
*
- * $Id: recent.c,v 1.5 2004/01/20 18:47:25 ulfl Exp $
+ * $Id: recent.c,v 1.6 2004/01/24 01:02:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
}
menu_recent_read_finished();
- font_apply();
+
+ switch (font_apply()) {
+
+ case FA_SUCCESS:
+ break;
+
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "font_apply()" popped up an alert box. */
+ recent.gui_zoom_level = 0; /* turn off zooming - font can't be resized */
+ break;
+
+ case FA_FONT_NOT_AVAILABLE:
+ /* XXX - did we successfully load the un-zoomed version earlier?
+ If so, this *probably* means the font is available, but not at
+ this particular zoom level, but perhaps some other failure
+ occurred; I'm not sure you can determine which is the case,
+ however. */
+ recent.gui_zoom_level = 0; /* turn off zooming - zoom level is unavailable */
+ break;
+ }
}