st: Add StDirectionType enum

In order to replace GTK+'s GtkDirectionType. It's bit-compatible with it,
too. All callers have been updated to use it.

This is a purely accessory change in terms of X11 Display usage cleanup,
but helps see better what is left.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/317
This commit is contained in:
Carlos Garnacho 2018-11-27 13:58:25 +01:00
parent a977c1388a
commit c59c5eb893
21 changed files with 80 additions and 84 deletions

View File

@ -23,7 +23,6 @@ const Gdm = imports.gi.Gdm;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Pango = imports.gi.Pango; const Pango = imports.gi.Pango;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
@ -183,7 +182,7 @@ var UserList = class {
if (global.stage.get_key_focus() != this.actor) if (global.stage.get_key_focus() != this.actor)
return; return;
let focusSet = this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); let focusSet = this.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
if (!focusSet) { if (!focusSet) {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => { Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
this._moveFocusToItems(); this._moveFocusToItems();

View File

@ -4,7 +4,6 @@ const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
@ -175,7 +174,7 @@ class BaseAppView {
_selectAppInternal(id) { _selectAppInternal(id) {
if (this._items[id]) if (this._items[id])
this._items[id].actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); this._items[id].actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
else else
log('No such application ' + id); log('No such application ' + id);
} }
@ -1468,18 +1467,18 @@ var AppFolderPopup = class AppFolderPopup {
let isLtr = Clutter.get_default_text_direction() == Clutter.TextDirection.LTR; let isLtr = Clutter.get_default_text_direction() == Clutter.TextDirection.LTR;
switch (event.get_key_symbol()) { switch (event.get_key_symbol()) {
case Clutter.Down: case Clutter.Down:
direction = Gtk.DirectionType.TAB_FORWARD; direction = St.DirectionType.TAB_FORWARD;
break; break;
case Clutter.Right: case Clutter.Right:
direction = isLtr ? Gtk.DirectionType.TAB_FORWARD : direction = isLtr ? St.DirectionType.TAB_FORWARD :
Gtk.DirectionType.TAB_BACKWARD; St.DirectionType.TAB_BACKWARD;
break; break;
case Clutter.Up: case Clutter.Up:
direction = Gtk.DirectionType.TAB_BACKWARD; direction = St.DirectionType.TAB_BACKWARD;
break; break;
case Clutter.Left: case Clutter.Left:
direction = isLtr ? Gtk.DirectionType.TAB_BACKWARD : direction = isLtr ? St.DirectionType.TAB_BACKWARD :
Gtk.DirectionType.TAB_FORWARD; St.DirectionType.TAB_FORWARD;
break; break;
default: default:
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
@ -1690,7 +1689,7 @@ var AppIcon = class AppIcon {
_onKeyboardPopupMenu() { _onKeyboardPopupMenu() {
this.popupMenu(); this.popupMenu();
this._menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); this._menu.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
} }
getId() { getId() {

View File

@ -1,7 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const St = imports.gi.St; const St = imports.gi.St;
@ -58,7 +57,7 @@ var CtrlAltTabManager = class CtrlAltTabManager {
if (item.focusCallback) if (item.focusCallback)
item.focusCallback(timestamp); item.focusCallback(timestamp);
else else
item.root.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); item.root.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
} }
// Sort the items into a consistent order; panel first, tray last, // Sort the items into a consistent order; panel first, tray last,

View File

@ -1,7 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const St = imports.gi.St; const St = imports.gi.St;
@ -187,7 +186,7 @@ var GrabHelper = class GrabHelper {
if (params.focus) { if (params.focus) {
params.focus.grab_key_focus(); params.focus.grab_key_focus();
} else if (newFocus && hadFocus) { } else if (newFocus && hadFocus) {
if (!newFocus.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false)) if (!newFocus.navigate_focus(null, St.DirectionType.TAB_FORWARD, false))
newFocus.grab_key_focus(); newFocus.grab_key_focus();
} }

View File

@ -2,7 +2,6 @@
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
@ -956,8 +955,8 @@ var PaginatedIconGrid = GObject.registerClass({
this._translatedChildren = []; this._translatedChildren = [];
this.emit('space-opened'); this.emit('space-opened');
} else { } else {
this._translateChildren(childrenUp, Gtk.DirectionType.UP, nRowsUp); this._translateChildren(childrenUp, St.DirectionType.UP, nRowsUp);
this._translateChildren(childrenDown, Gtk.DirectionType.DOWN, nRowsDown); this._translateChildren(childrenDown, St.DirectionType.DOWN, nRowsDown);
this._translatedChildren = childrenUp.concat(childrenDown); this._translatedChildren = childrenUp.concat(childrenDown);
} }
} }
@ -967,7 +966,7 @@ var PaginatedIconGrid = GObject.registerClass({
if (translationY == 0) if (translationY == 0)
return; return;
if (direction == Gtk.DirectionType.UP) if (direction == St.DirectionType.UP)
translationY *= -1; translationY *= -1;
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {

View File

@ -5,7 +5,6 @@ const Cogl = imports.gi.Cogl;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Pango = imports.gi.Pango; const Pango = imports.gi.Pango;
const St = imports.gi.St; const St = imports.gi.St;
@ -187,7 +186,7 @@ var Notebook = class Notebook {
// Focus the new tab before unmapping the old one // Focus the new tab before unmapping the old one
let tabData = this._tabs[index]; let tabData = this._tabs[index];
if (!tabData.scrollView.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false)) if (!tabData.scrollView.navigate_focus(null, St.DirectionType.TAB_FORWARD, false))
this.actor.grab_key_focus(); this.actor.grab_key_focus();
this._unselect(); this._unselect();

View File

@ -4,7 +4,6 @@ const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Atk = imports.gi.Atk; const Atk = imports.gi.Atk;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
@ -98,7 +97,7 @@ var FocusGrabber = class FocusGrabber {
this._focusActorChangedId = global.stage.connect('notify::key-focus', this._focusActorChanged.bind(this)); this._focusActorChangedId = global.stage.connect('notify::key-focus', this._focusActorChanged.bind(this));
if (!this._actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false)) if (!this._actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false))
this._actor.grab_key_focus(); this._actor.grab_key_focus();
this._focused = true; this._focused = true;

View File

@ -989,7 +989,7 @@ class Panel extends St.Widget {
menu.toggle(); menu.toggle();
if (menu.isOpen) if (menu.isOpen)
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); menu.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
} }
toggleAppMenu() { toggleAppMenu() {

View File

@ -3,7 +3,6 @@
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const St = imports.gi.St; const St = imports.gi.St;
@ -163,7 +162,7 @@ var Button = GObject.registerClass({
if (symbol == Clutter.KEY_Left || symbol == Clutter.KEY_Right) { if (symbol == Clutter.KEY_Left || symbol == Clutter.KEY_Right) {
let group = global.focus_manager.get_group(this.actor); let group = global.focus_manager.get_group(this.actor);
if (group) { if (group) {
let direction = (symbol == Clutter.KEY_Left) ? Gtk.DirectionType.LEFT : Gtk.DirectionType.RIGHT; let direction = (symbol == Clutter.KEY_Left) ? St.DirectionType.LEFT : St.DirectionType.RIGHT;
group.navigate_focus(this.actor, direction, false); group.navigate_focus(this.actor, direction, false);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }

View File

@ -1,7 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Gtk = imports.gi.Gtk;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
@ -543,7 +542,7 @@ var PopupMenuBase = class {
let sensitive = menuItem.getSensitive(); let sensitive = menuItem.getSensitive();
if (!sensitive && this._activeMenuItem == menuItem) { if (!sensitive && this._activeMenuItem == menuItem) {
if (!this.actor.navigate_focus(menuItem.actor, if (!this.actor.navigate_focus(menuItem.actor,
Gtk.DirectionType.TAB_FORWARD, St.DirectionType.TAB_FORWARD,
true)) true))
this.actor.grab_key_focus(); this.actor.grab_key_focus();
} else if (sensitive && this._activeMenuItem == null) { } else if (sensitive && this._activeMenuItem == null) {
@ -829,7 +828,7 @@ var PopupMenu = class extends PopupMenuBase {
} else if (symbol == navKey) { } else if (symbol == navKey) {
if (!this.isOpen) if (!this.isOpen)
this.toggle(); this.toggle();
this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); this.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else } else
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
@ -1150,7 +1149,7 @@ var PopupSubMenuMenuItem = class extends PopupBaseMenuItem {
if (symbol == Clutter.KEY_Right) { if (symbol == Clutter.KEY_Right) {
this._setOpenState(true); this._setOpenState(true);
this.menu.actor.navigate_focus(null, Gtk.DirectionType.DOWN, false); this.menu.actor.navigate_focus(null, St.DirectionType.DOWN, false);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.KEY_Left && this._getOpenState()) { } else if (symbol == Clutter.KEY_Left && this._getOpenState()) {
this._setOpenState(false); this._setOpenState(false);

View File

@ -8,7 +8,6 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const GnomeDesktop = imports.gi.GnomeDesktop; const GnomeDesktop = imports.gi.GnomeDesktop;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
@ -934,7 +933,7 @@ var ScreenShield = class {
if (this._dialog) { if (this._dialog) {
this._dialog.actor.grab_key_focus(); this._dialog.actor.grab_key_focus();
this._dialog.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); this._dialog.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
} }
} }

View File

@ -4,7 +4,6 @@ const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Signals = imports.signals; const Signals = imports.signals;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
@ -686,10 +685,10 @@ var SearchResults = class {
navigateFocus(direction) { navigateFocus(direction) {
let rtl = this.actor.get_text_direction() == Clutter.TextDirection.RTL; let rtl = this.actor.get_text_direction() == Clutter.TextDirection.RTL;
if (direction == Gtk.DirectionType.TAB_BACKWARD || if (direction == St.DirectionType.TAB_BACKWARD ||
direction == (rtl ? Gtk.DirectionType.RIGHT direction == (rtl ? St.DirectionType.RIGHT
: Gtk.DirectionType.LEFT) || : St.DirectionType.LEFT) ||
direction == Gtk.DirectionType.UP) { direction == St.DirectionType.UP) {
this.actor.navigate_focus(null, direction, false); this.actor.navigate_focus(null, direction, false);
return; return;
} }

View File

@ -1,7 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Gtk = imports.gi.Gtk;
const St = imports.gi.St; const St = imports.gi.St;
const BoxPointer = imports.ui.boxpointer; const BoxPointer = imports.ui.boxpointer;
@ -68,7 +67,7 @@ var EntryMenu = class extends PopupMenu.PopupMenu {
super.open(animate); super.open(animate);
this._entry.add_style_pseudo_class('focus'); this._entry.add_style_pseudo_class('focus');
let direction = Gtk.DirectionType.TAB_FORWARD; let direction = St.DirectionType.TAB_FORWARD;
if (!this.actor.navigate_focus(null, direction, false)) if (!this.actor.navigate_focus(null, direction, false))
this.actor.grab_key_focus(); this.actor.grab_key_focus();
} }

View File

@ -3,7 +3,6 @@
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Signals = imports.signals; const Signals = imports.signals;
@ -34,8 +33,8 @@ var ViewPage = {
var FocusTrap = GObject.registerClass( var FocusTrap = GObject.registerClass(
class FocusTrap extends St.Widget { class FocusTrap extends St.Widget {
vfunc_navigate_focus(from, direction) { vfunc_navigate_focus(from, direction) {
if (direction == Gtk.DirectionType.TAB_FORWARD || if (direction == St.DirectionType.TAB_FORWARD ||
direction == Gtk.DirectionType.TAB_BACKWARD) direction == St.DirectionType.TAB_BACKWARD)
return super.vfunc_navigate_focus(from, direction); return super.vfunc_navigate_focus(from, direction);
return false; return false;
} }
@ -397,7 +396,7 @@ var ViewSelector = class {
_a11yFocusPage(page) { _a11yFocusPage(page) {
this._showAppsButton.checked = page == this._appsPage; this._showAppsButton.checked = page == this._appsPage;
page.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); page.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
} }
_onShowAppsButtonToggled() { _onShowAppsButtonToggled() {
@ -426,10 +425,10 @@ var ViewSelector = class {
this.startSearch(event); this.startSearch(event);
} else if (!this._searchActive && !global.stage.key_focus) { } else if (!this._searchActive && !global.stage.key_focus) {
if (symbol == Clutter.Tab || symbol == Clutter.Down) { if (symbol == Clutter.Tab || symbol == Clutter.Down) {
this._activePage.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); this._activePage.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.ISO_Left_Tab) { } else if (symbol == Clutter.ISO_Left_Tab) {
this._activePage.navigate_focus(null, Gtk.DirectionType.TAB_BACKWARD, false); this._activePage.navigate_focus(null, St.DirectionType.TAB_BACKWARD, false);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
} }
@ -557,22 +556,22 @@ var ViewSelector = class {
let arrowNext, nextDirection; let arrowNext, nextDirection;
if (entry.get_text_direction() == Clutter.TextDirection.RTL) { if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
arrowNext = Clutter.Left; arrowNext = Clutter.Left;
nextDirection = Gtk.DirectionType.LEFT; nextDirection = St.DirectionType.LEFT;
} else { } else {
arrowNext = Clutter.Right; arrowNext = Clutter.Right;
nextDirection = Gtk.DirectionType.RIGHT; nextDirection = St.DirectionType.RIGHT;
} }
if (symbol == Clutter.Tab) { if (symbol == Clutter.Tab) {
this._searchResults.navigateFocus(Gtk.DirectionType.TAB_FORWARD); this._searchResults.navigateFocus(St.DirectionType.TAB_FORWARD);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.ISO_Left_Tab) { } else if (symbol == Clutter.ISO_Left_Tab) {
this._focusTrap.can_focus = false; this._focusTrap.can_focus = false;
this._searchResults.navigateFocus(Gtk.DirectionType.TAB_BACKWARD); this._searchResults.navigateFocus(St.DirectionType.TAB_BACKWARD);
this._focusTrap.can_focus = true; this._focusTrap.can_focus = true;
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.Down) { } else if (symbol == Clutter.Down) {
this._searchResults.navigateFocus(Gtk.DirectionType.DOWN); this._searchResults.navigateFocus(St.DirectionType.DOWN);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == arrowNext && this._text.position == -1) { } else if (symbol == arrowNext && this._text.position == -1) {
this._searchResults.navigateFocus(nextDirection); this._searchResults.navigateFocus(nextDirection);

View File

@ -1,6 +1,5 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -* // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const St = imports.gi.St; const St = imports.gi.St;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
@ -220,7 +219,7 @@ var WindowMenuManager = class {
this._sourceActor.show(); this._sourceActor.show();
menu.open(BoxPointer.PopupAnimation.NONE); menu.open(BoxPointer.PopupAnimation.NONE);
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); menu.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
menu.connect('open-state-changed', (menu_, isOpen) => { menu.connect('open-state-changed', (menu_, isOpen) => {
if (isOpen) if (isOpen)
return; return;

View File

@ -146,7 +146,7 @@ shell_stack_get_preferred_width (ClutterActor *actor,
static gboolean static gboolean
shell_stack_navigate_focus (StWidget *widget, shell_stack_navigate_focus (StWidget *widget,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction) StDirectionType direction)
{ {
ClutterActor *top_actor; ClutterActor *top_actor;

View File

@ -200,7 +200,7 @@ st_bin_popup_menu (StWidget *widget)
static gboolean static gboolean
st_bin_navigate_focus (StWidget *widget, st_bin_navigate_focus (StWidget *widget,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction) StDirectionType direction)
{ {
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (widget)); StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (widget));
ClutterActor *bin_actor = CLUTTER_ACTOR (widget); ClutterActor *bin_actor = CLUTTER_ACTOR (widget);

View File

@ -330,7 +330,7 @@ st_entry_style_changed (StWidget *self)
static gboolean static gboolean
st_entry_navigate_focus (StWidget *widget, st_entry_navigate_focus (StWidget *widget,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction) StDirectionType direction)
{ {
StEntryPrivate *priv = ST_ENTRY_PRIV (widget); StEntryPrivate *priv = ST_ENTRY_PRIV (widget);

View File

@ -75,7 +75,7 @@ st_focus_manager_stage_event (ClutterActor *stage,
gpointer user_data) gpointer user_data)
{ {
StFocusManager *manager = user_data; StFocusManager *manager = user_data;
GtkDirectionType direction; StDirectionType direction;
gboolean wrap_around = FALSE; gboolean wrap_around = FALSE;
ClutterActor *focused, *group; ClutterActor *focused, *group;
@ -85,26 +85,26 @@ st_focus_manager_stage_event (ClutterActor *stage,
switch (event->key.keyval) switch (event->key.keyval)
{ {
case CLUTTER_KEY_Up: case CLUTTER_KEY_Up:
direction = GTK_DIR_UP; direction = ST_DIR_UP;
break; break;
case CLUTTER_KEY_Down: case CLUTTER_KEY_Down:
direction = GTK_DIR_DOWN; direction = ST_DIR_DOWN;
break; break;
case CLUTTER_KEY_Left: case CLUTTER_KEY_Left:
direction = GTK_DIR_LEFT; direction = ST_DIR_LEFT;
break; break;
case CLUTTER_KEY_Right: case CLUTTER_KEY_Right:
direction = GTK_DIR_RIGHT; direction = ST_DIR_RIGHT;
break; break;
case CLUTTER_KEY_Tab: case CLUTTER_KEY_Tab:
if (event->key.modifier_state & CLUTTER_SHIFT_MASK) if (event->key.modifier_state & CLUTTER_SHIFT_MASK)
direction = GTK_DIR_TAB_BACKWARD; direction = ST_DIR_TAB_BACKWARD;
else else
direction = GTK_DIR_TAB_FORWARD; direction = ST_DIR_TAB_FORWARD;
wrap_around = TRUE; wrap_around = TRUE;
break; break;
case CLUTTER_KEY_ISO_Left_Tab: case CLUTTER_KEY_ISO_Left_Tab:
direction = GTK_DIR_TAB_BACKWARD; direction = ST_DIR_TAB_BACKWARD;
wrap_around = TRUE; wrap_around = TRUE;
break; break;

View File

@ -136,7 +136,7 @@ static void st_widget_recompute_style (StWidget *widget,
StThemeNode *old_theme_node); StThemeNode *old_theme_node);
static gboolean st_widget_real_navigate_focus (StWidget *widget, static gboolean st_widget_real_navigate_focus (StWidget *widget,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction); StDirectionType direction);
static AtkObject * st_widget_get_accessible (ClutterActor *actor); static AtkObject * st_widget_get_accessible (ClutterActor *actor);
@ -1848,7 +1848,7 @@ st_widget_popup_menu (StWidget *self)
static GList * static GList *
filter_by_position (GList *children, filter_by_position (GList *children,
ClutterActorBox *rbox, ClutterActorBox *rbox,
GtkDirectionType direction) StDirectionType direction)
{ {
ClutterActorBox cbox; ClutterActorBox cbox;
ClutterVertex abs_vertices[4]; ClutterVertex abs_vertices[4];
@ -1868,28 +1868,28 @@ filter_by_position (GList *children,
*/ */
switch (direction) switch (direction)
{ {
case GTK_DIR_UP: case ST_DIR_UP:
if (cbox.y2 > rbox->y1 + 0.1) if (cbox.y2 > rbox->y1 + 0.1)
continue; continue;
break; break;
case GTK_DIR_DOWN: case ST_DIR_DOWN:
if (cbox.y1 < rbox->y2 - 0.1) if (cbox.y1 < rbox->y2 - 0.1)
continue; continue;
break; break;
case GTK_DIR_LEFT: case ST_DIR_LEFT:
if (cbox.x2 > rbox->x1 + 0.1) if (cbox.x2 > rbox->x1 + 0.1)
continue; continue;
break; break;
case GTK_DIR_RIGHT: case ST_DIR_RIGHT:
if (cbox.x1 < rbox->x2 - 0.1) if (cbox.x1 < rbox->x2 - 0.1)
continue; continue;
break; break;
case GTK_DIR_TAB_BACKWARD: case ST_DIR_TAB_BACKWARD:
case GTK_DIR_TAB_FORWARD: case ST_DIR_TAB_FORWARD:
default: default:
g_return_val_if_reached (NULL); g_return_val_if_reached (NULL);
} }
@ -1946,7 +1946,7 @@ sort_by_distance (gconstpointer a,
static gboolean static gboolean
st_widget_real_navigate_focus (StWidget *widget, st_widget_real_navigate_focus (StWidget *widget,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction) StDirectionType direction)
{ {
StWidgetPrivate *priv = st_widget_get_instance_private (widget); StWidgetPrivate *priv = st_widget_get_instance_private (widget);
ClutterActor *widget_actor, *focus_child; ClutterActor *widget_actor, *focus_child;
@ -1998,15 +1998,15 @@ st_widget_real_navigate_focus (StWidget *widget,
} }
children = st_widget_get_focus_chain (widget); children = st_widget_get_focus_chain (widget);
if (direction == GTK_DIR_TAB_FORWARD || if (direction == ST_DIR_TAB_FORWARD ||
direction == GTK_DIR_TAB_BACKWARD) direction == ST_DIR_TAB_BACKWARD)
{ {
/* At this point we know that we want to navigate focus to one of /* At this point we know that we want to navigate focus to one of
* @widget's immediate children; the next one after @focus_child, or the * @widget's immediate children; the next one after @focus_child, or the
* first one if @focus_child is %NULL. (With "next" and "first" being * first one if @focus_child is %NULL. (With "next" and "first" being
* determined by @direction.) * determined by @direction.)
*/ */
if (direction == GTK_DIR_TAB_BACKWARD) if (direction == ST_DIR_TAB_BACKWARD)
children = g_list_reverse (children); children = g_list_reverse (children);
if (focus_child) if (focus_child)
@ -2044,20 +2044,20 @@ st_widget_real_navigate_focus (StWidget *widget,
clutter_actor_box_from_vertices (&sort_box, abs_vertices); clutter_actor_box_from_vertices (&sort_box, abs_vertices);
switch (direction) switch (direction)
{ {
case GTK_DIR_UP: case ST_DIR_UP:
sort_box.y1 = sort_box.y2; sort_box.y1 = sort_box.y2;
break; break;
case GTK_DIR_DOWN: case ST_DIR_DOWN:
sort_box.y2 = sort_box.y1; sort_box.y2 = sort_box.y1;
break; break;
case GTK_DIR_LEFT: case ST_DIR_LEFT:
sort_box.x1 = sort_box.x2; sort_box.x1 = sort_box.x2;
break; break;
case GTK_DIR_RIGHT: case ST_DIR_RIGHT:
sort_box.x2 = sort_box.x1; sort_box.x2 = sort_box.x1;
break; break;
case GTK_DIR_TAB_FORWARD: case ST_DIR_TAB_FORWARD:
case GTK_DIR_TAB_BACKWARD: case ST_DIR_TAB_BACKWARD:
default: default:
g_warn_if_reached (); g_warn_if_reached ();
} }
@ -2127,7 +2127,7 @@ st_widget_real_navigate_focus (StWidget *widget,
gboolean gboolean
st_widget_navigate_focus (StWidget *widget, st_widget_navigate_focus (StWidget *widget,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction, StDirectionType direction,
gboolean wrap_around) gboolean wrap_around)
{ {
g_return_val_if_fail (ST_IS_WIDGET (widget), FALSE); g_return_val_if_fail (ST_IS_WIDGET (widget), FALSE);

View File

@ -38,6 +38,16 @@ G_BEGIN_DECLS
#define ST_TYPE_WIDGET (st_widget_get_type ()) #define ST_TYPE_WIDGET (st_widget_get_type ())
G_DECLARE_DERIVABLE_TYPE (StWidget, st_widget, ST, WIDGET, ClutterActor) G_DECLARE_DERIVABLE_TYPE (StWidget, st_widget, ST, WIDGET, ClutterActor)
typedef enum
{
ST_DIR_TAB_FORWARD,
ST_DIR_TAB_BACKWARD,
ST_DIR_UP,
ST_DIR_DOWN,
ST_DIR_LEFT,
ST_DIR_RIGHT,
} StDirectionType;
typedef struct _StWidgetClass StWidgetClass; typedef struct _StWidgetClass StWidgetClass;
/** /**
@ -64,7 +74,7 @@ struct _StWidgetClass
*/ */
gboolean (* navigate_focus) (StWidget *self, gboolean (* navigate_focus) (StWidget *self,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction); StDirectionType direction);
GType (* get_accessible_type) (void); GType (* get_accessible_type) (void);
GList * (* get_focus_chain) (StWidget *widget); GList * (* get_focus_chain) (StWidget *widget);
@ -113,7 +123,7 @@ void st_widget_set_can_focus (StWidget *widg
gboolean st_widget_get_can_focus (StWidget *widget); gboolean st_widget_get_can_focus (StWidget *widget);
gboolean st_widget_navigate_focus (StWidget *widget, gboolean st_widget_navigate_focus (StWidget *widget,
ClutterActor *from, ClutterActor *from,
GtkDirectionType direction, StDirectionType direction,
gboolean wrap_around); gboolean wrap_around);
ClutterActor * st_widget_get_label_actor (StWidget *widget); ClutterActor * st_widget_get_label_actor (StWidget *widget);