Skip to content

Commit

Permalink
Clean up uses of gtk_toggle_button_get/set_active
Browse files Browse the repository at this point in the history
Replace all uses on check buttons by the corresponding
check button api.
  • Loading branch information
Matthias Clasen committed Aug 31, 2020
1 parent cfade23 commit 2c5c938
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 89 deletions.
14 changes: 7 additions & 7 deletions demos/gtk-demo/font_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,15 +1166,15 @@ font_features_reset_features (void)
{
FeatureItem *item = l->data;

if (GTK_IS_RADIO_BUTTON (item->feat))
if (GTK_IS_CHECK_BUTTON (item->feat))
{
if (strcmp (item->name, "xxxx") == 0)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->feat), TRUE);
}
else if (GTK_IS_CHECK_BUTTON (item->feat))
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->feat), FALSE);
set_inconsistent (GTK_CHECK_BUTTON (item->feat), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
else
{
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), FALSE);
set_inconsistent (GTK_CHECK_BUTTON (item->feat), TRUE);
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions demos/gtk-demo/fontrendering.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ update_image (void)
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
cairo_font_options_set_hint_style (fopt, hintstyle);

if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (hint_metrics)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (hint_metrics)))
hintmetrics = CAIRO_HINT_METRICS_ON;
else
hintmetrics = CAIRO_HINT_METRICS_OFF;
Expand All @@ -69,7 +69,7 @@ update_image (void)
cairo_font_options_destroy (fopt);
pango_context_changed (context);

if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_radio)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (text_radio)))
{
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
Expand Down Expand Up @@ -107,7 +107,7 @@ update_image (void)
cr = cairo_create (surface);
cairo_set_line_width (cr, 1);

if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_grid)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (show_grid)))
{
int i;
cairo_set_source_rgba (cr, 0.2, 0, 0, 0.2);
Expand All @@ -125,7 +125,7 @@ update_image (void)
}
}

if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_extents)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (show_extents)))
{
cairo_set_source_rgba (cr, 0, 0, 1, 1);

Expand Down
4 changes: 2 additions & 2 deletions demos/gtk-demo/listbox2.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ row_activated (GtkListBox *list,
}
else if (gtk_widget_is_ancestor (check, GTK_WIDGET (row)))
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
gtk_check_button_set_active (GTK_CHECK_BUTTON (check),
!gtk_check_button_get_active (GTK_CHECK_BUTTON (check)));
}
else if (gtk_widget_is_ancestor (image, GTK_WIDGET (row)))
{
Expand Down
6 changes: 3 additions & 3 deletions demos/gtk-demo/panes.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ create_pane_options (GtkPaned *paned,

check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), child1);

Expand All @@ -84,13 +84,13 @@ create_pane_options (GtkPaned *paned,

check_button = gtk_check_button_new_with_mnemonic ("_Resize");
gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), child2);

check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), child2);

Expand Down
2 changes: 1 addition & 1 deletion demos/gtk-demo/sizegroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ do_sizegroup (GtkWidget *do_widget)
check_button = gtk_check_button_new_with_mnemonic ("_Enable grouping");
gtk_box_append (GTK_BOX (vbox), check_button);

gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_grouping), size_group);
}
Expand Down
2 changes: 1 addition & 1 deletion demos/node-editor/node-editor-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ testcase_save_clicked_cb (GtkWidget *button,
png_file = g_build_filename (source_dir, png_file_name, NULL);
g_free (png_file_name);

if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->testcase_cairo_checkbutton)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (self->testcase_cairo_checkbutton)))
texture = create_cairo_texture (self);
else
texture = create_texture (self);
Expand Down
4 changes: 2 additions & 2 deletions examples/plugman.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,10 @@ configure_plugins (GSimpleAction *action,

dialog = (GtkWidget *)gtk_builder_get_object (builder, "plugin-dialog");
check = (GtkWidget *)gtk_builder_get_object (builder, "red-plugin");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), plugin_enabled ("red"));
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), plugin_enabled ("red"));
g_signal_connect (check, "toggled", G_CALLBACK (enable_or_disable_plugin), (char *) "red");
check = (GtkWidget *)gtk_builder_get_object (builder, "black-plugin");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), plugin_enabled ("black"));
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), plugin_enabled ("black"));
g_signal_connect (check, "toggled", G_CALLBACK (enable_or_disable_plugin), (char *) "black");

