diff options
author | Olivier Abad <oabad@noos.fr> | 2002-11-11 15:39:06 +0000 |
---|---|---|
committer | Olivier Abad <oabad@noos.fr> | 2002-11-11 15:39:06 +0000 |
commit | 29011060dee28a8ef2be7a833ee4bafb2137c3e1 (patch) | |
tree | e43f3076f0ab40791245e274e7f18470533bdd30 /gtk/print_prefs.c | |
parent | c2c5e20927a17ab9d0ede271f947881ab6f4650b (diff) |
Use gtk1/gtk2 compatibility macros to reduce #ifdefs.
svn path=/trunk/; revision=6610
Diffstat (limited to 'gtk/print_prefs.c')
-rw-r--r-- | gtk/print_prefs.c | 82 |
1 files changed, 25 insertions, 57 deletions
diff --git a/gtk/print_prefs.c b/gtk/print_prefs.c index 5301cae68b..815bc2ec6a 100644 --- a/gtk/print_prefs.c +++ b/gtk/print_prefs.c @@ -1,7 +1,7 @@ /* print_prefs.c * Dialog boxes for preferences for printing * - * $Id: print_prefs.c,v 1.15 2002/11/03 17:38:34 oabad Exp $ + * $Id: print_prefs.c,v 1.16 2002/11/11 15:39:06 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -38,6 +38,7 @@ #include "util.h" #include "ui_util.h" #include "dlg_utils.h" +#include "compat_macros.h" static void printer_opts_file_cb(GtkWidget *w, gpointer te); static void printer_opts_fs_ok_cb(GtkWidget *w, gpointer data); @@ -87,19 +88,19 @@ GtkWidget * printer_prefs_show(void) /* Output format */ button = create_preference_radio_buttons(main_tb, 0, "Format:", NULL, print_format_vals, prefs.pr_format); - gtk_object_set_data(GTK_OBJECT(main_vb), E_PRINT_FORMAT_KEY, button); + OBJECT_SET_DATA(main_vb, E_PRINT_FORMAT_KEY, button); /* Output destination */ button = create_preference_radio_buttons(main_tb, 1, "Print to:", NULL, print_dest_vals, prefs.pr_dest); - gtk_object_set_data(GTK_OBJECT(main_vb), E_PRINT_DESTINATION_KEY, + OBJECT_SET_DATA(main_vb, E_PRINT_DESTINATION_KEY, button); #ifndef _WIN32 /* Command text entry */ cmd_te = create_preference_entry(main_tb, 2, "Command:", NULL, prefs.pr_cmd); - gtk_object_set_data(GTK_OBJECT(main_vb), PRINT_CMD_TE_KEY, cmd_te); + OBJECT_SET_DATA(main_vb, PRINT_CMD_TE_KEY, cmd_te); #endif /* File button and text entry */ @@ -112,19 +113,12 @@ GtkWidget * printer_prefs_show(void) gtk_widget_show(file_bt); file_te = gtk_entry_new(); - gtk_object_set_data(GTK_OBJECT(main_vb), PRINT_FILE_TE_KEY, file_te); + OBJECT_SET_DATA(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); -#if GTK_MAJOR_VERSION < 2 - gtk_signal_connect(GTK_OBJECT(file_bt), "clicked", - GTK_SIGNAL_FUNC(printer_opts_file_cb), - GTK_OBJECT(file_te)); -#else - g_signal_connect(G_OBJECT(file_bt), "clicked", - G_CALLBACK(printer_opts_file_cb), G_OBJECT(file_te)); -#endif + SIGNAL_CONNECT(file_bt, "clicked", printer_opts_file_cb, file_te); gtk_widget_show(main_vb); return(main_vb); @@ -138,7 +132,7 @@ printer_opts_file_cb(GtkWidget *file_bt, gpointer file_te) { /* Has a file selection dialog box already been opened for that top-level widget? */ - fs = gtk_object_get_data(GTK_OBJECT(caller), E_FILE_SEL_DIALOG_PTR_KEY); + fs = OBJECT_GET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY); if (fs != NULL) { /* Yes. Just re-activate that dialog box. */ @@ -147,45 +141,24 @@ printer_opts_file_cb(GtkWidget *file_bt, gpointer file_te) { } fs = gtk_file_selection_new ("Ethereal: Print to a File"); - gtk_object_set_data(GTK_OBJECT(fs), PRINT_FILE_TE_KEY, file_te); + OBJECT_SET_DATA(fs, PRINT_FILE_TE_KEY, file_te); -#if GTK_MAJOR_VERSION < 2 /* Set the E_FS_CALLER_PTR_KEY for the new dialog to point to our caller. */ - gtk_object_set_data(GTK_OBJECT(fs), E_FS_CALLER_PTR_KEY, caller); + OBJECT_SET_DATA(fs, E_FS_CALLER_PTR_KEY, caller); /* Set the E_FILE_SEL_DIALOG_PTR_KEY for the caller to point to us */ - gtk_object_set_data(GTK_OBJECT(caller), E_FILE_SEL_DIALOG_PTR_KEY, fs); + OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, fs); /* Call a handler when the file selection box is destroyed, so we can inform our caller, if any, that it's been destroyed. */ - gtk_signal_connect(GTK_OBJECT(fs), "destroy", - GTK_SIGNAL_FUNC(printer_opts_fs_destroy_cb), NULL); + SIGNAL_CONNECT(fs, "destroy", printer_opts_fs_destroy_cb, NULL); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(fs)->ok_button), - "clicked", (GtkSignalFunc) printer_opts_fs_ok_cb, fs); + SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->ok_button, "clicked", + 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); -#else - /* Set the E_FS_CALLER_PTR_KEY for the new dialog to point to our caller. */ - g_object_set_data(G_OBJECT(fs), E_FS_CALLER_PTR_KEY, caller); - - /* Set the E_FILE_SEL_DIALOG_PTR_KEY for the caller to point to us */ - g_object_set_data(G_OBJECT(caller), E_FILE_SEL_DIALOG_PTR_KEY, fs); - - /* Call a handler when the file selection box is destroyed, so we can inform - our caller, if any, that it's been destroyed. */ - g_signal_connect(G_OBJECT(fs), "destroy", - G_CALLBACK(printer_opts_fs_destroy_cb), NULL); - - g_signal_connect(G_OBJECT (GTK_FILE_SELECTION(fs)->ok_button), "clicked", - G_CALLBACK(printer_opts_fs_ok_cb), fs); - - /* Connect the cancel_button to destroy the widget */ - g_signal_connect(G_OBJECT (GTK_FILE_SELECTION(fs)->cancel_button), "clicked", - G_CALLBACK(printer_opts_fs_cancel_cb), fs); -#endif + SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->cancel_button, "clicked", + printer_opts_fs_cancel_cb, fs); /* Catch the "key_press_event" signal in the window, so that we can catch the ESC key being pressed and act as if the "Cancel" button had @@ -198,9 +171,8 @@ printer_opts_file_cb(GtkWidget *file_bt, gpointer file_te) { 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))); + gtk_entry_set_text(GTK_ENTRY(OBJECT_GET_DATA(data, PRINT_FILE_TE_KEY)), + gtk_file_selection_get_filename(GTK_FILE_SELECTION(data))); printer_opts_fs_cancel_cb(w, data); } @@ -218,10 +190,10 @@ printer_opts_fs_destroy_cb(GtkWidget *win, gpointer data _U_) /* Get the widget that requested that we be popped up. (It should arrange to destroy us if it's destroyed, so that we don't get a pointer to a non-existent window here.) */ - caller = gtk_object_get_data(GTK_OBJECT(win), E_FS_CALLER_PTR_KEY); + caller = OBJECT_GET_DATA(win, E_FS_CALLER_PTR_KEY); /* Tell it we no longer exist. */ - gtk_object_set_data(GTK_OBJECT(caller), E_FILE_SEL_DIALOG_PTR_KEY, NULL); + OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, NULL); /* Now nuke this window. */ gtk_grab_remove(GTK_WIDGET(win)); @@ -232,26 +204,22 @@ void printer_prefs_fetch(GtkWidget *w) { prefs.pr_format = fetch_preference_radio_buttons_val( - gtk_object_get_data(GTK_OBJECT(w), E_PRINT_FORMAT_KEY), - print_format_vals); + OBJECT_GET_DATA(w, E_PRINT_FORMAT_KEY), print_format_vals); prefs.pr_dest = fetch_preference_radio_buttons_val( - gtk_object_get_data(GTK_OBJECT(w), E_PRINT_DESTINATION_KEY), - print_dest_vals); + OBJECT_GET_DATA(w, E_PRINT_DESTINATION_KEY), print_dest_vals); #ifndef _WIN32 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)))); + GTK_ENTRY(OBJECT_GET_DATA(w, PRINT_CMD_TE_KEY)))); #endif 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)))); + GTK_ENTRY(OBJECT_GET_DATA(w, PRINT_FILE_TE_KEY)))); } void @@ -267,7 +235,7 @@ printer_prefs_destroy(GtkWidget *w) /* Is there a file selection dialog associated with this Preferences dialog? */ - fs = gtk_object_get_data(GTK_OBJECT(caller), E_FILE_SEL_DIALOG_PTR_KEY); + fs = OBJECT_GET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY); if (fs != NULL) { /* Yes. Destroy it. */ |