Skip to content

Commit

Permalink
Use GTK2 get/set functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zturtleman authored and illwieckz committed Nov 9, 2024
1 parent 072c702 commit 6889455
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 79 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ set (icon_SIZE 22 32 48 128)
include_directories (${xqf_HEADERS_DIR} ${CMAKE_BINARY_DIR})

if (DEPRECATED_DISABLE)
add_definitions (-DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
add_definitions (-DGSEAL_ENABLE
-DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
-DG_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES)
endif (DEPRECATED_DISABLE)

Expand Down
2 changes: 1 addition & 1 deletion src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void set_widgets_sensitivity (GtkBuilder *builder) {
}
gtk_widget_set_state (filter_buttons[i], GTK_STATE_NORMAL);
gtk_widget_set_sensitive (filter_buttons[i], sens);
if (GTK_IS_TOGGLE_BUTTON (filter_buttons[i]) && GTK_TOGGLE_BUTTON (filter_buttons[i])->active) {
if (GTK_IS_TOGGLE_BUTTON (filter_buttons[i]) && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (filter_buttons[i]))) {
gtk_widget_set_state (filter_buttons[i], GTK_STATE_ACTIVE);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ GtkWidget *dialog_create_modal_transient_window (const char *title,

gtk_widget_realize (window);

gdk_window_set_decorations (window->window, (allow_resize)?
gdk_window_set_decorations (gtk_widget_get_window (window), (allow_resize)?
GDK_DECOR_BORDER | GDK_DECOR_TITLE | GDK_DECOR_RESIZEH :
GDK_DECOR_BORDER | GDK_DECOR_TITLE);

gdk_window_set_functions (window->window, (allow_resize)?
gdk_window_set_functions (gtk_widget_get_window (window), (allow_resize)?
GDK_FUNC_MOVE | GDK_FUNC_CLOSE | GDK_FUNC_RESIZE :
GDK_FUNC_MOVE | GDK_FUNC_CLOSE);

Expand Down Expand Up @@ -345,7 +345,7 @@ static int *enter_string_optval;
static void enter_string_activate_callback (GtkWidget *widget, gpointer data) {
enter_string_res = strdup_strip (gtk_entry_get_text (GTK_ENTRY (widget)));
if (enter_string_optval) {
*enter_string_optval = GTK_TOGGLE_BUTTON (enter_string_opt_button)->active;
*enter_string_optval = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enter_string_opt_button));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/flt-player.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ static void sync_pattern_data (void) {
list = g_slist_nth (curplrs, current_row);
pp = (struct player_pattern *) list->data;

if (GTK_TOGGLE_BUTTON (mode_buttons[PATTERN_MODE_STRING])->active)
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mode_buttons[PATTERN_MODE_STRING])))
mode = PATTERN_MODE_STRING;
else if (GTK_TOGGLE_BUTTON (mode_buttons[PATTERN_MODE_SUBSTR])->active)
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mode_buttons[PATTERN_MODE_SUBSTR])))
mode = PATTERN_MODE_SUBSTR;
else
mode = PATTERN_MODE_REGEXP;
Expand Down Expand Up @@ -705,7 +705,7 @@ static GtkWidget *player_filter_pattern_editor (void) {
gtk_box_pack_start (GTK_BOX (hbox), comment_text, TRUE, TRUE, 0);
gtk_widget_show (comment_text);

vscrollbar = gtk_vscrollbar_new (GTK_TEXT_VIEW (comment_text)->vadjustment);
vscrollbar = gtk_vscrollbar_new (gtk_text_view_get_vadjustment (GTK_TEXT_VIEW (comment_text)));
gtk_box_pack_start (GTK_BOX (hbox), vscrollbar, FALSE, FALSE, 0);
gtk_widget_show (vscrollbar);

Expand Down
20 changes: 10 additions & 10 deletions src/pixmaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ struct pixmap* cat_pixmaps (GtkWidget *window, struct pixmap *dest, struct pixma
gdk_window_get_size (s1->pix, &w1, &h1);
gdk_window_get_size (s2->pix, &w2, &h2);

dest->pix = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), -1);
dest->mask = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), 1);
dest->pix = gdk_pixmap_new (gtk_widget_get_window (window), w1 + w2, MAX (h1, h2), -1);
dest->mask = gdk_pixmap_new (gtk_widget_get_window (window), w1 + w2, MAX (h1, h2), 1);