g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
Expand Down
8 changes: 4 additions & 4 deletions gtk/gtkfilechooserwidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -8001,8 +8001,8 @@ gtk_file_chooser_widget_set_choice (GtkFileChooser *chooser,
}
}
}
else if (GTK_IS_TOGGLE_BUTTON (widget))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), g_str_equal (option, "true"));
else if (GTK_IS_CHECK_BUTTON (widget))
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), g_str_equal (option, "true"));
}

static const char *
Expand All @@ -8024,8 +8024,8 @@ gtk_file_chooser_widget_get_choice (GtkFileChooser *chooser,
return NULL;
}

else if (GTK_IS_TOGGLE_BUTTON (widget))
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? "true" : "false";
else if (GTK_IS_CHECK_BUTTON (widget))
return gtk_check_button_get_active (GTK_CHECK_BUTTON (widget)) ? "true" : "false";

return NULL;
}
Expand Down
16 changes: 8 additions & 8 deletions gtk/gtkpagesetupunixdialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "gtkbutton.h"
#include "gtkscrolledwindow.h"
#include "gtktogglebutton.h"
#include "gtkcheckbutton.h"
#include "gtklabel.h"
#include "gtkgrid.h"
#include "gtkcelllayout.h"
Expand Down Expand Up @@ -779,11 +779,11 @@ gtk_page_setup_unix_dialog_new (const char *title,
static GtkPageOrientation
get_orientation (GtkPageSetupUnixDialog *dialog)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->portrait_radio)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->portrait_radio)))
return GTK_PAGE_ORIENTATION_PORTRAIT;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->landscape_radio)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->landscape_radio)))
return GTK_PAGE_ORIENTATION_LANDSCAPE;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->reverse_landscape_radio)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->reverse_landscape_radio)))
return GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE;
return GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT;
}
Expand All @@ -795,16 +795,16 @@ set_orientation (GtkPageSetupUnixDialog *dialog,
switch (orientation)
{
case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->reverse_portrait_radio), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->reverse_portrait_radio), TRUE);
break;
case GTK_PAGE_ORIENTATION_PORTRAIT:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->portrait_radio), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->portrait_radio), TRUE);
break;
case GTK_PAGE_ORIENTATION_LANDSCAPE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->landscape_radio), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->landscape_radio), TRUE);
break;
case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->reverse_landscape_radio), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->reverse_landscape_radio), TRUE);
break;
default:
break;
Expand Down
5 changes: 2 additions & 3 deletions gtk/gtkprintbackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ store_auth_info_toggled (GtkCheckButton *chkbtn,
gpointer user_data)
{
gboolean *data = (gboolean *) user_data;
*data = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chkbtn));
*data = gtk_check_button_get_active (GTK_CHECK_BUTTON (chkbtn));
}

