Compare commits

...

9 Commits

Author SHA1 Message Date
Emmanuele Bassi
2855ea43a3 trashmonitor: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:28:38 +01:00
Emmanuele Bassi
2a9296f54e calendar: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:28:22 +01:00
Emmanuele Bassi
4c77a466af calendar: Remove unused field and translatable string
Since the switch to child widgets, GtkCalendar has stopped using the
"year_before" field, and does not need to compute whether the year
should be displayed before the month depending on the locale.
2023-06-28 15:27:10 +01:00
Emmanuele Bassi
91c7fc9cc5 colorswatch: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:26:45 +01:00
Emmanuele Bassi
595e2e6001 coloreditor: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:26:18 +01:00
Emmanuele Bassi
31e16ed7ba checkbutton: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:25:59 +01:00
Emmanuele Bassi
2925ba2228 button: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:25:37 +01:00
Emmanuele Bassi
40f6f11cae box: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:25:06 +01:00
Emmanuele Bassi
f92dd63401 aboutdialog: Replace internal 1-bit fields with bool
Single bit fields cannot be used by address, and will overflow when
set to values that are bigger than one bit; the behaviour (if not the
size) of the C99 bool type is better defined.
2023-06-28 15:22:07 +01:00
8 changed files with 116 additions and 127 deletions

View File