white_gc = window->style->base_gc[GTK_STATE_NORMAL];
white_gc = gtk_widget_get_style (window)->base_gc[GTK_STATE_NORMAL];

if (!masks_gc) {
masks_gc = gdk_gc_new (dest->mask);
Expand Down Expand Up @@ -356,17 +356,17 @@ void ensure_buddy_pix (GtkWidget *window, int n) {

gdk_window_get_size (buddy_pix[1].pix, &width, &height);

buddy_pix[n].pix = gdk_pixmap_new (window->window, width, height, -1);
buddy_pix[n].mask = gdk_pixmap_new (window->window, width, height, 1);
buddy_pix[n].pix = gdk_pixmap_new (gtk_widget_get_window (window), width, height, -1);
buddy_pix[n].mask = gdk_pixmap_new (gtk_widget_get_window (window), width, height, 1);

white_gc = window->style->white_gc;
white_gc = gtk_widget_get_style (window)->white_gc;

if (!masks_gc) {
masks_gc = gdk_gc_new (buddy_pix[n].mask);
gdk_gc_set_exposures (masks_gc, FALSE);
}

gdk_gc_set_foreground (masks_gc, &window->style->white);
gdk_gc_set_foreground (masks_gc, &gtk_widget_get_style (window)->white);

gdk_draw_pixmap (buddy_pix[n].pix, white_gc, buddy_pix[pri].pix,
0, 0, 0, 0, width, height);
Expand Down Expand Up @@ -414,10 +414,10 @@ void create_server_pixmap (GtkWidget *window, struct pixmap *stype,
gdk_window_get_size (buddy_pix[1].pix, &wb, &hb);
gdk_window_get_size (stype->pix, &ws, &hs);

*pix = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), -1);
*mask = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), 1);
*pix = gdk_pixmap_new (gtk_widget_get_window (window), wb + ws, MAX (hs, hb), -1);
*mask = gdk_pixmap_new (gtk_widget_get_window (window), wb + ws, MAX (hs, hb), 1);

white_gc = window->style->base_gc[GTK_STATE_NORMAL];
white_gc = gtk_widget_get_style (window)->base_gc[GTK_STATE_NORMAL];

if (!masks_gc) {
masks_gc = gdk_gc_new (*mask);
Expand Down
68 changes: 34 additions & 34 deletions src/pref.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,12 @@ void qw_update_prefs (struct game* g) {
config_set_int ("rate", default_qw_rate = i);
}

i = GTK_TOGGLE_BUTTON (cl_nodelta_check_button[0])->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cl_nodelta_check_button[0]));
if (i != default_qw_cl_nodelta) {
config_set_int ("cl_nodelta", default_qw_cl_nodelta = i);
}

i = 1 - GTK_TOGGLE_BUTTON (cl_predict_check_button[0])->active;
i = 1 - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cl_predict_check_button[0]));
if (i != default_qw_cl_predict) {
config_set_int ("cl_predict", default_qw_cl_predict = i);
}
Expand All @@ -896,13 +896,13 @@ void qw_update_prefs (struct game* g) {
config_set_int ("noskins", default_qw_noskins = pref_qw_noskins);
}

i = GTK_TOGGLE_BUTTON (noaim_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (noaim_check_button));
if (i != default_noaim) {
config_set_int ("noaim", default_noaim = i);
}

for (i = 0; i < 3; i++) {
if (GTK_TOGGLE_BUTTON (pushlatency_mode_radio_buttons[i])->active) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pushlatency_mode_radio_buttons[i]))) {
if (i != pushlatency_mode) {
config_set_int ("pushlatency mode", pushlatency_mode = i);
}
Expand Down Expand Up @@ -951,12 +951,12 @@ void q2_update_prefs (struct game* g) {
config_set_int ("rate", default_q2_rate = i);
}

i = GTK_TOGGLE_BUTTON (cl_nodelta_check_button[1])->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cl_nodelta_check_button[1]));
if (i != default_q2_cl_nodelta) {
config_set_int ("cl_nodelta", default_q2_cl_nodelta = i);
}