static void
Expand Down Expand Up @@ -670,7 +670,6 @@ request_password (GtkPrintBackend *backend,
gtk_widget_set_size_request (GTK_WIDGET (label), 320, -1);
g_free (markup);


/* Packing */
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_box_append (GTK_BOX (content_area), main_box);
Expand Down Expand Up @@ -719,7 +718,7 @@ request_password (GtkPrintBackend *backend,
chkbtn = gtk_check_button_new_with_mnemonic (_("_Remember password"));
gtk_widget_set_margin_top (chkbtn, 6);
gtk_widget_set_margin_bottom (chkbtn, 6);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbtn), FALSE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (chkbtn), FALSE);
gtk_box_append (GTK_BOX (vbox), chkbtn);
g_signal_connect (chkbtn, "toggled",
G_CALLBACK (store_auth_info_toggled),
Expand Down
4 changes: 2 additions & 2 deletions gtk/gtkprinteroptionwidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,9 +1123,9 @@ update_widgets (GtkPrinterOptionWidget *widget)
{
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
if (g_ascii_strcasecmp (source->value, "True") == 0)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (priv->check), TRUE);
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check), FALSE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (priv->check), FALSE);
break;
case GTK_PRINTER_OPTION_TYPE_PICKONE:
combo_box_set (priv->combo, source->value);
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -6591,7 +6591,7 @@ warn_response (GtkDialog *dialog,
display = gtk_inspector_window_get_inspected_display (GTK_INSPECTOR_WINDOW (inspector_window));

check = g_object_get_data (G_OBJECT (dialog), "check");
remember = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
remember = gtk_check_button_get_active (GTK_CHECK_BUTTON (check));

gtk_window_destroy (GTK_WINDOW (dialog));
g_object_set_data (G_OBJECT (inspector_window), "warning_dialog", NULL);
Expand Down
4 changes: 2 additions & 2 deletions gtk/inspector/logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "gtktextview.h"
#include "gtkmessagedialog.h"
#include "gtkfilechooserdialog.h"
#include "gtktogglebutton.h"
#include "gtkcheckbutton.h"
#include "gtklabel.h"
#include "gtktooltip.h"
#include "gtktextiter.h"
Expand Down Expand Up @@ -112,7 +112,7 @@ update_flag (GtkWidget *widget,
guint *flags,
guint flag)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (widget)))
*flags = *flags | flag;
else
*flags = *flags & ~flag;
Expand Down
2 changes: 1 addition & 1 deletion gtk/inspector/prop-editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ flags_modified (GtkCheckButton *button, ObjectProperty *p)
int i;
GValue val = G_VALUE_INIT;

active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
active = gtk_check_button_get_active (button);
i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "index"));
fclass = G_FLAGS_CLASS (g_type_class_peek (p->spec->value_type));

Expand Down
8 changes: 4 additions & 4 deletions gtk/ui/gtkpagesetupunixdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</object>
</child>
<child>
<object class="GtkRadioButton" id="portrait_radio">
<object class="GtkCheckButton" id="portrait_radio">
<property name="hexpand">1</property>
<property name="active">1</property>
<child>
Expand All @@ -118,7 +118,7 @@
</object>
</child>
<child>
<object class="GtkRadioButton" id="reverse_portrait_radio">
<object class="GtkCheckButton" id="reverse_portrait_radio">
<property name="hexpand">1</property>
<property name="active">1</property>
<property name="group">portrait_radio</property>
Expand All @@ -144,7 +144,7 @@
</object>
</child>
<child>
<object class="GtkRadioButton" id="landscape_radio">
<object class="GtkCheckButton" id="landscape_radio">
<property name="hexpand">1</property>
<property name="active">1</property>
<property name="group">portrait_radio</property>
Expand All @@ -170,7 +170,7 @@
</object>
</child>
<child>
<object class="GtkRadioButton" id="reverse_landscape_radio">
<object class="GtkCheckButton" id="reverse_landscape_radio">
<property name="hexpand">1</property>
<property name="group">portrait_radio</property>
<child>
Expand Down
4 changes: 2 additions & 2 deletions tests/testcalendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ flag_toggled_cb (GtkCheckButton *button,
} *data = user_data;

g_object_set (G_OBJECT (data->calendar), data->prop_name,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)),
gtk_check_button_get_active (GTK_CHECK_BUTTON (button)),
NULL);
}

Expand Down Expand Up @@ -255,7 +255,7 @@ create_calendar(void)
gtk_box_append (GTK_BOX (vbox), toggle);

g_object_get (G_OBJECT (calendar), flags[i].prop_name, &value, NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), value);
gtk_check_button_set_active (GTK_CHECK_BUTTON (toggle), value);

g_signal_connect (toggle, "toggled", G_CALLBACK (flag_toggled_cb), &flags[i]);
}
Expand Down
Loading

0 comments on commit 2c5c938

Please sign in to comment.