1999-09-09 04:25:49 +00:00
|
|
|
/* print_prefs.c
|
|
|
|
* Dialog boxes for preferences for printing
|
|
|
|
*
|
We need to catch a "window delete" event for the preferences dialog box
- that event happens if, say, you nuke the dialog box from a window
manager - and call "delete" routines for each of the preferences tabs,
so that, for preferences tabs that include list widgets, we can set a
flag on the preferences tab widget telling the selection callback for
the list widget that the buttons it would normally set the sensitivity
of, based on whether any row in the list is selected or not, have Joined
the Choir Invisible, and therefore that we shouldn't change their
sensitivity because GTK+ will whine at us if we do, just as is the case
if we press the "OK" or "Cancel" button (which also cause the window to
go away).
Can we just do this in the "window delete" handler? I.e., does that get
called if we explicitly destroy the widget? Or should we catch a
"destroy" event instead?
(There must be a better way to do this....)
svn path=/trunk/; revision=647
1999-09-10 06:53:32 +00:00
|
|
|
* $Id: print_prefs.c,v 1.4 1999/09/10 06:53:31 guy Exp $
|
1999-09-09 04:25:49 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
1999-09-01 03:04:24 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#ifndef __GLOBALS_H__
|
|
|
|
#include "globals.h"
|
|
|
|
#endif
|
|
|
|
|
We need to catch a "window delete" event for the preferences dialog box
- that event happens if, say, you nuke the dialog box from a window
manager - and call "delete" routines for each of the preferences tabs,
so that, for preferences tabs that include list widgets, we can set a
flag on the preferences tab widget telling the selection callback for
the list widget that the buttons it would normally set the sensitivity
of, based on whether any row in the list is selected or not, have Joined
the Choir Invisible, and therefore that we shouldn't change their
sensitivity because GTK+ will whine at us if we do, just as is the case
if we press the "OK" or "Cancel" button (which also cause the window to
go away).
Can we just do this in the "window delete" handler? I.e., does that get
called if we explicitly destroy the widget? Or should we catch a
"destroy" event instead?
(There must be a better way to do this....)
svn path=/trunk/; revision=647
1999-09-10 06:53:32 +00:00
|
|
|
#include "print_prefs.h"
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
#ifndef __KEYS_H__
|
|
|
|
#include "keys.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PRINT_H__
|
|
|
|
#include "print.h"
|
|
|
|
#endif
|
|
|
|
|
1999-09-09 03:32:03 +00:00
|
|
|
#ifndef __PREFS_DLG_H__
|
|
|
|
#include "prefs_dlg.h"
|
1999-09-01 03:04:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __UTIL_H__
|
|
|
|
#include "util.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void printer_opts_file_cb(GtkWidget *w, gpointer te);
|
|
|
|
static void printer_opts_fs_cancel_cb(GtkWidget *w, gpointer data);
|
|
|
|
static void printer_opts_fs_ok_cb(GtkWidget *w, gpointer data);
|
|
|
|
static void printer_opts_toggle_format(GtkWidget *widget, gpointer data);
|
|
|
|
static void printer_opts_toggle_dest(GtkWidget *widget, gpointer data);
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget * printer_prefs_show()
|
|
|
|
{
|
|
|
|
GtkWidget *main_vb, *main_tb, *button;
|
|
|
|
GtkWidget *format_hb, *format_lb;
|
|
|
|
GtkWidget *dest_hb, *dest_lb;
|
|
|
|
GtkWidget *cmd_lb, *cmd_te;
|
|
|
|
GtkWidget *file_bt_hb, *file_bt, *file_te;
|
|
|
|
GSList *format_grp, *dest_grp;
|
|
|
|
|
|
|
|
/* Enclosing containers for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 5);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
|
|
|
|
main_tb = gtk_table_new(4, 2, FALSE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
|
|
|
|
gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
|
|
|
|
gtk_widget_show(main_tb);
|
|
|
|
|
|
|
|
/* Output format */
|
|
|
|
format_lb = gtk_label_new("Format:");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(format_lb), 1.0, 0.5);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), format_lb, 0, 1, 0, 1);
|
|
|
|
gtk_widget_show(format_lb);
|
|
|
|
|
|
|
|
format_hb = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), format_hb, 1, 2, 0, 1);
|
|
|
|
gtk_widget_show(format_hb);
|
|
|
|
|
|
|
|
button = gtk_radio_button_new_with_label(NULL, "Plain Text");
|
|
|
|
if (prefs.pr_format == PR_FMT_TEXT) {
|
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
|
|
|
|
}
|
|
|
|
format_grp = gtk_radio_button_group(GTK_RADIO_BUTTON(button));
|
|
|
|
gtk_box_pack_start(GTK_BOX(format_hb), button, FALSE, FALSE, 10);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
button = gtk_radio_button_new_with_label(format_grp, "PostScript");
|
|
|
|
if (prefs.pr_format == PR_FMT_PS) {
|
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
|
|
|
|
}
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
|
|
|
GTK_SIGNAL_FUNC(printer_opts_toggle_format), NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(format_hb), button, FALSE, FALSE, 10);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
/* Output destination */
|
|
|
|
dest_lb = gtk_label_new("Print to:");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(dest_lb), 1.0, 0.5);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), dest_lb, 0, 1, 1, 2);
|
|
|
|
gtk_widget_show(dest_lb);
|
|
|
|
|
|
|
|
dest_hb = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), dest_hb, 1, 2, 1, 2);
|
|
|
|
gtk_widget_show(dest_hb);
|
|
|
|
|
|
|
|
button = gtk_radio_button_new_with_label(NULL, "Command");
|
|
|
|
if (prefs.pr_dest == PR_DEST_CMD) {
|
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
|
|
|
|
}
|
|
|
|
dest_grp = gtk_radio_button_group(GTK_RADIO_BUTTON(button));
|
|
|
|
gtk_box_pack_start(GTK_BOX(dest_hb), button, FALSE, FALSE, 10);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
button = gtk_radio_button_new_with_label(dest_grp, "File");
|
|
|
|
if (prefs.pr_dest == PR_DEST_FILE) {
|
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
|
|
|
|
}
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
|
|
|
GTK_SIGNAL_FUNC(printer_opts_toggle_dest), NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(dest_hb), button, FALSE, FALSE, 10);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
/* Command text entry */
|
|
|
|
cmd_lb = gtk_label_new("Command:");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(cmd_lb), 1.0, 0.5);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), cmd_lb, 0, 1, 2, 3);
|
|
|
|
gtk_widget_show(cmd_lb);
|
|
|
|
|
|
|
|
cmd_te = gtk_entry_new();
|
|
|
|
gtk_object_set_data(GTK_OBJECT(main_vb), PRINT_CMD_TE_KEY, cmd_te);
|
|
|
|
if (prefs.pr_cmd) gtk_entry_set_text(GTK_ENTRY(cmd_te), prefs.pr_cmd);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), cmd_te, 1, 2, 2, 3);
|
|
|
|
gtk_widget_show(cmd_te);
|
|
|
|
|
|
|
|
/* File button and text entry */
|
|
|
|
file_bt_hb = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), file_bt_hb, 0, 1, 3, 4);
|
|
|
|
gtk_widget_show(file_bt_hb);
|
|
|
|
|
|
|
|
file_bt = gtk_button_new_with_label("File:");
|
|
|
|
gtk_box_pack_end(GTK_BOX(file_bt_hb), file_bt, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(file_bt);
|
|
|
|
|
|
|
|
file_te = gtk_entry_new();
|
|
|
|
gtk_object_set_data(GTK_OBJECT(main_vb), PRINT_FILE_TE_KEY, file_te);
|
|
|
|
if (prefs.pr_file) gtk_entry_set_text(GTK_ENTRY(file_te), prefs.pr_file);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), file_te, 1, 2, 3, 4);
|
|
|
|
gtk_widget_show(file_te);
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(file_bt), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(printer_opts_file_cb), GTK_OBJECT(file_te));
|
|
|
|
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
return(main_vb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_opts_file_cb(GtkWidget *file_bt, gpointer file_te) {
|
|
|
|
GtkWidget *fs;
|
|
|
|
|
|
|
|
fs = gtk_file_selection_new ("Ethereal: Print to a File");
|
|
|
|
gtk_object_set_data(GTK_OBJECT(fs), PRINT_FILE_TE_KEY, file_te);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(fs)->ok_button),
|
|
|
|
"clicked", (GtkSignalFunc) printer_opts_fs_ok_cb, fs);
|
|
|
|
|
|
|
|
/* Connect the cancel_button to destroy the widget */
|
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(fs)->cancel_button),
|
|
|
|
"clicked", (GtkSignalFunc) printer_opts_fs_cancel_cb, fs);
|
|
|
|
|
|
|
|
gtk_widget_show(fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_opts_fs_ok_cb(GtkWidget *w, gpointer data) {
|
|
|
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(gtk_object_get_data(GTK_OBJECT(data),
|
|
|
|
PRINT_FILE_TE_KEY)),
|
|
|
|
gtk_file_selection_get_filename (GTK_FILE_SELECTION(data)));
|
|
|
|
printer_opts_fs_cancel_cb(w, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_opts_fs_cancel_cb(GtkWidget *w, gpointer data) {
|
|
|
|
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
printer_prefs_ok(GtkWidget *w)
|
|
|
|
{
|
|
|
|
if(prefs.pr_cmd) g_free(prefs.pr_cmd);
|
|
|
|
prefs.pr_cmd =
|
|
|
|
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_object_get_data(GTK_OBJECT(w),
|
|
|
|
PRINT_CMD_TE_KEY))));
|
|
|
|
|
|
|
|
if(prefs.pr_file) g_free(prefs.pr_file);
|
|
|
|
prefs.pr_file =
|
|
|
|
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_object_get_data(GTK_OBJECT(w),
|
|
|
|
PRINT_FILE_TE_KEY))));
|
We need to catch a "window delete" event for the preferences dialog box
- that event happens if, say, you nuke the dialog box from a window
manager - and call "delete" routines for each of the preferences tabs,
so that, for preferences tabs that include list widgets, we can set a
flag on the preferences tab widget telling the selection callback for
the list widget that the buttons it would normally set the sensitivity
of, based on whether any row in the list is selected or not, have Joined
the Choir Invisible, and therefore that we shouldn't change their
sensitivity because GTK+ will whine at us if we do, just as is the case
if we press the "OK" or "Cancel" button (which also cause the window to
go away).
Can we just do this in the "window delete" handler? I.e., does that get
called if we explicitly destroy the widget? Or should we catch a
"destroy" event instead?
(There must be a better way to do this....)
svn path=/trunk/; revision=647
1999-09-10 06:53:32 +00:00
|
|
|
|
|
|
|
printer_prefs_delete(w);
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
printer_prefs_save(GtkWidget *w)
|
|
|
|
{
|
|
|
|
printer_prefs_ok(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
printer_prefs_cancel(GtkWidget *w)
|
We need to catch a "window delete" event for the preferences dialog box
- that event happens if, say, you nuke the dialog box from a window
manager - and call "delete" routines for each of the preferences tabs,
so that, for preferences tabs that include list widgets, we can set a
flag on the preferences tab widget telling the selection callback for
the list widget that the buttons it would normally set the sensitivity
of, based on whether any row in the list is selected or not, have Joined
the Choir Invisible, and therefore that we shouldn't change their
sensitivity because GTK+ will whine at us if we do, just as is the case
if we press the "OK" or "Cancel" button (which also cause the window to
go away).
Can we just do this in the "window delete" handler? I.e., does that get
called if we explicitly destroy the widget? Or should we catch a
"destroy" event instead?
(There must be a better way to do this....)
svn path=/trunk/; revision=647
1999-09-10 06:53:32 +00:00
|
|
|
{
|
|
|
|
printer_prefs_delete(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
printer_prefs_delete(GtkWidget *w)
|
1999-09-01 03:04:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_opts_toggle_format(GtkWidget *widget, gpointer data)
|
|
|
|
{
|
We need to catch a "window delete" event for the preferences dialog box
- that event happens if, say, you nuke the dialog box from a window
manager - and call "delete" routines for each of the preferences tabs,
so that, for preferences tabs that include list widgets, we can set a
flag on the preferences tab widget telling the selection callback for
the list widget that the buttons it would normally set the sensitivity
of, based on whether any row in the list is selected or not, have Joined
the Choir Invisible, and therefore that we shouldn't change their
sensitivity because GTK+ will whine at us if we do, just as is the case
if we press the "OK" or "Cancel" button (which also cause the window to
go away).
Can we just do this in the "window delete" handler? I.e., does that get
called if we explicitly destroy the widget? Or should we catch a
"destroy" event instead?
(There must be a better way to do this....)
svn path=/trunk/; revision=647
1999-09-10 06:53:32 +00:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active) {
|
|
|
|
prefs.pr_format = PR_FMT_PS;
|
|
|
|
/* toggle file/cmd */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prefs.pr_format = PR_FMT_TEXT;
|
|
|
|
/* toggle file/cmd */
|
|
|
|
}
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_opts_toggle_dest(GtkWidget *widget, gpointer data)
|
|
|
|
{
|
We need to catch a "window delete" event for the preferences dialog box
- that event happens if, say, you nuke the dialog box from a window
manager - and call "delete" routines for each of the preferences tabs,
so that, for preferences tabs that include list widgets, we can set a
flag on the preferences tab widget telling the selection callback for
the list widget that the buttons it would normally set the sensitivity
of, based on whether any row in the list is selected or not, have Joined
the Choir Invisible, and therefore that we shouldn't change their
sensitivity because GTK+ will whine at us if we do, just as is the case
if we press the "OK" or "Cancel" button (which also cause the window to
go away).
Can we just do this in the "window delete" handler? I.e., does that get
called if we explicitly destroy the widget? Or should we catch a
"destroy" event instead?
(There must be a better way to do this....)
svn path=/trunk/; revision=647
1999-09-10 06:53:32 +00:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active) {
|
|
|
|
prefs.pr_dest = PR_DEST_FILE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prefs.pr_dest = PR_DEST_CMD;
|
|
|
|
}
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|