@@ -197,9 +197,8 @@ struct _GtkAboutDialog
GtkLicense license_type; GtkLicense license_type;
guint hovering_over_link : 1; bool hovering_over_link;
guint wrap_license : 1; bool wrap_license;
guint in_child_changed : 1;
}; };
struct _GtkAboutDialogClass struct _GtkAboutDialogClass
@@ -724,8 +723,8 @@ gtk_about_dialog_init (GtkAboutDialog *about)
about->documenters = NULL; about->documenters = NULL;
about->artists = NULL; about->artists = NULL;
about->hovering_over_link = FALSE; about->hovering_over_link = false;
about->wrap_license = FALSE; about->wrap_license = false;
about->license_type = GTK_LICENSE_UNKNOWN; about->license_type = GTK_LICENSE_UNKNOWN;
@@ -1305,11 +1304,11 @@ gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
{ {
g_return_if_fail (GTK_IS_ABOUT_DIALOG (about)); g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
wrap_license = wrap_license != FALSE; bool wrap = !!wrap_license;
if (about->wrap_license != wrap_license) if (about->wrap_license != wrap)
{ {
about->wrap_license = wrap_license; about->wrap_license = wrap;
g_object_notify_by_pspec (G_OBJECT (about), props[PROP_WRAP_LICENSE]); g_object_notify_by_pspec (G_OBJECT (about), props[PROP_WRAP_LICENSE]);
} }
@@ -1780,7 +1779,7 @@ set_cursor_if_appropriate (GtkAboutDialog *about,
{ {
GSList *tags = NULL, *tagp = NULL; GSList *tags = NULL, *tagp = NULL;
GtkTextIter iter; GtkTextIter iter;
gboolean hovering_over_link = FALSE; bool hovering_over_link = false;
gtk_text_view_get_iter_at_location (text_view, &iter, x, y); gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
@@ -1792,7 +1791,7 @@ set_cursor_if_appropriate (GtkAboutDialog *about,
if (uri != NULL) if (uri != NULL)
{ {
hovering_over_link = TRUE; hovering_over_link = true;
break; break;
} }
} }
@@ -2273,7 +2272,7 @@ gtk_about_dialog_set_license_type (GtkAboutDialog *about,
g_free (about->license); g_free (about->license);
about->license = g_string_free (str, FALSE); about->license = g_string_free (str, FALSE);
about->wrap_license = TRUE; about->wrap_license = true;
license_string = g_strdup_printf ("<span size=\"small\">%s</span>", license_string = g_strdup_printf ("<span size=\"small\">%s</span>",
about->license); about->license);

View File

@@ -86,10 +86,12 @@ enum {
typedef struct typedef struct
{ {
gint16 spacing; gint16 spacing;
guint homogeneous : 1; bool homogeneous;
guint baseline_pos : 2;
/* GtkBaselinePosition */
guint baseline_pos : 2;
} GtkBoxPrivate; } GtkBoxPrivate;
static GParamSpec *props[LAST_PROP] = { NULL, }; static GParamSpec *props[LAST_PROP] = { NULL, };
@@ -369,14 +371,13 @@ void
gtk_box_set_homogeneous (GtkBox *box, gtk_box_set_homogeneous (GtkBox *box,
gboolean homogeneous) gboolean homogeneous)
{ {
bool is_homogeneous = !!homogeneous;
GtkBoxLayout *box_layout; GtkBoxLayout *box_layout;
g_return_if_fail (GTK_IS_BOX (box)); g_return_if_fail (GTK_IS_BOX (box));
homogeneous = !!homogeneous;
box_layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (box))); box_layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (box)));
if (homogeneous == gtk_box_layout_get_homogeneous (box_layout)) if (is_homogeneous == gtk_box_layout_get_homogeneous (box_layout))
return; return;
gtk_box_layout_set_homogeneous (box_layout, homogeneous); gtk_box_layout_set_homogeneous (box_layout, homogeneous);

View File

@@ -83,18 +83,19 @@
struct _GtkButtonPrivate struct _GtkButtonPrivate
{ {
GtkWidget *child; GtkWidget *child;
GtkActionHelper *action_helper; GtkActionHelper *action_helper;
GtkGesture *gesture; GtkGesture *gesture;
guint activate_timeout; guint activate_timeout;
guint button_down : 1; bool button_down;
guint use_underline : 1; bool use_underline;
guint child_type : 2; bool can_shrink;
guint can_shrink : 1;
guint child_type : 2;
}; };
enum { enum {
@@ -353,7 +354,7 @@ click_pressed_cb (GtkGestureClick *gesture,
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
if (!priv->activate_timeout) if (!priv->activate_timeout)
priv->button_down = TRUE; priv->button_down = true;
} }
static void static void
@@ -444,8 +445,8 @@ gtk_button_init (GtkButton *button)
gtk_widget_set_focusable (GTK_WIDGET (button), TRUE); gtk_widget_set_focusable (GTK_WIDGET (button), TRUE);
gtk_widget_set_receives_default (GTK_WIDGET (button), TRUE); gtk_widget_set_receives_default (GTK_WIDGET (button), TRUE);
priv->button_down = FALSE; priv->button_down = false;
priv->use_underline = FALSE; priv->use_underline = false;
priv->child_type = WIDGET_CHILD; priv->child_type = WIDGET_CHILD;
priv->gesture = gtk_gesture_click_new (); priv->gesture = gtk_gesture_click_new ();
@@ -772,7 +773,7 @@ gtk_button_do_release (GtkButton *button,
if (priv->button_down) if (priv->button_down)
{ {
priv->button_down = FALSE; priv->button_down = false;
if (priv->activate_timeout) if (priv->activate_timeout)
return; return;
@@ -811,7 +812,7 @@ gtk_real_button_activate (GtkButton *button)
gdk_source_set_static_name_by_id (priv->activate_timeout, "[gtk] button_activate_timeout"); gdk_source_set_static_name_by_id (priv->activate_timeout, "[gtk] button_activate_timeout");
gtk_widget_add_css_class (GTK_WIDGET (button), "keyboard-activating"); gtk_widget_add_css_class (GTK_WIDGET (button), "keyboard-activating");
priv->button_down = TRUE; priv->button_down = true;
} }
} }
@@ -826,7 +827,7 @@ gtk_button_finish_activate (GtkButton *button,
g_source_remove (priv->activate_timeout); g_source_remove (priv->activate_timeout);
priv->activate_timeout = 0; priv->activate_timeout = 0;
priv->button_down = FALSE; priv->button_down = false;
if (do_it) if (do_it)
g_signal_emit (button, button_signals[CLICKED], 0); g_signal_emit (button, button_signals[CLICKED], 0);
@@ -918,20 +919,19 @@ gtk_button_set_use_underline (GtkButton *button,
gboolean use_underline) gboolean use_underline)
{ {
GtkButtonPrivate *priv = gtk_button_get_instance_private (button); GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
bool underline = !!use_underline;
g_return_if_fail (GTK_IS_BUTTON (button)); g_return_if_fail (GTK_IS_BUTTON (button));
use_underline = use_underline != FALSE; if (underline != priv->use_underline)
if (use_underline != priv->use_underline)
{ {
if (priv->child_type == LABEL_CHILD) if (priv->child_type == LABEL_CHILD)
{ {
gtk_label_set_use_underline (GTK_LABEL (priv->child), use_underline); gtk_label_set_use_underline (GTK_LABEL (priv->child), underline);
gtk_label_set_mnemonic_widget (GTK_LABEL (priv->child), GTK_WIDGET (button)); gtk_label_set_mnemonic_widget (GTK_LABEL (priv->child), GTK_WIDGET (button));
} }
priv->use_underline = use_underline; priv->use_underline = underline;
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_USE_UNDERLINE]); g_object_notify_by_pspec (G_OBJECT (button), props[PROP_USE_UNDERLINE]);
} }
} }
@@ -1118,14 +1118,13 @@ gtk_button_set_can_shrink (GtkButton *button,
gboolean can_shrink) gboolean can_shrink)
{ {
GtkButtonPrivate *priv = gtk_button_get_instance_private (button); GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
bool shrink = !!can_shrink;
g_return_if_fail (GTK_IS_BUTTON (button)); g_return_if_fail (GTK_IS_BUTTON (button));
can_shrink = !!can_shrink; if (priv->can_shrink != shrink)
if (priv->can_shrink != can_shrink)
{ {
priv->can_shrink = can_shrink; priv->can_shrink = shrink;
switch (priv->child_type) switch (priv->child_type)
{ {

View File

@@ -202,10 +202,9 @@ struct _GtkCalendar
{ {
GtkWidget widget; GtkWidget widget;
guint show_week_numbers : 1; bool show_week_numbers;
guint show_heading : 1; bool show_heading;
guint show_day_names : 1; bool show_day_names;
guint year_before : 1;
GtkWidget *header_box; GtkWidget *header_box;
GtkWidget *year_label; GtkWidget *year_label;
@@ -219,14 +218,14 @@ struct _GtkCalendar
GDateTime *date; GDateTime *date;
int day_month[6][7]; int day_month[6][7];
int day[6][7]; int day[6][7];
int num_marked_dates; int num_marked_dates;
int marked_date[31]; int marked_date[31];
int focus_row; int focus_row;
int focus_col; int focus_col;
int week_start; int week_start;
}; };
@@ -547,7 +546,6 @@ gtk_calendar_init (GtkCalendar *calendar)
char buffer[255]; char buffer[255];
time_t tmp_time; time_t tmp_time;
#endif #endif
char *year_before;
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
union { unsigned int word; char *string; } langinfo; union { unsigned int word; char *string; } langinfo;
int week_1stday = 0; int week_1stday = 0;
@@ -775,12 +773,12 @@ gtk_calendar_init (GtkCalendar *calendar)
gtk_widget_set_vexpand (calendar->grid, TRUE); gtk_widget_set_vexpand (calendar->grid, TRUE);
gtk_widget_set_parent (calendar->grid, GTK_WIDGET (calendar)); gtk_widget_set_parent (calendar->grid, GTK_WIDGET (calendar));
for (i=0;i<31;i++) for (i = 0; i < 31; i++)
calendar->marked_date[i] = FALSE; calendar->marked_date[i] = FALSE;
calendar->num_marked_dates = 0; calendar->num_marked_dates = 0;
calendar->show_heading = TRUE; calendar->show_heading = true;
calendar->show_day_names = TRUE; calendar->show_day_names = true;
calendar->focus_row = -1; calendar->focus_row = -1;
calendar->focus_col = -1; calendar->focus_col = -1;
@@ -791,24 +789,6 @@ gtk_calendar_init (GtkCalendar *calendar)
g_signal_connect (target, "drop", G_CALLBACK (gtk_calendar_drag_drop), calendar); g_signal_connect (target, "drop", G_CALLBACK (gtk_calendar_drag_drop), calendar);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (target)); gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (target));
calendar->year_before = 0;
/* Translate to calendar:YM if you want years to be displayed
* before months; otherwise translate to calendar:MY.
* Do *not* translate it to anything else, if it
* it isn't calendar:YM or calendar:MY it will not work.
*
* Note that the ordering described here is logical order, which is
* further influenced by BIDI ordering. Thus, if you have a default
* text direction of RTL and specify "calendar:YM", then the year
* will appear to the right of the month.
*/
year_before = _("calendar:MY");
if (strcmp (year_before, "calendar:YM") == 0)
calendar->year_before = 1;
else if (strcmp (year_before, "calendar:MY") != 0)
g_warning ("Whoever translated calendar:MY did so wrongly.");
gtk_orientable_set_orientation (GTK_ORIENTABLE (gtk_widget_get_layout_manager (GTK_WIDGET (calendar))), gtk_orientable_set_orientation (GTK_ORIENTABLE (gtk_widget_get_layout_manager (GTK_WIDGET (calendar))),
GTK_ORIENTATION_VERTICAL); GTK_ORIENTATION_VERTICAL);
@@ -1657,17 +1637,18 @@ void
gtk_calendar_set_show_week_numbers (GtkCalendar *self, gtk_calendar_set_show_week_numbers (GtkCalendar *self,
gboolean value) gboolean value)
{ {
bool show_week_numbers = !!value;
int i; int i;
g_return_if_fail (GTK_IS_CALENDAR (self)); g_return_if_fail (GTK_IS_CALENDAR (self));
if (self->show_week_numbers == value) if (self->show_week_numbers == show_week_numbers)
return; return;
self->show_week_numbers = value; self->show_week_numbers = show_week_numbers;
for (i = 0; i < 6; i ++) for (i = 0; i < 6; i ++)
gtk_widget_set_visible (self->week_number_labels[i], value); gtk_widget_set_visible (self->week_number_labels[i], show_week_numbers);
g_object_notify (G_OBJECT (self), "show-week-numbers"); g_object_notify (G_OBJECT (self), "show-week-numbers");
} }
@@ -1706,14 +1687,16 @@ void
gtk_calendar_set_show_heading (GtkCalendar *self, gtk_calendar_set_show_heading (GtkCalendar *self,
gboolean value) gboolean value)
{ {
bool show_heading = !!value;
g_return_if_fail (GTK_IS_CALENDAR (self)); g_return_if_fail (GTK_IS_CALENDAR (self));
if (self->show_heading == value) if (self->show_heading == show_heading)
return; return;
self->show_heading = value; self->show_heading = show_heading;
gtk_widget_set_visible (self->header_box, value); gtk_widget_set_visible (self->header_box, show_heading);
g_object_notify (G_OBJECT (self), "show-heading"); g_object_notify (G_OBJECT (self), "show-heading");
} }
@@ -1748,17 +1731,18 @@ void
gtk_calendar_set_show_day_names (GtkCalendar *self, gtk_calendar_set_show_day_names (GtkCalendar *self,
gboolean value) gboolean value)
{ {
bool show_day_names = !!value;
int i; int i;
g_return_if_fail (GTK_IS_CALENDAR (self)); g_return_if_fail (GTK_IS_CALENDAR (self));
if (self->show_day_names == value) if (self->show_day_names == show_day_names)
return; return;
self->show_day_names = value; self->show_day_names = show_day_names;
for (i = 0; i < 7; i ++) for (i = 0; i < 7; i ++)
gtk_widget_set_visible (self->day_name_labels[i], value); gtk_widget_set_visible (self->day_name_labels[i], show_day_names);
g_object_notify (G_OBJECT (self), "show-day-names"); g_object_notify (G_OBJECT (self), "show-day-names");
} }

View File

@@ -103,10 +103,11 @@ typedef struct {
GtkWidget *indicator_widget; GtkWidget *indicator_widget;
GtkWidget *child; GtkWidget *child;
guint inconsistent: 1; bool inconsistent;
guint active: 1; bool active;
guint use_underline: 1; bool use_underline;
guint child_type: 1;
guint child_type : 1;
GtkCheckButton *group_next; GtkCheckButton *group_next;
GtkCheckButton *group_prev; GtkCheckButton *group_prev;
@@ -790,13 +791,13 @@ gtk_check_button_set_inconsistent (GtkCheckButton *check_button,
gboolean inconsistent) gboolean inconsistent)
{ {
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (check_button); GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (check_button);
bool is_inconsistent = !!inconsistent;
g_return_if_fail (GTK_IS_CHECK_BUTTON (check_button)); g_return_if_fail (GTK_IS_CHECK_BUTTON (check_button));
inconsistent = !!inconsistent; if (priv->inconsistent != is_inconsistent)
if (priv->inconsistent != inconsistent)
{ {
priv->inconsistent = inconsistent; priv->inconsistent = is_inconsistent;
if (inconsistent) if (inconsistent)
{ {
@@ -863,15 +864,14 @@ gtk_check_button_set_active (GtkCheckButton *self,
gboolean setting) gboolean setting)
{ {
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self); GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
bool is_active = !!setting;
g_return_if_fail (GTK_IS_CHECK_BUTTON (self)); g_return_if_fail (GTK_IS_CHECK_BUTTON (self));
setting = !!setting; if (is_active == priv->active)
if (setting == priv->active)
return; return;
if (setting) if (is_active)
{ {
gtk_widget_set_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_CHECKED, FALSE); gtk_widget_set_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_CHECKED, FALSE);
gtk_widget_set_state_flags (priv->indicator_widget, GTK_STATE_FLAG_CHECKED, FALSE); gtk_widget_set_state_flags (priv->indicator_widget, GTK_STATE_FLAG_CHECKED, FALSE);
@@ -882,7 +882,7 @@ gtk_check_button_set_active (GtkCheckButton *self,
gtk_widget_unset_state_flags (priv->indicator_widget, GTK_STATE_FLAG_CHECKED); gtk_widget_unset_state_flags (priv->indicator_widget, GTK_STATE_FLAG_CHECKED);
} }
if (setting && (priv->group_prev || priv->group_next)) if (is_active && (priv->group_prev || priv->group_next))
{ {
GtkCheckButton *group_first = NULL; GtkCheckButton *group_first = NULL;
GtkCheckButton *iter; GtkCheckButton *iter;
@@ -897,7 +897,7 @@ gtk_check_button_set_active (GtkCheckButton *self,
/* ... and the next code block will set this one to active */ /* ... and the next code block will set this one to active */
} }
priv->active = setting; priv->active = is_active;
update_accessible_state (self); update_accessible_state (self);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVE]); g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVE]);
g_signal_emit (self, signals[TOGGLED], 0); g_signal_emit (self, signals[TOGGLED], 0);
@@ -1095,15 +1095,14 @@ gtk_check_button_set_use_underline (GtkCheckButton *self,
gboolean setting) gboolean setting)
{ {
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self); GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
bool use_underline = !!setting;
g_return_if_fail (GTK_IS_CHECK_BUTTON (self)); g_return_if_fail (GTK_IS_CHECK_BUTTON (self));
setting = !!setting; if (use_underline == priv->use_underline)
if (setting == priv->use_underline)
return; return;
priv->use_underline = setting; priv->use_underline = use_underline;
if (priv->child_type == LABEL_CHILD && priv->child != NULL) if (priv->child_type == LABEL_CHILD && priv->child != NULL)
gtk_label_set_use_underline (GTK_LABEL (priv->child), priv->use_underline); gtk_label_set_use_underline (GTK_LABEL (priv->child), priv->use_underline);

View File

@@ -76,8 +76,8 @@ struct _GtkColorEditor
int popup_position; int popup_position;
guint text_changed : 1; bool text_changed;
guint use_alpha : 1; bool use_alpha;
}; };
struct _GtkColorEditorClass struct _GtkColorEditorClass
@@ -118,7 +118,7 @@ entry_set_rgba (GtkColorEditor *editor,
scale_round (color->green, 255), scale_round (color->green, 255),
scale_round (color->blue, 255)); scale_round (color->blue, 255));
gtk_editable_set_text (GTK_EDITABLE (editor->entry), text); gtk_editable_set_text (GTK_EDITABLE (editor->entry), text);
editor->text_changed = FALSE; editor->text_changed = false;
g_free (text); g_free (text);
} }
@@ -139,7 +139,7 @@ entry_apply (GtkWidget *entry,
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (editor), &color); gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (editor), &color);
} }
editor->text_changed = FALSE; editor->text_changed = false;
g_free (text); g_free (text);
} }
@@ -158,7 +158,7 @@ entry_text_changed (GtkWidget *entry,
GParamSpec *pspec, GParamSpec *pspec,
GtkColorEditor *editor) GtkColorEditor *editor)
{ {
editor->text_changed = TRUE; editor->text_changed = true;
} }
static void static void
@@ -409,7 +409,7 @@ gtk_color_editor_init (GtkColorEditor *editor)
{ {
GtkEventController *controller; GtkEventController *controller;
editor->use_alpha = TRUE; editor->use_alpha = true;
g_type_ensure (GTK_TYPE_COLOR_SCALE); g_type_ensure (GTK_TYPE_COLOR_SCALE);
g_type_ensure (GTK_TYPE_COLOR_PLANE); g_type_ensure (GTK_TYPE_COLOR_PLANE);
@@ -489,7 +489,7 @@ gtk_color_editor_get_property (GObject *object,
static void static void
gtk_color_editor_set_use_alpha (GtkColorEditor *editor, gtk_color_editor_set_use_alpha (GtkColorEditor *editor,
gboolean use_alpha) bool use_alpha)
{ {
if (editor->use_alpha != use_alpha) if (editor->use_alpha != use_alpha)
{ {
@@ -573,7 +573,7 @@ gtk_color_editor_class_init (GtkColorEditorClass *class)
* @component: the component to edit, "h", "sv" or "a" * @component: the component to edit, "h", "sv" or "a"
* *
* Opens the edit popup for one of the color components. * Opens the edit popup for one of the color components.
*/ */
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit); gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
} }

View File

@@ -55,10 +55,11 @@ struct _GtkColorSwatch
GdkRGBA color; GdkRGBA color;
char *icon; char *icon;
guint has_color : 1;
guint use_alpha : 1; bool has_color;
guint selectable : 1; bool use_alpha;
guint has_menu : 1; bool has_menu;
bool selectable;
GtkWidget *overlay_widget; GtkWidget *overlay_widget;
@@ -549,9 +550,9 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
GtkEventController *controller; GtkEventController *controller;
GtkGesture *gesture; GtkGesture *gesture;
swatch->use_alpha = TRUE; swatch->use_alpha = true;
swatch->selectable = TRUE; swatch->selectable = true;
swatch->has_menu = TRUE; swatch->has_menu = true;
swatch->color.red = 0.75; swatch->color.red = 0.75;
swatch->color.green = 0.25; swatch->color.green = 0.25;
swatch->color.blue = 0.25; swatch->color.blue = 0.25;
@@ -610,7 +611,7 @@ void
gtk_color_swatch_set_rgba (GtkColorSwatch *swatch, gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
const GdkRGBA *color) const GdkRGBA *color)
{ {
swatch->has_color = TRUE; swatch->has_color = true;
swatch->color = *color; swatch->color = *color;
if (swatch->source) if (swatch->source)
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (swatch->source), GTK_PHASE_CAPTURE); gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (swatch->source), GTK_PHASE_CAPTURE);
@@ -711,21 +712,27 @@ gtk_color_swatch_set_can_drag (GtkColorSwatch *swatch,
void void
gtk_color_swatch_set_use_alpha (GtkColorSwatch *swatch, gtk_color_swatch_set_use_alpha (GtkColorSwatch *swatch,
gboolean use_alpha) gboolean value)
{ {
bool use_alpha = !!value;
if (use_alpha == swatch->use_alpha)
return;
swatch->use_alpha = use_alpha; swatch->use_alpha = use_alpha;
gtk_widget_queue_draw (GTK_WIDGET (swatch)); gtk_widget_queue_draw (GTK_WIDGET (swatch));
} }
void void
gtk_color_swatch_set_selectable (GtkColorSwatch *swatch, gtk_color_swatch_set_selectable (GtkColorSwatch *swatch,
gboolean selectable) gboolean value)
{ {
bool selectable = !!value;
if (selectable == swatch->selectable) if (selectable == swatch->selectable)
return; return;
swatch->selectable = selectable; swatch->selectable = selectable;
update_accessible_properties (swatch); update_accessible_properties (swatch);
g_object_notify (G_OBJECT (swatch), "selectable"); g_object_notify (G_OBJECT (swatch), "selectable");
} }

View File

@@ -33,10 +33,10 @@ struct _GtkTrashMonitor
GFileMonitor *file_monitor; GFileMonitor *file_monitor;
gulong file_monitor_changed_id; gulong file_monitor_changed_id;
gboolean pending; bool pending;
int timeout_id; int timeout_id;
guint has_trash : 1; bool has_trash;
}; };
struct _GtkTrashMonitorClass struct _GtkTrashMonitorClass
@@ -104,14 +104,14 @@ _gtk_trash_monitor_class_init (GtkTrashMonitorClass *class)
/* Updates the internal has_trash flag and emits the "trash-state-changed" signal */ /* Updates the internal has_trash flag and emits the "trash-state-changed" signal */
static void static void
update_has_trash_and_notify (GtkTrashMonitor *monitor, update_has_trash_and_notify (GtkTrashMonitor *monitor,
gboolean has_trash) bool has_trash)
{ {
if (monitor->has_trash == !!has_trash) if (monitor->has_trash == has_trash)
return; return;
monitor->has_trash = !!has_trash; monitor->has_trash = has_trash;
g_signal_emit (monitor, signals[TRASH_STATE_CHANGED], 0); g_signal_emit (monitor, signals[TRASH_STATE_CHANGED], 0);
} }
/* Use G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT since we only want to know whether the /* Use G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT since we only want to know whether the
@@ -127,7 +127,7 @@ trash_query_info_cb (GObject *source,
GtkTrashMonitor *monitor = GTK_TRASH_MONITOR (user_data); GtkTrashMonitor *monitor = GTK_TRASH_MONITOR (user_data);
GFileInfo *info; GFileInfo *info;
guint32 item_count; guint32 item_count;
gboolean has_trash = FALSE; bool has_trash = false;
info = g_file_query_info_finish (G_FILE (source), result, NULL); info = g_file_query_info_finish (G_FILE (source), result, NULL);
@@ -155,7 +155,7 @@ recompute_trash_state_cb (gpointer data)
monitor->timeout_id = 0; monitor->timeout_id = 0;
if (monitor->pending) if (monitor->pending)
{ {
monitor->pending = FALSE; monitor->pending = false;
recompute_trash_state (monitor); recompute_trash_state (monitor);
} }
@@ -173,7 +173,7 @@ recompute_trash_state (GtkTrashMonitor *monitor)
*/ */
if (monitor->timeout_id > 0) if (monitor->timeout_id > 0)
{ {
monitor->pending = TRUE; monitor->pending = true;
return; return;
} }
@@ -213,7 +213,7 @@ _gtk_trash_monitor_init (GtkTrashMonitor *monitor)
file = g_file_new_for_uri ("trash:///"); file = g_file_new_for_uri ("trash:///");
monitor->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); monitor->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL);
monitor->pending = FALSE; monitor->pending = false;
monitor->timeout_id = 0; monitor->timeout_id = 0;
g_object_unref (file); g_object_unref (file);