i = 1 - GTK_TOGGLE_BUTTON (cl_predict_check_button[1])->active;
i = 1 - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cl_predict_check_button[1]));
if (i != default_q2_cl_predict) {
config_set_int ("cl_predict", default_q2_cl_predict = i);
}
Expand Down Expand Up @@ -991,7 +991,7 @@ void q3_update_prefs_common (struct game* g) {

if (w->setfs_gamebutton) {
int o;
i = GTK_TOGGLE_BUTTON (w->setfs_gamebutton)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w->setfs_gamebutton));
o = str2bool(game_get_attribute(type,"setfs_game"));
if (i != o) {
config_set_bool ("setfs_game", i);
Expand All @@ -1001,7 +1001,7 @@ void q3_update_prefs_common (struct game* g) {

if (w->set_punkbusterbutton) {
int o;
i = GTK_TOGGLE_BUTTON (w->set_punkbusterbutton)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w->set_punkbusterbutton));
o = str2bool(game_get_attribute(type,"set_punkbuster"));
if (i != o) {
config_set_bool ("set_punkbuster", i);
Expand All @@ -1011,7 +1011,7 @@ void q3_update_prefs_common (struct game* g) {

if (w->console_button) {
int o;
i = GTK_TOGGLE_BUTTON (w->console_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w->console_button));
o = str2bool(game_get_attribute(type,"enable_console"));
if (i != o) {
config_set_bool ("enable_console", i);
Expand All @@ -1031,7 +1031,7 @@ void q3_update_prefs (struct game* g) {
q3_update_prefs_common(g);

if ( type == Q3_SERVER ) {
i = GTK_TOGGLE_BUTTON (pass_memory_options_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pass_memory_options_button));
config_set_bool ("pass_memory_options", i);
game_set_attribute(type,"pass_memory_options",g_strdup(bool2str(i)));

Expand Down Expand Up @@ -1172,12 +1172,12 @@ static void get_new_defaults (void) {

config_push_prefix ("/" CONFIG_FILE "/Games Config");

i = GTK_TOGGLE_BUTTON (nosound_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nosound_check_button));
if (i != default_nosound) {
config_set_bool ("nosound", default_nosound = i);
}

i = GTK_TOGGLE_BUTTON (nocdaudio_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nocdaudio_check_button));
if (i != default_nocdaudio) {
config_set_bool ("nocdaudio", default_nocdaudio = i);
}
Expand All @@ -1192,27 +1192,27 @@ static void get_new_defaults (void) {

config_push_prefix ("/" CONFIG_FILE "/Appearance");

i = GTK_TOGGLE_BUTTON (countbots_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (countbots_check_button));
if (i != serverlist_countbots) {
config_set_bool ("count bots", serverlist_countbots = i);
}

i = GTK_TOGGLE_BUTTON (refresh_sorts_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (refresh_sorts_check_button));
if (i != default_refresh_sorts) {
config_set_bool ("sort on refresh", default_refresh_sorts = i);
}

i = GTK_TOGGLE_BUTTON (refresh_on_update_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (refresh_on_update_check_button));
if (i != default_refresh_on_update) {
config_set_bool ("refresh on update", default_refresh_on_update = i);
}

i = GTK_TOGGLE_BUTTON (resolve_on_update_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (resolve_on_update_check_button));
if (i != default_resolve_on_update) {
config_set_bool ("resolve on update", default_resolve_on_update = i);
}

i = GTK_TOGGLE_BUTTON (show_only_configured_games_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_only_configured_games_check_button));
if (i != default_show_only_configured_games) {
config_set_bool ("show only configured games", default_show_only_configured_games = i);
}
Expand All @@ -1223,42 +1223,42 @@ static void get_new_defaults (void) {

config_push_prefix ("/" CONFIG_FILE "/General");

i = GTK_TOGGLE_BUTTON (terminate_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (terminate_check_button));
if (i != default_terminate) {
config_set_bool ("terminate", default_terminate = i);
}

i = GTK_TOGGLE_BUTTON (launchinfo_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (launchinfo_check_button));
if (i != default_launchinfo) {
config_set_bool ("launchinfo", default_launchinfo = i);
}

i = GTK_TOGGLE_BUTTON (prelaunchexec_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prelaunchexec_check_button));
if (i != default_prelaunchexec) {
config_set_bool ("prelaunchexec", default_prelaunchexec = i);
}

i = GTK_TOGGLE_BUTTON (save_lists_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_lists_check_button));
if (i != default_save_lists) {
config_set_bool ("save lists", default_save_lists = i);
}

i = GTK_TOGGLE_BUTTON (save_srvinfo_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_srvinfo_check_button));
if (i != default_save_srvinfo) {
config_set_bool ("save srvinfo", default_save_srvinfo = i);
}

i = GTK_TOGGLE_BUTTON (save_plrinfo_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_plrinfo_check_button));
if (i != default_save_plrinfo) {
config_set_bool ("save players", default_save_plrinfo = i);
}

i = GTK_TOGGLE_BUTTON (auto_favorites_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (auto_favorites_check_button));
if (i != default_auto_favorites) {
config_set_bool ("refresh favorites", default_auto_favorites = i);
}

i = GTK_TOGGLE_BUTTON (auto_maps_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (auto_maps_check_button));
if (i != default_auto_maps) {
config_set_bool ("search maps", default_auto_maps = i);
}
Expand Down Expand Up @@ -1307,7 +1307,7 @@ static void get_new_defaults (void) {

config_push_prefix ("/" CONFIG_FILE "/Sounds");

i = GTK_TOGGLE_BUTTON (sound_enable_check_button)->active;
i = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sound_enable_check_button));
if (i != sound_enable) {
config_set_bool ("sound_enable", sound_enable = i);
}
Expand Down Expand Up @@ -1338,11 +1338,11 @@ static void get_new_defaults (void) {

gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM (gtk_builder_get_object (builder, "view_hostnames_menu_item")),
GTK_TOGGLE_BUTTON (show_hostnames_check_button)->active);
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_hostnames_check_button)));

gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM (gtk_builder_get_object (builder, "view_defport_menu_item")),
GTK_TOGGLE_BUTTON (show_defport_check_button)->active);
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_defport_check_button)));

// i = gtk_notebook_get_current_page (GTK_NOTEBOOK (profile_notebook));
// config_set_string ("/" CONFIG_FILE "/Player Profile/game", type2id (i));
Expand Down Expand Up @@ -3645,21 +3645,21 @@ void add_t2_options_to_notebook(GtkWidget *notebook, enum server_type type) {
}

static void terminate_toggled_callback (GtkWidget *widget, gpointer data) {
//GTK_TOGGLE_BUTTON (terminate_check_button)->active;
//gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (terminate_check_button));
}

static void launchinfo_toggled_callback (GtkWidget *widget, gpointer data) {
//GTK_TOGGLE_BUTTON (launchinfo_check_button)->active;
//gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (launchinfo_check_button));
}

static void prelaunchexec_toggled_callback (GtkWidget *widget, gpointer data) {
//GTK_TOGGLE_BUTTON (prelaunchexec_check_button)->active;
//gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prelaunchexec_check_button));
}

static void save_srvinfo_toggled_callback (GtkWidget *widget, gpointer data) {
int val;

val = GTK_TOGGLE_BUTTON (save_srvinfo_check_button)->active;
val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_srvinfo_check_button));
gtk_widget_set_sensitive (save_plrinfo_check_button, val);
}

Expand Down Expand Up @@ -3839,7 +3839,7 @@ static GtkWidget *general_options_page (void) {
{
GtkWidget* button = gtk_button_new_with_label(_("scan now"));
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_misc_set_padding(GTK_MISC(GTK_BIN(button)->child),4,0);
gtk_misc_set_padding(GTK_MISC(gtk_bin_get_child(GTK_BIN(button))),4,0);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (scan_maps_callback), NULL);
gtk_widget_show (button);
}
Expand Down Expand Up @@ -4353,7 +4353,7 @@ void preferences_dialog (int page_num) {
gtk_widget_realize (window);
}

allocate_quake_player_colors (window->window);
allocate_quake_player_colors (gtk_widget_get_window (window));

vbox = gtk_vbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
Expand Down
4 changes: 2 additions & 2 deletions src/psearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ static void psearch_combo_activate_callback (GtkWidget *widget,
gpointer data) {
psearch_free_pattern ();

if (GTK_TOGGLE_BUTTON (mode_buttons[PSEARCH_MODE_STRING])->active)
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mode_buttons[PSEARCH_MODE_STRING])))
psearch.mode = PSEARCH_MODE_STRING;
else if (GTK_TOGGLE_BUTTON (mode_buttons[PSEARCH_MODE_SUBSTR])->active)
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mode_buttons[PSEARCH_MODE_SUBSTR])))
psearch.mode = PSEARCH_MODE_SUBSTR;
else
psearch.mode = PSEARCH_MODE_REGEXP;
Expand Down
Loading

0 comments on commit 6889455

Please sign in to comment.