Handle more stuff in old-gtk-compat.h to avoid guarding in the code.

svn path=/trunk/; revision=38160
This commit is contained in:
Jörg Mayer 2011-07-21 23:58:08 +00:00
parent 7439bba9dc
commit 58d8a2b1b2
7 changed files with 31 additions and 160 deletions

View File

@ -72,6 +72,8 @@
#include "gtk/keys.h"
#include "gtk/old-gtk-compat.h"
#ifdef HAVE_AIRPCAP
#include <airpcap.h>
#include "airpcap_loader.h"
@ -263,11 +265,7 @@ capture_filter_check_syntax_cb(GtkWidget *w _U_, gpointer user_data _U_)
filter_cm = g_object_get_data(G_OBJECT(top_level), E_CFILTER_CM_KEY);
filter_te = gtk_bin_get_child(GTK_BIN(filter_cm));
#if GTK_CHECK_VERSION(2,24,0)
filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
#else
filter_text = gtk_combo_box_get_active_text (GTK_COMBO_BOX(filter_cm));
#endif /*GTK_CHECK_VERSION(2,24,0)*/
if (strlen(filter_text) == 0) {
colorize_filter_te_as_empty(filter_te);
return;
@ -326,11 +324,7 @@ set_if_capabilities(gboolean monitor_mode_changed)
#endif
interface_options interface_opts;
#if GTK_CHECK_VERSION(2,24,0)
entry_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(if_cb));
#else
entry_text = gtk_combo_box_get_active_text (GTK_COMBO_BOX(if_cb));
#endif /* GTK_CHECK_VERSION(2,24,0) */
if(!entry_text)
entry_text = '\0';
@ -557,17 +551,10 @@ static const char *time_unit_name[MAX_TIME_UNITS] = {
static GtkWidget *time_unit_combo_box_new(guint32 value) {
GtkWidget *unit_combo_box;
int i;
#if GTK_CHECK_VERSION(2,24,0)
unit_combo_box = gtk_combo_box_text_new ();
for(i = 0; i < MAX_TIME_UNITS; i++) {
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (unit_combo_box), time_unit_name[i]);
}
#else
unit_combo_box = gtk_combo_box_new_text ();
for(i = 0; i < MAX_TIME_UNITS; i++) {
gtk_combo_box_append_text (GTK_COMBO_BOX (unit_combo_box), time_unit_name[i]);
}
#endif
/* the selected combo_box item can't be changed, once the combo_box
is created, so set the matching combo_box item now */
/* days */
@ -653,19 +640,10 @@ static const char *size_unit_name[MAX_SIZE_UNITS] = {
static GtkWidget *size_unit_combo_box_new(guint32 value) {
GtkWidget *unit_combo_box;
int i;
#if GTK_CHECK_VERSION(2,24,0)
unit_combo_box=gtk_combo_box_text_new();
for(i=0;i<MAX_SIZE_UNITS;i++){
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (unit_combo_box), size_unit_name[i]);
}
#else
unit_combo_box=gtk_combo_box_new_text();
for(i=0;i<MAX_SIZE_UNITS;i++){
gtk_combo_box_append_text (GTK_COMBO_BOX (unit_combo_box), size_unit_name[i]);
}
#endif /*GTK_CHECK_VERSION(2,24,0)*/
/* the selected combo_box item can't be changed, once the combo_box
is created, so set the matching combo_box item now */
/* gigabytes */
@ -1554,11 +1532,7 @@ capture_filter_compile_cb(GtkWidget *w _U_, gpointer user_data _U_)
pd = pcap_open_dead(g_array_index(global_capture_opts.ifaces, interface_options, 0).linktype, DUMMY_SNAPLENGTH);
filter_cm = g_object_get_data(G_OBJECT(top_level), E_CFILTER_CM_KEY);
#if GTK_CHECK_VERSION(2,24,0)
filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
#else
filter_text = gtk_combo_box_get_active_text (GTK_COMBO_BOX(filter_cm));
#endif /* GTK_CHECK_VERSION(2,24,0) */
/* pcap_compile will not alter the filter string, so the (char *) cast is "safe" */
#ifdef PCAP_NETMASK_UNKNOWN
if (pcap_compile(pd, &fcode, (char *)filter_text, 1 /* Do optimize */, PCAP_NETMASK_UNKNOWN) < 0) {
@ -1853,7 +1827,6 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
if (global_capture_opts.ifaces->len > 0 && interface_opts.name != NULL) {
if_device = build_capture_combo_name(if_list, interface_opts.name);
}
#if GTK_CHECK_VERSION(2,24,0)
if_cb = gtk_combo_box_text_new_with_entry();
combo_list = build_capture_combo_list(if_list, TRUE);
if (combo_list != NULL){
@ -1863,17 +1836,6 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
* if we do compare to the entry we are making
* and make that entry active if they are equal.
*/
#else
if_cb = gtk_combo_box_entry_new_text();
combo_list = build_capture_combo_list(if_list, TRUE);
if (combo_list != NULL){
for (combo_list_entry = combo_list; combo_list_entry != NULL; combo_list_entry = g_list_next(combo_list_entry)) {
gtk_combo_box_append_text(GTK_COMBO_BOX(if_cb), combo_list_entry->data);
/* Do we have a prefered if(if_device != NULL),
* if we do compare to the entry we are making
* and make that entry active if they are equal.
*/
#endif /* GTK_CHECK_VERSION(2,24,0) */
if((if_device)&&(strcmp(if_device, combo_list_entry->data) == 0)) {
gtk_combo_box_set_active(GTK_COMBO_BOX(if_cb),if_index);
}
@ -2077,11 +2039,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
/* Create the capture filter combo box*/
#if GTK_CHECK_VERSION(2,24,0)
filter_cm = gtk_combo_box_text_new_with_entry ();
#else
filter_cm = gtk_combo_box_entry_new_text ();
#endif
cfilter_list = g_object_get_data(G_OBJECT(top_level), E_CFILTER_FL_KEY);
g_object_set_data(G_OBJECT(top_level), E_CFILTER_FL_KEY, cfilter_list);
g_object_set_data(G_OBJECT(top_level), E_CFILTER_CM_KEY, filter_cm);
@ -2091,19 +2049,11 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
if (cfilter_list != NULL){
for (cf_entry = cfilter_list; cf_entry != NULL; cf_entry = g_list_next(cf_entry)) {
#if GTK_CHECK_VERSION(2,24,0)
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(filter_cm), cf_entry->data);
#else
gtk_combo_box_append_text(GTK_COMBO_BOX(filter_cm), cf_entry->data);
#endif
}
}
if (global_capture_opts.ifaces->len > 0 && g_array_index(global_capture_opts.ifaces, interface_options, 0).cfilter)
#if GTK_CHECK_VERSION(2,24,0)
gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(filter_cm), g_array_index(global_capture_opts.ifaces, interface_options, 0).cfilter);
#else
gtk_combo_box_prepend_text(GTK_COMBO_BOX(filter_cm), g_array_index(global_capture_opts.ifaces, interface_options, 0).cfilter);
#endif
gtk_widget_set_tooltip_text(filter_cm,
"Enter a capture filter to reduce the amount of packets to be captured. "
"See \"Capture Filters\" in the online help for further information how to use it. "
@ -2978,11 +2928,7 @@ if (global_capture_opts.ifaces->len > 0) {
n_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_N_RESOLVE_KEY);
t_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_T_RESOLVE_KEY);
#if GTK_CHECK_VERSION(2,24,0)
entry_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(if_cb));
#else
entry_text = gtk_combo_box_get_active_text (GTK_COMBO_BOX(if_cb));
#endif /* GTK_CHECK_VERSION(2,24,0) */
if(!entry_text)
entry_text = '\0';
@ -3043,11 +2989,7 @@ if (global_capture_opts.ifaces->len > 0) {
until a filter is set, which means they aren't bound at all if
no filter is set, which means no packets arrive as input on that
socket, which means Wireshark never sees any packets. */
#if GTK_CHECK_VERSION(2,24,0)
filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
#else
filter_text = gtk_combo_box_get_active_text (GTK_COMBO_BOX(filter_cm));
#endif /* GTK_CHECK_VERSION(2,24,0 */
if (interface_opts.cfilter)
g_free(interface_opts.cfilter);
g_assert(filter_text != NULL);

View File

@ -56,6 +56,7 @@
#include "gtk/filter_dlg.h"
#include "gtk/dfilter_expr_dlg.h"
#include "gtk/old-gtk-compat.h"
#define E_DFILTER_EXPR_TREE_KEY "dfilter_expr_tree"
#define E_DFILTER_EXPR_CURRENT_VAR_KEY "dfilter_expr_current_var"
@ -643,11 +644,7 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
/*
* Get the range to use, if any.
*/
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_sensitive(range_entry)) {
#else
if (GTK_WIDGET_SENSITIVE(range_entry)) {
#endif
range_str = g_strdup(gtk_entry_get_text(GTK_ENTRY(range_entry)));
/*
* XXX - strip this even for strings?
@ -725,11 +722,7 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
/*
* Get the value to use, if any.
*/
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_sensitive(value_entry)) {
#else
if (GTK_WIDGET_SENSITIVE(value_entry)) {
#endif
value_str = g_strdup(gtk_entry_get_text(GTK_ENTRY(value_entry)));
stripped_value_str = g_strstrip(value_str);
if (strcmp(stripped_value_str, "") == 0) {

View File

@ -289,12 +289,7 @@ static void gtk_vumeter_size_allocate (GtkWidget *widget, GtkAllocation *allocat
gtk_vumeter_size_calculate(widget, &requisition);
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_realized(widget)) {
#else
if (GTK_WIDGET_REALIZED (widget)) {
#endif
gdk_window_move_resize (gtk_widget_get_window(widget), allocation->x, allocation->y,
MAX (allocation->width, requisition.width),
MAX (allocation->height, requisition.height));
@ -670,11 +665,7 @@ static gboolean gtk_vumeter_redraw_timeout (gpointer data)
{
GtkVUMeter *vumeter = data;
/* Immediately return if need be */
#if GTK_CHECK_VERSION(2,20,0)
if (!gtk_widget_get_realized (GTK_WIDGET(vumeter))) { return TRUE; }
#else
if (!GTK_WIDGET_REALIZED (GTK_WIDGET(vumeter))) { return TRUE; }
#endif
if (vumeter->peak == FALSE) { return TRUE; }
if (vumeter->peak_level == vumeter->level) { return TRUE; }
@ -767,11 +758,7 @@ void gtk_vumeter_set_orientation (GtkVUMeter *vumeter, GtkVUMeterOrientation ori
vumeter->scale_inverted = FALSE;
}
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_realized (GTK_WIDGET(vumeter))) {
#else
if (GTK_WIDGET_REALIZED (vumeter)) {
#endif
gtk_widget_queue_draw (GTK_WIDGET (vumeter));
}
}
@ -994,11 +981,7 @@ void gtk_vumeter_set_scaling (GtkVUMeter *vumeter, GtkVUMeterScaling scaling)
if (scaling != vumeter->scaling) {
vumeter->scaling = CLAMP (scaling, GTK_VUMETER_SCALING_LINEAR, GTK_VUMETER_SCALING_LOG);
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_realized (GTK_WIDGET(vumeter))) {
#else
if (GTK_WIDGET_REALIZED (vumeter)) {
#endif
gtk_vumeter_setup_colors (vumeter);
gtk_widget_queue_draw (GTK_WIDGET (vumeter));
}
@ -1039,11 +1022,7 @@ void gtk_vumeter_set_scale_items(GtkVUMeter *vumeter, GList *scale_items)
gtk_vumeter_setup_scale_items(vumeter, scale_items);
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_realized(GTK_WIDGET(vumeter))) {
#else
if (GTK_WIDGET_REALIZED (vumeter)) {
#endif
gtk_widget_queue_draw (GTK_WIDGET (vumeter));
}
}
@ -1254,11 +1233,7 @@ void gtk_vumeter_set_colors_inverted (GtkVUMeter *vumeter, gboolean inverted)
g_return_if_fail (GTK_IS_VUMETER (vumeter));
vumeter->colors_inverted = inverted;
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_realized(GTK_WIDGET(vumeter))) {
#else
if (GTK_WIDGET_REALIZED (vumeter)) {
#endif
gtk_vumeter_setup_colors (vumeter);
gtk_widget_queue_draw (GTK_WIDGET (vumeter));
}
@ -1290,11 +1265,7 @@ void gtk_vumeter_set_yellow_level (GtkVUMeter *vumeter, gint yellow_level)
g_return_if_fail (GTK_IS_VUMETER (vumeter));
vumeter->yellow_level = CLAMP (yellow_level, vumeter->level_min, vumeter->level_max);
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_realized(GTK_WIDGET(vumeter))) {
#else
if (GTK_WIDGET_REALIZED (vumeter)) {
#endif
gtk_vumeter_setup_colors (vumeter);
gtk_widget_queue_draw (GTK_WIDGET (vumeter));
}
@ -1326,11 +1297,7 @@ void gtk_vumeter_set_brightness (GtkVUMeter *vumeter, gint foreground, gint back
{
vumeter->f_brightness = CLAMP(foreground, 0, 65535);
vumeter->b_brightness = CLAMP(background, 0, vumeter->f_brightness);
#if GTK_CHECK_VERSION(2,20,0)
if (gtk_widget_get_realized(GTK_WIDGET(vumeter))) {
#else
if (GTK_WIDGET_REALIZED (vumeter)) {
#endif
gtk_vumeter_setup_colors (vumeter);
gtk_widget_queue_draw (GTK_WIDGET (vumeter));
}

View File

@ -1523,21 +1523,12 @@ create_pixels_per_tick_menu_items(io_stat_t *io)
char str[5];
GtkWidget *combo_box;
int i;
#if GTK_CHECK_VERSION(2,24,0)
combo_box = gtk_combo_box_text_new ();
for(i=0;i<MAX_PIXELS_PER_TICK;i++){
g_snprintf(str, 5, "%u", pixels_per_tick[i]);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), str);
}
#else
combo_box = gtk_combo_box_new_text ();
for(i=0;i<MAX_PIXELS_PER_TICK;i++){
g_snprintf(str, 5, "%u", pixels_per_tick[i]);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), str);
}
#endif
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_PIXELS_PER_TICK_INDEX);
g_signal_connect(combo_box, "changed", G_CALLBACK(pixels_per_tick_select), io);
@ -1563,11 +1554,7 @@ create_tick_interval_menu_items(io_stat_t *io)
char str[15];
int i;
#if GTK_CHECK_VERSION(2,24,0)
combo_box = gtk_combo_box_text_new ();
#else
combo_box = gtk_combo_box_new_text ();
#endif
for(i=0;i<MAX_TICK_VALUES;i++){
if(tick_interval_values[i]>=60000){
@ -1581,11 +1568,7 @@ create_tick_interval_menu_items(io_stat_t *io)
} else {
g_snprintf(str, sizeof(str), "0.%03u sec", (tick_interval_values[i])%10);
}
#if GTK_CHECK_VERSION(2,24,0)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), str);
#else
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), str);
#endif
}
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_TICK_VALUE_INDEX);
g_signal_connect(combo_box, "changed", G_CALLBACK(tick_interval_select), io);
@ -1600,11 +1583,7 @@ create_yscale_max_menu_items(io_stat_t *io)
GtkWidget *combo_box;
int i;
#if GTK_CHECK_VERSION(2,24,0)
combo_box = gtk_combo_box_text_new ();
#else
combo_box = gtk_combo_box_new_text ();
#endif
for(i=0;i<MAX_YSCALE;i++){
if(yscale_max[i]==LOGARITHMIC_YSCALE){
g_strlcpy(str, "Logarithmic", 15);
@ -1613,11 +1592,7 @@ create_yscale_max_menu_items(io_stat_t *io)
} else {
g_snprintf(str, 15, "%u", yscale_max[i]);
}
#if GTK_CHECK_VERSION(2,24,0)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), str);
#else
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), str);
#endif
}
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_YSCALE_INDEX);
g_signal_connect(combo_box, "changed", G_CALLBACK(yscale_select), io);
@ -1663,18 +1638,10 @@ create_frames_or_bytes_menu_items(io_stat_t *io)
GtkWidget *combo_box;
int i;
#if GTK_CHECK_VERSION(2,24,0)
combo_box = gtk_combo_box_text_new ();
#else
combo_box = gtk_combo_box_new_text ();
#endif
for(i=0;i<MAX_COUNT_TYPES;i++){
#if GTK_CHECK_VERSION(2,24,0)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), count_type_names[i]);
#else
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), count_type_names[i]);
#endif
}
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_COUNT_TYPE);
g_signal_connect(combo_box, "changed", G_CALLBACK(count_type_select), io);
@ -1914,17 +1881,9 @@ create_calc_types_menu_items(io_stat_graph_t *gio)
GtkWidget *combo_box;
int i;
#if GTK_CHECK_VERSION(2,24,0)
combo_box = gtk_combo_box_text_new ();
#else
combo_box = gtk_combo_box_new_text ();
#endif
for(i=0;i<MAX_CALC_TYPES;i++){
#if GTK_CHECK_VERSION(2,24,0)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), calc_type_names[i]);
#else
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), calc_type_names[i]);
#endif
}
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_CALC_TYPE);
g_signal_connect(combo_box, "changed", G_CALLBACK(calc_type_select), gio);
@ -2065,17 +2024,9 @@ create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2,24,0)
combo_box = gtk_combo_box_text_new ();
#else
combo_box = gtk_combo_box_new_text ();
#endif
for(i=0;i<MAX_PLOT_STYLES;i++){
#if GTK_CHECK_VERSION(2,24,0)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), plot_style_name[i]);
#else
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), plot_style_name[i]);
#endif
}
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_PLOT_STYLE);
g_signal_connect(combo_box, "changed", G_CALLBACK(plot_style_select), &gio->io->graphs[num-1]);

