Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
gtk
Commits
b7ee2cbc
Commit
b7ee2cbc
authored
Jan 29, 2020
by
Timm Bäder
🤔
Committed by
Matthias Clasen
Feb 07, 2020
Browse files
Start using GtkWidget's new style class API
parent
b1d64a6b
Changes
60
Hide whitespace changes
Inline
Side-by-side
gtk/gtkappchooserdialog.c
View file @
b7ee2cbc
...
...
@@ -452,8 +452,8 @@ setup_search (GtkAppChooserDialog *self)
gtk_widget_set_valign
(
button
,
GTK_ALIGN_CENTER
);
image
=
gtk_image_new_from_icon_name
(
"edit-find-symbolic"
);
gtk_container_add
(
GTK_CONTAINER
(
button
),
image
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"image-button"
);
gtk_
style_context_remove_class
(
gtk_widget_get
_style_c
ontext
(
button
)
,
"text-button"
);
gtk_widget_
add
_style_c
lass
(
button
,
"image-button"
);
gtk_
widget_remove
_style_c
lass
(
button
,
"text-button"
);
header
=
gtk_dialog_get_header_bar
(
GTK_DIALOG
(
self
));
gtk_header_bar_pack_end
(
GTK_HEADER_BAR
(
header
),
button
);
...
...
gtk/gtkbutton.c
View file @
b7ee2cbc
...
...
@@ -654,9 +654,8 @@ gtk_button_new_with_mnemonic (const gchar *label)
*/
void
gtk_button_set_relief
(
GtkButton
*
button
,
GtkReliefStyle
relief
)
GtkReliefStyle
relief
)
{
GtkStyleContext
*
context
;
GtkReliefStyle
old_relief
;
g_return_if_fail
(
GTK_IS_BUTTON
(
button
));
...
...
@@ -664,11 +663,10 @@ gtk_button_set_relief (GtkButton *button,
old_relief
=
gtk_button_get_relief
(
button
);
if
(
old_relief
!=
relief
)
{
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
button
));
if
(
relief
==
GTK_RELIEF_NONE
)
gtk_
style_context_add_class
(
context
,
GTK_STYLE_CLASS_FLAT
);
gtk_
widget_add_style_class
(
GTK_WIDGET
(
button
)
,
GTK_STYLE_CLASS_FLAT
);
else
gtk_
style_contex
t_remove_class
(
context
,
GTK_STYLE_CLASS_FLAT
);
gtk_
widge
t_remove_
style_
class
(
GTK_WIDGET
(
button
)
,
GTK_STYLE_CLASS_FLAT
);
g_object_notify_by_pspec
(
G_OBJECT
(
button
),
props
[
PROP_RELIEF
]);
}
...
...
@@ -685,12 +683,9 @@ gtk_button_set_relief (GtkButton *button,
GtkReliefStyle
gtk_button_get_relief
(
GtkButton
*
button
)
{
GtkStyleContext
*
context
;
g_return_val_if_fail
(
GTK_IS_BUTTON
(
button
),
GTK_RELIEF_NORMAL
);
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
button
));
if
(
gtk_style_context_has_class
(
context
,
GTK_STYLE_CLASS_FLAT
))
if
(
gtk_widget_has_style_class
(
GTK_WIDGET
(
button
),
GTK_STYLE_CLASS_FLAT
))
return
GTK_RELIEF_NONE
;
else
return
GTK_RELIEF_NORMAL
;
...
...
@@ -787,12 +782,9 @@ gtk_button_set_label (GtkButton *button,
{
GtkButtonPrivate
*
priv
=
gtk_button_get_instance_private
(
button
);
GtkWidget
*
child
;
GtkStyleContext
*
context
;
g_return_if_fail
(
GTK_IS_BUTTON
(
button
));
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
button
));
child
=
gtk_bin_get_child
(
GTK_BIN
(
button
));
if
(
priv
->
child_type
!=
LABEL_CHILD
||
child
==
NULL
)
...
...
@@ -811,8 +803,8 @@ gtk_button_set_label (GtkButton *button,
gtk_label_set_xalign
(
GTK_LABEL
(
child
),
0
.
0
);
}
gtk_container_add
(
GTK_CONTAINER
(
button
),
child
);
gtk_
style_contex
t_remove_class
(
context
,
"image-button"
);
gtk_
style_context_add_class
(
context
,
"text-button"
);
gtk_
widge
t_remove_
style_
class
(
GTK_WIDGET
(
button
)
,
"image-button"
);
gtk_
widget_add_style_class
(
GTK_WIDGET
(
button
)
,
"text-button"
);
}
gtk_label_set_label
(
GTK_LABEL
(
child
),
label
);
...
...
@@ -944,13 +936,11 @@ gtk_button_set_icon_name (GtkButton *button,
{
GtkButtonPrivate
*
priv
=
gtk_button_get_instance_private
(
button
);
GtkWidget
*
child
;
GtkStyleContext
*
context
;
g_return_if_fail
(
GTK_IS_BUTTON
(
button
));
g_return_if_fail
(
icon_name
!=
NULL
);
child
=
gtk_bin_get_child
(
GTK_BIN
(
button
));
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
button
));
if
(
priv
->
child_type
!=
ICON_CHILD
||
child
==
NULL
)
{
...
...
@@ -959,8 +949,8 @@ gtk_button_set_icon_name (GtkButton *button,
child
=
gtk_image_new_from_icon_name
(
icon_name
);
gtk_container_add
(
GTK_CONTAINER
(
button
),
child
);
gtk_
style_contex
t_remove_class
(
context
,
"text-button"
);
gtk_
style_context_add_class
(
context
,
"image-button"
);
gtk_
widge
t_remove_
style_
class
(
GTK_WIDGET
(
button
)
,
"text-button"
);
gtk_
widget_add_style_class
(
GTK_WIDGET
(
button
)
,
"image-button"
);
}
else
{
...
...
gtk/gtkcalendar.c
View file @
b7ee2cbc
...
...
@@ -743,16 +743,15 @@ gtk_calendar_init (GtkCalendar *calendar)
gtk_widget_set_can_focus
(
widget
,
TRUE
);
gtk_style_context_add_class
(
gtk_widget_get_style_context
(
GTK_WIDGET
(
calendar
)),
GTK_STYLE_CLASS_VIEW
);
gtk_widget_add_style_class
(
GTK_WIDGET
(
calendar
),
GTK_STYLE_CLASS_VIEW
);
priv
->
header_box
=
g_object_new
(
GTK_TYPE_BOX
,
"css-name"
,
"header"
,
NULL
);
priv
->
year_label
=
gtk_label_new
(
""
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
priv
->
year_label
)
,
"year"
);
gtk_widget_
add
_style_c
lass
(
priv
->
year_label
,
"year"
);
priv
->
month_name_stack
=
gtk_stack_new
();
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
priv
->
month_name_stack
)
,
"month"
);
gtk_widget_
add
_style_c
lass
(
priv
->
month_name_stack
,
"month"
);
priv
->
arrow_widgets
[
0
]
=
gtk_button_new_from_icon_name
(
"pan-start-symbolic"
);
g_signal_connect_swapped
(
priv
->
arrow_widgets
[
0
],
"clicked"
,
G_CALLBACK
(
calendar_set_month_prev
),
calendar
);
priv
->
arrow_widgets
[
1
]
=
gtk_button_new_from_icon_name
(
"pan-end-symbolic"
);
...
...
gtk/gtkcheckbutton.c
View file @
b7ee2cbc
...
...
@@ -393,10 +393,9 @@ gtk_check_button_init (GtkCheckButton *check_button)
{
GtkCheckButtonPrivate
*
priv
=
gtk_check_button_get_instance_private
(
check_button
);
gtk_widget_set_receives_default
(
GTK_WIDGET
(
check_button
),
FALSE
);
gtk_
style_context_remove_class
(
gtk_widget_get
_style_c
ontext
(
GTK_WIDGET
(
check_button
)
)
,
"toggle"
);
gtk_
widget_remove
_style_c
lass
(
GTK_WIDGET
(
check_button
),
"toggle"
);
priv
->
draw_indicator
=
TRUE
;
draw_indicator_changed
(
check_button
);
...
...
gtk/gtkcolorbutton.c
View file @
b7ee2cbc
...
...
@@ -299,7 +299,6 @@ gtk_color_button_init (GtkColorButton *button)
GtkColorButtonPrivate
*
priv
=
gtk_color_button_get_instance_private
(
button
);
PangoLayout
*
layout
;
PangoRectangle
rect
;
GtkStyleContext
*
context
;
GdkContentFormats
*
targets
;
GdkContentProvider
*
content
;
GtkDragSource
*
source
;
...
...
@@ -340,8 +339,7 @@ gtk_color_button_init (GtkColorButton *button)
g_signal_connect
(
source
,
"drag-begin"
,
G_CALLBACK
(
gtk_color_button_drag_begin
),
button
);
gtk_widget_add_controller
(
priv
->
button
,
GTK_EVENT_CONTROLLER
(
source
));
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
priv
->
button
));
gtk_style_context_add_class
(
context
,
"color"
);
gtk_widget_add_style_class
(
priv
->
button
,
"color"
);
}
static
void
...
...
gtk/gtkcolorchooserwidget.c
View file @
b7ee2cbc
...
...
@@ -378,19 +378,19 @@ add_palette (GtkColorChooserWidget *cc,
if
(
orientation
==
GTK_ORIENTATION_HORIZONTAL
)
{
if
(
pos
==
left
)
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
p
)
,
GTK_STYLE_CLASS_LEFT
);
else
if
(
pos
==
right
)
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
p
)
,
GTK_STYLE_CLASS_RIGHT
);
if
(
pos
==
left
)
gtk_widget_
add
_style_c
lass
(
p
,
GTK_STYLE_CLASS_LEFT
);
else
if
(
pos
==
right
)
gtk_widget_
add
_style_c
lass
(
p
,
GTK_STYLE_CLASS_RIGHT
);
gtk_grid_attach
(
GTK_GRID
(
grid
),
p
,
pos
,
line
,
1
,
1
);
gtk_grid_attach
(
GTK_GRID
(
grid
),
p
,
pos
,
line
,
1
,
1
);
}
else
{
if
(
pos
==
0
)
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
p
)
,
GTK_STYLE_CLASS_TOP
);
gtk_widget_
add
_style_c
lass
(
p
,
GTK_STYLE_CLASS_TOP
);
else
if
(
pos
==
colors_per_line
-
1
)
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
p
)
,
GTK_STYLE_CLASS_BOTTOM
);
gtk_widget_
add
_style_c
lass
(
p
,
GTK_STYLE_CLASS_BOTTOM
);
gtk_grid_attach
(
GTK_GRID
(
grid
),
p
,
line
,
pos
,
1
,
1
);
}
...
...
gtk/gtkcoloreditor.c
View file @
b7ee2cbc
...
...
@@ -386,11 +386,9 @@ gtk_color_editor_init (GtkColorEditor *editor)
gtk_widget_init_template
(
GTK_WIDGET
(
editor
));
if
(
gtk_widget_get_direction
(
editor
->
priv
->
h_slider
)
==
GTK_TEXT_DIR_RTL
)
gtk_style_context_add_class
(
gtk_widget_get_style_context
(
editor
->
priv
->
h_slider
),
"marks-before"
);
gtk_widget_add_style_class
(
editor
->
priv
->
h_slider
,
"marks-before"
);
else
gtk_style_context_add_class
(
gtk_widget_get_style_context
(
editor
->
priv
->
h_slider
),
"marks-after"
);
gtk_widget_add_style_class
(
editor
->
priv
->
h_slider
,
"marks-after"
);
/* Create the scaled popup adjustments manually here because connecting user data is not
* supported by template GtkBuilder xml (it would be possible to set this up in the xml
...
...
@@ -419,7 +417,7 @@ gtk_color_editor_init (GtkColorEditor *editor)
g_signal_connect
(
controller
,
"key-pressed"
,
G_CALLBACK
(
popup_key_pressed
),
editor
);
gtk_widget_add_controller
(
editor
->
priv
->
a_entry
,
controller
);
gtk_
style_context_remove_class
(
gtk_widget_get
_style_c
ontext
(
editor
->
priv
->
swatch
)
,
"activatable"
);
gtk_
widget_remove
_style_c
lass
(
editor
->
priv
->
swatch
,
"activatable"
);
editor
->
priv
->
picker
=
gtk_color_picker_new
();
if
(
editor
->
priv
->
picker
==
NULL
)
...
...
gtk/gtkcolorscale.c
View file @
b7ee2cbc
...
...
@@ -148,7 +148,6 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
static
void
gtk_color_scale_init
(
GtkColorScale
*
scale
)
{
GtkStyleContext
*
context
;
GtkGesture
*
gesture
;
gesture
=
gtk_gesture_long_press_new
();
...
...
@@ -158,8 +157,7 @@ gtk_color_scale_init (GtkColorScale *scale)
GTK_PHASE_TARGET
);
gtk_widget_add_controller
(
GTK_WIDGET
(
scale
),
GTK_EVENT_CONTROLLER
(
gesture
));
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
scale
));
gtk_style_context_add_class
(
context
,
"color"
);
gtk_widget_add_style_class
(
GTK_WIDGET
(
scale
),
"color"
);
}
static
void
...
...
gtk/gtkcolorswatch.c
View file @
b7ee2cbc
...
...
@@ -558,7 +558,7 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
G_CALLBACK
(
key_controller_key_pressed
),
swatch
);
gtk_widget_add_controller
(
GTK_WIDGET
(
swatch
),
controller
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
GTK_WIDGET
(
swatch
)
)
,
"activatable"
);
gtk_widget_
add
_style_c
lass
(
GTK_WIDGET
(
swatch
),
"activatable"
);
priv
->
overlay_widget
=
g_object_new
(
GTK_TYPE_IMAGE
,
"css-name"
,
"overlay"
,
...
...
@@ -591,9 +591,6 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
const
GdkRGBA
*
color
)
{
GtkColorSwatchPrivate
*
priv
=
gtk_color_swatch_get_instance_private
(
swatch
);
GtkStyleContext
*
context
;
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
swatch
));
if
(
!
priv
->
has_color
)
{
...
...
@@ -614,13 +611,14 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
if
(
INTENSITY
(
priv
->
color
.
red
,
priv
->
color
.
green
,
priv
->
color
.
blue
)
>
0
.
5
)
{
gtk_
style_context_add_class
(
context
,
"light"
);
gtk_
style_contex
t_remove_class
(
context
,
"dark"
);
gtk_
widget_add_style_class
(
GTK_WIDGET
(
swatch
)
,
"light"
);
gtk_
widge
t_remove_
style_
class
(
GTK_WIDGET
(
swatch
)
,
"dark"
);
}
else
{
gtk_style_context_add_class
(
context
,
"dark"
);
gtk_style_context_remove_class
(
context
,
"light"
);
gtk_widget_add_style_class
(
GTK_WIDGET
(
swatch
),
"dark"
);
gtk_widget_remove_style_class
(
GTK_WIDGET
(
swatch
),
"light"
);
}
gtk_widget_queue_draw
(
GTK_WIDGET
(
swatch
));
...
...
gtk/gtkcombobox.c
View file @
b7ee2cbc
...
...
@@ -825,7 +825,6 @@ static void
gtk_combo_box_init
(
GtkComboBox
*
combo_box
)
{
GtkComboBoxPrivate
*
priv
=
gtk_combo_box_get_instance_private
(
combo_box
);
GtkStyleContext
*
context
;
GtkEventController
*
controller
;
priv
->
active
=
-
1
;
...
...
@@ -848,9 +847,8 @@ gtk_combo_box_init (GtkComboBox *combo_box)
g_type_ensure
(
GTK_TYPE_TREE_POPOVER
);
gtk_widget_init_template
(
GTK_WIDGET
(
combo_box
));
context
=
gtk_widget_get_style_context
(
priv
->
button
);
gtk_style_context_remove_class
(
context
,
"toggle"
);
gtk_style_context_add_class
(
context
,
"combo"
);
gtk_widget_remove_style_class
(
priv
->
button
,
"toggle"
);
gtk_widget_add_style_class
(
priv
->
button
,
"combo"
);
gtk_tree_popover_set_row_separator_func
(
GTK_TREE_POPOVER
(
priv
->
popup_widget
),
(
GtkTreeViewRowSeparatorFunc
)
gtk_combo_box_row_separator_func
,
...
...
@@ -1029,13 +1027,11 @@ gtk_combo_box_create_child (GtkComboBox *combo_box)
if
(
priv
->
has_entry
)
{
GtkWidget
*
entry
;
GtkStyleContext
*
context
;
entry
=
gtk_entry_new
();
gtk_container_add
(
GTK_CONTAINER
(
combo_box
),
entry
);
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
entry
));
gtk_style_context_add_class
(
context
,
"combo"
);
gtk_widget_add_style_class
(
GTK_WIDGET
(
entry
),
"combo"
);
g_signal_connect
(
combo_box
,
"changed"
,
G_CALLBACK
(
gtk_combo_box_entry_active_changed
),
NULL
);
...
...
gtk/gtkdialog.c
View file @
b7ee2cbc
...
...
@@ -398,12 +398,11 @@ update_suggested_action (GtkDialog *dialog)
for
(
l
=
children
;
l
!=
NULL
;
l
=
l
->
next
)
{
GtkWidget
*
child
=
l
->
data
;
GtkStyleContext
*
context
=
gtk_widget_get_style_context
(
child
);
if
(
gtk_
style_context_has
_class
(
c
ontext
,
GTK_STYLE_CLASS_DEFAULT
))
gtk_
style_context_add
_class
(
c
ontext
,
GTK_STYLE_CLASS_SUGGESTED_ACTION
);
if
(
gtk_
widget_has_style
_class
(
c
hild
,
GTK_STYLE_CLASS_DEFAULT
))
gtk_
widget_add_style
_class
(
c
hild
,
GTK_STYLE_CLASS_SUGGESTED_ACTION
);
else
gtk_
style_contex
t_remove_class
(
c
ontext
,
GTK_STYLE_CLASS_SUGGESTED_ACTION
);
gtk_
widge
t_remove_
style_
class
(
c
hild
,
GTK_STYLE_CLASS_SUGGESTED_ACTION
);
}
g_list_free
(
children
);
}
...
...
gtk/gtkemojichooser.c
View file @
b7ee2cbc
...
...
@@ -290,7 +290,7 @@ show_variations (GtkEmojiChooser *chooser,
parent_popover
=
gtk_widget_get_ancestor
(
child
,
GTK_TYPE_POPOVER
);
popover
=
gtk_popover_new
(
child
);
view
=
gtk_box_new
(
GTK_ORIENTATION_HORIZONTAL
,
0
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
view
)
,
"view"
);
gtk_widget_
add
_style_c
lass
(
view
,
"view"
);
box
=
gtk_flow_box_new
();
gtk_flow_box_set_homogeneous
(
GTK_FLOW_BOX
(
box
),
TRUE
);
gtk_flow_box_set_min_children_per_line
(
GTK_FLOW_BOX
(
box
),
6
);
...
...
gtk/gtkentry.c
View file @
b7ee2cbc
...
...
@@ -1341,7 +1341,6 @@ update_icon_style (GtkWidget *widget,
GtkEntryPrivate
*
priv
=
gtk_entry_get_instance_private
(
entry
);
EntryIconInfo
*
icon_info
=
priv
->
icons
[
icon_pos
];
const
gchar
*
sides
[
2
]
=
{
GTK_STYLE_CLASS_LEFT
,
GTK_STYLE_CLASS_RIGHT
};
GtkStyleContext
*
context
;
if
(
icon_info
==
NULL
)
return
;
...
...
@@ -1349,9 +1348,8 @@ update_icon_style (GtkWidget *widget,
if
(
gtk_widget_get_direction
(
widget
)
==
GTK_TEXT_DIR_RTL
)
icon_pos
=
1
-
icon_pos
;
context
=
gtk_widget_get_style_context
(
icon_info
->
widget
);
gtk_style_context_add_class
(
context
,
sides
[
icon_pos
]);
gtk_style_context_remove_class
(
context
,
sides
[
1
-
icon_pos
]);
gtk_widget_add_style_class
(
icon_info
->
widget
,
sides
[
icon_pos
]);
gtk_widget_remove_style_class
(
icon_info
->
widget
,
sides
[
1
-
icon_pos
]);
}
static
void
...
...
@@ -2200,15 +2198,13 @@ gtk_entry_get_activates_default (GtkEntry *entry)
* gtk_entry_set_has_frame:
* @entry: a #GtkEntry
* @setting: new value
*
*
* Sets whether the entry has a beveled frame around it.
**/
void
gtk_entry_set_has_frame
(
GtkEntry
*
entry
,
gboolean
setting
)
{
GtkStyleContext
*
context
;
g_return_if_fail
(
GTK_IS_ENTRY
(
entry
));
setting
=
(
setting
!=
FALSE
);
...
...
@@ -2216,11 +2212,10 @@ gtk_entry_set_has_frame (GtkEntry *entry,
if
(
setting
==
gtk_entry_get_has_frame
(
entry
))
return
;
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
entry
));
if
(
setting
)
gtk_
style_contex
t_remove_class
(
context
,
GTK_STYLE_CLASS_FLAT
);
gtk_
widge
t_remove_
style_
class
(
GTK_WIDGET
(
entry
)
,
GTK_STYLE_CLASS_FLAT
);
else
gtk_
style_context_add_class
(
context
,
GTK_STYLE_CLASS_FLAT
);
gtk_
widget_add_style_class
(
GTK_WIDGET
(
entry
)
,
GTK_STYLE_CLASS_FLAT
);
g_object_notify_by_pspec
(
G_OBJECT
(
entry
),
entry_props
[
PROP_HAS_FRAME
]);
}
...
...
@@ -2236,13 +2231,9 @@ gtk_entry_set_has_frame (GtkEntry *entry,
gboolean
gtk_entry_get_has_frame
(
GtkEntry
*
entry
)
{
GtkStyleContext
*
context
;
g_return_val_if_fail
(
GTK_IS_ENTRY
(
entry
),
FALSE
);
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
entry
));
return
!
gtk_style_context_has_class
(
context
,
GTK_STYLE_CLASS_FLAT
);
return
!
gtk_widget_has_style_class
(
GTK_WIDGET
(
entry
),
GTK_STYLE_CLASS_FRAME
);
}
/**
...
...
gtk/gtkentrycompletion.c
View file @
b7ee2cbc
...
...
@@ -585,7 +585,7 @@ gtk_entry_completion_constructed (GObject *object)
gtk_popover_set_position
(
GTK_POPOVER
(
priv
->
popup_window
),
GTK_POS_BOTTOM
);
gtk_popover_set_autohide
(
GTK_POPOVER
(
priv
->
popup_window
),
FALSE
);
gtk_popover_set_has_arrow
(
GTK_POPOVER
(
priv
->
popup_window
),
FALSE
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
priv
->
popup_window
)
,
"entry-completion"
);
gtk_widget_
add
_style_c
lass
(
priv
->
popup_window
,
"entry-completion"
);
controller
=
gtk_event_controller_key_new
();
g_signal_connect
(
controller
,
"key-pressed"
,
...
...
gtk/gtkexpander.c
View file @
b7ee2cbc
...
...
@@ -370,8 +370,7 @@ gtk_expander_init (GtkExpander *expander)
gtk_container_add
(
GTK_CONTAINER
(
priv
->
box
),
priv
->
title_widget
);
priv
->
arrow_widget
=
gtk_builtin_icon_new
(
"expander"
);
gtk_style_context_add_class
(
gtk_widget_get_style_context
(
priv
->
arrow_widget
),
GTK_STYLE_CLASS_HORIZONTAL
);
gtk_widget_add_style_class
(
priv
->
arrow_widget
,
GTK_STYLE_CLASS_HORIZONTAL
);
gtk_container_add
(
GTK_CONTAINER
(
priv
->
title_widget
),
priv
->
arrow_widget
);
formats
=
gdk_content_formats_new
(
NULL
,
0
);
...
...
gtk/gtkfontbutton.c
View file @
b7ee2cbc
...
...
@@ -555,7 +555,6 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
static
void
gtk_font_button_init
(
GtkFontButton
*
font_button
)
{
GtkStyleContext
*
context
;
GtkFontButtonPrivate
*
priv
=
gtk_font_button_get_instance_private
(
font_button
);
GtkWidget
*
box
;
...
...
@@ -592,8 +591,7 @@ gtk_font_button_init (GtkFontButton *font_button)
gtk_font_button_take_font_desc
(
font_button
,
NULL
);
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
priv
->
button
));
gtk_style_context_add_class
(
context
,
"font"
);
gtk_widget_add_style_class
(
priv
->
button
,
"font"
);
}
static
void
...
...
gtk/gtkframe.c
View file @
b7ee2cbc
...
...
@@ -534,11 +534,9 @@ gtk_frame_set_shadow_type (GtkFrame *frame,
priv
->
shadow_type
=
type
;
if
(
type
==
GTK_SHADOW_NONE
)
gtk_style_context_add_class
(
gtk_widget_get_style_context
(
GTK_WIDGET
(
frame
)),
GTK_STYLE_CLASS_FLAT
);
gtk_widget_add_style_class
(
GTK_WIDGET
(
frame
),
"flat"
);
else
gtk_style_context_remove_class
(
gtk_widget_get_style_context
(
GTK_WIDGET
(
frame
)),
GTK_STYLE_CLASS_FLAT
);
gtk_widget_remove_style_class
(
GTK_WIDGET
(
frame
),
"flat"
);
g_object_notify_by_pspec
(
G_OBJECT
(
frame
),
frame_props
[
PROP_SHADOW_TYPE
]);
}
...
...
gtk/gtkheaderbar.c
View file @
b7ee2cbc
...
...
@@ -163,7 +163,6 @@ init_sizing_box (GtkHeaderBar *bar)
{
GtkHeaderBarPrivate
*
priv
=
gtk_header_bar_get_instance_private
(
bar
);
GtkWidget
*
w
;
GtkStyleContext
*
context
;
/* We use this box to always request size for the two labels (title
* and subtitle) as if they were always visible, but then allocate
...
...
@@ -174,8 +173,7 @@ init_sizing_box (GtkHeaderBar *bar)
priv
->
label_sizing_box
=
g_object_ref_sink
(
w
);
w
=
gtk_label_new
(
NULL
);
context
=
gtk_widget_get_style_context
(
w
);
gtk_style_context_add_class
(
context
,
GTK_STYLE_CLASS_TITLE
);
gtk_widget_add_style_class
(
w
,
GTK_STYLE_CLASS_TITLE
);
gtk_container_add
(
GTK_CONTAINER
(
priv
->
label_sizing_box
),
w
);
gtk_label_set_wrap
(
GTK_LABEL
(
w
),
FALSE
);
gtk_label_set_single_line_mode
(
GTK_LABEL
(
w
),
TRUE
);
...
...
@@ -183,8 +181,7 @@ init_sizing_box (GtkHeaderBar *bar)
gtk_label_set_width_chars
(
GTK_LABEL
(
w
),
MIN_TITLE_CHARS
);
w
=
gtk_label_new
(
NULL
);
context
=
gtk_widget_get_style_context
(
w
);
gtk_style_context_add_class
(
context
,
GTK_STYLE_CLASS_SUBTITLE
);
gtk_widget_add_style_class
(
w
,
GTK_STYLE_CLASS_SUBTITLE
);
gtk_container_add
(
GTK_CONTAINER
(
priv
->
label_sizing_box
),
w
);
gtk_label_set_wrap
(
GTK_LABEL
(
w
),
FALSE
);
gtk_label_set_single_line_mode
(
GTK_LABEL
(
w
),
TRUE
);
...
...
@@ -202,14 +199,12 @@ create_title_box (const char *title,
GtkWidget
*
label_box
;
GtkWidget
*
title_label
;
GtkWidget
*
subtitle_label
;
GtkStyleContext
*
context
;
label_box
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
0
);
gtk_widget_set_valign
(
label_box
,
GTK_ALIGN_CENTER
);
title_label
=
gtk_label_new
(
title
);
context
=
gtk_widget_get_style_context
(
title_label
);
gtk_style_context_add_class
(
context
,
GTK_STYLE_CLASS_TITLE
);
gtk_widget_add_style_class
(
title_label
,
GTK_STYLE_CLASS_TITLE
);
gtk_label_set_wrap
(
GTK_LABEL
(
title_label
),
FALSE
);
gtk_label_set_single_line_mode
(
GTK_LABEL
(
title_label
),
TRUE
);
gtk_label_set_ellipsize
(
GTK_LABEL
(
title_label
),
PANGO_ELLIPSIZE_END
);
...
...
@@ -217,8 +212,7 @@ create_title_box (const char *title,
gtk_label_set_width_chars
(
GTK_LABEL
(
title_label
),
MIN_TITLE_CHARS
);
subtitle_label
=
gtk_label_new
(
subtitle
);
context
=
gtk_widget_get_style_context
(
subtitle_label
);
gtk_style_context_add_class
(
context
,
GTK_STYLE_CLASS_SUBTITLE
);
gtk_widget_add_style_class
(
subtitle_label
,
GTK_STYLE_CLASS_SUBTITLE
);
gtk_label_set_wrap
(
GTK_LABEL
(
subtitle_label
),
FALSE
);
gtk_label_set_single_line_mode
(
GTK_LABEL
(
subtitle_label
),
TRUE
);
gtk_label_set_ellipsize
(
GTK_LABEL
(
subtitle_label
),
PANGO_ELLIPSIZE_END
);
...
...
@@ -371,7 +365,7 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
t
=
g_strsplit
(
tokens
[
i
],
","
,
-
1
);
separator
=
gtk_separator_new
(
GTK_ORIENTATION_VERTICAL
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
separator
)
,
"titlebutton"
);
gtk_widget_
add
_style_c
lass
(
separator
,
"titlebutton"
);
box
=
gtk_box_new
(
GTK_ORIENTATION_HORIZONTAL
,
0
);
...
...
@@ -387,8 +381,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
button
=
gtk_image_new
();
gtk_widget_set_valign
(
button
,
GTK_ALIGN_CENTER
);
priv
->
titlebar_icon
=
button
;
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"titlebutton"
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"icon"
);
gtk_widget_
add
_style_c
lass
(
button
,
"titlebutton"
);
gtk_widget_
add
_style_c
lass
(
button
,
"icon"
);
gtk_widget_set_size_request
(
button
,
20
,
20
);
if
(
!
_gtk_header_bar_update_window_icon
(
bar
,
window
))
...
...
@@ -405,8 +399,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
button
=
gtk_menu_button_new
();
gtk_widget_set_valign
(
button
,
GTK_ALIGN_CENTER
);
gtk_menu_button_set_menu_model
(
GTK_MENU_BUTTON
(
button
),
menu
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"titlebutton"
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"menu"
);
gtk_widget_
add
_style_c
lass
(
button
,
"titlebutton"
);
gtk_widget_
add
_style_c
lass
(
button
,
"menu"
);
image
=
gtk_image_new
();
gtk_menu_button_add_child
(
GTK_MENU_BUTTON
(
button
),
image
);
gtk_widget_set_can_focus
(
button
,
FALSE
);
...
...
@@ -426,8 +420,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
{
button
=
gtk_button_new
();
gtk_widget_set_valign
(
button
,
GTK_ALIGN_CENTER
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"titlebutton"
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"minimize"
);
gtk_widget_
add
_style_c
lass
(
button
,
"titlebutton"
);
gtk_widget_
add
_style_c
lass
(
button
,
"minimize"
);
image
=
gtk_image_new_from_icon_name
(
"window-minimize-symbolic"
);
g_object_set
(
image
,
"use-fallback"
,
TRUE
,
NULL
);
gtk_container_add
(
GTK_CONTAINER
(
button
),
image
);
...
...
@@ -449,8 +443,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
icon_name
=
maximized
?
"window-restore-symbolic"
:
"window-maximize-symbolic"
;
button
=
gtk_button_new
();
gtk_widget_set_valign
(
button
,
GTK_ALIGN_CENTER
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"titlebutton"
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"maximize"
);
gtk_widget_
add
_style_c
lass
(
button
,
"titlebutton"
);
gtk_widget_
add
_style_c
lass
(
button
,
"maximize"
);
image
=
gtk_image_new_from_icon_name
(
icon_name
);
g_object_set
(
image
,
"use-fallback"
,
TRUE
,
NULL
);
gtk_container_add
(
GTK_CONTAINER
(
button
),
image
);
...
...
@@ -468,8 +462,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
button
=
gtk_button_new
();
gtk_widget_set_valign
(
button
,
GTK_ALIGN_CENTER
);
image
=
gtk_image_new_from_icon_name
(
"window-close-symbolic"
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"titlebutton"
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
button
)
,
"close"
);
gtk_widget_
add
_style_c
lass
(
button
,
"titlebutton"
);
gtk_widget_
add
_style_c
lass
(
button
,
"close"
);
g_object_set
(
image
,
"use-fallback"
,
TRUE
,
NULL
);
gtk_container_add
(
GTK_CONTAINER
(
button
),
image
);
gtk_widget_set_can_focus
(
button
,
FALSE
);
...
...
@@ -503,9 +497,9 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
gtk_box_reorder_child_after
(
GTK_BOX
(
box
),
separator
,
NULL
);
if
(
i
==
0
)
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
box
)
,
GTK_STYLE_CLASS_LEFT
);
gtk_widget_
add
_style_c
lass
(
box
,
GTK_STYLE_CLASS_LEFT
);
else
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
box
)
,
GTK_STYLE_CLASS_RIGHT
);
gtk_widget_
add
_style_c
lass
(
box
,
GTK_STYLE_CLASS_RIGHT
);
if
(
i
==
0
)
{
...
...
@@ -540,7 +534,6 @@ update_default_decoration (GtkHeaderBar *bar)
{
GtkHeaderBarPrivate
*
priv
=
gtk_header_bar_get_instance_private
(
bar
);
GtkLayoutManager
*
layout
=
gtk_widget_get_layout_manager
(
GTK_WIDGET
(
bar
));
GtkStyleContext
*
context
;
gboolean
have_children
=
FALSE
;
/* Check whether we have any child widgets that we didn't add ourselves */
...
...
@@ -576,12 +569,10 @@ update_default_decoration (GtkHeaderBar *bar)
}
}
context
=
gtk_widget_get_style_context
(
GTK_WIDGET
(
bar
));
if
(
have_children
||
priv
->
custom_title
!=
NULL
)
gtk_
style_contex
t_remove_class
(
context
,
"default-decoration"
);
gtk_
widge
t_remove_
style_
class
(
GTK_WIDGET
(
bar
)
,
"default-decoration"
);
else
gtk_
style_context_add_class
(
context
,
"default-decoration"
);
gtk_
widget_add_style_class
(
GTK_WIDGET
(
bar
)
,
"default-decoration"
);
}
void
...
...
@@ -1242,11 +1233,11 @@ gtk_header_bar_init (GtkHeaderBar *bar)
layout
=
gtk_widget_get_layout_manager
(
GTK_WIDGET
(
bar
));
priv
->
start_box
=
gtk_box_new
(
GTK_ORIENTATION_HORIZONTAL
,
0
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
priv
->
start_box
)
,
"start"
);
gtk_widget_
add
_style_c
lass
(
priv
->
start_box
,
"start"
);
gtk_widget_set_parent
(
priv
->
start_box
,
GTK_WIDGET
(
bar
));
gtk_center_layout_set_start_widget
(
GTK_CENTER_LAYOUT
(
layout
),
priv
->
start_box
);
priv
->
end_box
=
gtk_box_new
(
GTK_ORIENTATION_HORIZONTAL
,
0
);
gtk_style_context_add_class
(
gtk_widget_
get
_style_c
ontext
(
priv
->
end_box
)
,
"end"
);
gtk_widget_
add
_style_c
lass
(
priv
->
end_box
,
"end"
);
gtk_widget_set_parent
(
priv
->
end_box
,
GTK_WIDGET
(
bar
));
gtk_center_layout_set_end_widget
(
GTK_CENTER_LAYOUT
(
layout
),
priv
->
end_box
);
...
...
gtk/gtkiconview.c
View file @
b7ee2cbc
...
...
@@ -956,8 +956,7 @@ gtk_icon_view_init (GtkIconView *icon_view)
icon_view
->
priv
->
row_contexts
=
g_ptr_array_new_with_free_func
((
GDestroyNotify
)
g_object_unref
);
gtk_style_context_add_class
(
gtk_widget_get_style_context
(
GTK_WIDGET
(
icon_view
)),
GTK_STYLE_CLASS_VIEW
);
gtk_widget_add_style_class
(
GTK_WIDGET
(
icon_view
),
GTK_STYLE_CLASS_VIEW
);
gesture
=
gtk_gesture_click_new
()