From 2c62e45168035a973823ff16aa044cfc4db1707b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 17 Oct 2019 23:27:27 +0200 Subject: [PATCH] st: Remove StBin's align properties They are now completely unused, so remove them and stop the confusing shadowing of ClutterActor's own x/y-align properties. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/803 --- js/gdm/authPrompt.js | 8 +-- js/misc/util.js | 20 +++---- js/ui/calendar.js | 10 ++-- js/ui/checkBox.js | 2 +- js/ui/endSessionDialog.js | 2 +- js/ui/lookingGlass.js | 2 +- js/ui/padOsd.js | 10 ++-- js/ui/popupMenu.js | 2 +- js/ui/search.js | 14 +++-- js/ui/status/system.js | 19 +++--- src/st/st-bin.c | 119 -------------------------------------- src/st/st-bin.h | 6 -- 12 files changed, 45 insertions(+), 169 deletions(-) diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js index c5d93c946..62a65725e 100644 --- a/js/gdm/authPrompt.js +++ b/js/gdm/authPrompt.js @@ -162,9 +162,9 @@ var AuthPrompt = GObject.registerClass({ can_focus: true, label: _("Cancel"), x_expand: true, + x_align: Clutter.ActorAlign.START, + y_align: Clutter.ActorAlign.END, }); - this.cancelButton.set_x_align(Clutter.ActorAlign.START); - this.cancelButton.set_y_align(Clutter.ActorAlign.END); this.cancelButton.connect('clicked', () => this.cancel()); this._buttonBox.add_child(this.cancelButton); @@ -175,9 +175,9 @@ var AuthPrompt = GObject.registerClass({ reactive: true, can_focus: true, label: _("Next"), + x_align: Clutter.ActorAlign.END, + y_align: Clutter.ActorAlign.END, }); - this.nextButton.set_x_align(Clutter.ActorAlign.END); - this.nextButton.set_y_align(Clutter.ActorAlign.END); this.nextButton.connect('clicked', () => this.emit('next')); this.nextButton.add_style_pseudo_class('default'); this._buttonBox.add_child(this.nextButton); diff --git a/js/misc/util.js b/js/misc/util.js index 541f1876b..bdffffc52 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -346,19 +346,13 @@ function insertSorted(array, val, cmp) { var CloseButton = GObject.registerClass( class CloseButton extends St.Button { _init(boxpointer) { - super._init({ style_class: 'notification-close' }); - - // This is a bit tricky. St.Bin has its own x-align/y-align properties - // that compete with Clutter's properties. This should be fixed for - // Clutter 2.0. Since St.Bin doesn't define its own setters, the - // setters are a workaround to get Clutter's version. - this.set_x_align(Clutter.ActorAlign.END); - this.set_y_align(Clutter.ActorAlign.START); - - // XXX Clutter 2.0 workaround: ClutterBinLayout needs expand - // to respect the alignments. - this.set_x_expand(true); - this.set_y_expand(true); + super._init({ + style_class: 'notification-close', + x_expand: true, + y_expand: true, + x_align: Clutter.ActorAlign.END, + y_align: Clutter.ActorAlign.START, + }); this._boxPointer = boxpointer; if (boxpointer) diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 81bfc1fd1..ef13289c7 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -1082,10 +1082,12 @@ class CalendarMessageList extends St.Widget { this._scrollView.set_policy(St.PolicyType.NEVER, St.PolicyType.AUTOMATIC); box.add_actor(this._scrollView); - this._clearButton = new St.Button({ style_class: 'message-list-clear-button button', - label: _("Clear"), - can_focus: true }); - this._clearButton.set_x_align(Clutter.ActorAlign.END); + this._clearButton = new St.Button({ + style_class: 'message-list-clear-button button', + label: _('Clear'), + can_focus: true, + x_align: Clutter.ActorAlign.END, + }); this._clearButton.connect('clicked', () => { this._sectionList.get_children().forEach(s => s.clear()); }); diff --git a/js/ui/checkBox.js b/js/ui/checkBox.js index a58e6dbd4..e122fda41 100644 --- a/js/ui/checkBox.js +++ b/js/ui/checkBox.js @@ -16,8 +16,8 @@ class CheckBox extends St.Button { this._box = new St.Bin({ x_expand: true, y_expand: true, + y_align: Clutter.ActorAlign.START, }); - this._box.set_y_align(Clutter.ActorAlign.START); container.add_actor(this._box); this._label = new St.Label(); diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js index 11c5696dd..fc5440eb7 100644 --- a/js/ui/endSessionDialog.js +++ b/js/ui/endSessionDialog.js @@ -272,8 +272,8 @@ class EndSessionDialog extends ModalDialog.ModalDialog { this._iconBin = new St.Bin({ x_expand: true, + x_align: Clutter.ActorAlign.END, }); - this._iconBin.set_x_align(Clutter.ActorAlign.END); mainContentLayout.add_child(this._iconBin); let messageLayout = new St.BoxLayout({ vertical: true, diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 922ed988e..87f2aa04c 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -265,8 +265,8 @@ class ObjLink extends St.Button { track_hover: true, style_class: 'shell-link', label: text, + x_align: Clutter.ActorAlign.START, }); - this.set_x_align(Clutter.ActorAlign.START); this.get_child().single_line_mode = true; this._obj = o; diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js index 88dd61a68..854e0f61e 100644 --- a/js/ui/padOsd.js +++ b/js/ui/padOsd.js @@ -735,10 +735,12 @@ var PadOsd = GObject.registerClass({ x_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER }); this.add_actor(buttonBox); - this._editButton = new St.Button({ label: _("Edit…"), - style_class: 'button', - can_focus: true }); - this._editButton.set_x_align(Clutter.ActorAlign.CENTER); + this._editButton = new St.Button({ + label: _('Edit…'), + style_class: 'button', + can_focus: true, + x_align: Clutter.ActorAlign.CENTER, + }); this._editButton.connect('clicked', () => { this.setEditionMode(true); }); diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index fc7db5925..74c228f56 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -340,9 +340,9 @@ var PopupSwitchMenuItem = GObject.registerClass({ this.add_child(this.label); this._statusBin = new St.Bin({ + x_align: Clutter.ActorAlign.END, x_expand: true, }); - this._statusBin.set_x_align(Clutter.ActorAlign.END); this.add_child(this._statusBin); this._statusLabel = new St.Label({ diff --git a/js/ui/search.js b/js/ui/search.js index 3b4dbc25c..2f3f47d93 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -770,13 +770,15 @@ var ProviderInfo = GObject.registerClass( class ProviderInfo extends St.Button { _init(provider) { this.provider = provider; - super._init({ style_class: 'search-provider-icon', - reactive: true, - can_focus: true, - accessible_name: provider.appInfo.get_name(), - track_hover: true }); + super._init({ + style_class: 'search-provider-icon', + reactive: true, + can_focus: true, + accessible_name: provider.appInfo.get_name(), + track_hover: true, + y_align: Clutter.ActorAlign.START, + }); - this.set_y_align(Clutter.ActorAlign.START); this._content = new St.BoxLayout({ vertical: false, style_class: 'list-search-provider-content' }); this.set_child(this._content); diff --git a/js/ui/status/system.js b/js/ui/status/system.js index 8c7b3d1dd..8b9a74652 100644 --- a/js/ui/status/system.js +++ b/js/ui/status/system.js @@ -175,15 +175,16 @@ class Indicator extends PanelMenu.SystemIndicator { } _createActionButton(iconName, accessibleName) { - let icon = new St.Button({ reactive: true, - can_focus: true, - track_hover: true, - accessible_name: accessibleName, - x_expand: true, - style_class: 'system-menu-action' }); - icon.set_x_align(Clutter.ActorAlign.CENTER); - icon.child = new St.Icon({ icon_name: iconName }); - return icon; + return new St.Button({ + child: new St.Icon({ icon_name: iconName }), + reactive: true, + can_focus: true, + track_hover: true, + accessible_name: accessibleName, + x_expand: true, + x_align: Clutter.ActorAlign.CENTER, + style_class: 'system-menu-action', + }); } _createSubMenu() { diff --git a/src/st/st-bin.c b/src/st/st-bin.c index 49d66ce4b..b9c17e59c 100644 --- a/src/st/st-bin.c +++ b/src/st/st-bin.c @@ -43,9 +43,6 @@ struct _StBinPrivate { ClutterActor *child; - StAlign x_align; - StAlign y_align; - guint x_fill : 1; guint y_fill : 1; }; @@ -55,8 +52,6 @@ enum PROP_0, PROP_CHILD, - PROP_X_ALIGN, - PROP_Y_ALIGN, PROP_X_FILL, PROP_Y_FILL, @@ -273,18 +268,6 @@ st_bin_set_property (GObject *gobject, st_bin_set_child (bin, g_value_get_object (value)); break; - case PROP_X_ALIGN: - st_bin_set_alignment (bin, - g_value_get_enum (value), - priv->y_align); - break; - - case PROP_Y_ALIGN: - st_bin_set_alignment (bin, - priv->x_align, - g_value_get_enum (value)); - break; - case PROP_X_FILL: st_bin_set_fill (bin, g_value_get_boolean (value), @@ -324,14 +307,6 @@ st_bin_get_property (GObject *gobject, g_value_set_boolean (value, priv->y_fill); break; - case PROP_X_ALIGN: - g_value_set_enum (value, priv->x_align); - break; - - case PROP_Y_ALIGN: - g_value_set_enum (value, priv->y_align); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); } @@ -367,32 +342,6 @@ st_bin_class_init (StBinClass *klass) CLUTTER_TYPE_ACTOR, ST_PARAM_READWRITE); - /** - * StBin:x-align: - * - * The horizontal alignment of the #StBin child. - */ - props[PROP_X_ALIGN] = - g_param_spec_enum ("x-align", - "X Align", - "The horizontal alignment", - ST_TYPE_ALIGN, - ST_ALIGN_MIDDLE, - ST_PARAM_READWRITE | G_PARAM_DEPRECATED); - - /** - * StBin:y-align: - * - * The vertical alignment of the #StBin child. - */ - props[PROP_Y_ALIGN] = - g_param_spec_enum ("y-align", - "Y Align", - "The vertical alignment", - ST_TYPE_ALIGN, - ST_ALIGN_MIDDLE, - ST_PARAM_READWRITE | G_PARAM_DEPRECATED); - /** * StBin:x-fill: * @@ -425,10 +374,6 @@ st_bin_class_init (StBinClass *klass) static void st_bin_init (StBin *bin) { - StBinPrivate *priv = st_bin_get_instance_private (bin); - - priv->x_align = ST_ALIGN_MIDDLE; - priv->y_align = ST_ALIGN_MIDDLE; } /** @@ -499,70 +444,6 @@ st_bin_get_child (StBin *bin) return ((StBinPrivate *)st_bin_get_instance_private (bin))->child; } -/** - * st_bin_set_alignment: - * @bin: a #StBin - * @x_align: horizontal alignment - * @y_align: vertical alignment - * - * Sets the horizontal and vertical alignment of the child - * inside a #StBin. - */ -void -st_bin_set_alignment (StBin *bin, - StAlign x_align, - StAlign y_align) -{ - StBinPrivate *priv; - - g_return_if_fail (ST_IS_BIN (bin)); - - priv = st_bin_get_instance_private (bin); - - g_object_freeze_notify (G_OBJECT (bin)); - - if (priv->x_align != x_align) - { - priv->x_align = x_align; - g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_X_ALIGN]); - } - - if (priv->y_align != y_align) - { - priv->y_align = y_align; - g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_Y_ALIGN]); - } - - g_object_thaw_notify (G_OBJECT (bin)); -} - -/** - * st_bin_get_alignment: - * @bin: a #StBin - * @x_align: return location for the horizontal alignment, or %NULL - * @y_align: return location for the vertical alignment, or %NULL - * - * Retrieves the horizontal and vertical alignment of the child - * inside a #StBin, as set by st_bin_set_alignment(). - */ -void -st_bin_get_alignment (StBin *bin, - StAlign *x_align, - StAlign *y_align) -{ - StBinPrivate *priv; - - g_return_if_fail (ST_IS_BIN (bin)); - - priv = st_bin_get_instance_private (bin); - - if (x_align) - *x_align = priv->x_align; - - if (y_align) - *y_align = priv->y_align; -} - /** * st_bin_set_fill: * @bin: a #StBin diff --git a/src/st/st-bin.h b/src/st/st-bin.h index 0a22ca0cd..d4d9fa509 100644 --- a/src/st/st-bin.h +++ b/src/st/st-bin.h @@ -47,12 +47,6 @@ StWidget * st_bin_new (void); void st_bin_set_child (StBin *bin, ClutterActor *child); ClutterActor *st_bin_get_child (StBin *bin); -void st_bin_set_alignment (StBin *bin, - StAlign x_align, - StAlign y_align); -void st_bin_get_alignment (StBin *bin, - StAlign *x_align, - StAlign *y_align); void st_bin_set_fill (StBin *bin, gboolean x_fill, gboolean y_fill);