View File

@ -50,6 +50,8 @@
#include "main_toolbar.h"
#include "main_filter_toolbar.h"
#include "gtk/old-gtk-compat.h"
GtkWidget *main_display_filter_widget=NULL;
/* Run the current display filter on the current packet set, and
@ -104,13 +106,8 @@ GtkWidget *filter_toolbar_new(void)
/* filter toolbar */
filter_tb = gtk_toolbar_new();
#if GTK_CHECK_VERSION(2,16,0)
gtk_orientable_set_orientation(GTK_ORIENTABLE(filter_tb),
GTK_ORIENTATION_HORIZONTAL);
#else
gtk_toolbar_set_orientation(GTK_TOOLBAR(filter_tb),
GTK_ORIENTATION_HORIZONTAL);
#endif
g_object_set_data(G_OBJECT(top_level), E_TB_FILTER_KEY, filter_tb);
gtk_widget_show(filter_tb);

View File

@ -60,6 +60,8 @@
#include "gtk/packet_history.h"
#include "gtk/new_packet_list.h"
#include "gtk/old-gtk-compat.h"
static gboolean toolbar_init = FALSE;
#ifdef HAVE_LIBPCAP
@ -287,13 +289,8 @@ toolbar_new(void)
/* toolbar will be horizontal, with both icons and text (as default here) */
/* (this will usually be overwritten by the preferences setting) */
main_tb = gtk_toolbar_new();
#if GTK_CHECK_VERSION(2,16,0)
gtk_orientable_set_orientation(GTK_ORIENTABLE(main_tb),
GTK_ORIENTATION_HORIZONTAL);
#else
gtk_toolbar_set_orientation(GTK_TOOLBAR(main_tb),
GTK_ORIENTATION_HORIZONTAL);
#endif
g_object_set_data(G_OBJECT(top_level), E_TB_MAIN_KEY, main_tb);

View File

@ -41,4 +41,28 @@
# define gtk_adjustment_get_page_size(adj) (adj)->page_size
#endif
#if !GTK_CHECK_VERSION (2, 16, 0)
# define GTK_ORIENTABLE(x) GTK_TOOLBAR(x)
#endif
#if !GTK_CHECK_VERSION (2, 18, 0)
#endif
#if !GTK_CHECK_VERSION (2, 20, 0)
# define gtk_widget_get_sensitive(x) GTK_WIDGET_SENSITIVE(x)
# define gtk_widget_get_realized(x) GTK_WIDGET_REALIZED(x)
#endif
#if !GTK_CHECK_VERSION (2, 22, 0)
#endif
#if !GTK_CHECK_VERSION (2, 24, 0)
# define GTK_COMBO_BOX_TEXT(x) GTK_COMBO_BOX(x)
# define gtk_combo_box_text_get_active_text(x) gtk_combo_box_get_active_text(x)
# define gtk_combo_box_text_new(x) gtk_combo_box_new_text(x)
# define gtk_combo_box_text_append_text(x,y) gtk_combo_box_append_text(x,y)
# define gtk_combo_box_text_new_with_entry() gtk_combo_box_entry_new_text()
# define gtk_combo_box_text_prepend_text(x,y) gtk_combo_box_prepend_text(x,y)
#endif
#endif